1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file expected 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 HDI_COMMON_V1_1_H
17 #define HDI_COMMON_V1_1_H
18 
19 #include "hdi_common.h"
20 #include "v1_1/types.h"
21 #include "v1_1/icamera_host.h"
22 #include "v1_1/icamera_device.h"
23 #include "v1_1/istream_operator.h"
24 #include "v1_1/camera_host_proxy.h"
25 
26 namespace OHOS::Camera {
27 enum CameraIds {
28     DEVICE_0, // rear camera
29     DEVICE_1, // front camera
30     DEVICE_2,
31     DEVICE_3,
32     DEVICE_4,
33     DEVICE_5,
34     DEVICE_6,
35 };
36 using namespace OHOS::HDI::Camera::V1_1;
37 class HdiCommonV1_1 : public OHOS::Camera::HdiCommon {
38 public:
39     void Init();
40     void Open(int cameraId);
41     void GetCameraMetadata(int cameraId);
42     void DefaultPreview(std::shared_ptr<StreamInfo_V1_1> &infos);
43     void DefaultCapture(std::shared_ptr<StreamInfo_V1_1> &infos);
44     void DefaultInfosPreview(std::shared_ptr<StreamInfo_V1_1> &infos);
45     void DefaultInfosCapture(std::shared_ptr<StreamInfo_V1_1> &infos);
46     void DefaultInfosAnalyze(std::shared_ptr<StreamInfo_V1_1> &infos);
47     void DefaultInfosVideo(std::shared_ptr<StreamInfo_V1_1> &infos);
48     void StartStream(std::vector<StreamIntent> intents);
49     void StartStream(std::vector<StreamIntent> intents, OperationMode_V1_1 mode);
50     void StartCapture(int streamId, int captureId, bool shutterCallback, bool isStreaming);
51     void StopStream(std::vector<int>& captureIds, std::vector<int>& streamIds);
52     OHOS::sptr<OHOS::HDI::Camera::V1_1::ICameraHost> serviceV1_1 = nullptr;
53     OHOS::sptr<OHOS::HDI::Camera::V1_1::ICameraDevice> cameraDeviceV1_1 = nullptr;
54     OHOS::sptr<OHOS::HDI::Camera::V1_1::IStreamOperator> streamOperator_V1_1 = nullptr;
55     std::vector<StreamInfo_V1_1> streamInfos;
56     std::vector<StreamInfo_V1_1> streamInfosV1_1;
57     std::shared_ptr<PrelaunchConfig> prelaunchConfig = nullptr;
58     std::shared_ptr<StreamInfo_V1_1> streamInfoV1_1 = nullptr;
59     std::shared_ptr<StreamInfo_V1_1> streamInfo = nullptr;
60     std::shared_ptr<StreamInfo_V1_1> streamInfoSnapshot = nullptr;
61     std::shared_ptr<StreamInfo_V1_1> streamInfoCapture = nullptr;
62     std::shared_ptr<StreamInfo_V1_1> streamInfoAnalyze = nullptr;
63     std::shared_ptr<StreamInfo_V1_1> streamInfoPre = nullptr;
64     std::shared_ptr<StreamInfo_V1_1> streamInfoVideo = nullptr;
65 
66     class StreamConsumer : public OHOS::Camera::HdiCommon::StreamConsumer {
67     public:
68         void GetTimeStamp(int64_t *g_timestamp, uint32_t lenght, int64_t timestamp, int32_t gotSize);
69         OHOS::sptr<OHOS::IBufferProducer> CreateProducer(std::function<void(void*, uint32_t)> callback);
70         OHOS::sptr<BufferProducerSequenceable> CreateProducerSeq(std::function<void(void*, uint32_t)> callback);
71     public:
72         static int64_t g_timestamp[2];
73     };
74 };
75 }
76 #endif
77