• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CAPTURE_H
17 #define OHOS_CAMERA_H_STREAM_CAPTURE_H
18 
19 #include <cstdint>
20 #include <iostream>
21 #include <refbase.h>
22 
23 #include "camera_metadata_info.h"
24 #include "hstream_capture_stub.h"
25 #include "hstream_common.h"
26 #include "v1_0/istream_operator.h"
27 #include "v1_2/istream_operator.h"
28 
29 namespace OHOS {
30 namespace CameraStandard {
31 using OHOS::HDI::Camera::V1_0::BufferProducerSequenceable;
32 class HStreamCapture : public HStreamCaptureStub, public HStreamCommon {
33 public:
34     HStreamCapture(sptr<OHOS::IBufferProducer> producer, int32_t format, int32_t width, int32_t height);
35     ~HStreamCapture();
36 
37     int32_t LinkInput(sptr<OHOS::HDI::Camera::V1_0::IStreamOperator> streamOperator,
38         std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility) override;
39     void SetStreamInfo(StreamInfo_V1_1 &streamInfo) override;
40     int32_t SetThumbnail(bool isEnabled, const sptr<OHOS::IBufferProducer> &producer) override;
41     int32_t DeferImageDeliveryFor(int32_t type) override;
42     int32_t Capture(const std::shared_ptr<OHOS::Camera::CameraMetadata> &captureSettings) override;
43     int32_t CancelCapture() override;
44     int32_t ConfirmCapture() override;
45     int32_t ReleaseStream(bool isDelay) override;
46     int32_t Release() override;
47     int32_t SetCallback(sptr<IStreamCaptureCallback> &callback) override;
48     int32_t OnCaptureStarted(int32_t captureId);
49     int32_t OnCaptureStarted(int32_t captureId, uint32_t exposureTime);
50     int32_t OnCaptureEnded(int32_t captureId, int32_t frameCount);
51     int32_t OnCaptureError(int32_t captureId, int32_t errorType);
52     int32_t OnFrameShutter(int32_t captureId, uint64_t timestamp);
53     void DumpStreamInfo(std::string& dumpString) override;
54     void SetRotation(const std::shared_ptr<OHOS::Camera::CameraMetadata> &captureMetadataSetting_);
55     void PrintDebugLog(const std::shared_ptr<OHOS::Camera::CameraMetadata> &captureMetadataSetting_);
56     void SetMode(int32_t modeName);
57     int32_t GetMode();
58     int32_t IsDeferredPhotoEnabled() override;
59     int32_t IsDeferredVideoEnabled() override;
60 
61     int32_t OperatePermissionCheck(uint32_t interfaceCode) override;
62 
63 private:
64     sptr<IStreamCaptureCallback> streamCaptureCallback_;
65     std::mutex callbackLock_;
66     int32_t thumbnailSwitch_;
67     sptr<BufferProducerSequenceable> thumbnailBufferQueue_;
68     int32_t modeName_;
69     int32_t deferredPhotoSwitch_;
70     int32_t deferredVideoSwitch_;
71 };
72 } // namespace CameraStandard
73 } // namespace OHOS
74 #endif // OHOS_CAMERA_H_STREAM_CAPTURE_H
75