• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 NATIVE_AVCAPABILITY_H
17 #define NATIVE_AVCAPABILITY_H
18 
19 #include <stdint.h>
20 #include "native_averrors.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 typedef struct OH_AVCapability OH_AVCapability;
27 
28 /**
29  * @brief The bitrate mode of encoder.
30  * @syscap SystemCapability.Multimedia.Media.CodecBase
31  * @since 10
32  */
33 typedef enum OH_BitrateMode {
34     /* Constant Bit rate mode. */
35     BITRATE_MODE_CBR = 0,
36     /* Variable Bit rate mode. */
37     BITRATE_MODE_VBR = 1,
38     /* Constant Quality mode. */
39     BITRATE_MODE_CQ = 2
40 } OH_BitrateMode;
41 
42 /**
43  * @brief Range contain min and max value
44  * @syscap SystemCapability.Multimedia.Media.CodecBase
45  * @since 10
46  */
47 typedef struct OH_AVRange {
48     int32_t minVal;
49     int32_t maxVal;
50 } OH_AVRange;
51 
52 /**
53  * @brief The codec category
54  * @syscap SystemCapability.Multimedia.Media.CodecBase
55  * @since 10
56  */
57 typedef enum OH_AVCodecCategory {
58     HARDWARE = 0,
59     SOFTWARE
60 } OH_AVCodecCategory;
61 
62 /**
63  * @brief Get a system-recommended codec's capability.
64  * @syscap SystemCapability.Multimedia.Media.CodecBase
65  * @param mime Mime type
66  * @param isEncoder True for encoder, false for decoder
67  * @return Returns a capability instance if an existing codec matches,
68  * if the specified mime type doesn't match any existing codec, returns NULL.
69  * @since 10
70  */
71 OH_AVCapability *OH_AVCodec_GetCapability(const char *mime, bool isEncoder);
72 
73 /**
74  * @brief Get a codec's capability within the specified category. By specifying the category,
75  * the matched codec is limited to either hardware codecs or software codecs.
76  * @syscap SystemCapability.Multimedia.Media.CodecBase
77  * @param mime Mime type
78  * @param isEncoder True for encoder, false for decoder
79  * @param category The codec category
80  * @return Returns a capability instance if an existing codec matches,
81  * if the specified mime type doesn't match any existing codec, returns NULL
82  * @since 10
83  */
84 OH_AVCapability *OH_AVCodec_GetCapabilityByCategory(const char *mime, bool isEncoder, OH_AVCodecCategory category);
85 
86 /**
87  * @brief Check if the capability instance is describing a hardware codec.
88  * @syscap SystemCapability.Multimedia.Media.CodecBase
89  * @param capability Codec capability pointer
90  * @return Returns true if the capability instance is describing a hardware codec,
91  * false if the capability instance is describing a software codec
92  * @since 10
93  */
94 bool OH_AVCapability_IsHardware(OH_AVCapability *capability);
95 
96 /**
97  * @brief Get the codec name.
98  * @syscap SystemCapability.Multimedia.Media.CodecBase
99  * @param capability Codec capability pointer
100  * @return Returns codec name string
101  * @since 10
102  */
103 const char *OH_AVCapability_GetName(OH_AVCapability *capability);
104 
105 /**
106  * @brief Get the supported max instance number of the codec.
107  * @syscap SystemCapability.Multimedia.Media.CodecBase
108  * @param capability Codec capability pointer
109  * @return Returns the max supported codec instance number
110  * @since 10
111  */
112 int32_t OH_AVCapability_GetMaxSupportedInstances(OH_AVCapability *capability);
113 
114 /**
115  * @brief Get the encoder's supported bitrate range.
116  * @syscap SystemCapability.Multimedia.Media.CodecBase
117  * @param capability Encoder capability pointer. Do not give a decoder capability pointer
118  * @param bitrateRange Output parameter. Encoder bitrate range
119  * @return Returns AV_ERR_OK if the execution is successful,
120  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
121  * @since 10
122  */
123 OH_AVErrCode OH_AVCapability_GetEncoderBitrateRange(OH_AVCapability *capability, OH_AVRange *bitrateRange);
124 
125 /**
126  * @brief Check if the encoder supports the specific bitrate mode.
127  * @syscap SystemCapability.Multimedia.Media.CodecBase
128  * @param capability Encoder capability pointer. Do not give a decoder capability pointer
129  * @param bitrateMode Bitrate mode
130  * @return Returns true if the bitrate mode is supported, false if the bitrate mode is not supported
131  * @since 10
132  */
133 bool OH_AVCapability_IsEncoderBitrateModeSupported(OH_AVCapability *capability, OH_BitrateMode bitrateMode);
134 
135 /**
136  * @brief Get the encoder's supported quality range.
137  * @syscap SystemCapability.Multimedia.Media.CodecBase
138  * @param capability Encoder capability pointer. Do not give a decoder capability pointer
139  * @param qualityRange Output parameter. Encoder quality range
140  * @return Returns AV_ERR_OK if the execution is successful,
141  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
142  * @since 10
143  */
144 OH_AVErrCode OH_AVCapability_GetEncoderQualityRange(OH_AVCapability *capability, OH_AVRange *qualityRange);
145 
146 /**
147  * @brief Get the encoder's supported encoder complexity range.
148  * @syscap SystemCapability.Multimedia.Media.CodecBase
149  * @param capability Encoder capability pointer. Do not give a decoder capability pointer
150  * @param complexityRange Output parameter. Encoder complexity range
151  * @return Returns AV_ERR_OK if the execution is successful,
152  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
153  * @since 10
154  */
155 OH_AVErrCode OH_AVCapability_GetEncoderComplexityRange(OH_AVCapability *capability, OH_AVRange *complexityRange);
156 
157 /**
158  * @brief Get the audio codec's supported sample rates.
159  * @syscap SystemCapability.Multimedia.Media.CodecBase
160  * @param capability Audio codec capability pointer. Do not give a video codec capability pointer
161  * @param sampleRates Output parameter. A pointer to the sample rates array
162  * @param sampleRateNum Output parameter. The element number of the sample rates array
163  * @return Returns AV_ERR_OK if the execution is successful,
164  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
165  * @since 10
166  */
167 OH_AVErrCode OH_AVCapability_GetAudioSupportedSampleRates(OH_AVCapability *capability, const int32_t **sampleRates,
168                                                           uint32_t *sampleRateNum);
169 
170 /**
171  * @brief Get the audio codec's supported audio channel count range.
172  * @syscap SystemCapability.Multimedia.Media.CodecBase
173  * @param capability Audio codec capability pointer. Do not give a video codec capability pointer
174  * @param channelCountRange Output parameter. Audio channel count range
175  * @return Returns AV_ERR_OK if the execution is successful,
176  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
177  * @since 10
178  */
179 OH_AVErrCode OH_AVCapability_GetAudioChannelCountRange(OH_AVCapability *capability, OH_AVRange *channelCountRange);
180 
181 /**
182  * @brief Get the video codec's supported video width alignment.
183  * @syscap SystemCapability.Multimedia.Media.CodecBase
184  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
185  * @param widthAlignment Output parameter. Video width alignment
186  * @return Returns AV_ERR_OK if the execution is successful,
187  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
188  * @since 10
189  */
190 OH_AVErrCode OH_AVCapability_GetVideoWidthAlignment(OH_AVCapability *capability, int32_t *widthAlignment);
191 
192 /**
193  * @brief Get the video codec's supported video height alignment.
194  * @syscap SystemCapability.Multimedia.Media.CodecBase
195  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
196  * @param heightAlignment Output parameter. Video height alignment
197  * @return Returns AV_ERR_OK if the execution is successful,
198  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
199  * @since 10
200  */
201 OH_AVErrCode OH_AVCapability_GetVideoHeightAlignment(OH_AVCapability *capability, int32_t *heightAlignment);
202 
203 /**
204  * @brief Get the video codec's supported video width range for a specific height.
205  * @syscap SystemCapability.Multimedia.Media.CodecBase
206  * @param capability video codec capability pointer. Do not give an audio codec capability pointer
207  * @param height Vertical pixel number of the video
208  * @param widthRange Output parameter. Video width range
209  * @return Returns AV_ERR_OK if the execution is successful,
210  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
211  * @since 10
212  */
213 OH_AVErrCode OH_AVCapability_GetVideoWidthRangeForHeight(OH_AVCapability *capability, int32_t height,
214                                                          OH_AVRange *widthRange);
215 
216 /**
217  * @brief Get the video codec's supported video height range for a specific width.
218  * @syscap SystemCapability.Multimedia.Media.CodecBase
219  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
220  * @param width Horizontal pixel number of the video
221  * @param heightRange Output parameter. Video height range
222  * @return Returns AV_ERR_OK if the execution is successful,
223  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
224  * @since 10
225  */
226 OH_AVErrCode OH_AVCapability_GetVideoHeightRangeForWidth(OH_AVCapability *capability, int32_t width,
227                                                          OH_AVRange *heightRange);
228 
229 /**
230  * @brief Get the video codec's supported video width range.
231  * @syscap SystemCapability.Multimedia.Media.CodecBase
232  * @param capability Video codec capability pointer. DO not give an audio codec capability pointer
233  * @param widthRange Output parameter. Video width range
234  * @return Returns AV_ERR_OK if the execution is successful,
235  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
236  * @since 10
237  */
238 OH_AVErrCode OH_AVCapability_GetVideoWidthRange(OH_AVCapability *capability, OH_AVRange *widthRange);
239 
240 /**
241  * @brief Get the video codec's supported video height range.
242  * @syscap SystemCapability.Multimedia.Media.CodecBase
243  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
244  * @param heightRange Output parameter. Video height range
245  * @return Returns AV_ERR_OK if the execution is successful,
246  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
247  * @since 10
248  */
249 OH_AVErrCode OH_AVCapability_GetVideoHeightRange(OH_AVCapability *capability, OH_AVRange *heightRange);
250 
251 /**
252  * @brief Check if the video codec supports the specific video size.
253  * @syscap SystemCapability.Multimedia.Media.CodecBase
254  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
255  * @param width Horizontal pixel number of the video
256  * @param height Vertical pixel number of the video
257  * @return Returns true if the video size is supported, false if the video size is not supported
258  * @since 10
259  */
260 bool OH_AVCapability_IsVideoSizeSupported(OH_AVCapability *capability, int32_t width, int32_t height);
261 
262 /**
263  * @brief Get the video codec's supported video frame rate range.
264  * @syscap SystemCapability.Multimedia.Media.CodecBase
265  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
266  * @param frameRateRange Output parameter. Video frame rate range
267  * @return Returns AV_ERR_OK if the execution is successful,
268  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
269  * @since 10
270  */
271 OH_AVErrCode OH_AVCapability_GetVideoFrameRateRange(OH_AVCapability *capability, OH_AVRange *frameRateRange);
272 
273 /**
274  * @brief Get the Video codec's supported video frame rate range for a specified video size.
275  * @syscap SystemCapability.Multimedia.Media.CodecBase
276  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
277  * @param width Horizontal pixel number of the video
278  * @param height Vertical pixel number of the video
279  * @param frameRateRange Output parameter. Frame rate range
280  * @return Returns AV_ERR_OK if the execution is successful,
281  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
282  * @since 10
283  */
284 OH_AVErrCode OH_AVCapability_GetVideoFrameRateRangeForSize(OH_AVCapability *capability, int32_t width, int32_t height,
285                                                            OH_AVRange *frameRateRange);
286 
287 /**
288  * @brief Check if the video codec supports the specific combination of video size and frame rate.
289  * @syscap SystemCapability.Multimedia.Media.CodecBase
290  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
291  * @param width Horizontal pixel number of the video
292  * @param height Vertical pixel number of the video
293  * @param frameRate Frame number per second
294  * @return Returns true if the combination of video size and frame rate is supported,
295  * false if it is not supported
296  * @since 10
297  */
298 bool OH_AVCapability_AreVideoSizeAndFrameRateSupported(OH_AVCapability *capability, int32_t width, int32_t height,
299                                                        int32_t frameRate);
300 
301 /**
302  * @brief Get the video codec's supported video pixel format.
303  * @syscap SystemCapability.Multimedia.Media.CodecBase
304  * @param capability Video codec capability pointer. Do not give an audio codec capability pointer
305  * @param pixelFormats Output parameter. A pointer to the video pixel format array
306  * @param pixelFormatNum Output parameter. The element number of the pixel format array
307  * @return Returns AV_ERR_OK if the execution is successful,
308  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
309  * @since 10
310  */
311 OH_AVErrCode OH_AVCapability_GetVideoSupportedPixelFormats(OH_AVCapability *capability, const int32_t **pixelFormats,
312                                                            uint32_t *pixelFormatNum);
313 
314 /**
315  * @brief Get the codec's supported profiles.
316  * @syscap SystemCapability.Multimedia.Media.CodecBase
317  * @param capability Codec capability pointer
318  * @param profiles Output parameter. A pointer to the profile array
319  * @param profileNum Output parameter. The element number of the profile array
320  * @return Returns AV_ERR_OK if the execution is successful,
321  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
322  * @since 10
323  */
324 OH_AVErrCode OH_AVCapability_GetSupportedProfiles(OH_AVCapability *capability, const int32_t **profiles,
325                                                   uint32_t *profileNum);
326 
327 /**
328  * @brief Get codec's supported levels for a specific profile.
329  * @syscap SystemCapability.Multimedia.Media.CodecBase
330  * @param capability Codec capability pointer
331  * @param profile Codec profile
332  * @param levels Output parameter. A pointer to the level array
333  * @param levelNum Output parameter. The element number of the level array
334  * @return Returns AV_ERR_OK if the execution is successful,
335  * otherwise returns a specific error code, refer to {@link OH_AVErrCode}
336  * @since 10
337  */
338 OH_AVErrCode OH_AVCapability_GetSupportedLevelsForProfile(OH_AVCapability *capability, int32_t profile,
339                                                           const int32_t **levels, uint32_t *levelNum);
340 
341 /**
342  * @brief Check if the codec supports the specific combination of the profile and level.
343  * @syscap SystemCapability.Multimedia.Media.CodecBase
344  * @param capability Codec capability pointer
345  * @param profile Codec profile
346  * @param level Codec level
347  * @return Returns true if the combination of profile and level is supported,
348  * false if it is not supported
349  * @since 10
350  */
351 bool OH_AVCapability_AreProfileAndLevelSupported(OH_AVCapability *capability, int32_t profile, int32_t level);
352 
353 #ifdef __cplusplus
354 }
355 #endif
356 #endif // NATIVE_AVCAPABILITY_H