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_CAPTURE_OUTPUT_H 17 #define OHOS_CAMERA_CAPTURE_OUTPUT_H 18 19 #include <mutex> 20 #include <refbase.h> 21 #include "camera_error_code.h" 22 #include "icamera_util.h" 23 #include "istream_common.h" 24 #include "session/capture_session.h" 25 26 namespace OHOS { 27 namespace CameraStandard { 28 enum CaptureOutputType { 29 CAPTURE_OUTPUT_TYPE_PREVIEW, 30 CAPTURE_OUTPUT_TYPE_PHOTO, 31 CAPTURE_OUTPUT_TYPE_VIDEO, 32 CAPTURE_OUTPUT_TYPE_METADATA, 33 CAPTURE_OUTPUT_TYPE_MAX 34 }; 35 static const char* g_captureOutputTypeString[CAPTURE_OUTPUT_TYPE_MAX] = {"Preview", "Photo", "Video", "Metadata"}; 36 class CaptureSession; 37 class CaptureOutput : public RefBase { 38 public: 39 explicit CaptureOutput(CaptureOutputType OutputType, StreamType streamType, 40 sptr<IStreamCommon> stream); ~CaptureOutput()41 virtual ~CaptureOutput() 42 { 43 stream_ = nullptr; 44 session_ = nullptr; 45 } 46 47 /** 48 * @brief Releases the instance of CaptureOutput. 49 */ 50 virtual int32_t Release() = 0; 51 52 CaptureOutputType GetOutputType(); 53 const char* GetOutputTypeString(); 54 StreamType GetStreamType(); 55 sptr<IStreamCommon> GetStream(); 56 CaptureSession* GetSession(); 57 void SetSession(CaptureSession* captureSession); 58 std::mutex asyncOpMutex_; 59 private: 60 CaptureOutputType outputType_; 61 StreamType streamType_; 62 sptr<IStreamCommon> stream_; 63 CaptureSession* session_; 64 }; 65 } // namespace CameraStandard 66 } // namespace OHOS 67 #endif // OHOS_CAMERA_CAPTURE_OUTPUT_H 68