1# native_avmemory.h 2 3## Overview 4 5The file declares the attribute definition of the media struct AVMemory. 6 7**File to include**: <multimedia/player_framework/native_avmemory.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_AVMemory](capi-core-oh-avmemory.md) | OH_AVMemory | Describes a native object for the audio and video memory interface.| 24 25### Functions 26 27| Name| Description| 28| -- | -- | 29| [OH_AVMemory *OH_AVMemory_Create(int32_t size)](#oh_avmemory_create) | Creates an OH_AVMemory instance.| 30| [uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem)](#oh_avmemory_getaddr) | Obtains the virtual memory address.| 31| [int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem)](#oh_avmemory_getsize) | Obtains the memory length.| 32| [OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem)](#oh_avmemory_destroy) | Releases an OH_AVMemory instance.| 33 34## Function Description 35 36### OH_AVMemory_Create() 37 38``` 39OH_AVMemory *OH_AVMemory_Create(int32_t size) 40``` 41 42**Description** 43 44Creates an OH_AVMemory instance. 45 46**System capability**: SystemCapability.Multimedia.Media.Core 47 48**Since**: 10 49 50**Deprecated from**: 11 51 52**Substitute**: [OH_AVBuffer_Create](capi-native-avbuffer-h.md#oh_avbuffer_create) 53 54 55**Parameters** 56 57| Name| Description| 58| -- | -- | 59| int32_t size | Size of the created memory, in bytes.| 60 61**Returns** 62 63| Type| Description| 64| -- | -- | 65| [OH_AVMemory](capi-core-oh-avmemory.md) * | Pointer to the OH_AVMemory instance created. If the operation fails, NULL is returned.<br>The instance must be released by calling **OH_AVMemory_Destroy** when it is no longer required.<br>The possible causes of an operation failure are as follows:<br>1. The value of **size** is less than or equal to **0**.<br>2. The OH_AVMemory instance fails to be created.<br>3. Memory allocation fails.| 66 67### OH_AVMemory_GetAddr() 68 69``` 70uint8_t *OH_AVMemory_GetAddr(struct OH_AVMemory *mem) 71``` 72 73**Description** 74 75Obtains the virtual memory address. 76 77**System capability**: SystemCapability.Multimedia.Media.Core 78 79**Since**: 9 80 81**Deprecated from**: 11 82 83**Substitute**: [OH_AVBuffer_GetAddr](capi-native-avbuffer-h.md#oh_avbuffer_getaddr) 84 85 86**Parameters** 87 88| Name| Description| 89| -- | -- | 90| [struct OH_AVMemory](capi-core-oh-avmemory.md) *mem | Pointer to an OH_AVMemory instance.| 91 92**Returns** 93 94| Type| Description| 95| -- | -- | 96| uint8_t * | Pointer to the virtual memory address. If the memory is invalid, NULL is returned.<br>The possible causes of an operation failure are as follows:<br>1. The value of **mem** is nullptr.<br>2. The value of **mem** fails parameter structure verification.<br>3. The memory in the passed-in value of **mem** is nullptr.| 97 98### OH_AVMemory_GetSize() 99 100``` 101int32_t OH_AVMemory_GetSize(struct OH_AVMemory *mem) 102``` 103 104**Description** 105 106Obtains the memory length. 107 108**System capability**: SystemCapability.Multimedia.Media.Core 109 110**Since**: 9 111 112**Deprecated from**: 11 113 114**Substitute**: [OH_AVBuffer_GetCapacity](capi-native-avbuffer-h.md#oh_avbuffer_getcapacity) 115 116 117**Parameters** 118 119| Name| Description| 120| -- | -- | 121| [struct OH_AVMemory](capi-core-oh-avmemory.md) *mem | Pointer to an OH_AVMemory instance.| 122 123**Returns** 124 125| Type| Description| 126| -- | -- | 127| int32_t | Memory size. If the memory is invalid, **-1** is returned.<br>The possible causes of an operation failure are as follows:<br>1. The value of **mem** is nullptr.<br>2. The value of **mem** fails parameter structure verification.<br>3. The memory in the passed-in value of **mem** is nullptr.| 128 129### OH_AVMemory_Destroy() 130 131``` 132OH_AVErrCode OH_AVMemory_Destroy(struct OH_AVMemory *mem) 133``` 134 135**Description** 136 137Releases an OH_AVMemory instance. 138 139**System capability**: SystemCapability.Multimedia.Media.Core 140 141**Since**: 10 142 143**Deprecated from**: 11 144 145**Substitute**: [OH_AVBuffer_Destroy](capi-native-avbuffer-h.md#oh_avbuffer_destroy) 146 147 148**Parameters** 149 150| Name| Description| 151| -- | -- | 152| [struct OH_AVMemory](capi-core-oh-avmemory.md) *mem | Pointer to an OH_AVMemory instance.| 153 154**Returns** 155 156| Type| Description| 157| -- | -- | 158| [OH_AVErrCode](capi-native-averrors-h.md#oh_averrcode) | **AV_ERR_OK**: The release operation is successful.<br>**AV_ERR_INVALID_VAL**:<br>1. The value of **mem** is nullptr.<br>2. The value of **mem** fails parameter structure verification.<br>3. The value of **mem** is not created by the caller.| 159