1# avmetadata_extractor.h 2<!--Kit: Media Kit--> 3<!--Subsystem: Multimedia--> 4<!--Owner: @wang-haizhou6--> 5<!--Designer: @HmQQQ--> 6<!--Tester: @xchaosioda--> 7<!--Adviser: @zengyawen--> 8 9## Overview 10 11The file declares the AVMetadataExtractor APIs. You can use the APIs to obtain metadata from media assets. 12 13**File to include**: <multimedia/player_framework/avmetadata_extractor.h> 14 15**Library**: libavmetadata_extractor.so 16 17**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 18 19**Since**: 18 20 21**Related module**: [AVMetadataExtractor](capi-avmetadataextractor.md) 22 23## Summary 24 25### Structs 26 27| Name| typedef Keyword| Description| 28| -- | -- | -- | 29| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md) | OH_AVMetadataExtractor | Describes the OH_AVMetadataExtractor.| 30 31### Functions 32 33| Name| Description| 34| -- | -- | 35| [OH_AVMetadataExtractor* OH_AVMetadataExtractor_Create(void)](#oh_avmetadataextractor_create) | Creates an OH_AVMetadataExtractor instance.| 36| [OH_AVErrCode OH_AVMetadataExtractor_SetFDSource(OH_AVMetadataExtractor* extractor, int32_t fd, int64_t offset, int64_t size)](#oh_avmetadataextractor_setfdsource) | Sets a data source based on the media file descriptor.| 37| [OH_AVErrCode OH_AVMetadataExtractor_FetchMetadata(OH_AVMetadataExtractor* extractor, OH_AVFormat* avMetadata)](#oh_avmetadataextractor_fetchmetadata) | Obtains metadata from a media asset. This function must be called after [OH_AVMetadataExtractor_SetFDSource](#oh_avmetadataextractor_setfdsource).| 38| [OH_AVErrCode OH_AVMetadataExtractor_FetchAlbumCover(OH_AVMetadataExtractor* extractor, OH_PixelmapNative** pixelMap)](#oh_avmetadataextractor_fetchalbumcover) | Obtains the cover of an audio album. This function must be called after [OH_AVMetadataExtractor_SetFDSource](#oh_avmetadataextractor_setfdsource).| 39| [OH_AVErrCode OH_AVMetadataExtractor_Release(OH_AVMetadataExtractor* extractor)](#oh_avmetadataextractor_release) | Releases the resources used by the OH_AVMetadataExtractor instance and destroys the instance.| 40 41## Function Description 42 43### OH_AVMetadataExtractor_Create() 44 45``` 46OH_AVMetadataExtractor* OH_AVMetadataExtractor_Create(void) 47``` 48 49**Description** 50 51Creates an OH_AVMetadataExtractor instance. 52 53**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 54 55**Since**: 18 56 57**Return value** 58 59| Type| Description| 60| -- | -- | 61| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md)* | Pointer to the OH_AVMetadataExtractor instance created if the operation is successful; nullptr otherwise.<br>Possible cause of failures: **HstEngineFactory::CreateAVMetadataHelperEngine** fails to run.| 62 63### OH_AVMetadataExtractor_SetFDSource() 64 65``` 66OH_AVErrCode OH_AVMetadataExtractor_SetFDSource(OH_AVMetadataExtractor* extractor,int32_t fd, int64_t offset, int64_t size) 67``` 68 69**Description** 70 71Sets a data source based on the media file descriptor. 72 73**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 74 75**Since**: 18 76 77 78**Parameters** 79 80| Parameter| Description| 81| -- | -- | 82| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md)* extractor | Pointer to the OH_AVMetadataExtractor instance.| 83| int32_t fd | File descriptor of the media source.| 84| int64_t offset | Offset of the media source in the file descriptor.| 85| int64_t size | Size of the media source.| 86 87**Return value** 88 89| Type| Description| 90| -- | -- | 91| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | **AV_ERR_OK**: The operation is successful.<br>**AV_ERR_INVALID_VAL**: The input parameter **extractor** is nullptr or a parameter is invalid.<br>**AV_ERR_OPERATE_NOT_PERMIT**: The operation is forbidden.<br>**AV_ERR_NO_MEMORY**: Internal memory allocation failed.| 92 93### OH_AVMetadataExtractor_FetchMetadata() 94 95``` 96OH_AVErrCode OH_AVMetadataExtractor_FetchMetadata(OH_AVMetadataExtractor* extractor, OH_AVFormat* avMetadata) 97``` 98 99**Description** 100 101Obtains metadata from a media asset. 102 103This function must be called after [OH_AVMetadataExtractor_SetFDSource](#oh_avmetadataextractor_setfdsource). 104 105**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 106 107**Since**: 18 108 109 110**Parameters** 111 112| Parameter| Description| 113| -- | -- | 114| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md)* extractor | Pointer to the OH_AVMetadataExtractor instance.| 115| [OH_AVFormat](../apis-avcodec-kit/_core.md#oh_avformat)* avMetadata | Pointer to the OH_AVFormat instance, which contains the obtained metadata.| 116 117**Return value** 118 119| Type| Description| 120| -- | -- | 121| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | **AV_ERR_OK**: The operation is successful.<br>**AV_ERR_INVALID_VAL**: The input parameter **extractor** is nullptr or a parameter is invalid.<br>**AV_ERR_OPERATE_NOT_PERMIT**: The operation is forbidden.<br>**AV_ERR_UNSUPPORTED_FORMAT**: The format is not supported.<br>**AV_ERR_NO_MEMORY**: Internal memory allocation failed.| 122 123### OH_AVMetadataExtractor_FetchAlbumCover() 124 125``` 126OH_AVErrCode OH_AVMetadataExtractor_FetchAlbumCover(OH_AVMetadataExtractor* extractor, OH_PixelmapNative** pixelMap) 127``` 128 129**Description** 130 131Obtains the cover of an audio album. 132 133This function must be called after [OH_AVMetadataExtractor_SetFDSource](#oh_avmetadataextractor_setfdsource). 134 135**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 136 137**Since**: 18 138 139 140**Parameters** 141 142| Parameter| Description| 143| -- | -- | 144| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md)* extractor | Pointer to the OH_AVMetadataExtractor instance.| 145| [OH_PixelmapNative](../apis-image-kit/capi-image-nativemodule-oh-pixelmapnative.md)** pixelMap | Double pointer to the album cover obtained.| 146 147**Return value** 148 149| Type| Description| 150| -- | -- | 151| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | **AV_ERR_OK**: The operation is successful.<br>**AV_ERR_INVALID_VAL**: The input parameter **extractor** is nullptr or a parameter is invalid.<br>**AV_ERR_OPERATE_NOT_PERMIT**: The operation is forbidden.<br>**AV_ERR_UNSUPPORTED_FORMAT**: The format is not supported.<br>**AV_ERR_NO_MEMORY**: Internal memory allocation failed.| 152 153### OH_AVMetadataExtractor_Release() 154 155``` 156OH_AVErrCode OH_AVMetadataExtractor_Release(OH_AVMetadataExtractor* extractor) 157``` 158 159**Description** 160 161Releases the resources used by the OH_AVMetadataExtractor instance and destroys the instance. 162 163**System capability**: SystemCapability.Multimedia.Media.AVMetadataExtractor 164 165**Since**: 18 166 167 168**Parameters** 169 170| Parameter| Description| 171| -- | -- | 172| [OH_AVMetadataExtractor](capi-avmetadataextractor-oh-avmetadataextractor.md)* extractor | Pointer to the OH_AVMetadataExtractor instance.| 173 174**Return value** 175 176| Type| Description| 177| -- | -- | 178| [OH_AVErrCode](../apis-avcodec-kit/_core.md#oh_averrcode-1) | **AV_ERR_OK**: The operation is successful.<br>**AV_ERR_INVALID_VAL**: The input parameter **extractor** is nullptr or a parameter is invalid.| 179