• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# media_asset_base_capi.h
2
3## Overview
4
5The file declares the structs and enums for the media asset manager.
6
7**Library**: libmedia_asset_manager.so
8
9**File to include**: <multimedia/media_library/media_asset_base_capi.h>
10
11**System capability**: SystemCapability.FileManagement.PhotoAccessHelper.Core
12
13**Since**: 12
14
15**Related module**: [MediaAssetManager](capi-mediaassetmanager.md)
16
17## Summary
18
19### Structs
20
21| Name| typedef Keyword| Description|
22| -- | -- | -- |
23| [MediaLibrary_RequestId](capi-mediaassetmanager-medialibrary-requestid.md) | MediaLibrary_RequestId | Describes a request ID.<br>A value of this type is returned when a media asset is requested.<br>The request ID can be used to cancel a request.|
24| [OH_MediaAssetManager](capi-mediaassetmanager-oh-mediaassetmanager.md) | OH_MediaAssetManager | Describes the media asset manager.<br>You can use this struct to create a media asset manager instance.<br>If the creation fails, nullptr is returned.|
25| [OH_MediaAssetChangeRequest](capi-mediaassetmanager-oh-mediaassetchangerequest.md) | OH_MediaAssetChangeRequest | Describes a media asset change request.<br>This struct provides the capability of handling media asset change requests.|
26| [OH_MovingPhoto](capi-mediaassetmanager-oh-movingphoto.md) | OH_MovingPhoto | Describes a moving photo.<br>This struct provides the capability of obtaining information about a moving photo.|
27| [OH_MediaAsset](capi-mediaassetmanager-oh-mediaasset.md) | OH_MediaAsset | Describes a media asset.<br>This struct provides the capability of encapsulating media file attributes.|
28| [MediaLibrary_RequestOptions](capi-mediaassetmanager-medialibrary-requestoptions.md) | MediaLibrary_RequestOptions | Defines how media assets are requested and processed.<br>You can use this struct to set options related to the media asset quality, delivery mode, and more.|
29
30### Enums
31
32| Name| typedef Keyword| Description|
33| -- | -- | -- |
34| [MediaLibrary_ErrorCode](#medialibrary_errorcode) | MediaLibrary_ErrorCode | Enumerates the error codes of the media library.|
35| [MediaLibrary_DeliveryMode](#medialibrary_deliverymode) | MediaLibrary_DeliveryMode | Enumerates the delivery modes of the requested media asset.|
36| [MediaLibrary_MediaType](#medialibrary_mediatype) | MediaLibrary_MediaType | Enumerates the media asset types.|
37| [MediaLibrary_MediaSubType](#medialibrary_mediasubtype) | MediaLibrary_MediaSubType | Enumerates the media asset subtypes.|
38| [MediaLibrary_ResourceType](#medialibrary_resourcetype) | MediaLibrary_ResourceType | Enumerates the media library resource types.|
39| [MediaLibrary_ImageFileType](#medialibrary_imagefiletype) | MediaLibrary_ImageFileType | Enumerates the image file types.|
40| [MediaLibrary_MediaQuality](#medialibrary_mediaquality) | MediaLibrary_MediaQuality | Enumerates the media resource quality, which varies with the specified delivery mode for the requested media asset.|
41| [MediaLibrary_MediaContentType](#medialibrary_mediacontenttype) | MediaLibrary_MediaContentType | Enumerates the media content types.|
42
43### Functions
44
45| Name| typedef Keyword| Description|
46| -- | -- | -- |
47| [typedef void (\*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)](#oh_medialibrary_ondataprepared) | OH_MediaLibrary_OnDataPrepared | Called when the requested media asset is ready.|
48| [typedef void (\*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_ImageSourceNative* imageSourceNative)](#oh_medialibrary_onimagedataprepared) | OH_MediaLibrary_OnImageDataPrepared | Called when the requested image is ready.|
49| [typedef void (\*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_MovingPhoto* movingPhoto)](#oh_medialibrary_onmovingphotodataprepared) | OH_MediaLibrary_OnMovingPhotoDataPrepared | Called when the requested moving photo is ready.|
50
51### Variables
52
53| Name| Description|
54| -- | -- |
55| static const int32_t UUID_STR_MAX_LENGTH = 37 | Maximum length of a request ID.  <br>**Since**: 12|
56
57## Enum Description
58
59### MediaLibrary_ErrorCode
60
61```
62enum MediaLibrary_ErrorCode
63```
64
65**Description**
66
67Enumerates the error codes of the media library.
68
69**Since**: 12
70
71| Enum| Description|
72| -- | -- |
73| MEDIA_LIBRARY_OK = 0 | Operation success.|
74| MEDIA_LIBRARY_PERMISSION_DENIED = 201 | No access permission.|
75| MEDIA_LIBRARY_PARAMETER_ERROR = 401 | A mandatory parameter is not specified, the parameter type is incorrect, or parameter verification failed.|
76| MEDIA_LIBRARY_NO_SUCH_FILE = 23800101 | The file does not exist.|
77| MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102 | Invalid display name.|
78| MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103 | Invalid asset URI.|
79| MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104 | Invalid PhotoKey.|
80| MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201 | Unsupported operation.|
81| MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301 | Internal system error. Retry the operation and check logs. Possible causes:<br>1. The database is corrupted.<br>2. The file system is abnormal.<br>3. The IPC request timed out.|
82
83### MediaLibrary_DeliveryMode
84
85```
86enum MediaLibrary_DeliveryMode
87```
88
89**Description**
90
91Enumerates the delivery modes of the requested media asset.
92
93**MEDIA_LIBRARY_FAST_MODE**: Deliver the media asset available without considering its quality.
94
95**MEDIA_LIBRARY_HIGH_QUALITY_MODE**: Deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
96
97**MEDIA_LIBRARY_BALANCED_MODE**: Return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
98
99**Since**: 12
100
101| Enum| Description|
102| -- | -- |
103| MEDIA_LIBRARY_FAST_MODE = 0 | Fast mode.|
104| MEDIA_LIBRARY_HIGH_QUALITY_MODE = 1 | High-quality mode.|
105| MEDIA_LIBRARY_BALANCED_MODE = 2 | Balance mode.|
106
107### MediaLibrary_MediaType
108
109```
110enum MediaLibrary_MediaType
111```
112
113**Description**
114
115Enumerates the media asset types.
116
117**Since**: 12
118
119| Enum| Description|
120| -- | -- |
121| MEDIA_LIBRARY_IMAGE = 1 | Image.|
122| MEDIA_LIBRARY_VIDEO = 2 | Video.|
123
124### MediaLibrary_MediaSubType
125
126```
127enum MediaLibrary_MediaSubType
128```
129
130**Description**
131
132Enumerates the media asset subtypes.
133
134**Since**: 12
135
136| Enum| Description|
137| -- | -- |
138| MEDIA_LIBRARY_DEFAULT = 0 | Photo, which is the default type.|
139| MEDIA_LIBRARY_MOVING_PHOTO = 3 | Moving photo.|
140| MEDIA_LIBRARY_BURST = 4 | Burst photo.|
141
142### MediaLibrary_ResourceType
143
144```
145enum MediaLibrary_ResourceType
146```
147
148**Description**
149
150Enumerates the media library resource types.
151
152**Since**: 12
153
154| Enum| Description|
155| -- | -- |
156| MEDIA_LIBRARY_IMAGE_RESOURCE = 1 | Image resource.|
157| MEDIA_LIBRARY_VIDEO_RESOURCE = 2 | Video resource.|
158
159### MediaLibrary_ImageFileType
160
161```
162enum MediaLibrary_ImageFileType
163```
164
165**Description**
166
167Enumerates the image file types.
168
169**Since**: 12
170
171| Enum| Description|
172| -- | -- |
173| MEDIA_LIBRARY_IMAGE_JPEG = 1 | JPEG.|
174| MEDIA_LIBRARY_FILE_VIDEO = 3 | MPEG type.<br>**Since**: 19|
175
176### MediaLibrary_MediaQuality
177
178```
179enum MediaLibrary_MediaQuality
180```
181
182**Description**
183
184Enumerates the media resource quality,
185
186which varies with the specified delivery mode for the requested media asset.
187
188**MEDIA_LIBRARY_FAST_MODE**: Deliver the media asset available without considering its quality.
189
190**MEDIA_LIBRARY_HIGH_QUALITY_MODE**: Deliver a media asset with high quality. If there is no high-quality asset available, trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
191
192**MEDIA_LIBRARY_BALANCED_MODE**: Return the high-quality asset if there is any. Otherwise, return a low-quality asset first and trigger the process for creating a high-quality asset. Then, return the high-quality asset that is successfully created.
193
194**Since**: 12
195
196| Enum| Description|
197| -- | -- |
198| MEDIA_LIBRARY_QUALITY_FAST = 1 | Media asset available without considering its quality.|
199| MEDIA_LIBRARY_QUALITY_FULL = 2 | High-quality media asset.|
200
201### MediaLibrary_MediaContentType
202
203```
204enum MediaLibrary_MediaContentType
205```
206
207**Description**
208
209Enumerates the media content types.
210
211**Since**: 12
212
213| Enum| Description|
214| -- | -- |
215| MEDIA_LIBRARY_COMPRESSED = 1 | Compressed media content.|
216| MEDIA_LIBRARY_PICTURE_OBJECT = 2 | Image object.|
217
218
219## Function Description
220
221### OH_MediaLibrary_OnDataPrepared()
222
223```
224typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)
225```
226
227**Description**
228
229Called when the requested media asset is ready.
230
231**Since**: 12
232
233
234**Parameters**
235
236| Parameter| Description|
237| -- | -- |
238| int32_t result | Request processing result.|
239|  MediaLibrary_RequestId requestId | Request ID.|
240
241### OH_MediaLibrary_OnImageDataPrepared()
242
243```
244typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_ImageSourceNative* imageSourceNative)
245```
246
247**Description**
248
249Called when the requested image is ready.
250
251**Since**: 12
252
253
254**Parameters**
255
256| Parameter| Description|
257| -- | -- |
258| [MediaLibrary_ErrorCode](#medialibrary_errorcode) result | Request processing result, which is specified by [MediaLibrary_ErrorCode](#medialibrary_errorcode).|
259| [MediaLibrary_RequestId](capi-mediaassetmanager-medialibrary-requestid.md) requestId | Request ID, which is specified by [MediaLibrary_RequestId](capi-mediaassetmanager-medialibrary-requestid.md).|
260|  [MediaLibrary_MediaQuality](#medialibrary_mediaquality) mediaQuality | Quality of the requested source, which is specified by [MediaLibrary_MediaQuality](#medialibrary_mediaquality).|
261|  [MediaLibrary_MediaContentType](capi-media-asset-base-capi-h.md#medialibrary_mediacontenttype) type | Media content type of the requested source, which is specified by [MediaLibrary_MediaContentType](capi-media-asset-base-capi-h.md#medialibrary_mediacontenttype).|
262| [OH_ImageSourceNative](../apis-image-kit/capi-image-nativemodule-oh-imagesourcenative.md)* imageSourceNative | Pointer to the [OH_ImageSourceNative](../apis-image-kit/capi-image-nativemodule-oh-imagesourcenative.md) instance obtained when the requested image is ready.|
263
264### OH_MediaLibrary_OnMovingPhotoDataPrepared()
265
266```
267typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_MovingPhoto* movingPhoto)
268```
269
270**Description**
271
272Called when the requested moving photo is ready.
273
274**Since**: 13
275
276
277**Parameters**
278
279| Parameter| Description|
280| -- | -- |
281| [MediaLibrary_ErrorCode](#medialibrary_errorcode) result | Request processing result, which is specified by [MediaLibrary_ErrorCode](capi-media-asset-base-capi-h.md#medialibrary_errorcode).|
282| [MediaLibrary_RequestId](capi-mediaassetmanager-medialibrary-requestid.md) requestId | Request ID, which is specified by [MediaLibrary_RequestId](capi-mediaassetmanager-medialibrary-requestid.md).|
283|  [MediaLibrary_MediaQuality](#medialibrary_mediaquality) mediaQuality | Quality of the requested resource, which is specified by [MediaLibrary_MediaQuality](#medialibrary_mediaquality).|
284|  [MediaLibrary_MediaContentType](capi-media-asset-base-capi-h.md#medialibrary_mediacontenttype) type | Media content type of the requested resource, which is specified by [MediaLibrary_MediaContentType](capi-media-asset-base-capi-h.md#medialibrary_mediacontenttype).|
285| [OH_MovingPhoto](capi-mediaassetmanager-oh-movingphoto.md)* movingPhoto | Pointer to the [OH_MovingPhoto](capi-mediaassetmanager-oh-movingphoto.md) instance obtained when the requested moving photo is ready.|
286