1 /* 2 * Copyright (c) 2021 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 "single_instance.h" 25 26 namespace OHOS { 27 namespace DistributedHardware { 28 class DCameraSinkHandler : public IDistributedHardwareSink { 29 DECLARE_SINGLE_INSTANCE_BASE(DCameraSinkHandler); 30 public: 31 int32_t InitSink(const std::string& params) override; 32 int32_t ReleaseSink() override; 33 int32_t SubscribeLocalHardware(const std::string& dhId, const std::string& parameters) override; 34 int32_t UnsubscribeLocalHardware(const std::string& dhId) override; 35 private: 36 typedef enum { 37 DCAMERA_SA_STATE_STOP = 0, 38 DCAMERA_SA_STATE_START = 1, 39 } DCameraSAState; 40 DCameraSinkHandler() = default; 41 ~DCameraSinkHandler(); 42 void FinishStartSA(const std::string ¶ms); 43 void FinishStartSAFailed(const int32_t systemAbilityId); 44 private: 45 std::condition_variable producerCon_; 46 std::mutex producerMutex_; 47 DCameraSAState state_ = DCAMERA_SA_STATE_STOP; 48 friend class DCameraSinkLoadCallback; 49 }; 50 51 #ifdef __cplusplus 52 extern "C" { 53 #endif 54 __attribute__((visibility("default"))) IDistributedHardwareSink *GetSinkHardwareHandler(); 55 #ifdef __cplusplus 56 } 57 #endif 58 } // namespace DistributedHardware 59 } // namespace OHOS 60 #endif // OHOS_DCAMERA_SINK_HANDLER_H