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_OUTPUT_H 17 #define OHOS_DCAMERA_SINK_OUTPUT_H 18 19 #include "icamera_sink_output.h" 20 21 #include <map> 22 23 #include "icamera_channel.h" 24 #include "icamera_operator.h" 25 #include "icamera_sink_data_process.h" 26 27 #include "property_carrier.h" 28 29 namespace OHOS { 30 namespace DistributedHardware { 31 class DCameraSinkOutput : public ICameraSinkOutput, public std::enable_shared_from_this<DCameraSinkOutput> { 32 public: 33 DCameraSinkOutput(const std::string& dhId, std::shared_ptr<ICameraOperator>& cameraOperator); 34 ~DCameraSinkOutput() override; 35 36 int32_t Init() override; 37 int32_t UnInit() override; 38 int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) override; 39 int32_t StopCapture() override; 40 int32_t OpenChannel(std::shared_ptr<DCameraChannelInfo>& info) override; 41 int32_t CloseChannel() override; 42 43 void OnPhotoResult(std::shared_ptr<DataBuffer>& buffer); 44 void OnVideoResult(std::shared_ptr<DataBuffer>& buffer); 45 46 void OnSessionState(DCStreamType type, int32_t state); 47 void OnSessionError(DCStreamType type, int32_t eventType, int32_t eventReason, std::string detail); 48 void OnDataReceived(DCStreamType type, std::vector<std::shared_ptr<DataBuffer>>& dataBuffers); 49 50 int32_t GetProperty(const std::string& propertyName, PropertyCarrier& propertyCarrier) override; 51 52 private: 53 void InitInner(DCStreamType type); 54 55 bool isInit_; 56 std::string dhId_; 57 std::map<DCStreamType, int32_t> sessionState_; 58 std::map<DCStreamType, std::shared_ptr<ICameraChannel>> channels_; 59 std::map<DCStreamType, std::shared_ptr<ICameraSinkDataProcess>> dataProcesses_; 60 std::shared_ptr<ICameraOperator> operator_; 61 }; 62 } // namespace DistributedHardware 63 } // namespace OHOS 64 #endif // OHOS_DCAMERA_SINK_OUTPUT_H