1 /* 2 * Copyright (c) 2022-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 OHOS_DAUDIO_SINK_HANDLER_H 17 #define OHOS_DAUDIO_SINK_HANDLER_H 18 19 #include "idistributed_hardware_sink.h" 20 #include "daudio_sink_ipc_callback.h" 21 #include "single_instance.h" 22 23 #include "idaudio_sink.h" 24 25 namespace OHOS { 26 namespace DistributedHardware { 27 class DAudioSinkHandler : public IDistributedHardwareSink { 28 DECLARE_SINGLE_INSTANCE_BASE(DAudioSinkHandler); 29 public: 30 int32_t InitSink(const std::string ¶ms) override; 31 int32_t ReleaseSink() override; 32 int32_t SubscribeLocalHardware(const std::string &dhId, const std::string ¶m) override; 33 int32_t UnsubscribeLocalHardware(const std::string &dhId) override; 34 void OnRemoteSinkSvrDied(const wptr<IRemoteObject> &remote); 35 void FinishStartSA(const std::string ¶m, const sptr<IRemoteObject> &remoteObject); 36 int32_t RegisterPrivacyResources(std::shared_ptr<PrivacyResourcesListener> listener) override; 37 int32_t PauseDistributedHardware(const std::string &networkId) override; 38 int32_t ResumeDistributedHardware(const std::string &networkId) override; 39 int32_t StopDistributedHardware(const std::string &networkId) override; 40 41 private: 42 class DAudioSinkSvrRecipient : public IRemoteObject::DeathRecipient { 43 public: 44 void OnRemoteDied(const wptr<IRemoteObject> &remote) override; 45 }; 46 47 DAudioSinkHandler(); 48 ~DAudioSinkHandler(); 49 50 std::mutex sinkProxyMutex_; 51 std::condition_variable sinkProxyConVar_; 52 sptr<IDAudioSink> dAudioSinkProxy_ = nullptr; 53 sptr<DAudioSinkSvrRecipient> sinkSvrRecipient_ = nullptr; 54 sptr<DAudioSinkIpcCallback> dAudioSinkIpcCallback_ = nullptr; 55 }; 56 57 #ifdef __cplusplus 58 extern "C" { 59 #endif 60 __attribute__((visibility("default"))) IDistributedHardwareSink *GetSinkHardwareHandler(); 61 #ifdef __cplusplus 62 } 63 #endif 64 } // namespace DistributedHardware 65 } // namespace OHOS 66 #endif // OHOS_DAUDIO_SINK_HANDLER_H