• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 namespace OHOS {
28 namespace DistributedHardware {
29 class DCameraSinkOutput : public ICameraSinkOutput, public std::enable_shared_from_this<DCameraSinkOutput> {
30 public:
31     DCameraSinkOutput(const std::string& dhId, std::shared_ptr<ICameraOperator>& cameraOperator);
32     ~DCameraSinkOutput();
33 
34     int32_t Init() override;
35     int32_t UnInit() override;
36     int32_t StartCapture(std::vector<std::shared_ptr<DCameraCaptureInfo>>& captureInfos) override;
37     int32_t StopCapture() override;
38     int32_t OpenChannel(std::shared_ptr<DCameraChannelInfo>& info) override;
39     int32_t CloseChannel() override;
40 
41     void OnPhotoResult(std::shared_ptr<DataBuffer>& buffer);
42     void OnVideoResult(std::shared_ptr<DataBuffer>& buffer);
43 
44     void OnSessionState(DCStreamType type, int32_t state);
45     void OnSessionError(DCStreamType type, int32_t eventType, int32_t eventReason, std::string detail);
46     void OnDataReceived(DCStreamType type, std::vector<std::shared_ptr<DataBuffer>>& dataBuffers);
47 
48 private:
49     void InitInner(DCStreamType type);
50 
51     bool isInit_;
52     std::string dhId_;
53     std::map<DCStreamType, int32_t> sessionState_;
54     std::map<DCStreamType, std::shared_ptr<ICameraChannel>> channels_;
55     std::map<DCStreamType, std::shared_ptr<ICameraSinkDataProcess>> dataProcesses_;
56     std::shared_ptr<ICameraOperator> operator_;
57 };
58 } // namespace DistributedHardware
59 } // namespace OHOS
60 #endif // OHOS_DCAMERA_SINK_OUTPUT_H