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