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_OUTPUT_CAPABILITY_H 17 #define OHOS_CAMERA_OUTPUT_CAPABILITY_H 18 19 #include <cstdint> 20 #include <iostream> 21 #include <vector> 22 #include <refbase.h> 23 24 #include "istream_repeat_callback.h" 25 #include "metadata_type.h" 26 27 namespace OHOS { 28 namespace CameraStandard { 29 typedef struct { 30 uint32_t width; 31 uint32_t height; 32 } Size; 33 34 typedef struct { 35 uint32_t fixedFps; 36 uint32_t minFps; 37 uint32_t maxFps; 38 } Fps; 39 40 enum CameraFormat { 41 CAMERA_FORMAT_INVALID = -1, 42 CAMERA_FORMAT_YCBCR_420_888 = 2, 43 CAMERA_FORMAT_RGBA_8888 = 3, 44 CAMERA_FORMAT_YUV_420_SP = 1003, 45 CAMERA_FORMAT_JPEG = 2000, 46 CAMERA_FORMAT_YCBCR_P010 = 2001, 47 CAMERA_FORMAT_YCRCB_P010 = 2002 48 }; 49 50 class Profile { 51 public: 52 Profile(CameraFormat format, Size size); 53 Profile(CameraFormat format, Size size, Fps fps, std::vector<uint32_t> abilityId); 54 Profile() = default; 55 Profile& operator=(const Profile& profile) 56 { 57 if (this != &profile) { 58 this->format_ = profile.format_; 59 this->size_ = profile.size_; 60 this->fps_ = profile.fps_; 61 this->abilityId_ = profile.abilityId_; 62 } 63 return *this; 64 } 65 bool operator==(const Profile& profile) 66 { 67 return this->format_ == profile.format_ && this->size_.width == profile.size_.width && 68 this->size_.height == profile.size_.height; 69 } 70 virtual ~Profile() = default; 71 72 /** 73 * @brief Get camera format of the profile. 74 * 75 * @return camera format of the profile. 76 */ 77 CameraFormat GetCameraFormat(); 78 79 /** 80 * @brief Get resolution of the profile. 81 * 82 * @return resolution of the profile. 83 */ 84 Size GetSize(); 85 std::vector<uint32_t> GetAbilityId(); 86 87 CameraFormat format_ = CAMERA_FORMAT_INVALID; 88 Size size_ = {0, 0}; 89 Fps fps_ = {0, 0, 0}; 90 std::vector<uint32_t> abilityId_ = {}; 91 }; 92 93 class VideoProfile : public Profile { 94 public: 95 VideoProfile(CameraFormat format, Size size, std::vector<int32_t> framerates); 96 VideoProfile() = default; 97 virtual ~VideoProfile() = default; 98 99 /** 100 * @brief Get supported framerates of the profile. 101 * 102 * @return vector of supported framerate. 103 */ 104 std::vector<int32_t> GetFrameRates(); 105 106 std::vector<int32_t> framerates_ = {}; 107 }; 108 109 class CameraOutputCapability : public RefBase { 110 public: 111 CameraOutputCapability() = default; 112 virtual ~CameraOutputCapability() = default; 113 114 /** 115 * @brief Get Photo profiles. 116 * 117 * @return vector of supported photo profiles. 118 */ 119 std::vector<Profile> GetPhotoProfiles(); 120 121 /** 122 * @brief Set Photo profiles. 123 * 124 * @param vector of photo profiles. 125 */ 126 void SetPhotoProfiles(std::vector<Profile> photoProfiles); 127 128 /** 129 * @brief Get Preview profiles. 130 * 131 * @return vector of supported preview profiles. 132 */ 133 std::vector<Profile> GetPreviewProfiles(); 134 135 /** 136 * @brief Set preview profiles. 137 * 138 * @param vector of preview profiles. 139 */ 140 void SetPreviewProfiles(std::vector<Profile> previewProfiles); 141 142 /** 143 * @brief Get video profiles. 144 * 145 * @return vector of supported video profiles. 146 */ 147 std::vector<VideoProfile> GetVideoProfiles(); 148 149 /** 150 * @brief Set video profiles. 151 * 152 * @param vector of video profiles. 153 */ 154 void SetVideoProfiles(std::vector<VideoProfile> videoProfiles); 155 156 /** 157 * @brief Get supported meta object types. 158 * 159 * @return vector of supported metadata object types. 160 */ 161 std::vector<MetadataObjectType> GetSupportedMetadataObjectType(); 162 163 /** 164 * @brief Get supported meta object types. 165 * 166 * @return vector of supported metadata object types. 167 */ 168 void SetSupportedMetadataObjectType(std::vector<MetadataObjectType> metadataObjTypes); 169 170 private: 171 std::vector<Profile> photoProfiles_ = {}; 172 std::vector<Profile> previewProfiles_ = {}; 173 std::vector<VideoProfile> videoProfiles_ = {}; 174 std::vector<MetadataObjectType> metadataObjTypes_ = {}; 175 }; 176 } // namespace CameraStandard 177 } // namespace OHOS 178 #endif // OHOS_CAMERA_OUTPUT_CAPABILITY_H 179