1 2 /* 3 * Copyright (c) 2021-2025 Huawei Device Co., Ltd. 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef ST_AUDIO_SERVER_PROXY_H 18 #define ST_AUDIO_SERVER_PROXY_H 19 20 #include <bitset> 21 #include <list> 22 #include <string> 23 #include <unordered_map> 24 #include <unordered_set> 25 #include <mutex> 26 #include "singleton.h" 27 #include "audio_group_handle.h" 28 #include "audio_manager_base.h" 29 #include "audio_module_info.h" 30 #include "audio_ec_info.h" 31 #include "hdi_adapter_type.h" 32 #include "datashare_helper.h" 33 #include "audio_errors.h" 34 35 #include "ipc_skeleton.h" 36 #include "istandard_audio_service.h" 37 38 namespace OHOS { 39 namespace AudioStandard { 40 class AudioServerProxy { 41 public: GetInstance()42 static AudioServerProxy& GetInstance() 43 { 44 static AudioServerProxy instance; 45 return instance; 46 } 47 const sptr<IStandardAudioService> GetAudioServerProxy(); 48 int32_t SetAudioSceneProxy(AudioScene audioScene, BluetoothOffloadState state); 49 float GetMaxAmplitudeProxy(bool flag, std::string portName, SourceType sourceType = SOURCE_TYPE_INVALID); 50 int64_t GetVolumeDataCount(std::string sinkName); 51 void UpdateEffectBtOffloadSupportedProxy(const bool &isSupported); 52 void SetOutputDeviceSinkProxy(DeviceType deviceType, std::string sinkName); 53 void SetActiveOutputDeviceProxy(DeviceType deviceType); 54 bool GetEffectOffloadEnabledProxy(); 55 int32_t UpdateActiveDevicesRouteProxy(std::vector<std::pair<DeviceType, DeviceFlag>> &activeDevices, 56 BluetoothOffloadState state, const std::string &deviceName = ""); 57 int32_t UpdateDualToneStateProxy(const bool &enable, const int32_t &sessionId); 58 void UpdateSessionConnectionStateProxy(const int32_t &sessionID, const int32_t &state); 59 int32_t CheckRemoteDeviceStateProxy(std::string networkId, DeviceRole deviceRole, bool isStartDevice); 60 void SetAudioParameterProxy(const std::string &key, const std::string &value); 61 void ResetAudioEndpointProxy(); 62 bool NotifyStreamVolumeChangedProxy(AudioStreamType streamType, float volume); 63 void OffloadSetVolumeProxy(float volume, const std::string &deviceClass, const std::string &networkId); 64 void SetVoiceVolumeProxy(float volume); 65 void UnsetOffloadModeProxy(uint32_t sessionId); 66 void SetOffloadModeProxy(uint32_t sessionId, int32_t state, bool isAppBack); 67 void CheckHibernateStateProxy(bool hibernate); 68 void RestoreSessionProxy(const uint32_t &sessionID, RestoreInfo RestoreInfo); 69 int32_t GetAudioEnhancePropertyProxy(AudioEnhancePropertyArray &propertyArray, 70 DeviceType deviceType = DEVICE_TYPE_NONE); 71 int32_t SetAudioEnhancePropertyProxy(const AudioEnhancePropertyArray &propertyArray, 72 DeviceType deviceType = DEVICE_TYPE_NONE); 73 void SetSinkMuteForSwitchDeviceProxy(const std::string &devceClass, int32_t durationUs, bool mute); 74 int32_t SetMicrophoneMuteProxy(bool isMute); 75 void SuspendRenderSinkProxy(const std::string &sinkName); 76 void RestoreRenderSinkProxy(const std::string &sinkName); 77 void LoadHdiEffectModelProxy(); 78 void NotifyDeviceInfoProxy(std::string networkId, bool connected); 79 std::string GetAudioParameterProxy(const std::string &key); 80 std::string GetAudioParameterProxy(const std::string& networkId, const AudioParamKey key, 81 const std::string& condition); 82 void ResetRouteForDisconnectProxy(DeviceType type); 83 bool CreatePlaybackCapturerManagerProxy(); 84 bool LoadAudioEffectLibrariesProxy(const std::vector<Library> libraries, const std::vector<Effect> effects, 85 std::vector<Effect>& successEffectList); 86 bool CreateEffectChainManagerProxy(std::vector<EffectChain> &effectChains, 87 const EffectChainManagerParam &effectParam, const EffectChainManagerParam &enhanceParam); 88 int32_t RegiestPolicyProviderProxy(const sptr<IRemoteObject> &object); 89 int32_t RegistCoreServiceProviderProxy(const sptr<IRemoteObject> &object); 90 void SetParameterCallbackProxy(const sptr<IRemoteObject>& object); 91 int32_t SetAudioEffectPropertyProxy(const AudioEffectPropertyArrayV3 &propertyArray, 92 const DeviceType& deviceType = DEVICE_TYPE_NONE); 93 int32_t GetAudioEffectPropertyProxy(AudioEffectPropertyArrayV3 &propertyArray); 94 int32_t SetAudioEffectPropertyProxy(const AudioEffectPropertyArray &propertyArray); 95 int32_t GetAudioEffectPropertyProxy(AudioEffectPropertyArray &propertyArray); 96 void SetRotationToEffectProxy(const uint32_t rotate); 97 void SetAudioMonoStateProxy(bool audioMono); 98 void SetAudioBalanceValueProxy(float audioBalance); 99 void NotifyAccountsChanged(); 100 void GetAllSinkInputsProxy(std::vector<SinkInput> &sinkInputs); 101 void NotifyAudioPolicyReady(); 102 void SetDefaultAdapterEnableProxy(bool isEnable); 103 void SetDmDeviceTypeProxy(uint16_t dmDeviceType, DeviceType deviceType = DEVICE_TYPE_INVALID); 104 #ifdef HAS_FEATURE_INNERCAPTURER 105 int32_t SetInnerCapLimitProxy(uint32_t innerCapLimit); 106 #endif 107 int32_t LoadHdiAdapterProxy(uint32_t devMgrType, const std::string &adapterName); 108 void UnloadHdiAdapterProxy(uint32_t devMgrType, const std::string &adapterName, bool force); 109 uint32_t CreateHdiSinkPortProxy(const std::string &deviceClass, const std::string &idInfo, 110 const IAudioSinkAttr &attr); 111 uint32_t CreateHdiSourcePortProxy(const std::string &deviceClass, const std::string &idInfo, 112 const IAudioSourceAttr &attr); 113 void DestroyHdiPortProxy(uint32_t id); 114 void SetDeviceConnectedFlag(bool flag); 115 void NotifySettingsDataReady(); 116 bool IsAcousticEchoCancelerSupported(SourceType sourceType); 117 bool SetKaraokeParameters(const std::string ¶meters); 118 bool IsAudioLoopbackSupported(AudioLoopbackMode mode); 119 void SetLatestMuteState(const uint32_t sessionId, const bool muteFlag); 120 void SetSessionMuteState(const uint32_t sessionId, const bool insert, const bool muteFlag); 121 void SetBtHdiInvalidState(); 122 int32_t ForceStopAudioStreamProxy(StopAudioType audioType); 123 private: AudioServerProxy()124 AudioServerProxy() {} ~AudioServerProxy()125 ~AudioServerProxy() {} 126 private: 127 std::mutex adProxyMutex_; 128 }; 129 } 130 } 131 #endif 132