1 /* 2 * Copyright (c) 2023 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 ST_AUDIO_EFFECT_SERVICE_H 17 #define ST_AUDIO_EFFECT_SERVICE_H 18 19 #include "audio_policy_log.h" 20 #include "audio_effect.h" 21 #include "audio_effect_config_parser.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class AudioEffectService { 26 public: 27 explicit AudioEffectService(); 28 ~AudioEffectService(); GetAudioEffectService()29 static AudioEffectService& GetAudioEffectService() 30 { 31 static AudioEffectService audioEffectService; 32 return audioEffectService; 33 } 34 void EffectServiceInit(); 35 void GetOriginalEffectConfig(OriginalEffectConfig &oriEffectConfig); 36 void GetAvailableEffects(std::vector<Effect> &availableEffects); 37 void UpdateAvailableEffects(std::vector<Effect> &newAvailableEffects); 38 void GetSupportedEffectConfig(SupportedEffectConfig &supportedEffectConfig); 39 void BuildAvailableAEConfig(); 40 void SetMasterSinkAvailable(); 41 void SetEffectChainManagerAvailable(); 42 bool CanLoadEffectSinks(); 43 void ConstructEffectChainManagerParam(EffectChainManagerParam &effectChainMgrParam); 44 void ConstructEnhanceChainManagerParam(EffectChainManagerParam &enhanceChainMgrParam); 45 int32_t QueryEffectManagerSceneMode(SupportedEffectConfig &supportedEffectConfig); 46 int32_t AddSupportedAudioEffectPropertyByDevice(const DeviceType& deviceType, 47 std::set<std::pair<std::string, std::string>> &mergedSet); 48 int32_t AddSupportedAudioEnhancePropertyByDevice(const DeviceType& deviceType, 49 std::set<std::pair<std::string, std::string>> &mergedSet); 50 51 private: 52 OriginalEffectConfig oriEffectConfig_; 53 std::vector<Effect> availableEffects_; 54 SupportedEffectConfig supportedEffectConfig_; 55 int32_t existDefault_ = 0; 56 bool isMasterSinkAvailable_ = false; 57 bool isEffectChainManagerAvailable_ = false; 58 std::vector<std::string> postSceneTypeSet_; 59 std::unordered_map<std::string, std::set<std::pair<std::string, std::string>>> device2EffectPropertySet_; 60 std::unordered_map<std::string, std::set<std::pair<std::string, std::string>>> device2EnhancePropertySet_; 61 62 void ConstructEffectChainMode(StreamEffectMode &mode, std::string sceneType, 63 EffectChainManagerParam &effectChainMgrParam); 64 void UpdateAvailableAEConfig(OriginalEffectConfig &aeConfig); 65 void UpdateEffectChains(std::vector<std::string> &availableLayout); 66 void UpdateDuplicateBypassMode(ProcessNew &processNew); 67 void UpdateDuplicateMode(ProcessNew &processNew); 68 void UpdateDuplicateDefaultScene(ProcessNew &processNew); 69 void UpdateDuplicateScene(ProcessNew &processNew); 70 void UpdateDuplicateDevice(ProcessNew &processNew); 71 int32_t UpdateUnavailableEffectChains(std::vector<std::string> &availableLayout, ProcessNew &processNew); 72 bool VerifySceneMappingItem(const SceneMappingItem &item); 73 void UpdateSupportedEffectProperty(const Device &device, 74 std::unordered_map<std::string, std::set<std::pair<std::string, std::string>>> &device2PropertySet); 75 void UpdateDuplicateProcessNew(std::vector<std::string> &availableLayout, ProcessNew &processNew); 76 void ConstructDefaultEffectProperty(const std::string &chainName, 77 std::unordered_map<std::string, std::string> &defaultProperty); 78 int32_t AddSupportedPropertyByDeviceInner(const DeviceType& deviceType, 79 std::set<std::pair<std::string, std::string>> &mergedSet, 80 const std::unordered_map<std::string, std::set<std::pair<std::string, std::string>>> &device2PropertySet); 81 }; 82 } // namespce AudioStandard 83 } // namespace OHOS 84 #endif // ST_AUDIO_EFFECT_SERVICE_H