1 /* 2 * Copyright (c) 2022 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_MANAGER_LISTENER_PROXY_H 17 #define AUDIO_MANAGER_LISTENER_PROXY_H 18 19 #include "iremote_proxy.h" 20 #include "audio_system_manager.h" 21 #include "i_standard_audio_server_manager_listener.h" 22 23 namespace OHOS { 24 namespace AudioStandard { 25 class AudioManagerListenerProxy : public IRemoteProxy<IStandardAudioServerManagerListener> { 26 public: 27 explicit AudioManagerListenerProxy(const sptr<IRemoteObject>& impl); 28 virtual ~AudioManagerListenerProxy(); 29 DISALLOW_COPY_AND_MOVE(AudioManagerListenerProxy); 30 void OnAudioParameterChange(const std::string networkId, const AudioParamKey key, 31 const std::string& condition, const std::string& value) override; 32 void OnCapturerState(bool isActive) override; 33 void OnWakeupClose() override; 34 35 private: 36 static inline BrokerDelegator<AudioManagerListenerProxy> delegator_; 37 void WriteParameterEventParams(MessageParcel& data, const std::string networkId, const AudioParamKey key, 38 const std::string& condition, const std::string& value); 39 }; 40 41 class AudioManagerListenerCallback : public AudioParameterCallback, public WakeUpSourceCallback { 42 public: 43 AudioManagerListenerCallback(const sptr<IStandardAudioServerManagerListener>& listener); 44 virtual ~AudioManagerListenerCallback(); 45 DISALLOW_COPY_AND_MOVE(AudioManagerListenerCallback); 46 void OnAudioParameterChange(const std::string networkId, const AudioParamKey key, 47 const std::string& condition, const std::string& value) override; 48 void OnCapturerState(bool isActive) override final; 49 void OnWakeupClose() override; 50 void TrigerFirstOnCapturerStateCallback(bool isActive); 51 private: 52 sptr<IStandardAudioServerManagerListener> listener_ = nullptr; 53 std::atomic<bool> isFirstOnCapturerStateCallbackSent_ = false; 54 }; 55 } // namespace AudioStandard 56 } // namespace OHOS 57 #endif // AUDIO_MANAGER_LISTENER_PROXY_H 58