1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTI_STAGES_PHOTO_CAPTURE_MANAGER_H 17 #define FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTI_STAGES_PHOTO_CAPTURE_MANAGER_H 18 19 #include <string> 20 #include <unordered_set> 21 #include <unordered_map> 22 #include <mutex> 23 24 #include "deferred_photo_proc_adapter.h" 25 #include "medialibrary_type_const.h" 26 #include "medialibrary_command.h" 27 #include "result_set.h" 28 #include "picture_manager_thread.h" 29 30 namespace OHOS { 31 namespace Media { 32 #define EXPORT __attribute__ ((visibility ("default"))) 33 34 class MultiStagesPhotoCaptureManager { 35 public: 36 EXPORT static MultiStagesPhotoCaptureManager& GetInstance(); 37 bool Init(); 38 39 EXPORT int32_t UpdateDbInfo(MediaLibraryCommand &cmd); 40 void UpdateLocation(const NativeRdb::ValuesBucket &values); 41 42 std::shared_ptr<OHOS::NativeRdb::ResultSet> HandleMultiStagesOperation(MediaLibraryCommand &cmd, 43 const std::vector<std::string> &columns); 44 45 EXPORT bool CancelProcessRequest(const std::string &photoId); 46 void RemoveImage(const std::string &photoId, bool isRestorable = true); 47 void RestoreImage(const std::string &photoId); 48 EXPORT void AddImage(int32_t fileId, const std::string &photoId, int32_t deferredProcType); 49 void ProcessImage(int fileId, int deliveryMode); 50 51 void AddImageInternal(int32_t fileId, const std::string &photoId, int32_t deferredProcType, 52 bool discardable = false); 53 bool IsHighQualityPhotoExist(const std::string &uri); 54 void DealHighQualityPicture(const std::string &imageId, std::shared_ptr<Media::Picture> picture, 55 bool isEdited = false); 56 void DealLowQualityPicture(const std::string &imageId, std::shared_ptr<Media::Picture> picture, 57 bool isEdited = false); 58 void SaveLowQualityImageInfo(MediaLibraryCommand &cmd); 59 void SaveLowQualityPicture(const std::string &imageId); 60 61 EXPORT bool IsPhotoDeleted(const std::string &photoId); 62 63 EXPORT void SyncWithDeferredProcSession(); 64 EXPORT void SyncWithDeferredProcSessionInternal(); 65 66 private: 67 MultiStagesPhotoCaptureManager(); 68 ~MultiStagesPhotoCaptureManager(); 69 MultiStagesPhotoCaptureManager(const MultiStagesPhotoCaptureManager &manager) = delete; 70 const MultiStagesPhotoCaptureManager &operator=(const MultiStagesPhotoCaptureManager &manager) = delete; 71 72 void CancelRequestAndRemoveImage(const std::vector<std::string> &columns); 73 void AddImage(MediaLibraryCommand &cmd); 74 int32_t UpdatePictureQuality(const std::string &photoId); 75 76 std::unordered_set<int32_t> setOfDeleted_; 77 78 std::shared_ptr<DeferredPhotoProcessingAdapter> deferredProcSession_; 79 80 std::mutex deferredProcMutex_; 81 }; 82 } // namespace Media 83 } // namespace OHOS 84 #endif // FRAMEWORKS_SERVICES_MEDIA_MULTI_STAGES_CAPTURE_INCLUDE_MULTI_STAGES_PHOTO_CAPTURE_MANAGER_H