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 AUDIO_ENHANCE_CHAIN_MANAGER_H 17 #define AUDIO_ENHANCE_CHAIN_MANAGER_H 18 19 #include <map> 20 #include <memory> 21 #include <string> 22 #include <vector> 23 #include <mutex> 24 #include <set> 25 26 #include "audio_effect.h" 27 #include "audio_enhance_chain.h" 28 29 namespace OHOS { 30 namespace AudioStandard { 31 32 class AudioEnhanceChainManager { 33 public: 34 AudioEnhanceChainManager(); 35 ~AudioEnhanceChainManager(); 36 static AudioEnhanceChainManager* GetInstance(); 37 void InitAudioEnhanceChainManager(std::vector<EffectChain> &enhanceChains, 38 const EffectChainManagerParam &managerParam, 39 std::vector<std::shared_ptr<AudioEffectLibEntry>> &enhanceLibraryList); 40 int32_t CreateAudioEnhanceChainDynamic(const std::string &sceneType, 41 const std::string &enhanceMode, const std::string &upAndDownDevice); 42 int32_t ReleaseAudioEnhanceChainDynamic(const std::string &sceneType, const std::string &upAndDownDevice); 43 int32_t ApplyAudioEnhanceChain(const std::string &sceneType, EnhanceBufferAttr *enhanceBufferAttr); 44 bool ExistAudioEnhanceChain(const std::string &sceneType); 45 std::string GetUpAndDownDevice(); 46 47 private: 48 int32_t SetAudioEnhanceChainDynamic(const std::string &sceneType, const std::string &enhanceMode, 49 const std::string &upAndDownDevice); 50 51 std::map<std::string, std::shared_ptr<AudioEnhanceChain>> sceneTypeToEnhanceChainMap_; 52 std::map<std::string, int32_t> sceneTypeToEnhanceChainCountMap_; 53 std::map<std::string, std::string> sceneTypeAndModeToEnhanceChainNameMap_; 54 std::map<std::string, std::vector<std::string>> enhanceChainToEnhancesMap_; 55 std::map<std::string, std::shared_ptr<AudioEffectLibEntry>> enhanceToLibraryEntryMap_; 56 std::map<std::string, std::string> enhanceToLibraryNameMap_; 57 std::mutex chainManagerMutex_; 58 bool isInitialized_; 59 std::string upAndDownDevice_; 60 }; 61 62 } // namespace AudioStandard 63 } // namespace OHOS 64 #endif // AUDIO_ENHANCE_CHAIN_MANAGER_H