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_CLOUD_ENHANCEMENT_INCLUDE_ENHANCEMENT_MANAGER_H 17 #define FRAMEWORKS_SERVICES_MEDIA_CLOUD_ENHANCEMENT_INCLUDE_ENHANCEMENT_MANAGER_H 18 19 #include <string> 20 #include <unordered_map> 21 #include <mutex> 22 23 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 24 #include "enhancement_service_adapter.h" 25 #include "enhancement_database_operations.h" 26 #endif 27 28 #include "medialibrary_type_const.h" 29 #include "medialibrary_command.h" 30 #include "result_set.h" 31 #include "rdb_predicates.h" 32 #include "rdb_store.h" 33 #include "rdb_utils.h" 34 #include "medialibrary_rdbstore.h" 35 #include "enhancement_thread_manager.h" 36 #include "cloud_enhancement_dfx_get_count.h" 37 38 namespace OHOS { 39 namespace Media { 40 #define EXPORT __attribute__ ((visibility ("default"))) 41 42 class EnhancementManager { 43 public: 44 EXPORT static EnhancementManager& GetInstance(); 45 EXPORT bool Init(); 46 EXPORT bool InitAsync(); 47 EXPORT bool LoadService(); 48 EXPORT void CancelTasksInternal(const std::vector<std::string> &fildIds, std::vector<std::string> &photoIds, 49 CloudEnhancementAvailableType type); 50 EXPORT void RemoveTasksInternal(const std::vector<std::string> &fildIds, std::vector<std::string> &photoIds); 51 EXPORT bool RevertEditUpdateInternal(int32_t fileId); 52 EXPORT bool RecoverTrashUpdateInternal(const std::vector<std::string> &fildIds); 53 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 54 EXPORT int32_t HandleAddOperation(MediaLibraryCommand &cmd, const bool hasCloudWatermark); 55 EXPORT int32_t AddServiceTask(OHOS::MediaEnhance::MediaEnhanceBundleHandle* mediaEnhanceBundle, int32_t fileId, 56 const std::string &photoId, const bool hasCloudWatermark); 57 #endif 58 59 EXPORT int32_t HandleEnhancementUpdateOperation(MediaLibraryCommand &cmd); 60 EXPORT std::shared_ptr<NativeRdb::ResultSet> HandleEnhancementQueryOperation(MediaLibraryCommand &cmd, 61 const std::vector<std::string> &columns); 62 63 EXPORT int32_t HandlePrioritizeOperation(MediaLibraryCommand &cmd); 64 EXPORT std::shared_ptr<NativeRdb::ResultSet> HandleQueryOperation(MediaLibraryCommand &cmd, 65 const std::vector<std::string> &columns); 66 EXPORT int32_t HandleCancelOperation(MediaLibraryCommand &cmd); 67 EXPORT int32_t HandleCancelAllOperation(); 68 EXPORT int32_t HandleSyncOperation(); 69 EXPORT std::shared_ptr<NativeRdb::ResultSet> HandleGetPairOperation(MediaLibraryCommand &cmd); 70 71 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 72 std::shared_ptr<EnhancementServiceAdapter> enhancementService_; 73 #endif 74 std::shared_ptr<EnhancementThreadManager> threadManager_; 75 76 private: 77 EnhancementManager(); 78 ~EnhancementManager(); 79 EnhancementManager(const EnhancementManager &manager) = delete; 80 const EnhancementManager &operator=(const EnhancementManager &manager) = delete; 81 82 static std::mutex mutex_; 83 }; 84 } // namespace Media 85 } // namespace OHOS 86 #endif // FRAMEWORKS_SERVICES_MEDIA_CLOUD_ENHANCEMENT_INCLUDE_ENHANCEMENT_TASK_HANDLER_H 87