openharmony 鸿蒙 capi-media-asset-base-capi-h

2025-06-12 浏览 (1)

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: <multimedia/media_library/media_asset_base_capi.h>

System capability: SystemCapability.FileManagement.PhotoAccessHelper.Core

Since: 12

Related module: MediaAssetManager

Summary

Structs

Nametypedef KeywordDescription
MediaLibrary_RequestIdMediaLibrary_RequestIdDescribes 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_MediaAssetManagerOH_MediaAssetManagerDescribes 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_MediaAssetChangeRequestOH_MediaAssetChangeRequestDescribes a media asset change request.
This struct provides the capability of handling media asset change requests.
OH_MovingPhotoOH_MovingPhotoDescribes a moving photo.
This struct provides the capability of obtaining information about a moving photo.
OH_MediaAssetOH_MediaAssetDescribes a media asset.
This struct provides the capability of encapsulating media file attributes.
MediaLibrary_RequestOptionsMediaLibrary_RequestOptionsDefines 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

Nametypedef KeywordDescription
MediaLibrary_ErrorCodeMediaLibrary_ErrorCodeEnumerates the error codes of the media library.
MediaLibrary_DeliveryModeMediaLibrary_DeliveryModeEnumerates the delivery modes of the requested media asset.
MediaLibrary_MediaTypeMediaLibrary_MediaTypeEnumerates the media asset types.
MediaLibrary_MediaSubTypeMediaLibrary_MediaSubTypeEnumerates the media asset subtypes.
MediaLibrary_ResourceTypeMediaLibrary_ResourceTypeEnumerates the media library resource types.
MediaLibrary_ImageFileTypeMediaLibrary_ImageFileTypeEnumerates the image file types.
MediaLibrary_MediaQualityMediaLibrary_MediaQualityEnumerates the media resource quality, which varies with the specified delivery mode for the requested media asset.
MediaLibrary_MediaContentTypeMediaLibrary_MediaContentTypeEnumerates the media content types.

Functions

Nametypedef KeywordDescription
typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId)OH_MediaLibrary_OnDataPreparedCalled 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_OnImageDataPreparedCalled 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_OnMovingPhotoDataPreparedCalled when the requested moving photo is ready.

Variables

NameDescription
static const int32_t UUID_STR_MAX_LENGTH = 37Maximum 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

EnumDescription
MEDIA_LIBRARY_OK = 0Operation success.
MEDIA_LIBRARY_PERMISSION_DENIED = 201No access permission.
MEDIA_LIBRARY_PARAMETER_ERROR = 401A mandatory parameter is not specified, the parameter type is incorrect, or parameter verification failed.
MEDIA_LIBRARY_NO_SUCH_FILE = 23800101The file does not exist.
MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102Invalid display name.
MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103Invalid asset URI.
MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104Invalid PhotoKey.
MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201Unsupported operation.
MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301Internal 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

EnumDescription
MEDIA_LIBRARY_FAST_MODE = 0Fast mode.
MEDIA_LIBRARY_HIGH_QUALITY_MODE = 1High-quality mode.
MEDIA_LIBRARY_BALANCED_MODE = 2Balance mode.

MediaLibrary_MediaType

enum MediaLibrary_MediaType

Description

Enumerates the media asset types.

Since: 12

EnumDescription
MEDIA_LIBRARY_IMAGE = 1Image.
MEDIA_LIBRARY_VIDEO = 2Video.

MediaLibrary_MediaSubType

enum MediaLibrary_MediaSubType

Description

Enumerates the media asset subtypes.

Since: 12

EnumDescription
MEDIA_LIBRARY_DEFAULT = 0Photo, which is the default type.
MEDIA_LIBRARY_MOVING_PHOTO = 3Moving photo.
MEDIA_LIBRARY_BURST = 4Burst photo.

MediaLibrary_ResourceType

enum MediaLibrary_ResourceType

Description

Enumerates the media library resource types.

Since: 12

EnumDescription
MEDIA_LIBRARY_IMAGE_RESOURCE = 1Image resource.
MEDIA_LIBRARY_VIDEO_RESOURCE = 2Video resource.

MediaLibrary_ImageFileType

enum MediaLibrary_ImageFileType

Description

Enumerates the image file types.

Since: 12

EnumDescription
MEDIA_LIBRARY_IMAGE_JPEG = 1JPEG.

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

EnumDescription
MEDIA_LIBRARY_QUALITY_FAST = 1Media asset available without considering its quality.
MEDIA_LIBRARY_QUALITY_FULL = 2High-quality media asset.

MediaLibrary_MediaContentType

enum MediaLibrary_MediaContentType

Description

Enumerates the media content types.

Since: 12

EnumDescription
MEDIA_LIBRARY_COMPRESSED = 1Compressed media content.
MEDIA_LIBRARY_PICTURE_OBJECT = 2Image 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

ParameterDescription
int32_t resultRequest processing result.
MediaLibrary_RequestId requestIdRequest 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

ParameterDescription
MediaLibrary_ErrorCode resultRequest processing result, which is specified by MediaLibrary_ErrorCode.
MediaLibrary_RequestId requestIdRequest ID, which is specified by MediaLibrary_RequestId.
MediaLibrary_MediaQuality mediaQualityQuality of the requested source, which is specified by MediaLibrary_MediaQuality.
MediaLibrary_MediaContentType typeMedia content type of the requested source, which is specified by MediaLibrary_MediaContentType.
OH_ImageSourceNative* imageSourceNativePointer 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

ParameterDescription
MediaLibrary_ErrorCode resultRequest processing result, which is specified by MediaLibrary_ErrorCode.
MediaLibrary_RequestId requestIdRequest ID, which is specified by MediaLibrary_RequestId.
MediaLibrary_MediaQuality mediaQualityQuality of the requested resource, which is specified by MediaLibrary_MediaQuality.
MediaLibrary_MediaContentType typeMedia content type of the requested resource, which is specified by MediaLibrary_MediaContentType.
OH_MovingPhoto* movingPhotoPointer 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

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ESGI2e