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_SOURCE_CONTROLLER_H 17 #define OHOS_DCAMERA_SOURCE_CONTROLLER_H 18 19 #include "icamera_controller.h" 20 21 #include "dcamera_index.h" 22 #include "icamera_channel_listener.h" 23 #include "dcamera_source_state_machine.h" 24 #include "event_bus.h" 25 #include "icamera_channel.h" 26 27 #include "v1_0/id_camera_provider.h" 28 29 namespace OHOS { 30 namespace DistributedHardware { 31 class DCameraSourceController : public ICameraController, public EventSender, 32 public std::enable_shared_from_this<DCameraSourceController> { 33 public: 34 DCameraSourceController(std::string devId, std::string dhId, 35 std::shared_ptr<DCameraSourceStateMachine>& stateMachine, std::shared_ptr<EventBus>& eventBus); 36 ~DCameraSourceController(); 37 int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) override; 38 int32_t StopCapture() override; 39 int32_t ChannelNeg(std::shared_ptr<DCameraChannelInfo>& info) override; 40 int32_t DCameraNotify(std::shared_ptr<DCameraEvent>& events) override; 41 int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; 42 int32_t GetCameraInfo(std::shared_ptr<DCameraInfo>& camInfo) override; 43 int32_t OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo) override; 44 int32_t CloseChannel() override; 45 int32_t Init(std::vector<DCameraIndex>& indexs) override; 46 int32_t UnInit() override; 47 48 void OnSessionState(int32_t state); 49 void OnSessionError(int32_t eventType, int32_t eventReason, std::string detail); 50 void OnDataReceived(std::vector<std::shared_ptr<DataBuffer>>& buffers); 51 52 private: 53 void HandleMetaDataResult(std::string& jsonStr); 54 55 private: 56 std::string devId_; 57 std::string dhId_; 58 std::shared_ptr<ICameraChannel> channel_; 59 std::shared_ptr<ICameraChannelListener> listener_; 60 std::vector<DCameraIndex> indexs_; 61 std::shared_ptr<DCameraSourceStateMachine> stateMachine_; 62 std::shared_ptr<EventBus> eventBus_; 63 int32_t channelState_; 64 sptr<IDCameraProvider> camHdiProvider_; 65 66 bool isInit; 67 const std::string SESSION_FLAG = "control"; 68 }; 69 } // namespace DistributedHardware 70 } // namespace OHOS 71 #endif // OHOS_DCAMERA_SOURCE_CONTROLLER_H 72