1# native_avformat.h 2 3## Overview 4 5The file declares the functions and enums related to OH_AVFormat. 6 7**File to include**: <multimedia/player_framework/native_avformat.h> 8 9**Library**: libnative_media_core.so 10 11**System capability**: SystemCapability.Multimedia.Media.Core 12 13**Since**: 9 14 15**Related module**: [Core](capi-core.md) 16 17## Summary 18 19### Structs 20 21| Name| typedef Keyword| Description| 22| -- | -- | -- | 23| [OH_AVFormat](capi-core-oh-avformat.md) | OH_AVFormat | Describes a native object for the OH_AVFormat interface.| 24 25### Enums 26 27| Name| typedef Keyword| Description| 28| -- | -- | -- | 29| [OH_AVPixelFormat](#oh_avpixelformat) | OH_AVPixelFormat | Enumerates the video pixel formats.| 30 31### Functions 32 33| Name| Description| 34| -- | -- | 35| [struct OH_AVFormat *OH_AVFormat_Create(void)](#oh_avformat_create) | Create an OH_AVFormat instance for reading data.| 36| [struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType,int32_t sampleRate,int32_t channelCount)](#oh_avformat_createaudioformat) | Creates an audio OH_AVFormat instance with specified parameters for reading and writing data.| 37| [struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType,int32_t width,int32_t height)](#oh_avformat_createvideoformat) | Creates a video OH_AVFormat instance with specified parameters for reading and writing data.| 38| [void OH_AVFormat_Destroy(struct OH_AVFormat *format)](#oh_avformat_destroy) | Destroys an OH_AVFormat instance. The instance cannot be destroyed repeatedly.| 39| [bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from)](#oh_avformat_copy) | Copies an OH_AVFormat instance.| 40| [bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value)](#oh_avformat_setintvalue) | Assigns a value of the int type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 41| [bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value)](#oh_avformat_setlongvalue) | Assigns a value of the long type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 42| [bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value)](#oh_avformat_setfloatvalue) | Assigns a value of the float type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 43| [bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value)](#oh_avformat_setdoublevalue) | Assigns a value of the double type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 44| [bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value)](#oh_avformat_setstringvalue) | Assigns a value of the string type to a key in an OH_AVFormat instance.| 45| [bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size)](#oh_avformat_setbuffer) | Writes data blocks of a specified length to an OH_AVFormat instance.| 46| [bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out)](#oh_avformat_getintvalue) | Obtains the value of the int type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 47| [bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out)](#oh_avformat_getlongvalue) | Obtains the value of the long type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 48| [bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out)](#oh_avformat_getfloatvalue) | Obtains the value of the float type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 49| [bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out)](#oh_avformat_getdoublevalue) | Obtains the value of the double type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 50| [bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, const char **out)](#oh_avformat_getstringvalue) | Obtains the value of the string type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance.| 51| [bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size)](#oh_avformat_getbuffer) | Reads data blocks of a specified length from an OH_AVFormat instance.| 52| [bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size)](#oh_avformat_getintbuffer) | Reads an array of int32_t data from an OH_AVFormat instance. Note that the buffer lifecycle is bound to the OH_AVFormat instance. The buffer becomes invalid automatically when the OH_AVFormat instance is destroyed.<br>To keep the data for an extended period, explicitly copy the data to newly allocated memory.| 53| [const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format)](#oh_avformat_dumpinfo) | Returns a string consisting of key-value pairs in an OH_AVFormat instance. A string of up to 1024 bytes can be returned. The string pointer is released when the OH_AVFormat instance is destroyed.| 54| [bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size)](#oh_avformat_setintbuffer) | Writes data blocks of the int32_t type with a specified length to an OH_AVFormat instance.| 55 56## Enum Description 57 58### OH_AVPixelFormat 59 60``` 61enum OH_AVPixelFormat 62``` 63 64**Description** 65 66Enumerates the video pixel formats. 67 68**System capability**: SystemCapability.Multimedia.Media.Core 69 70**Since**: 9 71 72| Value| Description| 73| -- | -- | 74| AV_PIXEL_FORMAT_YUVI420 = 1 | YUV 420 Planar.| 75| AV_PIXEL_FORMAT_NV12 = 2 | NV12. YUV 420 semi-planar.| 76| AV_PIXEL_FORMAT_NV21 = 3 | NV21. YVU 420 semi-planar.| 77| AV_PIXEL_FORMAT_SURFACE_FORMAT = 4 | Pixel format obtained from the surface. This value takes effect only in surface mode.| 78| AV_PIXEL_FORMAT_RGBA = 5 | RGBA8888.| 79| AV_PIXEL_FORMAT_RGBA1010102 = 6 | RGBA1010102.<br>**Since**: 20| 80 81 82## Function Description 83 84### OH_AVFormat_Create() 85 86``` 87struct OH_AVFormat *OH_AVFormat_Create(void) 88``` 89 90**Description** 91 92Create an OH_AVFormat instance for reading data. 93 94**System capability**: SystemCapability.Multimedia.Media.Core 95 96**Since**: 9 97 98**Returns** 99 100| Type| Description| 101| -- | -- | 102| [struct OH_AVFormat](capi-core-oh-avformat.md) * | Pointer to an OH_AVFormat instance. If system resources are insufficient, NULL is returned.| 103 104### OH_AVFormat_CreateAudioFormat() 105 106``` 107struct OH_AVFormat *OH_AVFormat_CreateAudioFormat(const char *mimeType,int32_t sampleRate,int32_t channelCount) 108``` 109 110**Description** 111 112Creates an audio OH_AVFormat instance with specified parameters for reading and writing data. 113 114**System capability**: SystemCapability.Multimedia.Media.Core 115 116**Since**: 10 117 118 119**Parameters** 120 121| Name| Description| 122| -- | -- | 123| const char *mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](capi-native-avcodec-base-h.md#variables).| 124| int32_t sampleRate | Sampling rate, in Hz.| 125| int32_t channelCount | Number of audio channels. For example, 1 indicates mono and 2 indicates stereo.| 126 127**Returns** 128 129| Type| Description| 130| -- | -- | 131| [struct OH_AVFormat](capi-core-oh-avformat.md) * | Pointer to the OH_AVFormat instance created. If the operation fails, NULL is returned.<br>The possible causes of an operation failure are as follows:<br>1. The value of **mimeType** is NULL.<br>2. System resources are insufficient.| 132 133### OH_AVFormat_CreateVideoFormat() 134 135``` 136struct OH_AVFormat *OH_AVFormat_CreateVideoFormat(const char *mimeType,int32_t width,int32_t height) 137``` 138 139**Description** 140 141Creates a video OH_AVFormat instance with specified parameters for reading and writing data. 142 143**System capability**: SystemCapability.Multimedia.Media.Core 144 145 146**Parameters** 147 148| Name| Description| 149| -- | -- | 150| const char *mimeType | Pointer to a string that describes the MIME type. For details, see [AVCODEC_MIMETYPE](capi-native-avcodec-base-h.md#variables).| 151| int32_t width | Luminance width, in pixels.| 152| int32_t height | Luminance height, in pixels.| 153 154**Returns** 155 156| Type| Description| 157| -- | -- | 158| [struct OH_AVFormat](capi-core-oh-avformat.md) * | Pointer to the OH_AVFormat instance created. If the operation fails, NULL is returned.<br>The possible causes of an operation failure are as follows:<br>1. The value of **mimeType** is NULL.<br>2. System resources are insufficient.| 159 160### OH_AVFormat_Destroy() 161 162``` 163void OH_AVFormat_Destroy(struct OH_AVFormat *format) 164``` 165 166**Description** 167 168Destroys an OH_AVFormat instance. The instance cannot be destroyed repeatedly. 169 170**System capability**: SystemCapability.Multimedia.Media.Core 171 172**Since**: 9 173 174 175**Parameters** 176 177| Name| Description| 178| -- | -- | 179| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 180 181### OH_AVFormat_Copy() 182 183``` 184bool OH_AVFormat_Copy(struct OH_AVFormat *to, struct OH_AVFormat *from) 185``` 186 187**Description** 188 189Copies an OH_AVFormat instance. 190 191**System capability**: SystemCapability.Multimedia.Media.Core 192 193**Since**: 9 194 195 196**Parameters** 197 198| Name| Description| 199| -- | -- | 200| [struct OH_AVFormat](capi-core-oh-avformat.md) *to | Pointer to the OH_AVFormat instance to which the data will be copied.| 201| [struct OH_AVFormat](capi-core-oh-avformat.md) *from | Pointer to the OH_AVFormat instance from which the data will be copied.| 202 203**Returns** 204 205| Type| Description| 206| -- | -- | 207| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The input parameter is nullptr.<br>2. The value of **OH_AVFormat** fails parameter structure verification.| 208 209### OH_AVFormat_SetIntValue() 210 211``` 212bool OH_AVFormat_SetIntValue(struct OH_AVFormat *format, const char *key, int32_t value) 213``` 214 215**Description** 216 217Assigns a value of the int type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. This function can be used to set only parameters of the int type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 218 219**System capability**: SystemCapability.Multimedia.Media.Core 220 221**Since**: 9 222 223 224**Parameters** 225 226| Name| Description| 227| -- | -- | 228| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 229| const char *key | Pointer to the key of the data to write.| 230| int32_t value | Value of the data to write.| 231 232**Returns** 233 234| Type| Description| 235| -- | -- | 236| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value type corresponding to the key is incorrect.| 237 238### OH_AVFormat_SetLongValue() 239 240``` 241bool OH_AVFormat_SetLongValue(struct OH_AVFormat *format, const char *key, int64_t value) 242``` 243 244**Description** 245 246Assigns a value of the long type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. This function can be used to set only parameters of the long type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 247 248**System capability**: SystemCapability.Multimedia.Media.Core 249 250**Since**: 9 251 252 253**Parameters** 254 255| Name| Description| 256| -- | -- | 257| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 258| const char *key | Pointer to the key of the data to write.| 259| int64_t value | Value of the data to write.| 260 261**Returns** 262 263| Type| Description| 264| -- | -- | 265| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value type corresponding to the key is incorrect.| 266 267### OH_AVFormat_SetFloatValue() 268 269``` 270bool OH_AVFormat_SetFloatValue(struct OH_AVFormat *format, const char *key, float value) 271``` 272 273**Description** 274 275Assigns a value of the float type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. This function can be used to set only parameters of the float type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 276 277**System capability**: SystemCapability.Multimedia.Media.Core 278 279**Since**: 9 280 281 282**Parameters** 283 284| Name| Description| 285| -- | -- | 286| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 287| const char *key | Pointer to the key of the data to write.| 288| float value | Value of the data to write.| 289 290**Returns** 291 292| Type| Description| 293| -- | -- | 294| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value type corresponding to the key is incorrect.| 295 296### OH_AVFormat_SetDoubleValue() 297 298``` 299bool OH_AVFormat_SetDoubleValue(struct OH_AVFormat *format, const char *key, double value) 300``` 301 302**Description** 303 304Assigns a value of the double type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. This function can be used to set only parameters of the double type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 305 306**System capability**: SystemCapability.Multimedia.Media.Core 307 308**Since**: 9 309 310 311**Parameters** 312 313| Name| Description| 314| -- | -- | 315| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 316| const char *key | Pointer to the key of the data to write.| 317| double value | Value of the data to write.| 318 319**Returns** 320 321| Type| Description| 322| -- | -- | 323| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value type corresponding to the key is incorrect.| 324 325### OH_AVFormat_SetStringValue() 326 327``` 328bool OH_AVFormat_SetStringValue(struct OH_AVFormat *format, const char *key, const char *value) 329``` 330 331**Description** 332 333Assigns a value of the string type to a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. This function can be used to set only parameters of the string type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 334 335**System capability**: SystemCapability.Multimedia.Media.Core 336 337**Since**: 9 338 339 340**Parameters** 341 342| Name| Description| 343| -- | -- | 344| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 345| const char *key | Pointer to the key of the data to write.| 346| const char *value | Pointer to the data to be written to the string. The length should not exceed 256 bytes.| 347 348**Returns** 349 350| Type| Description| 351| -- | -- | 352| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The passed-in value of **value** is a null pointer.<br>5. The value type corresponding to the key is incorrect.| 353 354### OH_AVFormat_SetBuffer() 355 356``` 357bool OH_AVFormat_SetBuffer(struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size) 358``` 359 360**Description** 361 362Writes data blocks of a specified length to an OH_AVFormat instance. This function can be used to set only parameters of the buffer type. For details, see [native_avcodec_base.h](capi-native-avcodec-base-h.md#variables). 363 364**System capability**: SystemCapability.Multimedia.Media.Core 365 366**Since**: 9 367 368 369**Parameters** 370 371| Name| Description| 372| -- | -- | 373| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 374| const char *key | Pointer to the key of the data to write.| 375| const uint8_t *addr | Pointer to the address to which data is written. The lifecycle is managed by the developer.| 376| size_t size | Length of the data written, in MB. The value range is (0, 1].| 377 378**Returns** 379 380| Type| Description| 381| -- | -- | 382| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **addr** is nullptr.<br>5. The size is 0 or exceeds the upper limit 1 MB.<br>6. The value type corresponding to the key is incorrect.| 383 384### OH_AVFormat_GetIntValue() 385 386``` 387bool OH_AVFormat_GetIntValue(struct OH_AVFormat *format, const char *key, int32_t *out) 388``` 389 390**Description** 391 392Obtains the value of the int type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. 393 394**System capability**: SystemCapability.Multimedia.Media.Core 395 396**Since**: 9 397 398 399**Parameters** 400 401| Name| Description| 402| -- | -- | 403| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 404| const char *key | Pointer to the key of the data to read.| 405| int32_t *out | Pointer to the value of the data read.| 406 407**Returns** 408 409| Type| Description| 410| -- | -- | 411| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **out** is nullptr.<br>5. The obtained key does not exist or is not set.| 412 413### OH_AVFormat_GetLongValue() 414 415``` 416bool OH_AVFormat_GetLongValue(struct OH_AVFormat *format, const char *key, int64_t *out) 417``` 418 419**Description** 420 421Obtains the value of the long type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. 422 423**System capability**: SystemCapability.Multimedia.Media.Core 424 425**Since**: 9 426 427 428**Parameters** 429 430| Name| Description| 431| -- | -- | 432| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 433| const char *key | Pointer to the key of the data to read.| 434| int64_t *out | Pointer to the value of the data read.| 435 436**Returns** 437 438| Type| Description| 439| -- | -- | 440| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **out** is nullptr.<br>5. The obtained key does not exist or is not set.| 441 442### OH_AVFormat_GetFloatValue() 443 444``` 445bool OH_AVFormat_GetFloatValue(struct OH_AVFormat *format, const char *key, float *out) 446``` 447 448**Description** 449 450Obtains the value of the float type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. 451 452**System capability**: SystemCapability.Multimedia.Media.Core 453 454**Since**: 9 455 456 457**Parameters** 458 459| Name| Description| 460| -- | -- | 461| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 462| const char *key | Pointer to the key of the data to read.| 463| float *out | Pointer to the value of the data read.| 464 465**Returns** 466 467| Type| Description| 468| -- | -- | 469| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **out** is nullptr.<br>5. The obtained key does not exist or is not set.| 470 471### OH_AVFormat_GetDoubleValue() 472 473``` 474bool OH_AVFormat_GetDoubleValue(struct OH_AVFormat *format, const char *key, double *out) 475``` 476 477**Description** 478 479Obtains the value of the double type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. 480 481**System capability**: SystemCapability.Multimedia.Media.Core 482 483**Since**: 9 484 485 486**Parameters** 487 488| Name| Description| 489| -- | -- | 490| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 491| const char *key | Pointer to the key of the data to read.| 492| double *out | Pointer to the value of the data read.| 493 494**Returns** 495 496| Type| Description| 497| -- | -- | 498| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **out** is nullptr.<br>5. The obtained key does not exist or is not set.| 499 500### OH_AVFormat_GetStringValue() 501 502``` 503bool OH_AVFormat_GetStringValue(struct OH_AVFormat *format, const char *key, const char **out) 504``` 505 506**Description** 507 508Obtains the value of the string type of a [key](capi-codecbase.md#media-data-key-value-pairs) in an OH_AVFormat instance. 509 510**System capability**: SystemCapability.Multimedia.Media.Core 511 512**Since**: 9 513 514 515**Parameters** 516 517| Name| Description| 518| -- | -- | 519| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 520| const char *key | Pointer to the key of the data to read.| 521| const char **out | Double pointer to the string read. The lifecycle of the **out** data matches the string in **format**. To keep the **out** data for an extended period of time, you must copy it to the memory. The maximum length of the output string is 256 bytes. If the length exceeds 256 bytes, **false** is returned.| 522 523**Returns** 524 525| Type| Description| 526| -- | -- | 527| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **out** is nullptr.<br>5. The system resources are insufficient.<br>6. The obtained key does not exist or is not set.<br>7. The length of the **out** data exceeds 256 bytes.| 528 529### OH_AVFormat_GetBuffer() 530 531``` 532bool OH_AVFormat_GetBuffer(struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size) 533``` 534 535**Description** 536 537Reads data blocks of a specified length from an OH_AVFormat instance. 538 539**System capability**: SystemCapability.Multimedia.Media.Core 540 541**Since**: 9 542 543 544**Parameters** 545 546| Name| Description| 547| -- | -- | 548| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 549| const char *key | Pointer to the key of the data to read.| 550| uint8_t **addr | Double pointer to the address where the data read is stored. The data read is destroyed when the OH_AVFormat instance is destroyed. To hold the data for an extended period of time, copy it to the memory.| 551| size_t *size | Pointer to the size of the data read.| 552 553**Returns** 554 555| Type| Description| 556| -- | -- | 557| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **addr** is nullptr.<br>5. The value of **size** is nullptr.<br>6. The obtained key does not exist or is not set.| 558 559### OH_AVFormat_GetIntBuffer() 560 561``` 562bool OH_AVFormat_GetIntBuffer(struct OH_AVFormat *format, const char *key, int32_t **addr, size_t *size) 563``` 564 565**Description** 566 567Reads an array of int32_t data from an OH_AVFormat instance. 568 569Note that the buffer lifecycle is bound to the OH_AVFormat instance. The buffer becomes invalid automatically when the OH_AVFormat instance is destroyed. 570 571To keep the data for an extended period, explicitly copy the data to newly allocated memory. 572 573**System capability**: SystemCapability.Multimedia.Media.Core 574 575**Since**: 20 576 577 578**Parameters** 579 580| Name| Description| 581| -- | -- | 582| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 583| const char *key | Pointer to the key of the data to read.| 584| int32_t **addr | Double pointer to the memory where the data is stored.| 585| size_t *size | Pointer to the number of elements read.| 586 587**Returns** 588 589| Type| Description| 590| -- | -- | 591| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **addr** is nullptr.<br>5. The value of **size** is nullptr.| 592 593### OH_AVFormat_DumpInfo() 594 595``` 596const char *OH_AVFormat_DumpInfo(struct OH_AVFormat *format) 597``` 598 599**Description** 600 601Returns a string consisting of key-value pairs in an OH_AVFormat instance. A string of up to 1024 bytes can be returned. The string pointer is released when the OH_AVFormat instance is destroyed. 602 603**System capability**: SystemCapability.Multimedia.Media.Core 604 605**Since**: 9 606 607 608**Parameters** 609 610| Name| Description| 611| -- | -- | 612| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 613 614**Returns** 615 616| Type| Description| 617| -- | -- | 618| const char * | A string consisting of key-value pairs. If the operation fails, NULL is returned.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is NULL.<br>2. System resources are insufficient.| 619 620### OH_AVFormat_SetIntBuffer() 621 622``` 623bool OH_AVFormat_SetIntBuffer(struct OH_AVFormat *format, const char *key, const int32_t *addr, size_t size) 624``` 625 626**Description** 627 628Writes data blocks of the int32_t type with a specified length to an OH_AVFormat instance. 629 630**System capability**: SystemCapability.Multimedia.Media.Core 631 632**Since**: 20 633 634 635**Parameters** 636 637| Name| Description| 638| -- | -- | 639| [struct OH_AVFormat](capi-core-oh-avformat.md) *format | Pointer to an OH_AVFormat instance.| 640| const char *key | Pointer to the key of the data to write.| 641| const int32_t *addr | Pointer to the address to which data is written. The lifecycle is managed by the developer.| 642| size_t size | Length of the data to write, in units of elements, not bytes.| 643 644**Returns** 645 646| Type| Description| 647| -- | -- | 648| bool | **true** if the operation is successful; **false** otherwise.<br>The possible causes of an operation failure are as follows:<br>1. The value of **format** is nullptr.<br>2. The value of **format** fails parameter structure verification.<br>3. The value of **key** is nullptr.<br>4. The value of **addr** is nullptr.<br>5. The value of **size** is nullptr.| 649