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 <iostream> 20 #include <refbase.h> 21 22 #include "camera_metadata_info.h" 23 #include "display_type.h" 24 #include "hstream_capture_stub.h" 25 #include "istream_operator.h" 26 27 namespace OHOS { 28 namespace CameraStandard { 29 class HStreamCapture : public HStreamCaptureStub { 30 public: 31 HStreamCapture(sptr<OHOS::IBufferProducer> surface, int32_t format); 32 ~HStreamCapture(); 33 34 static void ResetCaptureId(); 35 int32_t LinkInput(sptr<Camera::IStreamOperator> streamOperator, 36 std::shared_ptr<Camera::CameraMetadata> cameraAbility, int32_t streamId); 37 void SetStreamInfo(std::shared_ptr<Camera::StreamInfo> streamInfo); 38 int32_t Capture(const std::shared_ptr<Camera::CameraMetadata> &captureSettings) override; 39 int32_t CancelCapture() override; 40 int32_t Release() override; 41 int32_t SetCallback(sptr<IStreamCaptureCallback> &callback) override; 42 int32_t OnCaptureStarted(int32_t captureId); 43 int32_t OnCaptureEnded(int32_t captureId, int32_t frameCount); 44 int32_t OnCaptureError(int32_t captureId, int32_t errorType); 45 int32_t OnFrameShutter(int32_t captureId, uint64_t timestamp); 46 int32_t GetStreamId(); 47 bool IsReleaseStream(); 48 int32_t SetReleaseStream(bool isReleaseStream); 49 void dumpCaptureStreamInfo(std::string& dumpString); 50 51 private: 52 static int32_t photoCaptureId_; 53 bool IsValidCaptureID(); 54 sptr<Camera::IStreamOperator> streamOperator_; 55 int32_t photoStreamId_; 56 int32_t format_; 57 bool isReleaseStream_; 58 sptr<OHOS::IBufferProducer> producer_; 59 sptr<IStreamCaptureCallback> streamCaptureCallback_; 60 std::shared_ptr<Camera::CameraMetadata> cameraAbility_; 61 }; 62 } // namespace CameraStandard 63 } // namespace OHOS 64 #endif // OHOS_CAMERA_H_STREAM_CAPTURE_H 65