• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# CodecBase
2
3
4## Overview
5
6Provides the common structs, character constants, and enums for running **OH_AVCodec** instances.
7
8\@syscap SystemCapability.Multimedia.Media.CodecBase
9
10**Since:**
119
12
13
14## Summary
15
16
17### Files
18
19| Name | Description |
20| -------- | -------- |
21| [native_avcodec_base.h](native__avcodec__base_8h.md) | Declares the common structs, character constants, and enums for running **OH_AVCodec** instances. <br>File to Include: <multimedia/player_framework/native_avcodec_base.h> |
22
23
24### Structs
25
26| Name | Description |
27| -------- | -------- |
28| [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) | Defines the buffer attributes of an **OH_AVCodec** instance.  |
29| [OH_AVCodecAsyncCallback](_o_h___a_v_codec_async_callback.md) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.  |
30
31
32### Types
33
34| Name | Description |
35| -------- | -------- |
36| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) | Enumerates the buffer flags of an **OH_AVCodec** instance.  |
37| [OH_AVCodecBufferAttr](#oh_avcodecbufferattr) | Defines the buffer attributes of an **OH_AVCodec** instance.  |
38| [OH_AVCodecOnError](#oh_avcodeconerror)) (OH_AVCodec \*codec, int32_t errorCode, void \*userData) | Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.  |
39| [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged)) (OH_AVCodec \*codec, OH_AVFormat \*format, void \*userData) | Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.  |
40| [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, void \*userData) | Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance.  |
41| [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata)) (OH_AVCodec \*codec, uint32_t index, OH_AVMemory \*data, [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md) \*attr, void \*userData) | Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.  |
42| [OH_AVCodecAsyncCallback](#oh_avcodecasynccallback) | Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.  |
43| [OH_MediaType](#oh_mediatype) | Enumerates the media types.  |
44| [OH_AVCProfile](#oh_avcprofile) | Enumerates the AVC profiles.  |
45| [OH_AACProfile](#oh_aacprofile) | Enumerates the AAC profiles.  |
46
47
48### Enums
49
50| Name | Description |
51| -------- | -------- |
52| [OH_AVCodecBufferFlags](#oh_avcodecbufferflags) {<br/>**AVCODEC_BUFFER_FLAGS_NONE** = 0, AVCODEC_BUFFER_FLAGS_EOS = 1 &lt;&lt; 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 &lt;&lt; 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 &lt;&lt; 2,<br/>AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 &lt;&lt; 3<br/>} | Enumerates the buffer flags of an **OH_AVCodec** instance.  |
53| [OH_MediaType](#oh_mediatype) { MEDIA_TYPE_AUD = 0, MEDIA_TYPE_VID = 1 } | Enumerates the media types.  |
54| [OH_AVCProfile](#oh_avcprofile) { **AVC_PROFILE_BASELINE** = 0, **AVC_PROFILE_HIGH** = 4, **AVC_PROFILE_MAIN** = 8 } | Enumerates the AVC profiles.  |
55| [OH_AACProfile](#oh_aacprofile) { **AAC_PROFILE_LC** = 0 } | Enumerates the AAC profiles.  |
56
57
58### Variables
59
60| Name | Description |
61| -------- | -------- |
62| [OH_AVCodecBufferAttr::pts](#pts) | Presentation timestamp of the buffer, in microseconds.  |
63| [OH_AVCodecBufferAttr::size](#size) | Size of the data contained in the buffer, in bytes.  |
64| [OH_AVCodecBufferAttr::offset](#offset) | Start offset of valid data in the buffer.  |
65| [OH_AVCodecBufferAttr::flags](#flags) | Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags).  |
66| [OH_AVCODEC_MIMETYPE_VIDEO_AVC](#oh_avcodec_mimetype_video_avc) | Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC).  |
67| [OH_AVCODEC_MIMETYPE_AUDIO_AAC](#oh_avcodec_mimetype_audio_aac) | Defines the MIME type for Advanced Audio Coding (AAC).  |
68| [OH_ED_KEY_TIME_STAMP](#oh_ed_key_time_stamp) | Provides unified character descriptors for the auxiliary data of the surface buffer.  |
69| [OH_ED_KEY_EOS](#oh_ed_key_eos) | Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.  |
70| [OH_MD_KEY_TRACK_TYPE](#oh_md_key_track_type) |  Provides unified character descriptors for the media playback framework.  |
71| [OH_MD_KEY_CODEC_MIME](#oh_md_key_codec_mime) | Character descriptor of the MIME type. The value type is string.  |
72| [OH_MD_KEY_DURATION](#oh_md_key_duration) | Character descriptor of duration. The value type is int64_t.  |
73| [OH_MD_KEY_BITRATE](#oh_md_key_bitrate) | Character descriptor of the bit rate. The value type is uint32_t.  |
74| [OH_MD_KEY_MAX_INPUT_SIZE](#oh_md_key_max_input_size) | Character descriptor of the maximum input size. The value type is uint32_t.  |
75| [OH_MD_KEY_WIDTH](#oh_md_key_width) | Character descriptor of the video width. The value type is uint32_t.  |
76| [OH_MD_KEY_HEIGHT](#oh_md_key_height) | Character descriptor of the video height. The value type is uint32_t.  |
77| [OH_MD_KEY_PIXEL_FORMAT](#oh_md_key_pixel_format) | Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).  |
78| [OH_MD_KEY_AUDIO_SAMPLE_FORMAT](#oh_md_key_audio_sample_format) | Character descriptor of the audio sample format. The value type is uint32_t.  |
79| [OH_MD_KEY_FRAME_RATE](#oh_md_key_frame_rate) | Character descriptor of the video frame rate. The value type is double.  |
80| [OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE](#oh_md_key_video_encode_bitrate_mode) | Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).  |
81| [OH_MD_KEY_PROFILE](#oh_md_key_profile) | Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).  |
82| [OH_MD_KEY_AUD_CHANNEL_COUNT](#oh_md_key_aud_channel_count) | Character descriptor of the number of audio channels. The value type is uint32_t.  |
83| [OH_MD_KEY_AUD_SAMPLE_RATE](#oh_md_key_aud_sample_rate) | Character descriptor of the audio sampling rate. The value type is uint32_t.  |
84| [OH_MD_KEY_I_FRAME_INTERVAL](#oh_md_key_i_frame_interval) | Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms.  |
85| [OH_MD_KEY_ROTATION](#oh_md_key_rotation) | Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0.  |
86
87
88## Type Description
89
90
91### OH_AACProfile
92
93
94```
95typedef enum OH_AACProfileOH_AACProfile
96```
97**Description**<br>
98Enumerates the AAC profiles.
99
100\@syscap SystemCapability.Multimedia.Media.CodecBase
101
102
103### OH_AVCodecAsyncCallback
104
105
106```
107typedef struct OH_AVCodecAsyncCallbackOH_AVCodecAsyncCallback
108```
109**Description**<br>
110Defines a collection of asynchronous callback functions for an **OH_AVCodec** instance. You must register this struct instance for an **OH_AVCodec** instance and process the information reported through these callbacks to ensure the normal running of the instance.
111
112\@syscap SystemCapability.Multimedia.Media.CodecBase
113
114 **Parameters**
115
116| Name | Description |
117| -------- | -------- |
118| onError | Indicates the callback used to report errors occurred during the running of the instance. For details, see [OH_AVCodecOnError](#oh_avcodeconerror).  |
119| onStreamChanged | Indicates the callback used to report stream information. For details, see [OH_AVCodecOnStreamChanged](#oh_avcodeconstreamchanged).  |
120| onNeedInputData | Indicates the callback used to report input data needed. For details, see [OH_AVCodecOnNeedInputData](#oh_avcodeconneedinputdata).  |
121| onNeedInputData | Indicates the callback used to report output data needed. For details, see [OH_AVCodecOnNewOutputData](#oh_avcodeconnewoutputdata).  |
122
123
124### OH_AVCodecBufferAttr
125
126
127```
128typedef struct OH_AVCodecBufferAttrOH_AVCodecBufferAttr
129```
130**Description**<br>
131Defines the buffer attributes of an **OH_AVCodec** instance.
132
133\@syscap SystemCapability.Multimedia.Media.CodecBase
134
135
136### OH_AVCodecBufferFlags
137
138
139```
140typedef enum OH_AVCodecBufferFlagsOH_AVCodecBufferFlags
141```
142**Description**<br>
143Enumerates the buffer flags of an **OH_AVCodec** instance.
144
145\@syscap SystemCapability.Multimedia.Media.CodecBase
146
147
148### OH_AVCodecOnError
149
150
151```
152typedef void(* OH_AVCodecOnError) (OH_AVCodec *codec, int32_t errorCode, void *userData)
153```
154**Description**<br>
155Defines the function pointer that is called to report error information when an error occurs during the running of an **OH_AVCodec** instance.
156
157\@syscap SystemCapability.Multimedia.Media.CodecBase
158
159 **Parameters**
160
161| Name | Description |
162| -------- | -------- |
163| codec | Indicates the pointer to an **OH_AVCodec** instance.  |
164| errorCode | Indicates an error code.  |
165| userData | Indicates the pointer to user-specific data.  |
166
167
168### OH_AVCodecOnNeedInputData
169
170
171```
172typedef void(* OH_AVCodecOnNeedInputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, void *userData)
173```
174**Description**<br>
175Defines the function pointer that is called, with a new buffer to fill in new input data, when new input data is required during the running of an **OH_AVCodec** instance.
176
177\@syscap SystemCapability.Multimedia.Media.CodecBase
178
179 **Parameters**
180
181| Name | Description |
182| -------- | -------- |
183| codec | Indicates the pointer to an **OH_AVCodec** instance.  |
184| index | Indicates the index of an input buffer.  |
185| data | Indicates the pointer to the new input data.  |
186| userData | Indicates the pointer to user-specific data.  |
187
188
189### OH_AVCodecOnNewOutputData
190
191
192```
193typedef void(* OH_AVCodecOnNewOutputData) (OH_AVCodec *codec, uint32_t index, OH_AVMemory *data, OH_AVCodecBufferAttr *attr, void *userData)
194```
195**Description**<br>
196Defines the function pointer that is called, with a buffer containing new output data, when the new output data is generated during the running of an **OH_AVCodec** instance. Note that the lifecycle of the pointer to the **[OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md)** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
197
198\@syscap SystemCapability.Multimedia.Media.CodecBase
199
200 **Parameters**
201
202| Name | Description |
203| -------- | -------- |
204| codec | Indicates the pointer to an **OH_AVCodec** instance.  |
205| index | Indicates the index of a new output buffer.  |
206| data | Indicates the pointer to the new output data.  |
207| attr | Indicates the pointer to the attributes of the new output buffer. For details, see [OH_AVCodecBufferAttr](_o_h___a_v_codec_buffer_attr.md).  |
208| userData | Indicates the pointer to user-specific data.  |
209| userData | specified data  |
210
211
212### OH_AVCodecOnStreamChanged
213
214
215```
216typedef void(* OH_AVCodecOnStreamChanged) (OH_AVCodec *codec, OH_AVFormat *format, void *userData)
217```
218**Description**<br>
219Defines the function pointer that is called to report the attributes of the new stream when the output stream changes. Note that the lifecycle of the pointer to the **OH_AVFormat** instance is valid only when the function pointer is being called. Do not access the pointer to the instance after the function pointer is called.
220
221\@syscap SystemCapability.Multimedia.Media.CodecBase
222
223 **Parameters**
224
225| Name | Description |
226| -------- | -------- |
227| codec | Indicates the pointer to an **OH_AVCodec** instance.  |
228| format | Indicates the handle to the attributes of the new output stream.  |
229| userData | Indicates the pointer to user-specific data.  |
230
231
232### OH_AVCProfile
233
234
235```
236typedef enum OH_AVCProfileOH_AVCProfile
237```
238**Description**<br>
239Enumerates the AVC profiles.
240
241\@syscap SystemCapability.Multimedia.Media.CodecBase
242
243
244### OH_MediaType
245
246
247```
248typedef enum OH_MediaTypeOH_MediaType
249```
250**Description**<br>
251Enumerates the media types.
252
253\@syscap SystemCapability.Multimedia.Media.CodecBase
254
255
256## Enum Description
257
258
259### OH_AACProfile
260
261
262```
263enum OH_AACProfile
264```
265**Description**<br>
266Enumerates the AAC profiles.
267
268\@syscap SystemCapability.Multimedia.Media.CodecBase
269
270
271### OH_AVCodecBufferFlags
272
273
274```
275enum OH_AVCodecBufferFlags
276```
277**Description**<br>
278Enumerates the buffer flags of an **OH_AVCodec** instance.
279
280\@syscap SystemCapability.Multimedia.Media.CodecBase
281
282| Name | Description |
283| -------- | -------- |
284| AVCODEC_BUFFER_FLAGS_EOS  | The buffer contains an end-of-stream frame. |
285| AVCODEC_BUFFER_FLAGS_SYNC_FRAME  | The buffer contains a sync frame. |
286| AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME  | The buffer contains part of a frame. |
287| AVCODEC_BUFFER_FLAGS_CODEC_DATA  | The buffer contains codec-specific data. |
288
289
290### OH_AVCProfile
291
292
293```
294enum OH_AVCProfile
295```
296**Description**<br>
297Enumerates the AVC profiles.
298
299\@syscap SystemCapability.Multimedia.Media.CodecBase
300
301
302### OH_MediaType
303
304
305```
306enum OH_MediaType
307```
308**Description**<br>
309Enumerates the media types.
310
311\@syscap SystemCapability.Multimedia.Media.CodecBase
312
313| Name | Description |
314| -------- | -------- |
315| MEDIA_TYPE_AUD  | Audio track. |
316| MEDIA_TYPE_VID  | Video track. |
317
318
319## Variable Description
320
321
322### flags
323
324
325```
326uint32_t OH_AVCodecBufferAttr::flags
327```
328**Description**<br>
329Buffer flag, which is a combination of multiple [OH_AVCodecBufferFlags](#oh_avcodecbufferflags).
330
331
332### offset
333
334
335```
336int32_t OH_AVCodecBufferAttr::offset
337```
338**Description**<br>
339Start offset of valid data in the buffer.
340
341
342### OH_AVCODEC_MIMETYPE_AUDIO_AAC
343
344
345```
346const char* OH_AVCODEC_MIMETYPE_AUDIO_AAC
347```
348**Description**<br>
349Defines the MIME type for Advanced Audio Coding (AAC).
350
351\@syscap SystemCapability.Multimedia.Media.CodecBase
352
353
354### OH_AVCODEC_MIMETYPE_VIDEO_AVC
355
356
357```
358const char* OH_AVCODEC_MIMETYPE_VIDEO_AVC
359```
360**Description**<br>
361Defines the Multipurpose Internet Mail Extension (MIME) type for Advanced Video Coding (AVC).
362
363\@syscap SystemCapability.Multimedia.Media.CodecBase
364
365
366### OH_ED_KEY_EOS
367
368
369```
370const char* OH_ED_KEY_EOS
371```
372**Description**<br>
373Character descriptor of the end-of-stream in the surface auxiliary data. The value type is bool.
374
375
376### OH_ED_KEY_TIME_STAMP
377
378
379```
380const char* OH_ED_KEY_TIME_STAMP
381```
382**Description**<br>
383Provides unified character descriptors for the auxiliary data of the surface buffer.
384
385\@syscap SystemCapability.Multimedia.Media.CodecBase
386
387
388### OH_MD_KEY_AUD_CHANNEL_COUNT
389
390
391```
392const char* OH_MD_KEY_AUD_CHANNEL_COUNT
393```
394**Description**<br>
395Character descriptor of the number of audio channels. The value type is uint32_t.
396
397
398### OH_MD_KEY_AUD_SAMPLE_RATE
399
400
401```
402const char* OH_MD_KEY_AUD_SAMPLE_RATE
403```
404**Description**<br>
405Character descriptor of the audio sampling rate. The value type is uint32_t.
406
407
408### OH_MD_KEY_AUDIO_SAMPLE_FORMAT
409
410
411```
412const char* OH_MD_KEY_AUDIO_SAMPLE_FORMAT
413```
414**Description**<br>
415Character descriptor of the audio sample format. The value type is uint32_t.
416
417
418### OH_MD_KEY_BITRATE
419
420
421```
422const char* OH_MD_KEY_BITRATE
423```
424**Description**<br>
425Character descriptor of the bit rate. The value type is uint32_t.
426
427
428### OH_MD_KEY_CODEC_MIME
429
430
431```
432const char* OH_MD_KEY_CODEC_MIME
433```
434**Description**<br>
435Character descriptor of the MIME type. The value type is string.
436
437
438### OH_MD_KEY_DURATION
439
440
441```
442const char* OH_MD_KEY_DURATION
443```
444**Description**<br>
445Character descriptor of duration. The value type is int64_t.
446
447
448### OH_MD_KEY_FRAME_RATE
449
450
451```
452const char* OH_MD_KEY_FRAME_RATE
453```
454**Description**<br>
455Character descriptor of the video frame rate. The value type is double.
456
457
458### OH_MD_KEY_HEIGHT
459
460
461```
462const char* OH_MD_KEY_HEIGHT
463```
464**Description**<br>
465Character descriptor of the video height. The value type is uint32_t.
466
467
468### OH_MD_KEY_I_FRAME_INTERVAL
469
470
471```
472const char* OH_MD_KEY_I_FRAME_INTERVAL
473```
474**Description**<br>
475Character descriptor of the I-frame interval. The value type is int32_t, and the unit is ms.
476
477
478### OH_MD_KEY_MAX_INPUT_SIZE
479
480
481```
482const char* OH_MD_KEY_MAX_INPUT_SIZE
483```
484**Description**<br>
485Character descriptor of the maximum input size. The value type is uint32_t.
486
487
488### OH_MD_KEY_PIXEL_FORMAT
489
490
491```
492const char* OH_MD_KEY_PIXEL_FORMAT
493```
494**Description**<br>
495Character descriptor of the video pixel format. The value type is int32_t. For details, see [OH_AVPixelFormat](_core.md#oh_avpixelformat).
496
497
498### OH_MD_KEY_PROFILE
499
500
501```
502const char* OH_MD_KEY_PROFILE
503```
504**Description**<br>
505Character descriptor of the audio/video encoding capability. The value type is int32_t. For details, see [OH_AVCProfile](#oh_avcprofile) or [OH_AACProfile](#oh_aacprofile).
506
507
508### OH_MD_KEY_ROTATION
509
510
511```
512const char* OH_MD_KEY_ROTATION
513```
514**Description**<br>
515Character descriptor of the surface rotation angle. The value type is int32_t. The value range is {0, 90, 180, 270}. The default value is 0.
516
517
518### OH_MD_KEY_TRACK_TYPE
519
520
521```
522const char* OH_MD_KEY_TRACK_TYPE
523```
524**Description**<br>
525Provides unified character descriptors for the media playback framework.
526
527\@syscap SystemCapability.Multimedia.Media.CodecBase
528
529
530### OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
531
532
533```
534const char* OH_MD_KEY_VIDEO_ENCODE_BITRATE_MODE
535```
536**Description**<br>
537Character descriptor of the video encoding bit rate mode. The value type is int32_t. For details, see [OH_VideoEncodeBitrateMode](_video_encoder.md#oh_videoencodebitratemode).
538
539
540### OH_MD_KEY_WIDTH
541
542
543```
544const char* OH_MD_KEY_WIDTH
545```
546**Description**<br>
547Character descriptor of the video width. The value type is uint32_t.
548
549
550### pts
551
552
553```
554int64_t OH_AVCodecBufferAttr::pts
555```
556**Description**<br>
557Presentation timestamp of the buffer, in microseconds.
558
559
560### size
561
562
563```
564int32_t OH_AVCodecBufferAttr::size
565```
566**Description**<br>
567Size of the data contained in the buffer, in bytes.
568