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_ICAMERA_SOURCE_DATA_PROCESS_H
17 #define OHOS_ICAMERA_SOURCE_DATA_PROCESS_H
18 
19 #include <vector>
20 
21 #include "data_buffer.h"
22 #include "v1_1/dcamera_types.h"
23 
24 namespace OHOS {
25 namespace DistributedHardware {
26 using namespace OHOS::HDI::DistributedCamera::V1_1;
27 class DCameraStreamConfig {
28 public:
DCameraStreamConfig(int32_t width,int32_t height,int32_t format,int32_t dataspace,DCEncodeType encodeType,DCStreamType streamType)29     DCameraStreamConfig(int32_t width, int32_t height, int32_t format, int32_t dataspace,
30         DCEncodeType encodeType, DCStreamType streamType)
31         : width_(width), height_(height), format_(format), dataspace_(dataspace), encodeType_(encodeType),
32         type_(streamType)
33     {}
34     ~DCameraStreamConfig() = default;
35     int32_t width_;
36     int32_t height_;
37     int32_t format_;
38     int32_t dataspace_;
39     DCEncodeType encodeType_;
40     DCStreamType type_;
41 
42     bool operator == (const DCameraStreamConfig& others) const
43     {
44         return this->width_ == others.width_ && this->height_ == others.height_ && this->format_ == others.format_ &&
45             this->dataspace_ == others.dataspace_ && this->encodeType_ == others.encodeType_ &&
46             this->type_ == others.type_;
47     }
48 
49     bool operator < (const DCameraStreamConfig& others) const
50     {
51         return (this->width_ < others.width_) || ((this->width_ == others.width_) && (this->height_ < others.height_));
52     }
53 };
54 
55 class ICameraSourceDataProcess {
56 public:
57     virtual ~ICameraSourceDataProcess() = default;
58 
59     virtual int32_t FeedStream(std::vector<std::shared_ptr<DataBuffer>>& buffers) = 0;
60     virtual int32_t ConfigStreams(std::vector<std::shared_ptr<DCStreamInfo>>& streamInos) = 0;
61     virtual int32_t ReleaseStreams(std::vector<int32_t>& streamIds) = 0;
62     virtual int32_t StartCapture(std::shared_ptr<DCCaptureInfo>& captureInfo) = 0;
63     virtual int32_t StopCapture(std::vector<int32_t>& streamIds) = 0;
64     virtual int32_t GetProducerSize() = 0;
65     virtual void GetAllStreamIds(std::vector<int32_t>& streamIds) = 0;
66 };
67 } // namespace DistributedHardware
68 } // namespace OHOS
69 #endif // OHOS_ICAMERA_SOURCE_DATA_PROCESS_H
70