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_CAMERA_H_STREAM_DEPTH_DATA_H
17 #define OHOS_CAMERA_H_STREAM_DEPTH_DATA_H
18 
19 #include <cstdint>
20 #include <functional>
21 #include <iostream>
22 #include <refbase.h>
23 
24 #include "camera_metadata_info.h"
25 #include "hstream_common.h"
26 #include "hstream_depth_data_stub.h"
27 #include "istream_depth_data_callback.h"
28 #include "v1_0/istream_operator.h"
29 
30 namespace OHOS {
31 namespace CameraStandard {
32 
33 enum class DepthDataStreamStatus {
34     STOPED,
35     STARTED
36 };
37 
38 class HStreamDepthData : public HStreamDepthDataStub, public HStreamCommon {
39 public:
40     HStreamDepthData(
41         sptr<OHOS::IBufferProducer> producer, int32_t format, int32_t width, int32_t height);
42     ~HStreamDepthData();
43 
44     int32_t LinkInput(sptr<OHOS::HDI::Camera::V1_0::IStreamOperator> streamOperator,
45         std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility) override;
46     void SetStreamInfo(StreamInfo_V1_1& streamInfo) override;
47     int32_t ReleaseStream(bool isDelay) override;
48     int32_t Release() override;
49     int32_t Start() override;
50     int32_t Stop() override;
51     int32_t SetCallback(sptr<IStreamDepthDataCallback>& callback) override;
52     int32_t OnDepthDataError(int32_t errorType);
53     int32_t SetDataAccuracy(int32_t accuracy) override;
54     void DumpStreamInfo(CameraInfoDumper& infoDumper) override;
55     int32_t OperatePermissionCheck(uint32_t interfaceCode) override;
56 
57 private:
58     sptr<IStreamDepthDataCallback> streamDepthDataCallback_;
59     std::mutex callbackLock_;
60     std::mutex streamStartStopLock_;
61     wptr<HStreamDepthData> parentStreamDepthData_;
62     DepthDataStreamStatus depthDataStreamStatus_ = DepthDataStreamStatus::STOPED;
63     sptr<OHOS::IBufferProducer> metaProducer_;
64     std::vector<int32_t> streamDepthDataAccuracy_ = {};
65 };
66 } // namespace CameraStandard
67 } // namespace OHOS
68 #endif // OHOS_CAMERA_H_STREAM_DEPTH_DATA_H