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_SERVICE_ADAPTER_H 17 #define FRAMEWORKS_SERVICES_MEDIA_CLOUD_ENHANCEMENT_INCLUDE_ENHANCEMENT_SERVICE_ADAPTER_H 18 19 #include <string> 20 #include <map> 21 #include <memory> 22 23 #include "dynamic_loader.h" 24 #include "enhancement_thread_manager.h" 25 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 26 #include "media_enhance_constants_c_api.h" 27 #include "media_enhance_handles.h" 28 #include "media_enhance_client_c_api.h" 29 #include "media_enhance_bundle_c_api.h" 30 #endif 31 32 namespace OHOS { 33 namespace Media { 34 #define EXPORT __attribute__ ((visibility ("default"))) 35 36 class EnhancementServiceAdapter { 37 public: 38 EXPORT EnhancementServiceAdapter(); 39 EXPORT virtual ~EnhancementServiceAdapter(); 40 41 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 42 void InitEnhancementClient(MediaEnhance::MediaEnhance_TASK_TYPE taskType); 43 void DestroyEnhancementClient(); 44 int32_t SetResultCallback(); 45 int32_t LoadSA(); 46 bool IsConnected(MediaEnhance::MediaEnhanceClientHandle* clientWrapper); 47 bool IsConnected(); 48 EXPORT MediaEnhance::MediaEnhanceBundleHandle* CreateBundle(); 49 void DestroyBundle(MediaEnhance::MediaEnhanceBundleHandle* bundle); 50 int32_t GetInt(MediaEnhance::MediaEnhanceBundleHandle* bundle, const char* key); 51 int32_t FillTaskWithResultBuffer(MediaEnhance::MediaEnhanceBundleHandle* bundle, 52 CloudEnhancementThreadTask& task); 53 EXPORT void PutInt(MediaEnhance::MediaEnhanceBundleHandle* bundle, const char* key, 54 int32_t value); 55 void PutString(MediaEnhance::MediaEnhanceBundleHandle* bundle, const char* key, 56 const char* value); 57 void DeleteRawData(MediaEnhance::Raw_Data* rawData, uint32_t size); 58 void DeletePendingTasks(MediaEnhance::Pending_Task* taskIdList, uint32_t size); 59 EXPORT int32_t AddTask(const std::string& taskId, MediaEnhance::MediaEnhanceBundleHandle* bundle); 60 EXPORT int32_t RemoveTask(const std::string &taskId); 61 EXPORT int32_t CancelTask(const std::string &taskId); 62 EXPORT int32_t CancelAllTasks(); 63 EXPORT int32_t LoadEnhancementService(); 64 EXPORT int32_t GetPendingTasks(std::vector<std::string> &taskIdList); 65 EXPORT int32_t PauseAllTasks(MediaEnhance::MediaEnhanceBundleHandle* bundle); 66 EXPORT int32_t ResumeAllTasks(MediaEnhance::MediaEnhanceBundleHandle* bundle); 67 #endif 68 69 private: 70 #ifdef ABILITY_CLOUD_ENHANCEMENT_SUPPORT 71 void ClientFuncInit(); 72 void TaskFuncInit(); 73 void BundleFuncInit(); 74 #endif 75 76 static std::mutex mtx_; 77 static std::shared_ptr<DynamicLoader> dynamicLoader_; 78 }; 79 } // namespace Media 80 } // namespace OHOS 81 #endif // FRAMEWORKS_SERVICES_MEDIA_CLOUD_ENHANCEMENT_INCLUDE_ENHANCEMENT_SERVICE_ADAPTER_H