1 /* 2 * Copyright (c) 2020-2021 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 /** 17 * @addtogroup MultiMedia_Camera 18 * @{ 19 * 20 * @brief Defines the <b>Camera</b> class for camera-related operations. 21 * 22 * @since 1.0 23 * @version 1.0 24 */ 25 26 /** 27 * @file camera.h 28 * 29 * @brief Declares functions in the <b>Camera</b> class to implement camera 30 * operations. 31 * 32 * 33 * @since 1.0 34 * @version 1.0 35 */ 36 37 #ifndef OHOS_CAMERA_H 38 #define OHOS_CAMERA_H 39 40 #include <list> 41 #include <string> 42 43 #include "camera_config.h" 44 #include "frame_config.h" 45 46 namespace OHOS { 47 namespace Media { 48 /** 49 * 50 * @brief Provides functions in the <b>Camera</b> class to implement camera operations. 51 * operations. 52 * 53 * 54 * @since 1.0 55 * @version 1.0 56 */ 57 class Camera { 58 public: 59 /** 60 * @brief A destructor used to delete the <b>Camera</b> instance. 61 * 62 */ 63 virtual ~Camera() = default; 64 65 /** 66 * @brief Obtains the camera ID. 67 * 68 * @return Returns the camera ID if obtained; returns the "Error" string if 69 * the camera fails to be created. 70 */ GetCameraId()71 virtual std::string GetCameraId() 72 { 73 return std::string(); 74 } 75 76 /** 77 * @brief Obtains the camera configuration. 78 * You can use the obtained <b>CameraConfig</b> object to configure the 79 * camera. 80 * @return Returns the pointer to the <b>CameraConfig</b> object if obtained; 81 * returns <b>NULL</b> otherwise. 82 */ GetCameraConfig()83 virtual const CameraConfig *GetCameraConfig() const 84 { 85 return nullptr; 86 } 87 88 /** 89 * @brief Obtains the frame configuration. 90 * 91 * @param type Indicates the type of the frame configuration. 92 * @return Returns the pointer to the <b>FrameConfig</b> object if obtained; 93 * returns <b>NULL</b> otherwise. 94 */ GetFrameConfig(int32_t type)95 virtual FrameConfig *GetFrameConfig(int32_t type) 96 { 97 return nullptr; 98 } 99 100 /** 101 * @brief Configures the camera using the <b>CameraConfig</b> object. 102 * 103 * @param config Indicates the pointer to the <b>CameraConfig</b> object. 104 */ Configure(CameraConfig & config)105 virtual void Configure(CameraConfig &config) {} 106 107 /** 108 * @brief Triggers looping-frame capture. 109 * 110 * @param fc Indicates the frame configuration. 111 * @return Returns <b>true</b> if the looping-frame capture is successfully 112 * started; returns <b>false</b> otherwise. 113 */ TriggerLoopingCapture(FrameConfig & frameConfig)114 virtual int32_t TriggerLoopingCapture(FrameConfig &frameConfig) 115 { 116 return -1; 117 } 118 119 /** 120 * @brief Stops looping-frame capture. 121 * 122 * @param type Indicates the looping-frame capture type, such as FRAME_CONFIG_RECORD; 123 * Stop all looping-frame capture type if the value of type is -1. 124 * @return Returns <b>true</b> if the looping-frame capture is successfully 125 * stopped; returns <b>false</b> otherwise. 126 */ StopLoopingCapture(int32_t type)127 virtual void StopLoopingCapture(int32_t type) {} 128 129 /** 130 * @brief Starts single-frame capture. The frame parameters are set through 131 * the <b>FrameConfig</b> object, and the captured image data is stored in the 132 * surface of the <b>FrameConfig</b> object. 133 * 134 * @param fc Indicates the frame configuration. 135 * @return Returns <b>true</b> if the single-frame capture is successfully 136 * started and the data is stored; returns <b>false</b> otherwise. 137 */ TriggerSingleCapture(FrameConfig & frameConfig)138 virtual int32_t TriggerSingleCapture(FrameConfig &frameConfig) 139 { 140 return -1; 141 } 142 143 /** 144 * @brief Releases the <b>Camera</b> object and associated resources. 145 * 146 */ Release()147 virtual void Release() {} 148 149 protected: 150 /** 151 * @brief A constructor used to create a <b>Camera</b> instance. 152 * 153 */ 154 Camera() = default; 155 }; 156 } // namespace Media 157 } // namespace OHOS 158 #endif // OHOS_CAMERA_H 159