harmony 鸿蒙media_asset_base_capi.h

  • 2025-06-12
  • 浏览 (4)

media_asset_base_capi.h

Overview

The media_asset_base_capi.h file declares the structs and enums for the media asset manager.

Library: libmedia_asset_manager.so

File to include:

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

Since: 12

Related module: MediaAssetManager

Summary

Structs

|Name|typedef Keyword|Description| |–|–|–| |MediaLibrary_RequestId|MediaLibrary_RequestId|Describes a request ID.
A value of this type is returned when a media asset is requested.
The request ID can be used to cancel a request.| |OH_MediaAssetManager|OH_MediaAssetManager|Describes the media asset manager.
You can use this struct to create a media asset manager instance.
If the creation fails, a null pointer is returned.| |OH_MediaAssetChangeRequest|OH_MediaAssetChangeRequest|Describes a media asset change request.
This struct provides the capability of handling media asset change requests.| |OH_MovingPhoto|OH_MovingPhoto|Describes a moving photo.
This struct provides the capability of obtaining information about a moving photo.| |OH_MediaAsset|OH_MediaAsset|Describes a media asset.
This struct provides the capability of encapsulating media file attributes.| |MediaLibrary_RequestOptions|MediaLibrary_RequestOptions|Defines how media assets are requested and processed.
You can use this struct to set options related to the media asset quality, delivery mode, and more.|

Enums

|Name|typedef Keyword|Description| |–|–|–| |MediaLibrary_ErrorCode|MediaLibrary_ErrorCode|Enumerates the error codes of the media library.| |MediaLibrary_DeliveryMode|MediaLibrary_DeliveryMode|Enumerates the delivery modes of the requested media asset.| |MediaLibrary_MediaType|MediaLibrary_MediaType|Enumerates the media asset types.| |MediaLibrary_MediaSubType|MediaLibrary_MediaSubType|Enumerates the media asset subtypes.| |MediaLibrary_ResourceType|MediaLibrary_ResourceType|Enumerates the media library resource types.| |MediaLibrary_ImageFileType|MediaLibrary_ImageFileType|Enumerates the image file types.| |MediaLibrary_MediaQuality|MediaLibrary_MediaQuality|Enumerates the media resource quality, which varies with the specified delivery mode for the requested media asset.| |MediaLibrary_MediaContentType|MediaLibrary_MediaContentType|Enumerates the media content types.|

Functions

|Name|typedef Keyword|Description| |–|–|–| |typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)|OH_MediaLibrary_OnDataPrepared|Called when the requested media asset is ready.| |typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_ImageSourceNative* imageSourceNative)|OH_MediaLibrary_OnImageDataPrepared|Called when the requested image is ready.| |typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_MovingPhoto* movingPhoto)|OH_MediaLibrary_OnMovingPhotoDataPrepared|Called when the requested moving photo is ready.|

Variables

|Name|Description| |–|–| |static const int32_t UUID_STR_MAX_LENGTH = 37|Maximum length of a request ID.
Since: 12|

Enum Description

MediaLibrary_ErrorCode

enum MediaLibrary_ErrorCode

Description

Enumerates the error codes of the media library.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_OK = 0|Operation success.| |MEDIA_LIBRARY_PERMISSION_DENIED = 201|No access permission.| |MEDIA_LIBRARY_PARAMETER_ERROR = 401|A mandatory parameter is not specified, the parameter type is incorrect, or parameter verification failed.| |MEDIA_LIBRARY_NO_SUCH_FILE = 23800101|The file does not exist.| |MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102|Invalid display name.| |MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103|Invalid asset URI.| |MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104|Invalid PhotoKey.| |MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201|Unsupported operation.| |MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301|Internal system error. Retry the operation and check logs. Possible causes:
1. The database is corrupted.
2. The file system is abnormal.
3. The IPC request timed out.|

MediaLibrary_DeliveryMode

enum MediaLibrary_DeliveryMode

Description

Enumerates the delivery modes of the requested media asset.

MEDIA_LIBRARY_FAST_MODE: Deliver the media asset available without considering its quality.

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.

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.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_FAST_MODE = 0|Fast mode.| |MEDIA_LIBRARY_HIGH_QUALITY_MODE = 1|High-quality mode.| |MEDIA_LIBRARY_BALANCED_MODE = 2|Balance mode.|

MediaLibrary_MediaType

enum MediaLibrary_MediaType

Description

Enumerates the media asset types.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_IMAGE = 1|Image.| |MEDIA_LIBRARY_VIDEO = 2|Video.|

MediaLibrary_MediaSubType

enum MediaLibrary_MediaSubType

Description

Enumerates the media asset subtypes.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_DEFAULT = 0|Photo, which is the default type.| |MEDIA_LIBRARY_MOVING_PHOTO = 3|Moving photo.| |MEDIA_LIBRARY_BURST = 4|Burst photo.|

MediaLibrary_ResourceType

enum MediaLibrary_ResourceType

Description

Enumerates the media library resource types.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_IMAGE_RESOURCE = 1|Image resource.| |MEDIA_LIBRARY_VIDEO_RESOURCE = 2|Video resource.|

MediaLibrary_ImageFileType

enum MediaLibrary_ImageFileType

Description

Enumerates the image file types.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_IMAGE_JPEG = 1|JPEG.|

MediaLibrary_MediaQuality

enum MediaLibrary_MediaQuality

Description

Enumerates the media resource quality,

which varies with the specified delivery mode for the requested media asset.

MEDIA_LIBRARY_FAST_MODE: Deliver the media asset available without considering its quality.

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.

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.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_QUALITY_FAST = 1|Media asset available without considering its quality.| |MEDIA_LIBRARY_QUALITY_FULL = 2|High-quality media asset.|

MediaLibrary_MediaContentType

enum MediaLibrary_MediaContentType

Description

Enumerates the media content types.

Since: 12

|Enum|Description| |–|–| |MEDIA_LIBRARY_COMPRESSED = 1|Compressed media content.| |MEDIA_LIBRARY_PICTURE_OBJECT = 2|Image object.|

Function Description

OH_MediaLibrary_OnDataPrepared()

typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)

Description

Called when the requested media asset is ready.

Since: 12

Parameters

|Parameter|Description| |–|–| |int32_t result|Request processing result.| | MediaLibrary_RequestId requestId|Request ID.|

OH_MediaLibrary_OnImageDataPrepared()

typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_ImageSourceNative* imageSourceNative)

Description

Called when the requested image is ready.

Since: 12

Parameters

|Parameter|Description| |–|–| |MediaLibrary_ErrorCode result|Request processing result, which is specified by MediaLibrary_ErrorCode.| |MediaLibrary_RequestId requestId|Request ID, which is specified by MediaLibrary_RequestId.| | MediaLibrary_MediaQuality mediaQuality|Quality of the requested source, which is specified by MediaLibrary_MediaQuality.| | MediaLibrary_MediaContentType type|Media content type of the requested source, which is specified by MediaLibrary_MediaContentType.| |OH_ImageSourceNative* imageSourceNative|Pointer to the OH_ImageSourceNative instance obtained when the requested image is ready.|

OH_MediaLibrary_OnMovingPhotoDataPrepared()

typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result,MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,OH_MovingPhoto* movingPhoto)

Description

Called when the requested moving photo is ready.

Since: 13

Parameters

|Parameter|Description| |–|–| |MediaLibrary_ErrorCode result|Request processing result, which is specified by MediaLibrary_ErrorCode.| |MediaLibrary_RequestId requestId|Request ID, which is specified by MediaLibrary_RequestId.| | MediaLibrary_MediaQuality mediaQuality|Quality of the requested resource, which is specified by MediaLibrary_MediaQuality.| | MediaLibrary_MediaContentType type|Media content type of the requested resource, which is specified by MediaLibrary_MediaContentType.| |OH_MovingPhoto* movingPhoto|Pointer to the OH_MovingPhoto instance obtained when the requested moving photo is ready.|

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Media Library Kit (Media File Management Service)

harmony 鸿蒙media_access_helper_capi.h

harmony 鸿蒙media_asset_capi.h

harmony 鸿蒙media_asset_change_request_capi.h

harmony 鸿蒙media_asset_manager_capi.h

harmony 鸿蒙MediaAssetManager

harmony 鸿蒙MediaLibrary_RequestId

harmony 鸿蒙MediaLibrary_RequestOptions

harmony 鸿蒙moving_photo_capi.h

harmony 鸿蒙OH_MediaAsset

0  赞