1 /*
2  * Copyright (c) 2021-2022 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_DATRA_PROCESS_H
17 #define OHOS_DCAMERA_SOURCE_DATRA_PROCESS_H
18 
19 #include <mutex>
20 #include <set>
21 #include <string>
22 
23 #include "dcamera_stream_data_process.h"
24 #include "icamera_source_data_process.h"
25 
26 #include "v1_1/dcamera_types.h"
27 
28 namespace OHOS {
29 namespace DistributedHardware {
30 using namespace OHOS::HDI::DistributedCamera::V1_1;
31 class DCameraSourceDataProcess : public ICameraSourceDataProcess {
32 public:
33     DCameraSourceDataProcess(std::string devId, std::string dhId, DCStreamType streamType);
34     ~DCameraSourceDataProcess() override;
35 
36     int32_t FeedStream(std::vector<std::shared_ptr<DataBuffer>>& buffers) override;
37     int32_t ConfigStreams(std::vector<std::shared_ptr<DCStreamInfo>>& streamInfos) override;
38     int32_t ReleaseStreams(std::vector<int32_t>& streamIds) override;
39     int32_t StartCapture(std::shared_ptr<DCCaptureInfo>& captureInfo) override;
40     int32_t StopCapture(std::vector<int32_t>& streamIds) override;
41     int32_t GetProducerSize() override;
42     void GetAllStreamIds(std::vector<int32_t>& streamIds) override;
43 
44 private:
45     void DestroyPipeline();
46 
47 private:
48     std::mutex streamMutex_;
49     std::vector<std::shared_ptr<DCameraStreamDataProcess>> streamProcess_;
50     std::set<int32_t> streamIds_;
51     std::string devId_;
52     std::string dhId_;
53     DCStreamType streamType_;
54     bool isFirstContStream_;
55 };
56 } // namespace DistributedHardware
57 } // namespace OHOS
58 #endif // OHOS_DCAMERA_SOURCE_DATRA_PROCESS_H