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_INPUT_H 17 #define OHOS_DCAMERA_SOURCE_INPUT_H 18 19 #include "icamera_channel.h" 20 #include "icamera_channel_listener.h" 21 #include "icamera_input.h" 22 #include "icamera_source_data_process.h" 23 24 #include "event_bus.h" 25 #include "event_sender.h" 26 27 namespace OHOS { 28 namespace DistributedHardware { 29 class DCameraSourceInput : public ICameraInput, public EventSender, 30 public std::enable_shared_from_this<DCameraSourceInput> { 31 public: 32 DCameraSourceInput(std::string devId, std::string dhId, std::shared_ptr<EventBus>& eventBus); 33 ~DCameraSourceInput(); 34 35 int32_t ConfigStreams(std::vector<std::shared_ptr<DCStreamInfo>>& streamInfos) override; 36 int32_t ReleaseStreams(std::vector<int>& streamIds, bool& isAllRelease) override; 37 int32_t ReleaseAllStreams() override; 38 int32_t StartCapture(std::vector<std::shared_ptr<DCCaptureInfo>>& captureInfos) override; 39 int32_t StopCapture(std::vector<int>& streamIds, bool& isAllStop) override; 40 int32_t StopAllCapture() override; 41 int32_t OpenChannel(std::vector<DCameraIndex>& indexs) override; 42 int32_t CloseChannel() override; 43 int32_t Init() override; 44 int32_t UnInit() override; 45 int32_t UpdateSettings(std::vector<std::shared_ptr<DCameraSettings>>& settings) override; 46 47 void OnSessionState(DCStreamType streamType, int32_t state); 48 void OnSessionError(DCStreamType streamType, int32_t eventType, int32_t eventReason, std::string detail); 49 void OnDataReceived(DCStreamType streamType, std::vector<std::shared_ptr<DataBuffer>>& buffers); 50 51 private: 52 void FinshFrameAsyncTrace(DCStreamType streamType); 53 54 private: 55 std::map<DCStreamType, std::shared_ptr<ICameraChannel>> channels_; 56 std::map<DCStreamType, std::shared_ptr<ICameraChannelListener>> listeners_; 57 std::map<DCStreamType, std::shared_ptr<ICameraSourceDataProcess>> dataProcess_; 58 std::map<DCStreamType, DCameraChannelState> channelState_; 59 std::string devId_; 60 std::string dhId_; 61 std::shared_ptr<EventBus> eventBus_; 62 63 bool isInit = false; 64 }; 65 } // namespace DistributedHardware 66 } // namespace OHOS 67 #endif // OHOS_DCAMERA_SOURCE_INPUT_H 68