• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Core
2
3
4## 概述
5
6Core模块提供用于播放框架的基础骨干能力,包含内存、错误码、格式载体等相关函数。
7
8@syscap SystemCapability.Multimedia.Media.Core
9
10**起始版本:**
119
12
13## 汇总
14
15
16### 文件
17
18  | 名称 | 描述 |
19| -------- | -------- |
20| [native_averrors.h](native__averrors_8h.md) | 声明了媒体播放框架的错误码。<br>引用文件:<multimedia/player_framework/native_averrors.h>  |
21| [native_avformat.h](native__avformat_8h.md) | 声明了格式相关的函数和枚举。<br>引用文件:<multimedia/player_framework/native_avformat.h>  |
22| [native_avmemory.h](native__avmemory_8h.md) | 声明了AVMemory的函数接口。<br>引用文件:<multimedia/player_framework/native_avmemory.h>  |
23
24
25### 类型定义
26
27  | 名称 | 描述 |
28| -------- | -------- |
29| [OH_AVErrCode](#oh_averrcode) | 音视频错误码。  |
30| [OH_AVPixelFormat](#oh_avpixelformat) | AVPixel 格式的枚举。  |
31
32
33### 枚举
34
35  | 名称 | 描述 |
36| -------- | -------- |
37| [OH_AVErrCode](#oh_averrcode) {<br/>**AV_ERR_OK** = 0, **AV_ERR_NO_MEMORY** = 1, **AV_ERR_OPERATE_NOT_PERMIT** = 2, **AV_ERR_INVALID_VAL** = 3, **AV_ERR_IO** = 4, **AV_ERR_TIMEOUT** = 5, **AV_ERR_UNKNOWN** = 6, **AV_ERR_SERVICE_DIED** = 7, **AV_ERR_INVALID_STATE** = 8, **AV_ERR_UNSUPPORT** = 9, **AV_ERR_EXTEND_START** = 100<br/>} | 音视频错误码。  |
38| [OH_AVPixelFormat](#oh_avpixelformat) {<br/>**AV_PIXEL_FORMAT_YUVI420** = 1, **AV_PIXEL_FORMAT_NV12** = 2, **AV_PIXEL_FORMAT_NV21** = 3, **AV_PIXEL_FORMAT_SURFACE_FORMAT** = 4, **AV_PIXEL_FORMAT_RGBA** = 5<br/>} | AVPixel 格式的枚举。  |
39
40
41### 函数
42
43  | 名称 | 描述 |
44| -------- | -------- |
45| [OH_AVFormat_Create](#oh_avformat_create) (void) | 创建一个OH_AVFormat句柄指针,用以读写数据。  |
46| [OH_AVFormat_Destroy](#oh_avformat_destroy) (struct OH_AVFormat \*format) | 销毁指定OH_AVFormat句柄资源。  |
47| [OH_AVFormat_Copy](#oh_avformat_copy) (struct OH_AVFormat \*to, struct OH_AVFormat \*from) | 拷贝OH_AVFormat句柄资源.  |
48| [OH_AVFormat_SetIntValue](#oh_avformat_setintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t value) | 向OH_AVFormat写入Int数据.  |
49| [OH_AVFormat_SetLongValue](#oh_avformat_setlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t value) | 向OH_AVFormat写入Long数据。  |
50| [OH_AVFormat_SetFloatValue](#oh_avformat_setfloatvalue) (struct OH_AVFormat \*format, const char \*key, float value) | 向OH_AVFormat写入Float数据。  |
51| [OH_AVFormat_SetDoubleValue](#oh_avformat_setdoublevalue) (struct OH_AVFormat \*format, const char \*key, double value) | 向OH_AVFormat写入Double数据。  |
52| [OH_AVFormat_SetStringValue](#oh_avformat_setstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*value) | 向OH_AVFormat写入String数据。  |
53| [OH_AVFormat_SetBuffer](#oh_avformat_setbuffer) (struct OH_AVFormat \*format, const char \*key, const uint8_t \*addr, size_t size) | 向OH_AVFormat写入一块指定长度的数据。  |
54| [OH_AVFormat_GetIntValue](#oh_avformat_getintvalue) (struct OH_AVFormat \*format, const char \*key, int32_t \*out) | 从OH_AVFormat读取Int数据。  |
55| [OH_AVFormat_GetLongValue](#oh_avformat_getlongvalue) (struct OH_AVFormat \*format, const char \*key, int64_t \*out) | 从OH_AVFormat读取Long数据。  |
56| [OH_AVFormat_GetFloatValue](#oh_avformat_getfloatvalue) (struct OH_AVFormat \*format, const char \*key, float \*out) | 从OH_AVFormat读取Float数据。  |
57| [OH_AVFormat_GetDoubleValue](#oh_avformat_getdoublevalue) (struct OH_AVFormat \*format, const char \*key, double \*out) | 从OH_AVFormat读取Double数据。  |
58| [OH_AVFormat_GetStringValue](#oh_avformat_getstringvalue) (struct OH_AVFormat \*format, const char \*key, const char \*\*out) | 从OH_AVFormat读取Double数据。  |
59| [OH_AVFormat_GetBuffer](#oh_avformat_getbuffer) (struct OH_AVFormat \*format, const char \*key, uint8_t \*\*addr, size_t \*size) | 从OH_AVFormat读取一块指定长度的数据。  |
60| [OH_AVFormat_DumpInfo](#oh_avformat_dumpinfo) (struct OH_AVFormat \*format) | 以字符串的形式输出OH_AVFormat所包含的信息。  |
61| [OH_AVMemory_GetAddr](#oh_avmemory_getaddr) (struct OH_AVMemory \*mem) | 获取入参的内存虚拟地址。  |
62| [OH_AVMemory_GetSize](#oh_avmemory_getsize) (struct OH_AVMemory \*mem) | 获取入参的内存长度。  |
63
64
65## 类型定义说明
66
67
68### OH_AVErrCode
69
70
71```
72typedef enum OH_AVErrCodeOH_AVErrCode
73```
74**描述:**
75音视频错误码。
76
77@syscap SystemCapability.Multimedia.Media.Core
78
79
80### OH_AVPixelFormat
81
82
83```
84typedef enum OH_AVPixelFormatOH_AVPixelFormat
85```
86**描述:**
87AVPixel 格式的枚举。
88
89@syscap SystemCapability.Multimedia.Media.Core
90
91
92## 枚举类型说明
93
94
95### OH_AVErrCode
96
97
98```
99enum OH_AVErrCode
100```
101**描述:**
102音视频错误码。
103
104@syscap SystemCapability.Multimedia.Media.Core
105
106  | 枚举值 | 描述 |
107| -------- | -------- |
108| AV_ERR_OK  | 操作成功 |
109| AV_ERR_NO_MEMORY  | 无内存 |
110| AV_ERR_OPERATE_NOT_PERMIT  | 无效参数 |
111| AV_ERR_INVALID_VAL  | 无效值 |
112| AV_ERR_IO  | IO 错误 |
113| AV_ERR_TIMEOUT  | 超时错误 |
114| AV_ERR_UNKNOWN  | 未知错误 |
115| AV_ERR_SERVICE_DIED  | 媒体服务死亡 |
116| AV_ERR_INVALID_STATE  | 当前状态不支持此操作 |
117| AV_ERR_UNSUPPORT  | 未支持的接口 |
118| AV_ERR_EXTEND_START  | 扩展错误码初始值 |
119
120
121### OH_AVPixelFormat
122
123
124```
125enum OH_AVPixelFormat
126```
127**描述:**
128AVPixel 格式的枚举。
129
130@syscap SystemCapability.Multimedia.Media.Core
131
132  | 枚举值 | 描述 |
133| -------- | -------- |
134| AV_PIXEL_FORMAT_YUVI420  | yuv 420 planar |
135| AV_PIXEL_FORMAT_NV12  | NV12. yuv 420 semiplanar |
136| AV_PIXEL_FORMAT_NV21  | NV21. yvu 420 semiplanar |
137| AV_PIXEL_FORMAT_SURFACE_FORMAT  | surface格式 |
138| AV_PIXEL_FORMAT_RGBA  | RGBA8888 |
139
140
141## 函数说明
142
143
144### OH_AVFormat_Copy()
145
146
147```
148bool OH_AVFormat_Copy (struct OH_AVFormat * to, struct OH_AVFormat * from )
149```
150**描述:**
151拷贝OH_AVFormat句柄资源.
152
153@syscap SystemCapability.Multimedia.Media.Core
154
155**参数:**
156
157  | 名称 | 描述 |
158| -------- | -------- |
159| to | 接收数据的OH_AVFormat句柄指针  |
160| from | 被拷贝数据的OH_AVFormat句柄指针  |
161
162**返回:**
163
164返回值为TRUE表示成功
165
166返回值为FALSE表示失败
167
168
169### OH_AVFormat_Create()
170
171
172```
173struct OH_AVFormat* OH_AVFormat_Create (void )
174```
175**描述:**
176创建一个OH_AVFormat句柄指针,用以读写数据。
177
178@syscap SystemCapability.Multimedia.Media.Core
179
180**返回:**
181
182返回OH_AVFormat实例的指针
183
184
185### OH_AVFormat_Destroy()
186
187
188```
189void OH_AVFormat_Destroy (struct OH_AVFormat * format)
190```
191**描述:**
192销毁指定OH_AVFormat句柄资源。
193
194@syscap SystemCapability.Multimedia.Media.Core
195
196**参数:**
197
198  | 名称 | 描述 |
199| -------- | -------- |
200| format | 指向OH_AVFormat实例的指针  |
201
202**返回:**
203
204void
205
206
207### OH_AVFormat_DumpInfo()
208
209
210```
211const char* OH_AVFormat_DumpInfo (struct OH_AVFormat * format)
212```
213**描述:**
214以字符串的形式输出OH_AVFormat所包含的信息。
215
216@syscap SystemCapability.Multimedia.Media.Core
217
218**参数:**
219
220  | 名称 | 描述 |
221| -------- | -------- |
222| format | 指向OH_AVFormat实例的指针  |
223
224**返回:**
225
226返回由键值和数据组成的字符串指针
227
228
229### OH_AVFormat_GetBuffer()
230
231
232```
233bool OH_AVFormat_GetBuffer (struct OH_AVFormat * format, const char * key, uint8_t ** addr, size_t * size )
234```
235**描述:**
236从OH_AVFormat读取一块指定长度的数据。
237
238@syscap SystemCapability.Multimedia.Media.Core
239
240**参数:**
241
242  | 名称 | 描述 |
243| -------- | -------- |
244| format | 指向OH_AVFormat实例的指针  |
245| key | 读写数据的键值  |
246| addr | 生命周期是format持有,伴随format销毁,如果调用者需要长期持有,必须进行内存拷贝  |
247| size | 读写数据的长度  |
248
249**返回:**
250
251返回值为TRUE表示成功
252
253返回值为FALSE表示失败
254
255
256### OH_AVFormat_GetDoubleValue()
257
258
259```
260bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat * format, const char * key, double * out )
261```
262**描述:**
263从OH_AVFormat读取Double数据。
264
265@syscap SystemCapability.Multimedia.Media.Core
266
267**参数:**
268
269  | 名称 | 描述 |
270| -------- | -------- |
271| format | 指向OH_AVFormat实例的指针  |
272| key | 读取数据的键值  |
273| out | 读取的数据  |
274
275**返回:**
276
277返回值为TRUE表示成功
278
279返回值为FALSE表示失败
280
281
282### OH_AVFormat_GetFloatValue()
283
284
285```
286bool OH_AVFormat_GetFloatValue (struct OH_AVFormat * format, const char * key, float * out )
287```
288**描述:**
289从OH_AVFormat读取Float数据。
290
291@syscap SystemCapability.Multimedia.Media.Core
292
293**参数:**
294
295  | 名称 | 描述 |
296| -------- | -------- |
297| format | 指向OH_AVFormat实例的指针  |
298| key | 读取数据的键值  |
299| out | 读取的数据  |
300
301**返回:**
302
303返回值为TRUE表示成功
304
305返回值为FALSE表示失败
306
307
308### OH_AVFormat_GetIntValue()
309
310
311```
312bool OH_AVFormat_GetIntValue (struct OH_AVFormat * format, const char * key, int32_t * out )
313```
314**描述:**
315从OH_AVFormat读取Int数据。
316
317@syscap SystemCapability.Multimedia.Media.Core
318
319**参数:**
320
321  | 名称 | 描述 |
322| -------- | -------- |
323| format | 指向OH_AVFormat实例的指针  |
324| key | 读取数据的键值  |
325| out | 读取的数据  |
326
327**返回:**
328
329返回值为TRUE表示成功
330
331返回值为FALSE表示失败
332
333
334### OH_AVFormat_GetLongValue()
335
336
337```
338bool OH_AVFormat_GetLongValue (struct OH_AVFormat * format, const char * key, int64_t * out )
339```
340**描述:**
341从OH_AVFormat读取Long数据。
342
343@syscap SystemCapability.Multimedia.Media.Core
344
345**参数:**
346
347  | 名称 | 描述 |
348| -------- | -------- |
349| format | 指向OH_AVFormat实例的指针  |
350| key | 读取数据的键值  |
351| out | 读取的数据  |
352
353**返回:**
354
355返回值为TRUE表示成功
356
357返回值为FALSE表示失败
358
359
360### OH_AVFormat_GetStringValue()
361
362
363```
364bool OH_AVFormat_GetStringValue (struct OH_AVFormat * format, const char * key, const char ** out )
365```
366**描述:**
367从OH_AVFormat读取Double数据。
368
369@syscap SystemCapability.Multimedia.Media.Core
370
371**参数:**
372
373  | 名称 | 描述 |
374| -------- | -------- |
375| format | 指向OH_AVFormat实例的指针  |
376| key | 读取数据的键值  |
377| out | 读取的字符串指针,指向的数据生命周期伴随GetString更新,伴随format销毁,如果调用者需要长期持有,必须进行内存拷贝  |
378
379**返回:**
380
381返回值为TRUE表示成功
382
383返回值为FALSE表示失败
384
385
386### OH_AVFormat_SetBuffer()
387
388
389```
390bool OH_AVFormat_SetBuffer (struct OH_AVFormat * format, const char * key, const uint8_t * addr, size_t size )
391```
392**描述:**
393向OH_AVFormat写入一块指定长度的数据。
394
395@syscap SystemCapability.Multimedia.Media.Core
396
397**参数:**
398
399  | 名称 | 描述 |
400| -------- | -------- |
401| format | 指向OH_AVFormat实例的指针  |
402| key | 写入数据的键值  |
403| addr | 写入的数据地址  |
404| size | 写入的数据长度  |
405
406**返回:**
407
408返回值为TRUE表示成功
409
410返回值为FALSE表示失败
411
412
413### OH_AVFormat_SetDoubleValue()
414
415
416```
417bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat * format, const char * key, double value )
418```
419**描述:**
420向OH_AVFormat写入Double数据。
421
422@syscap SystemCapability.Multimedia.Media.Core
423
424**参数:**
425
426  | 名称 | 描述 |
427| -------- | -------- |
428| format | 指向OH_AVFormat实例的指针  |
429| key | 写入数据的键值  |
430| value | 写入的数据  |
431
432**返回:**
433
434返回值为TRUE表示成功
435
436返回值为FALSE表示失败
437
438
439### OH_AVFormat_SetFloatValue()
440
441
442```
443bool OH_AVFormat_SetFloatValue (struct OH_AVFormat * format, const char * key, float value )
444```
445**描述:**
446向OH_AVFormat写入Float数据。
447
448@syscap SystemCapability.Multimedia.Media.Core
449
450**参数:**
451
452  | 名称 | 描述 |
453| -------- | -------- |
454| format | 指向OH_AVFormat实例的指针  |
455| key | 写入数据的键值  |
456| value | 写入的数据  |
457
458**返回:**
459
460返回值为TRUE表示成功
461
462返回值为FALSE表示失败
463
464
465### OH_AVFormat_SetIntValue()
466
467
468```
469bool OH_AVFormat_SetIntValue (struct OH_AVFormat * format, const char * key, int32_t value )
470```
471**描述:**
472向OH_AVFormat写入Int数据.
473
474@syscap SystemCapability.Multimedia.Media.Core
475
476**参数:**
477
478  | 名称 | 描述 |
479| -------- | -------- |
480| format | 指向OH_AVFormat实例的指针  |
481| key | 写入数据的键值  |
482| value | 写入的数据  |
483
484**返回:**
485
486返回值为TRUE表示成功
487
488返回值为FALSE表示失败
489
490
491### OH_AVFormat_SetLongValue()
492
493
494```
495bool OH_AVFormat_SetLongValue (struct OH_AVFormat * format, const char * key, int64_t value )
496```
497**描述:**
498向OH_AVFormat写入Long数据。
499
500@syscap SystemCapability.Multimedia.Media.Core
501
502**参数:**
503
504  | 名称 | 描述 |
505| -------- | -------- |
506| format | 指向OH_AVFormat实例的指针  |
507| key | 写入数据的键值  |
508| value | 写入的数据  |
509
510**返回:**
511
512返回值为TRUE表示成功
513
514返回值为FALSE表示失败
515
516
517### OH_AVFormat_SetStringValue()
518
519
520```
521bool OH_AVFormat_SetStringValue (struct OH_AVFormat * format, const char * key, const char * value )
522```
523**描述:**
524向OH_AVFormat写入String数据。
525
526@syscap SystemCapability.Multimedia.Media.Core
527
528**参数:**
529
530  | 名称 | 描述 |
531| -------- | -------- |
532| format | 指向OH_AVFormat实例的指针  |
533| key | 写入数据的键值  |
534| value | 写入的数据  |
535
536**返回:**
537
538返回值为TRUE表示成功
539
540返回值为FALSE表示失败
541
542
543### OH_AVMemory_GetAddr()
544
545
546```
547uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory * mem)
548```
549**描述:**
550获取入参的内存虚拟地址。
551
552@syscap SystemCapability.Multimedia.Media.Core
553
554**参数:**
555
556  | 名称 | 描述 |
557| -------- | -------- |
558| mem | 指向OH_AVMemory实例的指针  |
559
560**返回:**
561
562如果内存有效,返回内存的虚拟地址
563
564如果内存无效,返回nullptr
565
566
567### OH_AVMemory_GetSize()
568
569
570```
571int32_t OH_AVMemory_GetSize (struct OH_AVMemory * mem)
572```
573**描述:**
574获取入参的内存长度。
575
576@syscap SystemCapability.Multimedia.Media.Core
577
578**参数:**
579
580  | 名称 | 描述 |
581| -------- | -------- |
582| mem | 指向OH_AVMemory实例的指针  |
583
584**返回:**
585
586如果内存有效,返回内存长度
587
588如果内存无效,返回-1
589