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