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_CameraKit 18 * @{ 19 * 20 * @brief Defines the <b>CameraKit</b> class for using camera functionalities. 21 * @since 1.0 22 * @version 1.0 23 */ 24 25 /** 26 * @file camera_kit.h 27 * 28 * @brief Declares functions in the <b>CameraKit</b> class. 29 * 30 * 31 * @since 1.0 32 * @version 1.0 33 */ 34 35 #ifndef OHOS_CAMERA_KIT_H 36 #define OHOS_CAMERA_KIT_H 37 38 #include <list> 39 #include <string> 40 41 #include "camera_ability.h" 42 #include "camera_info.h" 43 #include "camera_device_callback.h" 44 #include "camera_state_callback.h" 45 #include "event_handler.h" 46 47 namespace OHOS { 48 namespace Media { 49 /** 50 * 51 * @brief Provides functions in the <b>CameraKit</b> class. 52 * 53 * 54 * @since 1.0 55 * @version 1.0 56 */ 57 class CameraKit { 58 public: 59 /** 60 * @brief A destructor used to delete the <b>CameraKit</b> instance. 61 * 62 */ 63 ~CameraKit(); 64 /** 65 * @brief Obtains a single instance of the <b>CameraKit</b>. 66 * @return Returns the <b>CameraKit</b> instance if obtained; returns <b>NULL</b> otherwise. 67 */ 68 static CameraKit *GetInstance(); 69 70 /** 71 * @brief Obtains num of supported camera mode. 72 * 73 * @return Returns the num. 74 */ 75 uint8_t GetCameraModeNum(); 76 77 /** 78 * @brief set camera working mode index. 79 * 80 * @return Returns 0 if success, other if fail. 81 */ 82 int32_t SetCameraMode(uint8_t modeIndex); 83 84 /** 85 * @brief Obtains IDs of cameras that are currently available. 86 * 87 * @return Returns the camera IDs if obtained; returns <b>NULL</b> otherwise. 88 */ 89 std::list<std::string> GetCameraIds(); 90 91 /** 92 * @brief Obtains the camera capability, including the resolutions and frame rates. 93 * 94 * @param cameraId Indicates the camera ID. 95 * @return Returns the <b>CameraAbility</b> object. 96 */ 97 const CameraAbility *GetCameraAbility(std::string cameraId); 98 99 /** 100 * @brief Obtains the camera device info, including the camera type and facing type. 101 * 102 * @param cameraId Indicates the camera ID. 103 * @return Returns the <b>CameraInfo</b> object. 104 */ 105 const CameraInfo *GetCameraInfo(std::string cameraId); 106 107 /** 108 * @brief Registers a camera callback for camera status changes 109 * and an event callback to respond to a triggered event. 110 * 111 * @param callback Indicates the camera callback to register. 112 * @param handler Indicates the event callback to register. 113 */ 114 void RegisterCameraDeviceCallback(CameraDeviceCallback &callback, EventHandler &handler); 115 116 /** 117 * @brief Unregisters a camera callback. 118 * 119 * @param callback Indicates the camera callback to unregister. 120 */ 121 void UnregisterCameraDeviceCallback(CameraDeviceCallback &callback); 122 123 /** 124 * @brief Creates a camera object. 125 * 126 * @param cameraId Indicates the camera ID. 127 * @param callback Indicates the camera callback. 128 * @param handler Indicates the event callback to register. 129 */ 130 void CreateCamera(const std::string &cameraId, CameraStateCallback &callback, EventHandler &handler); 131 132 private: 133 /** 134 * @brief A constructor used to create a <b>CameraDeviceCallback</b> instance. 135 * 136 */ 137 CameraKit(); 138 }; 139 } // namespace Media 140 } // namespace OHOS 141 142 #endif // OHOS_CAMERA_KIT_H 143