1 /* 2 * Copyright (c) 2021-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_DCAMERA_SINK_HANDLER_H 17 #define OHOS_DCAMERA_SINK_HANDLER_H 18 19 #include <cstdint> 20 #include <mutex> 21 #include <condition_variable> 22 23 #include "idistributed_hardware_sink.h" 24 #include "dcamera_sink_callback.h" 25 #include "single_instance.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 class DCameraSinkHandler : public IDistributedHardwareSink { 30 DECLARE_SINGLE_INSTANCE_BASE(DCameraSinkHandler); 31 public: 32 int32_t InitSink(const std::string& params) override; 33 int32_t ReleaseSink() override; 34 int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; 35 int32_t UnsubscribeLocalHardware(const std::string& dhId) override; 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 void SetSAState(); 41 private: 42 typedef enum { 43 DCAMERA_SA_STATE_STOP = 0, 44 DCAMERA_SA_STATE_START = 1, 45 } DCameraSAState; 46 DCameraSinkHandler(); 47 ~DCameraSinkHandler(); 48 void FinishStartSA(const std::string ¶ms); 49 void FinishStartSAFailed(const int32_t systemAbilityId); 50 private: 51 std::condition_variable producerCon_; 52 std::mutex producerMutex_; 53 DCameraSAState state_ = DCAMERA_SA_STATE_STOP; 54 friend class DCameraSinkLoadCallback; 55 sptr<DCameraSinkCallback> dCameraSinkCallback_ = nullptr; 56 }; 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 __attribute__((visibility("default"))) IDistributedHardwareSink *GetSinkHardwareHandler(); 62 #ifdef __cplusplus 63 } 64 #endif 65 } // namespace DistributedHardware 66 } // namespace OHOS 67 #endif // OHOS_DCAMERA_SINK_HANDLER_H