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