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 /**
17  * @addtogroup CodecBase
18  * @{
19  *
20  * @brief The CodecBase module provides variables, properties, and functions
21  * for audio and video muxer, demuxer, and basic encoding and decoding functions.
22  *
23  * @syscap SystemCapability.Multimedia.Media.CodecBase
24  * @since 9
25  */
26 
27 /**
28  * @file native_avcodec_base.h
29  *
30  * @brief Declare the Native API used for audio and video muxer,
31  * demuxer and basic encoding and decoding functions.
32  *
33  * @kit AVCodecKit
34  * @library libnative_media_codecbase.so
35  * @syscap SystemCapability.Multimedia.Media.CodecBase
36  * @since 9
37  */
38 
39 #ifndef NATIVE_AVCODEC_BASE_H
40 #define NATIVE_AVCODEC_BASE_H
41 
42 #include <stdint.h>
43 #include <stdio.h>
44 #include "native_avbuffer.h"
45 #include "native_avmemory.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 typedef struct NativeWindow OHNativeWindow;
52 typedef struct OH_AVCodec OH_AVCodec;
53 
54 /**
55  * @brief When an error occurs in the running of the OH_AVCodec instance, the function pointer will be called
56  * to report specific error information.
57  * @syscap SystemCapability.Multimedia.Media.CodecBase
58  * @param codec OH_AVCodec instance
59  * @param errorCode specific error code
60  * @param userData User specific data
61  * @since 9
62  * @version 1.0
63  */
64 typedef void (*OH_AVCodecOnError)(OH_AVCodec *codec, int32_t errorCode, void *userData);
65 
66 /**
67  * @brief When the output stream changes, the function pointer will be called to report the new stream description
68  * information. It should be noted that the life cycle of the OH_AVFormat pointer
69  * is only valid when the function pointer is called, and it is forbidden to continue to access after the call ends.
70  * @syscap SystemCapability.Multimedia.Media.CodecBase
71  * @param codec OH_AVCodec instance
72  * @param format New output stream description information
73  * @param userData User specific data
74  * @since 9
75  * @version 1.0
76  */
77 typedef void (*OH_AVCodecOnStreamChanged)(OH_AVCodec *codec, OH_AVFormat *format, void *userData);
78 
79 /**
80  * @brief When OH_AVCodec needs new input data during the running process,
81  * the function pointer will be called and carry an available Buffer to fill in the new input data.
82  * @syscap SystemCapability.Multimedia.Media.CodecBase
83  * @param codec OH_AVCodec instance
84  * @param index The index corresponding to the newly available input buffer.
85  * @param data New available input buffer.
86  * @param userData User specific data
87  * @deprecated since 11
88  * @useinstead OH_AVCodecOnNeedInputBuffer
89  * @since 9
90  * @version 1.0
91  */
92 typedef void (*OH_AVCodecOnNeedInputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData);
93 
94 /**
95  * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be
96  * called and carry a Buffer containing the new output data. It should be noted that the life cycle of the
97  * OH_AVCodecBufferAttr pointer is only valid when the function pointer is called. , which prohibits continued
98  * access after the call ends.
99  * @syscap SystemCapability.Multimedia.Media.CodecBase
100  * @param codec OH_AVCodec instance
101  * @param index The index corresponding to the new output Buffer.
102  * @param data Buffer containing the new output data
103  * @param attr The description of the new output Buffer, please refer to {@link OH_AVCodecBufferAttr}
104  * @param userData specified data
105  * @deprecated since 11
106  * @useinstead OH_AVCodecOnNewOutputBuffer
107  * @since 9
108  * @version 1.0
109  */
110 typedef void (*OH_AVCodecOnNewOutputData)(OH_AVCodec *codec, uint32_t index, OH_AVMemory *data,
111                                           OH_AVCodecBufferAttr *attr, void *userData);
112 
113 /**
114  * @brief When OH_AVCodec needs new input data during the running process,
115  * the function pointer will be called and carry an available Buffer to fill in the new input data.
116  * @syscap SystemCapability.Multimedia.Media.CodecBase
117  * @param codec OH_AVCodec instance
118  * @param index The index corresponding to the newly available input buffer.
119  * @param buffer New available input buffer.
120  * @param userData User specific data
121  * @since 11
122  */
123 typedef void (*OH_AVCodecOnNeedInputBuffer)(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData);
124 
125 /**
126  * @brief When new output data is generated during the operation of OH_AVCodec, the function pointer will be
127  * called and carry a Buffer containing the new output data.
128  * @syscap SystemCapability.Multimedia.Media.CodecBase
129  * @param codec OH_AVCodec instance
130  * @param index The index corresponding to the new output Buffer.
131  * @param buffer Buffer containing the new output buffer.
132  * @param userData specified data
133  * @since 11
134  */
135 typedef void (*OH_AVCodecOnNewOutputBuffer)(OH_AVCodec *codec, uint32_t index, OH_AVBuffer *buffer, void *userData);
136 
137 /**
138  * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this
139  * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the
140  * normal operation of OH_AVCodec.
141  * @syscap SystemCapability.Multimedia.Media.CodecBase
142  * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError}
143  * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged}
144  * @param onNeedInputData Monitoring codec requires input data, refer to {@link OH_AVCodecOnNeedInputData}
145  * @param onNeedOutputData Monitor codec to generate output data, refer to {@link OH_AVCodecOnNewOutputData}
146  * @deprecated since 11
147  * @useinstead OH_AVCodecCallback
148  * @since 9
149  * @version 1.0
150  */
151 typedef struct OH_AVCodecAsyncCallback {
152     OH_AVCodecOnError onError;
153     OH_AVCodecOnStreamChanged onStreamChanged;
154     OH_AVCodecOnNeedInputData onNeedInputData;
155     OH_AVCodecOnNewOutputData onNeedOutputData;
156 } OH_AVCodecAsyncCallback;
157 
158 /**
159  * @brief A collection of all asynchronous callback function pointers in OH_AVCodec. Register an instance of this
160  * structure to the OH_AVCodec instance, and process the information reported through the callback to ensure the
161  * normal operation of OH_AVCodec.
162  * @syscap SystemCapability.Multimedia.Media.CodecBase
163  * @param onError Monitor OH_AVCodec operation errors, refer to {@link OH_AVCodecOnError}
164  * @param onStreamChanged Monitor codec stream information, refer to {@link OH_AVCodecOnStreamChanged}
165  * @param onNeedInputBuffer Monitoring codec requires input buffer, refer to {@link OH_AVCodecOnNeedInputBuffer}
166  * @param onNewOutputBuffer Monitor codec to generate output buffer, refer to {@link OH_AVCodecOnNewOutputBuffer}
167  * @since 11
168  */
169 typedef struct OH_AVCodecCallback {
170     OH_AVCodecOnError onError;
171     OH_AVCodecOnStreamChanged onStreamChanged;
172     OH_AVCodecOnNeedInputBuffer onNeedInputBuffer;
173     OH_AVCodecOnNewOutputBuffer onNewOutputBuffer;
174 } OH_AVCodecCallback;
175 
176 /**
177  * @brief The function pointer will be called to get sequenced media data.
178  * @syscap SystemCapability.Multimedia.Media.CodecBase
179  * @param data The buffer to fill.
180  * @param length Length of data to read.
181  * @param offset Start offset to read.
182  * @return Actual length of data read to the buffer.
183  * @since 12
184  */
185 typedef int32_t (*OH_AVDataSourceReadAt)(OH_AVBuffer *data, int32_t length, int64_t offset);
186 
187 /**
188  * @brief User customized data source.
189  * @syscap SystemCapability.Multimedia.Media.CodecBase
190  * @since 12
191  */
192 typedef struct OH_AVDataSource {
193     /**
194      * @brief Total size of the data source.
195      * @syscap SystemCapability.Multimedia.Media.CodecBase
196      * @since 12
197      */
198     int64_t size;
199     /**
200      * @brief Data callback of the data source.
201      * @syscap SystemCapability.Multimedia.Media.CodecBase
202      * @since 12
203      */
204     OH_AVDataSourceReadAt readAt;
205 } OH_AVDataSource;
206 
207 /**
208  * @brief Enumerates the MIME types of audio and video codecs
209  * @syscap SystemCapability.Multimedia.Media.CodecBase
210  * @since 9
211  * @version 1.0
212  */
213 extern const char *OH_AVCODEC_MIMETYPE_VIDEO_AVC;
214 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AAC;
215 
216 /**
217  * @brief Enumerates the MIME types of audio and video codecs
218  * @syscap SystemCapability.Multimedia.Media.CodecBase
219  * @since 10
220  */
221 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_FLAC;
222 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VORBIS;
223 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_MPEG;
224 extern const char *OH_AVCODEC_MIMETYPE_VIDEO_HEVC;
225 
226 /**
227  * @brief Enumerates the types of audio and video muxer
228  * @syscap SystemCapability.Multimedia.Media.CodecBase
229  * @deprecated since 11
230  * @since 10
231  */
232 extern const char *OH_AVCODEC_MIMETYPE_VIDEO_MPEG4;
233 
234 /**
235  * @brief Enumerates the types of audio and video muxer
236  * @syscap SystemCapability.Multimedia.Media.CodecBase
237  * @since 10
238  */
239 extern const char *OH_AVCODEC_MIMETYPE_IMAGE_JPG;
240 extern const char *OH_AVCODEC_MIMETYPE_IMAGE_PNG;
241 extern const char *OH_AVCODEC_MIMETYPE_IMAGE_BMP;
242 
243 /**
244  * @brief Enumerates the MIME types of audio codecs
245  * @syscap SystemCapability.Multimedia.Media.CodecBase
246  * @since 11
247  */
248 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_VIVID;
249 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_NB;
250 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_AMR_WB;
251 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_OPUS;
252 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_G711MU;
253 
254 /**
255  * @brief Enumerates the MIME type of audio low bitrate voice codec.
256  *
257  * @syscap SystemCapability.Multimedia.Media.CodecBase
258  * @since 12
259  */
260 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_LBVC;
261 
262 /**
263  * @brief Enumerates the MIME type of audio ape codec.
264  *
265  * @syscap SystemCapability.Multimedia.Media.CodecBase
266  * @since 12
267  */
268 extern const char *OH_AVCODEC_MIMETYPE_AUDIO_APE;
269 
270 /**
271  * @brief Enumerates the MIME type of versatile video coding.
272  *
273  * @syscap SystemCapability.Multimedia.Media.CodecBase
274  * @since 12
275  */
276 extern const char *OH_AVCODEC_MIMETYPE_VIDEO_VVC;
277 
278 /**
279  * @brief Enumerates the MIME type of subtitle.
280  *
281  * @syscap SystemCapability.Multimedia.Media.CodecBase
282  * @since 12
283  */
284 extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_SRT;
285 
286 /**
287  * @brief Enumerates the mime type of subtitle webvtt.
288  *
289  * @syscap SystemCapability.Multimedia.Media.CodecBase
290  * @since 12
291  */
292 extern const char *OH_AVCODEC_MIMETYPE_SUBTITLE_WEBVTT;
293 
294 /**
295  * @brief The extra data's key of surface Buffer
296  * @syscap SystemCapability.Multimedia.Media.CodecBase
297  * @since 9
298  * @version 1.0
299  */
300 /* Key for timeStamp in surface's extraData, value type is int64 */
301 extern const char *OH_ED_KEY_TIME_STAMP;
302 /* Key for endOfStream in surface's extraData, value type is bool */
303 extern const char *OH_ED_KEY_EOS;
304 
305 /**
306  * @brief Provides the uniform key for storing the media description.
307  * @syscap SystemCapability.Multimedia.Media.CodecBase
308  * @since 9
309  * @version 1.0
310  */
311 /* Key for track type, value type is int32_t, see @OH_MediaType. */
312 extern const char *OH_MD_KEY_TRACK_TYPE;
313 /* Key for codec mime type, value type is string. */
314 extern const char *OH_MD_KEY_CODEC_MIME;
315 /* Key for file duration, value type is int64_t. */
316 extern const char *OH_MD_KEY_DURATION;
317 /* Key for bitrate, value type is int64_t. */
318 extern const char *OH_MD_KEY_BITRATE;
319 /* Key for max input size, value type is int32_t */
320 extern const char *OH_MD_KEY_MAX_INPUT_SIZE;
321 /* Key for video width, value type is int32_t */
322 extern const char *OH_MD_KEY_WIDTH;
323 /* Key for video height, value type is int32_t */
324 extern const char *OH_MD_KEY_HEIGHT;
325 /* Key for video pixel format, value type is int32_t, see @OH_AVPixelFormat */
326 extern const char *OH_MD_KEY_PIXEL_FORMAT;
327 /* key for audio raw format, value type is int32_t , see @OH_BitsPerSample */
328 extern const char *OH_MD_KEY_AUDIO_SAMPLE_FORMAT;
329 /* Key for video frame rate, value type is double. */
330 extern const char *OH_MD_KEY_FRAME_RATE;
331 /* video encode bitrate mode, the value type is int32_t, see @OH_VideoEncodeBitrateMode */
332 extern const char *OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE;
333 /* encode profile, the value type is int32_t. see @OH_AVCProfile, OH_HEVCProfile, OH_AACProfile. */
334 extern const char *OH_MD_KEY_PROFILE;
335 /* Key for audio channel count, value type is int32_t */
336 extern const char *OH_MD_KEY_AUD_CHANNEL_COUNT;
337 /* Key for audio sample rate, value type is int32_t */
338 extern const char *OH_MD_KEY_AUD_SAMPLE_RATE;
339 /**
340  * @brief Key for the interval of key frame. value type is int32_t, the unit is milliseconds. A negative value means no
341  * key frames are requested after the first frame. A zero value means a stream containing all key frames is requested.
342  *
343  * @syscap SystemCapability.Multimedia.Media.CodecBase
344  * @since 9
345  */
346 extern const char *OH_MD_KEY_I_FRAME_INTERVAL;
347 /* Key of the surface rotation angle. value type is int32_t: should be {0, 90, 180, 270}, default is 0. */
348 extern const char *OH_MD_KEY_ROTATION;
349 
350 /**
351  * @brief Provides the uniform key for storing the media description.
352  * @syscap SystemCapability.Multimedia.Media.CodecBase
353  * @since 10
354  */
355 /* Key for video YUV value range flag, value type is bool, true for full range, false for limited range */
356 extern const char *OH_MD_KEY_RANGE_FLAG;
357 /* Key for video color primaries, value type is int32_t, see @OH_ColorPrimary */
358 extern const char *OH_MD_KEY_COLOR_PRIMARIES;
359 /* Key for video transfer characteristics, value type is int32_t, see @OH_TransferCharacteristic */
360 extern const char *OH_MD_KEY_TRANSFER_CHARACTERISTICS;
361 /* Key for video matrix coefficients, value type is int32_t, see @OH_MatrixCoefficient */
362 extern const char *OH_MD_KEY_MATRIX_COEFFICIENTS;
363 /* Key for the request an I-Frame immediately, value type is bool */
364 extern const char *OH_MD_KEY_REQUEST_I_FRAME;
365 /* Key for the desired encoding quality, value type is int32_t, this key is only
366  * supported for encoders that are configured in constant quality mode */
367 extern const char *OH_MD_KEY_QUALITY;
368 /* Key of the codec specific data. value type is a uint8_t pointer */
369 extern const char *OH_MD_KEY_CODEC_CONFIG;
370 /* source format Key for title, value type is string */
371 extern const char *OH_MD_KEY_TITLE;
372 /* source format Key for artist, value type is string */
373 extern const char *OH_MD_KEY_ARTIST;
374 /* source format Key for album, value type is string */
375 extern const char *OH_MD_KEY_ALBUM;
376 /* source format Key for album artist, value type is string */
377 extern const char *OH_MD_KEY_ALBUM_ARTIST;
378 /* source format Key for date, value type is string */
379 extern const char *OH_MD_KEY_DATE;
380 /* source format Key for comment, value type is string */
381 extern const char *OH_MD_KEY_COMMENT;
382 /* source format Key for genre, value type is string */
383 extern const char *OH_MD_KEY_GENRE;
384 /* source format Key for copyright, value type is string */
385 extern const char *OH_MD_KEY_COPYRIGHT;
386 /* source format Key for language, value type is string */
387 extern const char *OH_MD_KEY_LANGUAGE;
388 /* source format Key for description, value type is string */
389 extern const char *OH_MD_KEY_DESCRIPTION;
390 /* source format Key for lyrics, value type is string */
391 extern const char *OH_MD_KEY_LYRICS;
392 /* source format Key for track count, value type is int32_t */
393 extern const char *OH_MD_KEY_TRACK_COUNT;
394 /* Key for the desired encoding channel layout, value type is int64_t, this key is only supported for encoders */
395 extern const char *OH_MD_KEY_CHANNEL_LAYOUT;
396 /* Key for bits per coded sample, value type is int32_t, supported for flac encoder, see @OH_BitsPerSample */
397 extern const char *OH_MD_KEY_BITS_PER_CODED_SAMPLE;
398 /* Key for the aac format, value type is int32_t, supported for aac decoder */
399 extern const char *OH_MD_KEY_AAC_IS_ADTS;
400 /* Key for aac sbr mode, value type is int32_t, supported for aac encoder */
401 extern const char *OH_MD_KEY_SBR;
402 /* Key for flac compliance level, value type is int32_t */
403 extern const char *OH_MD_KEY_COMPLIANCE_LEVEL;
404 /* Key for vorbis identification header, value type is a uint8_t pointer, supported only for vorbis decoder */
405 extern const char *OH_MD_KEY_IDENTIFICATION_HEADER;
406 /* Key for vorbis setup header, value type is a uint8_t pointer, supported only for vorbis decoder */
407 extern const char *OH_MD_KEY_SETUP_HEADER;
408 /* Key for video scale type, value type is int32_t, see @OH_ScalingMode */
409 extern const char *OH_MD_KEY_SCALING_MODE;
410 /* Key for max input buffer count, value type is int32_t */
411 extern const char *OH_MD_MAX_INPUT_BUFFER_COUNT;
412 /* Key for max output buffer count, value type is int32_t */
413 extern const char *OH_MD_MAX_OUTPUT_BUFFER_COUNT;
414 
415 /**
416  * @brief Provides the uniform key for storing the media description.
417  * @syscap SystemCapability.Multimedia.Media.CodecBase
418  * @since 11
419  */
420 /* Key for audio codec compression level, value type is int32_t */
421 extern const char *OH_MD_KEY_AUDIO_COMPRESSION_LEVEL;
422 /* Key of the video is hdr vivid. value type is bool */
423 extern const char *OH_MD_KEY_VIDEO_IS_HDR_VIVID;
424 /* Key for number of audio objects. value type is int32_t */
425 extern const char *OH_MD_KEY_AUDIO_OBJECT_NUMBER;
426 /* Key for meta data of audio vivid. value type is a uint8_t pointer */
427 extern const char *OH_MD_KEY_AUDIO_VIVID_METADATA;
428 
429 /**
430  * @brief Key for querying the maximum long-term reference count of video encoder, value type is int32_t.
431  * You should query the count through interface {@link OH_AVCapability_GetFeatureProperties}
432  * with enum {@link VIDEO_ENCODER_LONG_TERM_REFERENCE}.
433  *
434  * @syscap SystemCapability.Multimedia.Media.CodecBase
435  * @since 12
436  */
437 extern const char *OH_FEATURE_PROPERTY_KEY_VIDEO_ENCODER_MAX_LTR_FRAME_COUNT;
438 /**
439  * @brief Key for enable the temporal scalability mode, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise.
440  * The default value is 0. To query supported, you should use the interface {@link OH_AVCapability_IsFeatureSupported}
441  * with enum {@link VIDEO_ENCODER_TEMPORAL_SCALABILITY}. This is an optional key that applies only to video encoder.
442  * It is used in configure.
443  *
444  * @syscap SystemCapability.Multimedia.Media.CodecBase
445  * @since 12
446  */
447 extern const char *OH_MD_KEY_VIDEO_ENCODER_ENABLE_TEMPORAL_SCALABILITY;
448 /**
449  * @brief Key for describing the temporal group of picture size, value type is int32_t. It takes effect only when
450  * temporal level scale is enable. This is an optional key that applies only to video encoder. It is used in configure.
451  *
452  * @syscap SystemCapability.Multimedia.Media.CodecBase
453  * @since 12
454  */
455 extern const char *OH_MD_KEY_VIDEO_ENCODER_TEMPORAL_GOP_SIZE;
456 /**
457  * @brief Key for describing the reference mode in temporal group of picture, value type is int32_t, see enum
458  * {@link OH_TemporalGopReferenceMode}. It takes effect only when temporal level sacle is enabled.
459  * This is an optional key that applies only to video encoder. It is used in configure.
460  *
461  * @syscap SystemCapability.Multimedia.Media.CodecBase
462  * @since 12
463  */
464 extern const char *OH_MD_KEY_VIDEO_ENCODER_TEMPORAL_GOP_REFERENCE_MODE;
465 /**
466  * @brief Key for describing the count of used long-term reference frames, value type is int32_t, must be within the
467  * supported range. To get supported range, you should query wthether the capability is supported through the interface
468  * {@link OH_AVCapability_GetFeatureProperties} with enum {@link VIDEO_ENCODER_LONG_TERM_REFERENCE}, otherwise, not set
469  * the key. This is an optional key that applies only to video encoder. It is used in configure.
470  *
471  * @syscap SystemCapability.Multimedia.Media.CodecBase
472  * @since 12
473  */
474 extern const char *OH_MD_KEY_VIDEO_ENCODER_LTR_FRAME_COUNT;
475 /**
476  * @brief Key for describing mark this frame as a long term reference frame, value type is int32_t (0 or 1): 1 is mark,
477  * 0 otherwise. It takes effect only when the number of used long term reference frames is configured. This is an
478  * optional key that applies only to video encoder input loop. It takes effect immediately.
479  *
480  * @syscap SystemCapability.Multimedia.Media.CodecBase
481  * @since 12
482  */
483 extern const char *OH_MD_KEY_VIDEO_ENCODER_PER_FRAME_MARK_LTR;
484 /**
485  * @brief Key for describing the long term reference frame poc referenced by this frame, value type is int32_t. This is
486  * an optional key that applies only to video encoder input loop. It takes effect immediately.
487  *
488  * @syscap SystemCapability.Multimedia.Media.CodecBase
489  * @since 12
490  */
491 extern const char *OH_MD_KEY_VIDEO_ENCODER_PER_FRAME_USE_LTR;
492 /**
493  * @brief Key for indicating this frame is a long-term reference frame, value type is int32_t (0 or 1): 1 is LTR,
494  * 0 otherwise. This is an optional key that applies only to video encoder output loop.
495  * It indicates the attribute of the frame.
496  *
497  * @syscap SystemCapability.Multimedia.Media.CodecBase
498  * @since 12
499  */
500 extern const char *OH_MD_KEY_VIDEO_PER_FRAME_IS_LTR;
501 /**
502  * @brief Key for describing the frame poc, value type is int32_t. This is an optional key that applies only to video
503  * encoder output loop. It indicates the attribute of the frame.
504  *
505  * @syscap SystemCapability.Multimedia.Media.CodecBase
506  * @since 12
507  */
508 extern const char *OH_MD_KEY_VIDEO_PER_FRAME_POC;
509 /**
510  * @brief Key for describing the top-coordinate (y) of the crop rectangle, value type is int32_t. This is the top-most
511  * row included in the crop frame, where row indices start at 0.
512  *
513  * @syscap SystemCapability.Multimedia.Media.CodecBase
514  * @since 12
515  */
516 extern const char *OH_MD_KEY_VIDEO_CROP_TOP;
517 /**
518  * @brief Key for describing the bottom-coordinate (y) of the crop rectangle, value type is int32_t. This is the
519  * bottom-most row included in the crop frame, where row indices start at 0.
520  *
521  * @syscap SystemCapability.Multimedia.Media.CodecBase
522  * @since 12
523  */
524 extern const char *OH_MD_KEY_VIDEO_CROP_BOTTOM;
525 /**
526  * @brief Key for describing the left-coordinate (x) of the crop rectangle, value type is int32_t.
527  * This is the left-most column included in the crop frame, where column indices start at 0.
528  *
529  * @syscap SystemCapability.Multimedia.Media.CodecBase
530  * @since 12
531  */
532 extern const char *OH_MD_KEY_VIDEO_CROP_LEFT;
533 /**
534  * @brief Key for describing the right-coordinate (x) of the crop rectangle, value type is int32_t. This is the
535  * right-most column included in the crop frame, where column indices start at 0.
536  *
537  * @syscap SystemCapability.Multimedia.Media.CodecBase
538  * @since 12
539  */
540 extern const char *OH_MD_KEY_VIDEO_CROP_RIGHT;
541 /**
542  * @brief Key for describing the stride of the video buffer layout, value type is int32_t. Stride (or row increment) is
543  * the difference between the index of a pixel and that of the pixel directly underneath. For YUV 420 formats, the
544  * stride corresponds to the Y plane; the stride of the U and V planes can be calculated based on the color format,
545  * though it is generally undefined and depends on the device and release.
546  *
547  * @syscap SystemCapability.Multimedia.Media.CodecBase
548  * @since 12
549  */
550 extern const char *OH_MD_KEY_VIDEO_STRIDE;
551 /**
552  * @brief Key for describing the plane height of a multi-planar (YUV) video buffer layout, value type is int32_t.
553  * Slice height (or plane height/vertical stride) is the number of rows that must be skipped to get from
554  * the top of the Y plane to the top of the U plane in the buffer. In essence the offset of the U plane
555  * is sliceHeight * stride. The height of the U/V planes can be calculated based on the color format,
556  * though it is generally undefined and depends on the device and release.
557  *
558  * @syscap SystemCapability.Multimedia.Media.CodecBase
559  * @since 12
560  */
561 extern const char *OH_MD_KEY_VIDEO_SLICE_HEIGHT;
562 /**
563  * @brief Key for describing the valid picture width of the video, value type is int32_t.
564  * Get the value from an OH_AVFormat instance, which obtained by calling {@link OH_VideoDecoder_GetOutputDescription}
565  * or {@link OH_AVCodecOnStreamChanged}.
566  *
567  * @syscap SystemCapability.Multimedia.Media.CodecBase
568  * @since 12
569  */
570 extern const char *OH_MD_KEY_VIDEO_PIC_WIDTH;
571 /**
572  * @brief Key for describing the valid picture height of the video, value type is int32_t.
573  * Get the value from an OH_AVFormat instance, which obtained by calling {@link OH_VideoDecoder_GetOutputDescription}
574  * or {@link OH_AVCodecOnStreamChanged}.
575  *
576  * @syscap SystemCapability.Multimedia.Media.CodecBase
577  * @since 12
578  */
579 extern const char *OH_MD_KEY_VIDEO_PIC_HEIGHT;
580 /**
581  * @brief Key to enable the low latency mode, value type is int32_t (0 or 1):1 is enabled, 0 otherwise.
582  * If enabled, the video encoder or video decoder doesn't hold input and output data more than required by
583  * the codec standards. This is an optional key that applies only to video encoder or video decoder.
584  * It is used in configure.
585  *
586  * @syscap SystemCapability.Multimedia.Media.CodecBase
587  * @since 12
588  */
589 extern const char *OH_MD_KEY_VIDEO_ENABLE_LOW_LATENCY;
590 /**
591  * @brief Key for describing the maximum quantization parameter allowed for video encoder, value type is int32_t.
592  * It is used in configure/setparameter or takes effect immediately with the frame.
593  *
594  * @syscap SystemCapability.Multimedia.Media.CodecBase
595  * @since 12
596  */
597 extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_MAX;
598 /**
599  * @brief Key for describing the minimum quantization parameter allowed for video encoder, value type is int32_t.
600  * It is used in configure/setparameter or takes effect immediately with the frame.
601  *
602  * @syscap SystemCapability.Multimedia.Media.CodecBase
603  * @since 12
604  */
605 extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_MIN;
606 /**
607  * @brief Key for describing the video frame averge quantization parameter, value type is int32_t.
608  * This is a part of a video encoder statistics export feature. This value is emitted from video encoder for a video
609  * frame.
610  *
611  * @syscap SystemCapability.Multimedia.Media.CodecBase
612  * @since 12
613  */
614 extern const char *OH_MD_KEY_VIDEO_ENCODER_QP_AVERAGE;
615 /**
616  * @brief Key for describing video frame mean squared error, value type is double.
617  * This is a part of a video encoder statistics export feature. This value is emitted from video encoder for a video
618  * frame.
619  *
620  * @syscap SystemCapability.Multimedia.Media.CodecBase
621  * @since 12
622  */
623 extern const char *OH_MD_KEY_VIDEO_ENCODER_MSE;
624 /**
625  * @brief Key for decoding timestamp of the buffer in microseconds, value type is int64_t.
626  *
627  * @syscap SystemCapability.Multimedia.Media.CodecBase
628  * @since 12
629  */
630 extern const char *OH_MD_KEY_DECODING_TIMESTAMP;
631 /**
632  * @brief Key for duration of the buffer in microseconds, value type is int64_t.
633  *
634  * @syscap SystemCapability.Multimedia.Media.CodecBase
635  * @since 12
636  */
637 extern const char *OH_MD_KEY_BUFFER_DURATION;
638 /**
639  * @brief Key for sample aspect ratio, value type is double.
640  *
641  * @syscap SystemCapability.Multimedia.Media.CodecBase
642  * @since 12
643  */
644 extern const char *OH_MD_KEY_VIDEO_SAR;
645 /**
646  * @brief Key for start time of file, value type is int64_t.
647  *
648  * @syscap SystemCapability.Multimedia.Media.CodecBase
649  * @since 12
650  */
651 extern const char *OH_MD_KEY_START_TIME;
652 /**
653  * @brief Key for start time of track, value type is int64_t.
654  *
655  * @syscap SystemCapability.Multimedia.Media.CodecBase
656  * @since 12
657  */
658 extern const char *OH_MD_KEY_TRACK_START_TIME;
659 /**
660  * @brief Key for setting the output color space of video decoder. The value type is int32_t.
661  * The supported value is {@link OH_COLORSPACE_BT709_LIMIT}, see {@link OH_NativeBuffer_ColorSpace}. It is used in
662  * {@link OH_VideoDecoder_Configure}. If the color space conversion capability is supported and this key is configured,
663  * the video decoder will automatically transcode an HDR Vivid video to an SDR video with color space BT709.
664  * If color space conversion capability is not supported, {@link OH_VideoDecoder_Configure} returns
665  * {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION}.
666  * If the input video is not an HDR vivid video, an error {@link AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION} will
667  * be reported by callback function {@link OH_AVCodecOnError}.
668  *
669  * @syscap SystemCapability.Multimedia.Media.CodecBase
670  * @since 12
671  */
672 extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_COLOR_SPACE;
673 /**
674  * @brief Key for describing if enable VRR or not, value type is int32_t (0 or 1): 1 is enabled, 0 otherwise.
675  * This is an optional key that applies only to video decoder. It is used in configure.
676  *
677  * @syscap SystemCapability.Multimedia.Media.CodecBase
678  * @since 14
679  */
680 extern const char *OH_MD_KEY_VIDEO_DECODER_OUTPUT_ENABLE_VRR;
681 /**
682  * @brief Key for creation timestamp of a media file, value type is string.
683  *
684  * @syscap SystemCapability.Multimedia.Media.CodecBase
685  * @since 14
686  */
687 extern const char *OH_MD_KEY_CREATION_TIME;
688 
689 /**
690  * @brief Media type.
691  * @syscap SystemCapability.Multimedia.Media.CodecBase
692  * @since 9
693  * @version 1.0
694  */
695 typedef enum OH_MediaType {
696     /* track is audio. */
697     MEDIA_TYPE_AUD = 0,
698     /* track is video. */
699     MEDIA_TYPE_VID = 1,
700     /** track is subtitle.
701      * @since 12
702      */
703     MEDIA_TYPE_SUBTITLE = 2,
704 } OH_MediaType;
705 
706 /**
707  * @brief AAC Profile
708  * @syscap SystemCapability.Multimedia.Media.CodecBase
709  * @since 9
710  * @version 1.0
711  */
712 typedef enum OH_AACProfile {
713     AAC_PROFILE_LC = 0,
714     AAC_PROFILE_HE = 3,
715     AAC_PROFILE_HE_V2 = 4,
716 } OH_AACProfile;
717 
718 /**
719  * @brief AVC Profile
720  * @syscap SystemCapability.Multimedia.Media.CodecBase
721  * @since 9
722  * @version 1.0
723  */
724 typedef enum OH_AVCProfile {
725     AVC_PROFILE_BASELINE = 0,
726     AVC_PROFILE_HIGH = 4,
727     AVC_PROFILE_MAIN = 8,
728 } OH_AVCProfile;
729 
730 /**
731  * @brief HEVC Profile
732  * @syscap SystemCapability.Multimedia.Media.CodecBase
733  * @since 10
734  */
735 typedef enum OH_HEVCProfile {
736     HEVC_PROFILE_MAIN = 0,
737     HEVC_PROFILE_MAIN_10 = 1,
738     HEVC_PROFILE_MAIN_STILL = 2,
739     HEVC_PROFILE_MAIN_10_HDR10 = 3,
740     HEVC_PROFILE_MAIN_10_HDR10_PLUS = 4,
741 } OH_HEVCProfile;
742 
743 /**
744  * @brief VVC Profile: A specified subset of the syntax of VVC.
745  * @syscap SystemCapability.Multimedia.Media.CodecBase
746  * @since 14
747  */
748 typedef enum OH_VVCProfile {
749     /** Main 10 profile */
750     VVC_PROFILE_MAIN_10 = 1,
751     /** Main 12 profile */
752     VVC_PROFILE_MAIN_12 = 2,
753     /** Main 12 Intra profile */
754     VVC_PROFILE_MAIN_12_INTRA = 10,
755     /** Multilayer Main 10 profile */
756     VVC_PROFILE_MULTI_MAIN_10 = 17,
757     /** Main 10 4:4:4 profile */
758     VVC_PROFILE_MAIN_10_444 = 33,
759     /** Main 12 4:4:4 profile */
760     VVC_PROFILE_MAIN_12_444 = 34,
761     /** Main 16 4:4:4 profile */
762     VVC_PROFILE_MAIN_16_444 = 36,
763     /** Main 12 4:4:4 Intra profile */
764     VVC_PROFILE_MAIN_12_444_INTRA = 42,
765     /** Main 16 4:4:4 Intra profile */
766     VVC_PROFILE_MAIN_16_444_INTRA = 44,
767     /** Multilayer Main 10 4:4:4 profile */
768     VVC_PROFILE_MULTI_MAIN_10_444 = 49,
769     /** Main 10 Still Picture profile */
770     VVC_PROFILE_MAIN_10_STILL = 65,
771     /** Main 12 Still Picture profile */
772     VVC_PROFILE_MAIN_12_STILL = 66,
773     /** Main 10 4:4:4 Still Picture profile */
774     VVC_PROFILE_MAIN_10_444_STILL = 97,
775     /** Main 12 4:4:4 Still Picture profile */
776     VVC_PROFILE_MAIN_12_444_STILL = 98,
777     /** Main 16 4:4:4 Still Picture profile */
778     VVC_PROFILE_MAIN_16_444_STILL = 100,
779 } OH_VVCProfile;
780 
781 /**
782  * @brief Enumerates the muxer output file format
783  * @syscap SystemCapability.Multimedia.Media.CodecBase
784  * @since 10
785  */
786 typedef enum OH_AVOutputFormat {
787     AV_OUTPUT_FORMAT_DEFAULT = 0,
788     AV_OUTPUT_FORMAT_MPEG_4 = 2,
789     AV_OUTPUT_FORMAT_M4A = 6,
790     /**
791      * The muxer output amr file format.
792      * @since 12
793      */
794     AV_OUTPUT_FORMAT_AMR = 8,
795     /**
796      * The muxer output mp3 file format.
797      * @since 12
798      */
799     AV_OUTPUT_FORMAT_MP3 = 9,
800     /**
801      * The muxer output wav file format.
802      * @since 12
803      */
804     AV_OUTPUT_FORMAT_WAV = 10,
805 } OH_AVOutputFormat;
806 
807 /**
808  * @brief Seek Mode
809  * @syscap SystemCapability.Multimedia.Media.CodecBase
810  * @since 10
811  */
812 typedef enum OH_AVSeekMode {
813     /* seek to sync sample after the time */
814     SEEK_MODE_NEXT_SYNC = 0,
815     /* seek to sync sample before the time */
816     SEEK_MODE_PREVIOUS_SYNC,
817     /* seek to sync sample closest to time */
818     SEEK_MODE_CLOSEST_SYNC,
819 } OH_AVSeekMode;
820 
821 /**
822  * @brief Scaling Mode
823  * @syscap SystemCapability.Multimedia.Media.CodecBase
824  * @since 10
825  */
826 typedef enum OH_ScalingMode {
827     SCALING_MODE_SCALE_TO_WINDOW = 1,
828     SCALING_MODE_SCALE_CROP = 2,
829 } OH_ScalingMode;
830 
831 /**
832  * @brief enum Audio Bits Per Coded Sample
833  * @syscap SystemCapability.Multimedia.Media.CodecBase
834  * @since 10
835  */
836 typedef enum OH_BitsPerSample {
837     SAMPLE_U8 = 0,
838     SAMPLE_S16LE = 1,
839     SAMPLE_S24LE = 2,
840     SAMPLE_S32LE = 3,
841     SAMPLE_F32LE = 4,
842     SAMPLE_U8P = 5,
843     SAMPLE_S16P = 6,
844     SAMPLE_S24P = 7,
845     SAMPLE_S32P = 8,
846     SAMPLE_F32P = 9,
847     INVALID_WIDTH = -1
848 } OH_BitsPerSample;
849 
850 /**
851  * @brief Color Primary
852  * @syscap SystemCapability.Multimedia.Media.CodecBase
853  * @since 10
854  */
855 typedef enum OH_ColorPrimary {
856     COLOR_PRIMARY_BT709 = 1,
857     COLOR_PRIMARY_UNSPECIFIED = 2,
858     COLOR_PRIMARY_BT470_M = 4,
859     COLOR_PRIMARY_BT601_625 = 5,
860     COLOR_PRIMARY_BT601_525 = 6,
861     COLOR_PRIMARY_SMPTE_ST240 = 7,
862     COLOR_PRIMARY_GENERIC_FILM = 8,
863     COLOR_PRIMARY_BT2020 = 9,
864     COLOR_PRIMARY_SMPTE_ST428 = 10,
865     COLOR_PRIMARY_P3DCI = 11,
866     COLOR_PRIMARY_P3D65 = 12,
867 } OH_ColorPrimary;
868 
869 /**
870  * @brief Transfer Characteristic
871  * @syscap SystemCapability.Multimedia.Media.CodecBase
872  * @since 10
873  */
874 typedef enum OH_TransferCharacteristic {
875     TRANSFER_CHARACTERISTIC_BT709 = 1,
876     TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2,
877     TRANSFER_CHARACTERISTIC_GAMMA_2_2 = 4,
878     TRANSFER_CHARACTERISTIC_GAMMA_2_8 = 5,
879     TRANSFER_CHARACTERISTIC_BT601 = 6,
880     TRANSFER_CHARACTERISTIC_SMPTE_ST240 = 7,
881     TRANSFER_CHARACTERISTIC_LINEAR = 8,
882     TRANSFER_CHARACTERISTIC_LOG = 9,
883     TRANSFER_CHARACTERISTIC_LOG_SQRT = 10,
884     TRANSFER_CHARACTERISTIC_IEC_61966_2_4 = 11,
885     TRANSFER_CHARACTERISTIC_BT1361 = 12,
886     TRANSFER_CHARACTERISTIC_IEC_61966_2_1 = 13,
887     TRANSFER_CHARACTERISTIC_BT2020_10BIT = 14,
888     TRANSFER_CHARACTERISTIC_BT2020_12BIT = 15,
889     TRANSFER_CHARACTERISTIC_PQ = 16,
890     TRANSFER_CHARACTERISTIC_SMPTE_ST428 = 17,
891     TRANSFER_CHARACTERISTIC_HLG = 18,
892 } OH_TransferCharacteristic;
893 
894 /**
895  * @brief Matrix Coefficient
896  * @syscap SystemCapability.Multimedia.Media.CodecBase
897  * @since 10
898  */
899 typedef enum OH_MatrixCoefficient {
900     MATRIX_COEFFICIENT_IDENTITY = 0,
901     MATRIX_COEFFICIENT_BT709 = 1,
902     MATRIX_COEFFICIENT_UNSPECIFIED = 2,
903     MATRIX_COEFFICIENT_FCC = 4,
904     MATRIX_COEFFICIENT_BT601_625 = 5,
905     MATRIX_COEFFICIENT_BT601_525 = 6,
906     MATRIX_COEFFICIENT_SMPTE_ST240 = 7,
907     MATRIX_COEFFICIENT_YCGCO = 8,
908     MATRIX_COEFFICIENT_BT2020_NCL = 9,
909     MATRIX_COEFFICIENT_BT2020_CL = 10,
910     MATRIX_COEFFICIENT_SMPTE_ST2085 = 11,
911     MATRIX_COEFFICIENT_CHROMATICITY_NCL = 12,
912     MATRIX_COEFFICIENT_CHROMATICITY_CL = 13,
913     MATRIX_COEFFICIENT_ICTCP = 14,
914 } OH_MatrixCoefficient;
915 
916 /**
917  * @brief AVC Level.
918  *
919  * @syscap SystemCapability.Multimedia.Media.CodecBase
920  * @since 12
921  */
922 typedef enum OH_AVCLevel {
923     AVC_LEVEL_1 = 0,
924     AVC_LEVEL_1b = 1,
925     AVC_LEVEL_11 = 2,
926     AVC_LEVEL_12 = 3,
927     AVC_LEVEL_13 = 4,
928     AVC_LEVEL_2 = 5,
929     AVC_LEVEL_21 = 6,
930     AVC_LEVEL_22 = 7,
931     AVC_LEVEL_3 = 8,
932     AVC_LEVEL_31 = 9,
933     AVC_LEVEL_32 = 10,
934     AVC_LEVEL_4 = 11,
935     AVC_LEVEL_41 = 12,
936     AVC_LEVEL_42 = 13,
937     AVC_LEVEL_5 = 14,
938     AVC_LEVEL_51 = 15,
939     AVC_LEVEL_52 = 16,
940     AVC_LEVEL_6 = 17,
941     AVC_LEVEL_61 = 18,
942     AVC_LEVEL_62 = 19,
943 } OH_AVCLevel;
944 
945 /**
946  * @brief HEVC Level.
947  *
948  * @syscap SystemCapability.Multimedia.Media.CodecBase
949  * @since 12
950  */
951 typedef enum OH_HEVCLevel {
952     HEVC_LEVEL_1 = 0,
953     HEVC_LEVEL_2 = 1,
954     HEVC_LEVEL_21 = 2,
955     HEVC_LEVEL_3 = 3,
956     HEVC_LEVEL_31 = 4,
957     HEVC_LEVEL_4 = 5,
958     HEVC_LEVEL_41 = 6,
959     HEVC_LEVEL_5 = 7,
960     HEVC_LEVEL_51 = 8,
961     HEVC_LEVEL_52 = 9,
962     HEVC_LEVEL_6 = 10,
963     HEVC_LEVEL_61 = 11,
964     HEVC_LEVEL_62 = 12,
965 } OH_HEVCLevel;
966 
967 /**
968  * @brief VVC Level: A defined set of constraints on the values that may be taken by the syntax elements and variables
969  * of VVC, or the value of a transform coefficient prior to scaling.
970  *
971  * @syscap SystemCapability.Multimedia.Media.CodecBase
972  * @since 14
973  */
974 typedef enum OH_VVCLevel {
975     /** VVC level 1.0 */
976     VVC_LEVEL_1 = 16,
977     /** VVC level 2.0 */
978     VVC_LEVEL_2 = 32,
979     /** VVC level 2.1 */
980     VVC_LEVEL_21 = 35,
981     /** VVC level 3.0 */
982     VVC_LEVEL_3 = 48,
983     /** VVC level 3.1 */
984     VVC_LEVEL_31 = 51,
985     /** VVC level 4.0 */
986     VVC_LEVEL_4 = 64,
987     /** VVC level 4.1 */
988     VVC_LEVEL_41 = 67,
989     /** VVC level 5.0 */
990     VVC_LEVEL_5 = 80,
991     /** VVC level 5.1 */
992     VVC_LEVEL_51 = 83,
993     /** VVC level 5.2 */
994     VVC_LEVEL_52 = 86,
995     /** VVC level 6.0 */
996     VVC_LEVEL_6 = 96,
997     /** VVC level 6.1 */
998     VVC_LEVEL_61 = 99,
999     /** VVC level 6.2 */
1000     VVC_LEVEL_62 = 102,
1001     /** VVC level 6.3 */
1002     VVC_LEVEL_63 = 105,
1003     /** VVC level 15.5 */
1004     VVC_LEVEL_155 = 255,
1005 } OH_VVCLevel;
1006 
1007 /**
1008  * @brief The reference mode in temporal group of picture.
1009  *
1010  * @syscap SystemCapability.Multimedia.Media.CodecBase
1011  * @since 12
1012  */
1013 typedef enum OH_TemporalGopReferenceMode {
1014     /** Refer to latest short-term reference frame. */
1015     ADJACENT_REFERENCE = 0,
1016     /** Refer to latest long-term reference frame. */
1017     JUMP_REFERENCE = 1,
1018     /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest
1019      *  enhance layer. The temporal group of pictures must be power of 2. */
1020     UNIFORMLY_SCALED_REFERENCE = 2,
1021 } OH_TemporalGopReferenceMode;
1022 
1023 #ifdef __cplusplus
1024 }
1025 #endif
1026 
1027 #endif // NATIVE_AVCODEC_BASE_H
1028 /** @} */