harmony 鸿蒙Core

2025-06-12 浏览 (1)

Core

Overview

The Core module provides the basic backbone capabilities for the media system, including functions related to the memory, error code, and media data struct.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Summary

Files

NameDescription
media_types.hDeclares the common media types.
native_audio_channel_layout.hDeclares the functions related to the speaker layout during recording and playback.
native_avbuffer.hDeclares the functions of the media struct AVBuffer.
native_avbuffer_info.hDeclares the attribute definition of the media struct AVBuffer.
native_averrors.hDeclares the error codes used by the media system.
native_avformat.hDeclares the functions and enums related to OH_AVFormat.
native_avmemory.hDeclares the attribute definition of the media struct AVMemory.

Structs

NameDescription
struct OH_AVCodecBufferAttrDescribes the description information about the buffer of an OH_AVCodec instance.

Types

NameDescription
typedef enum OH_Core_HdrType OH_Core_HdrTypeDefines an enum for the HDR types.
typedef enum OH_AudioChannelSet OH_AudioChannelSetDefines an enum for the audio channel sets.
typedef enum OH_AmbAttributeSet OH_AmbAttributeSetDefines an enum for the Hi-Fi stereo reverberation settings.
typedef enum OH_AudioChannelLayout OH_AudioChannelLayoutDefines an enum for the audio channel layouts.
typedef struct OH_AVBuffer OH_AVBufferDefines a struct that describes a native object for the media memory interface.
typedef struct OH_NativeBuffer OH_NativeBufferDefines a struct that describes a native object for the graphics memory interface.
typedef enum OH_AVCodecBufferFlags OH_AVCodecBufferFlagsDefines an enum for the flags for the buffer of an OH_AVCodec instance.
typedef struct OH_AVCodecBufferAttr OH_AVCodecBufferAttrDefines the description information about the buffer of an OH_AVCodec instance.
typedef enum OH_AVErrCode OH_AVErrCodeDefines an enum for the error codes used by the media system.
typedef struct OH_AVFormat OH_AVFormatDefines a struct for a native object for the OH_AVFormat interface.
typedef enum OH_AVPixelFormat OH_AVPixelFormatDefines an enum for the video pixel formats.
typedef struct OH_AVMemory OH_AVMemoryDefines a struct that describes a native object for the audio and video memory interface.

Enums

NameDescription
OH_Core_HdrType {
OH_CORE_HDR_TYPE_NONE = 0,
OH_CORE_HDR_TYPE_VIVID = 1 }
Enumerates the HDR types.
OH_AudioChannelSet {
CH_SET_FRONT_LEFT = 1ULL << 0U,
CH_SET_FRONT_RIGHT = 1ULL << 1U,
CH_SET_FRONT_CENTER = 1ULL << 2U,
CH_SET_LOW_FREQUENCY = 1ULL << 3U,
CH_SET_BACK_LEFT = 1ULL << 4U,
CH_SET_BACK_RIGHT = 1ULL << 5U,
CH_SET_FRONT_LEFT_OF_CENTER = 1ULL << 6U,
CH_SET_FRONT_RIGHT_OF_CENTER = 1ULL << 7U,
CH_SET_BACK_CENTER = 1ULL << 8U,
CH_SET_SIDE_LEFT = 1ULL << 9U,
CH_SET_SIDE_RIGHT = 1ULL << 10U,
CH_SET_TOP_CENTER = 1ULL << 11U,
CH_SET_TOP_FRONT_LEFT = 1ULL << 12U,
CH_SET_TOP_FRONT_CENTER = 1ULL << 13U,
CH_SET_TOP_FRONT_RIGHT = 1ULL << 14U,
CH_SET_TOP_BACK_LEFT = 1ULL << 15U,
CH_SET_TOP_BACK_CENTER = 1ULL << 16U,
CH_SET_TOP_BACK_RIGHT = 1ULL << 17U,
CH_SET_STEREO_LEFT = 1ULL << 29U,
CH_SET_STEREO_RIGHT = 1ULL << 30U,
CH_SET_WIDE_LEFT = 1ULL << 31U,
CH_SET_WIDE_RIGHT = 1ULL << 32U,
CH_SET_SURROUND_DIRECT_LEFT = 1ULL << 33U,
CH_SET_SURROUND_DIRECT_RIGHT = 1ULL << 34U,
CH_SET_LOW_FREQUENCY_2 = 1ULL << 35U,
CH_SET_TOP_SIDE_LEFT = 1ULL << 36U,
CH_SET_TOP_SIDE_RIGHT = 1ULL << 37U,
CH_SET_BOTTOM_FRONT_CENTER = 1ULL << 38U,
CH_SET_BOTTOM_FRONT_LEFT = 1ULL << 39U,
CH_SET_BOTTOM_FRONT_RIGHT = 1ULL << 40U
}
Enumerates the audio channel sets.
OH_AmbAttributeSet {
AMB_ORD_1 = 1ULL << 0U,
AMB_ORD_2 = 2ULL << 0U,
AMB_ORD_3 = 3ULL << 0U,
AMB_COM_ACN = 0ULL << 8U,
AMB_COM_FUMA = 1ULL << 8U,
AMB_NOR_N3D = 0ULL << 12U,
AMB_NOR_SN3D = 1ULL << 12U,
AMB_MODE = 1ULL << 44U
}
Enumerates the Hi-Fi stereo reverberation settings.
OH_AudioChannelLayout {
CH_LAYOUT_UNKNOWN = 0ULL,
CH_LAYOUT_MONO = CH_SET_FRONT_CENTER,
CH_LAYOUT_STEREO = CH_SET_FRONT_LEFT |CH_SET_FRONT_RIGHT,
CH_LAYOUT_STEREO_DOWNMIX = CH_SET_STEREO_LEFT |CH_SET_STEREO_RIGHT,
CH_LAYOUT_2POINT1 = CH_LAYOUT_STEREO |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_3POINT0 = CH_LAYOUT_STEREO |CH_SET_BACK_CENTER,
CH_LAYOUT_SURROUND = CH_LAYOUT_STEREO |CH_SET_FRONT_CENTER,
CH_LAYOUT_3POINT1 = CH_LAYOUT_SURROUND |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_4POINT0 = CH_LAYOUT_SURROUND |CH_SET_BACK_CENTER,
CH_LAYOUT_QUAD_SIDE = CH_LAYOUT_STEREO |CH_SET_SIDE_LEFT |CH_SET_SIDE_RIGHT,
CH_LAYOUT_QUAD = CH_LAYOUT_STEREO |CH_SET_BACK_LEFT |CH_SET_BACK_RIGHT,
CH_LAYOUT_2POINT0POINT2 = CH_LAYOUT_STEREO |CH_SET_TOP_SIDE_LEFT |CH_SET_TOP_SIDE_RIGHT,
CH_LAYOUT_AMB_ORDER1_ACN_N3D = AMB_MODE |AMB_ORD_1 |AMB_COM_ACN |AMB_NOR_N3D, CH_LAYOUT_AMB_ORDER1_ACN_SN3D = AMB_MODE |AMB_ORD_1 |AMB_COM_ACN |AMB_NOR_SN3D,
CH_LAYOUT_AMB_ORDER1_FUMA = AMB_MODE |AMB_ORD_1 |AMB_COM_FUMA,
CH_LAYOUT_4POINT1 = CH_LAYOUT_4POINT0 |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_5POINT0 = CH_LAYOUT_SURROUND |CH_SET_SIDE_LEFT |CH_SET_SIDE_RIGHT,
CH_LAYOUT_5POINT0_BACK = CH_LAYOUT_SURROUND |CH_SET_BACK_LEFT |CH_SET_BACK_RIGHT,
CH_LAYOUT_2POINT1POINT2 = CH_LAYOUT_2POINT0POINT2 |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_3POINT0POINT2 = CH_LAYOUT_2POINT0POINT2 |CH_SET_FRONT_CENTER,
CH_LAYOUT_5POINT1 = CH_LAYOUT_5POINT0 |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_5POINT1_BACK = CH_LAYOUT_5POINT0_BACK |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_6POINT0 = CH_LAYOUT_5POINT0 |CH_SET_BACK_CENTER,
CH_LAYOUT_3POINT1POINT2 = CH_LAYOUT_3POINT1 |CH_SET_TOP_FRONT_LEFT |CH_SET_TOP_FRONT_RIGHT,
CH_LAYOUT_6POINT0_FRONT = CH_LAYOUT_QUAD_SIDE |CH_SET_FRONT_LEFT_OF_CENTER |CH_SET_FRONT_RIGHT_OF_CENTER,
CH_LAYOUT_HEXAGONAL = CH_LAYOUT_5POINT0_BACK |CH_SET_BACK_CENTER,
CH_LAYOUT_6POINT1 = CH_LAYOUT_5POINT1 |CH_SET_BACK_CENTER,
CH_LAYOUT_6POINT1_BACK = CH_LAYOUT_5POINT1_BACK |CH_SET_BACK_CENTER,
CH_LAYOUT_6POINT1_FRONT = CH_LAYOUT_6POINT0_FRONT |CH_SET_LOW_FREQUENCY,
CH_LAYOUT_7POINT0 = CH_LAYOUT_5POINT0 |CH_SET_BACK_LEFT |CH_SET_BACK_RIGHT,
CH_LAYOUT_7POINT0_FRONT = CH_LAYOUT_5POINT0 |CH_SET_FRONT_LEFT_OF_CENTER |CH_SET_FRONT_RIGHT_OF_CENTER,
CH_LAYOUT_7POINT1 = CH_LAYOUT_5POINT1 |CH_SET_BACK_LEFT |CH_SET_BACK_RIGHT,
CH_LAYOUT_OCTAGONAL = CH_LAYOUT_5POINT0 |CH_SET_BACK_LEFT |CH_SET_BACK_CENTER |CH_SET_BACK_RIGHT,
CH_LAYOUT_5POINT1POINT2 = CH_LAYOUT_5POINT1 |CH_SET_TOP_SIDE_LEFT |CH_SET_TOP_SIDE_RIGHT,
CH_LAYOUT_7POINT1_WIDE = CH_LAYOUT_5POINT1 |CH_SET_FRONT_LEFT_OF_CENTER |CH_SET_FRONT_RIGHT_OF_CENTER,
CH_LAYOUT_7POINT1_WIDE_BACK = CH_LAYOUT_5POINT1_BACK |CH_SET_FRONT_LEFT_OF_CENTER |CH_SET_FRONT_RIGHT_OF_CENTER,
CH_LAYOUT_AMB_ORDER2_ACN_N3D = AMB_MODE |AMB_ORD_2 |AMB_COM_ACN |AMB_NOR_N3D,
CH_LAYOUT_AMB_ORDER2_ACN_SN3D = AMB_MODE |AMB_ORD_2 |AMB_COM_ACN |AMB_NOR_SN3D,
CH_LAYOUT_AMB_ORDER2_FUMA = AMB_MODE |AMB_ORD_2 |AMB_COM_FUMA,
CH_LAYOUT_5POINT1POINT4,
CH_LAYOUT_7POINT1POINT2 = CH_LAYOUT_7POINT1 |CH_SET_TOP_SIDE_LEFT |CH_SET_TOP_SIDE_RIGHT,
CH_LAYOUT_7POINT1POINT4,
CH_LAYOUT_10POINT2,
CH_LAYOUT_9POINT1POINT4 = CH_LAYOUT_7POINT1POINT4 |CH_SET_WIDE_LEFT |CH_SET_WIDE_RIGHT,
CH_LAYOUT_9POINT1POINT6 = CH_LAYOUT_9POINT1POINT4 |CH_SET_TOP_SIDE_LEFT |CH_SET_TOP_SIDE_RIGHT,
CH_LAYOUT_HEXADECAGONAL,
CH_LAYOUT_AMB_ORDER3_ACN_N3D = AMB_MODE |AMB_ORD_3 |AMB_COM_ACN |AMB_NOR_N3D,
CH_LAYOUT_AMB_ORDER3_ACN_SN3D = AMB_MODE |AMB_ORD_3 |AMB_COM_ACN |AMB_NOR_SN3D,
CH_LAYOUT_AMB_ORDER3_FUMA = AMB_MODE |AMB_ORD_3 |AMB_COM_FUMA,
CH_LAYOUT_22POINT2
}
Enumerates the audio channel layouts.
OH_AVCodecBufferFlags {
AVCODEC_BUFFER_FLAGS_NONE = 0,
AVCODEC_BUFFER_FLAGS_EOS = 1 << 0, AVCODEC_BUFFER_FLAGS_SYNC_FRAME = 1 << 1, AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAME = 1 << 2,
AVCODEC_BUFFER_FLAGS_CODEC_DATA = 1 << 3,
AVCODEC_BUFFER_FLAGS_DISCARD = 1 << 4,
AVCODEC_BUFFER_FLAGS_DISPOSABLE = 1 << 5
}
Enumerates the flags for the buffer of an OH_AVCodec instance.
OH_AVErrCode {
AV_ERR_OK = 0,
AV_ERR_NO_MEMORY = 1,
AV_ERR_OPERATE_NOT_PERMIT = 2,
AV_ERR_INVALID_VAL = 3,
AV_ERR_IO = 4,
AV_ERR_TIMEOUT = 5,
AV_ERR_UNKNOWN = 6,
AV_ERR_SERVICE_DIED = 7,
AV_ERR_INVALID_STATE = 8,
AV_ERR_UNSUPPORT = 9,
AV_ERR_UNSUPPORTED_FORMAT = 11,
AV_ERR_EXTEND_START = 100,
AV_ERR_DRM_BASE = 200,
AV_ERR_DRM_DECRYPT_FAILED = 201,
AV_ERR_VIDEO_BASE = 300,
AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSION = 301
}
Enumerates the error codes used by the media system.
OH_AVPixelFormat {
AV_PIXEL_FORMAT_YUVI420 = 1,
AV_PIXEL_FORMAT_NV12 = 2,
AV_PIXEL_FORMAT_NV21 = 3,
AV_PIXEL_FORMAT_SURFACE_FORMAT = 4,
AV_PIXEL_FORMAT_RGBA = 5
}
Enumerates the video pixel formats.

Functions

NameDescription
OH_AVBuffer * OH_AVBuffer_Create (int32_t capacity)Creates an OH_AVBuffer instance. You must call OH_AVBuffer_Destroy to manually release the OH_AVBuffer instance returned.
OH_AVErrCode OH_AVBuffer_Destroy (OH_AVBuffer *buffer)Releases an OH_AVBuffer instance.
OH_AVErrCode OH_AVBuffer_GetBufferAttr (OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr)Obtains the basic attributes, including pts, size, offset, and flags, of a buffer.
OH_AVErrCode OH_AVBuffer_SetBufferAttr (OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr)Sets the basic attributes, including pts, size, offset, and flags, of a buffer.
OH_AVFormat * OH_AVBuffer_GetParameter (OH_AVBuffer *buffer)Obtains parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance.
OH_AVErrCode OH_AVBuffer_SetParameter (OH_AVBuffer *buffer, const OH_AVFormat *format)Sets parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance.
uint8_t * OH_AVBuffer_GetAddr (OH_AVBuffer *buffer)Obtains the virtual address of a data buffer.
int32_t OH_AVBuffer_GetCapacity (OH_AVBuffer *buffer)Obtains the capacity (in bytes) of a buffer.
OH_NativeBuffer * OH_AVBuffer_GetNativeBuffer (OH_AVBuffer *buffer)Obtains the pointer to an OH_NativeBuffer instance.
struct OH_AVFormat * OH_AVFormat_Create (void)Create an OH_AVFormat instance for reading and writing data.
struct OH_AVFormat * OH_AVFormat_CreateAudioFormat (const char *mimeType, int32_t sampleRate, int32_t channelCount)Creates an audio OH_AVFormat instance with specified parameters for reading and writing data.
struct OH_AVFormat * OH_AVFormat_CreateVideoFormat (const char *mimeType, int32_t width, int32_t height)Creates a video OH_AVFormat instance with specified parameters for reading and writing data.
void OH_AVFormat_Destroy (struct OH_AVFormat *format)Destroys an OH_AVFormat instance.
bool OH_AVFormat_Copy (struct OH_AVFormat *to, struct OH_AVFormat *from)Copies an OH_AVFormat instance.
bool OH_AVFormat_SetIntValue (struct OH_AVFormat *format, const char *key, int32_t value)Assigns a value of the int type to a key in an OH_AVFormat instance.
bool OH_AVFormat_SetLongValue (struct OH_AVFormat *format, const char *key, int64_t value)Assigns a value of the long type to a key in an OH_AVFormat instance.
bool OH_AVFormat_SetFloatValue (struct OH_AVFormat *format, const char *key, float value)Assigns a value of the float type to a key in an OH_AVFormat instance.
bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat *format, const char *key, double value)Assigns a value of the double type to a key in an OH_AVFormat instance.
bool OH_AVFormat_SetStringValue (struct OH_AVFormat *format, const char *key, const char *value)Assigns a value of the string type to a key in an OH_AVFormat instance.
bool OH_AVFormat_SetBuffer (struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size)Writes data blocks of a specified length to an OH_AVFormat instance.
bool OH_AVFormat_GetIntValue (struct OH_AVFormat *format, const char *key, int32_t *out)Obtains the value of the int type of a key in an OH_AVFormat instance.
bool OH_AVFormat_GetLongValue (struct OH_AVFormat *format, const char *key, int64_t *out)Obtains the value of the long type of a key in an OH_AVFormat instance.
bool OH_AVFormat_GetFloatValue (struct OH_AVFormat *format, const char *key, float *out)Obtains the value of the float type of a key in an OH_AVFormat instance.
bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat *format, const char *key, double *out)Obtains the value of the double type of a key in an OH_AVFormat instance.
bool OH_AVFormat_GetStringValue (struct OH_AVFormat *format, const char *key, const char **out)Obtains the value of the string type of a key in an OH_AVFormat instance.
bool OH_AVFormat_GetBuffer (struct OH_AVFormat *format, const char *key, uint8_t **addr, size_t *size)Reads data blocks of a specified length from an OH_AVFormat instance.
const char * OH_AVFormat_DumpInfo (struct OH_AVFormat *format)Returns a string consisting of key-value pairs contained in an OH_AVFormat instance.
OH_AVMemory * OH_AVMemory_Create (int32_t size)Creates an OH_AVMemory instance. (This function is deprecated in API version 11.)
uint8_t * OH_AVMemory_GetAddr (struct OH_AVMemory *mem)Obtains the virtual memory address. (This function is deprecated in API version 11.)
int32_t OH_AVMemory_GetSize (struct OH_AVMemory *mem)Obtains the memory length. (This function is deprecated in API version 11.)
OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory *mem)Releases an OH_AVMemory instance. (This function is deprecated in API version 11.)

Type Description

OH_AmbAttributeSet

typedef enum OH_AmbAttributeSet OH_AmbAttributeSet

Description

Defines an enum for the Hi-Fi stereo reverberation settings.

int64_t integers are used to indicate the Hi-Fi stereo reverberation attributes.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

OH_AudioChannelLayout

typedef enum OH_AudioChannelLayout OH_AudioChannelLayout

Description

Defines an enum for the audio channel layouts.

int64_t integers are used to indicate the appearance and sequence of speakers during recording or playback.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

OH_AudioChannelSet

typedef enum OH_AudioChannelSet OH_AudioChannelSet

Description

Defines an enum for the audio channel sets.

Each audio channel is mapped to an int64_t variable.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

OH_AVBuffer

typedef struct OH_AVBuffer OH_AVBuffer

Description

Defines a struct that describes a native object for the media memory interface.

Since: 11

OH_AVCodecBufferAttr

typedef struct OH_AVCodecBufferAttr OH_AVCodecBufferAttr

Description

Defines the description information about the buffer of an OH_AVCodec instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

OH_AVCodecBufferFlags

typedef enum OH_AVCodecBufferFlags OH_AVCodecBufferFlags

Description

Defines an enum for the flags for the buffer of an OH_AVCodec instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

OH_AVErrCode

typedef enum OH_AVErrCode OH_AVErrCode

Description

Defines an enum for the error codes used by the media system.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

OH_AVFormat

typedef struct OH_AVFormat OH_AVFormat

Description

Defines a struct for a native object for the OH_AVFormat interface.

Since: 9

OH_AVMemory

typedef struct OH_AVMemory OH_AVMemory

Description

Defines a struct that describes a native object for the audio and video memory interface.

Since: 9

OH_AVPixelFormat

typedef enum OH_AVPixelFormat OH_AVPixelFormat

Description

Defines an enum for the video pixel formats.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

OH_NativeBuffer

typedef struct OH_NativeBuffer OH_NativeBuffer

Description

Defines a struct that describes a native object for the graphics memory interface.

Since: 11

OH_Core_HdrType

typedef enum OH_Core_HdrType OH_Core_HdrType

Description

Defines an enum for the HDR types.

System capability: SystemCapability.Multimedia.Media.Core

Since: 18

Enum Description

OH_AmbAttributeSet

enum OH_AmbAttributeSet

Description

Enumerates the Hi-Fi stereo reverberation settings.

int64_t integers are used to indicate the Hi-Fi stereo reverberation attributes.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

ValueDescription
AMB_ORD_1First-order Hi-Fi stereo reverberation.
AMB_ORD_2Second-order Hi-Fi stereo reverberation.
AMB_ORD_3Third-order Hi-Fi stereo reverberation.
AMB_COM_ACNHi-Fi stereo reverberation with ACN channel sorting.
AMB_COM_FUMAHi-Fi stereo reverberation with FUMA channel sorting.
AMB_NOR_N3DN3D normalized Hi-Fi stereo reverberation.
AMB_NOR_SN3DSN3D normalized Hi-Fi stereo reverberation.
AMB_MODEAudio channel layout for Hi-Fi stereo reverberation.

OH_AudioChannelLayout

enum OH_AudioChannelLayout

Description

Enumerates the audio channel layouts.

int64_t integers are used to indicate the appearance and sequence of speakers during recording or playback.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

ValueDescription
CH_LAYOUT_UNKNOWNUnknown.
CH_LAYOUT_MONOMono layout; 1 audio channel in total.
CH_LAYOUT_STEREOStereo layout; 2 audio channels in total.
CH_LAYOUT_STEREO_DOWNMIXStereo downmix layout; 2 audio channels in total.
CH_LAYOUT_2POINT12.1 layout; 3 audio channels in total.
CH_LAYOUT_3POINT03.0 layout; 3 audio channels in total.
CH_LAYOUT_SURROUNDSurround; 3 audio channels in total.
CH_LAYOUT_3POINT13.1 layout; 4 audio channels in total.
CH_LAYOUT_4POINT04.0 layout; 4 audio channels in total.
CH_LAYOUT_QUAD_SIDEQuad side layout; 4 audio channels in total.
CH_LAYOUT_QUADQuad layout; 4 audio channels in total.
CH_LAYOUT_2POINT0POINT22.0.2 layout; 4 audio channels in total.
CH_LAYOUT_AMB_ORDER1_ACN_N3DFirst-order FOA layout in ACN_N3D (ITU standards); 4 audio channels in total
CH_LAYOUT_AMB_ORDER1_ACN_SN3DFirst-order FOA layout in ACN_SN3D (ITU standards); 4 audio channels in total
CH_LAYOUT_AMB_ORDER1_FUMAFirst-order FOA layout in FUMA (ITU standards); 4 audio channels in total
CH_LAYOUT_4POINT14.1 layout; 5 audio channels in total.
CH_LAYOUT_5POINT05.0 layout; 5 audio channels in total.
CH_LAYOUT_5POINT0_BACK5.0 rear layout; 5 audio channels in total.
CH_LAYOUT_2POINT1POINT22.1.2 layout; 5 audio channels in total.
CH_LAYOUT_3POINT0POINT23.0.2 layout; 5 audio channels in total.
CH_LAYOUT_5POINT15.1 layout; 6 audio channels in total.
CH_LAYOUT_5POINT1_BACK5.1 rear layout; 6 audio channels in total.
CH_LAYOUT_6POINT06.0 layout; 6 audio channels in total.
CH_LAYOUT_3POINT1POINT23.1.2 layout; 6 audio channels in total.
CH_LAYOUT_6POINT0_FRONT6.0 front layout; 6 audio channels in total.
CH_LAYOUT_HEXAGONALHexagonal layout; 6 audio channels in total.
CH_LAYOUT_6POINT16.1 layout; 7 audio channels in total.
CH_LAYOUT_6POINT1_BACK6.1 rear layout; 7 audio channels in total.
CH_LAYOUT_6POINT1_FRONT6.1 front layout; 7 audio channels in total.
CH_LAYOUT_7POINT07.0 layout; 7 audio channels in total.
CH_LAYOUT_7POINT0_FRONT7.0 front layout; 7 audio channels in total.
CH_LAYOUT_7POINT17.1 layout; 8 audio channels in total.
CH_LAYOUT_OCTAGONALOctagonal layout; 8 audio channels in total.
CH_LAYOUT_5POINT1POINT25.1.2 layout; 8 audio channels in total.
CH_LAYOUT_7POINT1_WIDE7.1 wide layout; 8 audio channels in total.
CH_LAYOUT_7POINT1_WIDE_BACK7.1 rear wide layout; 8 audio channels in total.
CH_LAYOUT_AMB_ORDER2_ACN_N3DSecond-order HOA layout in ACN_N3D (ITU standards); 9 audio channels in total
CH_LAYOUT_AMB_ORDER2_ACN_SN3DSecond-order HOA layout in ACN_SN3D (ITU standards); 9 audio channels in total
CH_LAYOUT_AMB_ORDER2_FUMASecond-order HOA layout in FUMA (ITU standards); 9 audio channels in total
CH_LAYOUT_5POINT1POINT45.1.4 layout; 10 audio channels in total.
CH_LAYOUT_7POINT1POINT27.1.2 layout; 10 audio channels in total.
CH_LAYOUT_7POINT1POINT47.1.4 layout; 12 audio channels in total.
CH_LAYOUT_10POINT210.2 layout; 12 audio channels in total.
CH_LAYOUT_9POINT1POINT49.1.4 layout; 14 audio channels in total.
CH_LAYOUT_9POINT1POINT69.1.6 layout; 16 audio channels in total.
CH_LAYOUT_HEXADECAGONALHexadecagonal layout; 16 audio channels in total.
CH_LAYOUT_AMB_ORDER3_ACN_N3DThird-order HOA layout in ACN_N3D (ITU standards); 16 audio channels in total
CH_LAYOUT_AMB_ORDER3_ACN_SN3DThird-order HOA layout in ACN_SN3D (ITU standards); 16 audio channels in total
CH_LAYOUT_AMB_ORDER3_FUMAThird-order HOA layout in FUMA (ITU standards); 16 audio channels in total
CH_LAYOUT_22POINT222.2 layout; 24 audio channels in total.

OH_AudioChannelSet

enum OH_AudioChannelSet

Description

Enumerates the audio channel sets.

Each audio channel is mapped to an int64_t variable.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

ValueDescription
CH_SET_FRONT_LEFTFront left channel.
CH_SET_FRONT_RIGHTFront right channel
CH_SET_FRONT_CENTERFront center channel.
CH_SET_LOW_FREQUENCYLow-frequency channel.
CH_SET_BACK_LEFTRear left channel.
CH_SET_BACK_RIGHTRear right channel
CH_SET_FRONT_LEFT_OF_CENTERFront left center channel.
CH_SET_FRONT_RIGHT_OF_CENTERFront right center channel.
CH_SET_BACK_CENTERRear center channel.
CH_SET_SIDE_LEFTLeft channel.
CH_SET_SIDE_RIGHTRight channel.
CH_SET_TOP_CENTERTop center channel.
CH_SET_TOP_FRONT_LEFTTop left front channel.
CH_SET_TOP_FRONT_CENTERTop center front channel.
CH_SET_TOP_FRONT_RIGHTTop right front channel.
CH_SET_TOP_BACK_LEFTTop left rear channel.
CH_SET_TOP_BACK_CENTERTop center rear channel.
CH_SET_TOP_BACK_RIGHTTop right rear channel.
CH_SET_STEREO_LEFTStereo left channel.
CH_SET_STEREO_RIGHTStereo right channel.
CH_SET_WIDE_LEFTWide left channel.
CH_SET_WIDE_RIGHTWide right channel.
CH_SET_SURROUND_DIRECT_LEFTLeft surround channel.
CH_SET_SURROUND_DIRECT_RIGHTRight surround channel.
CH_SET_LOW_FREQUENCY_2Low-frequency channel 2.
CH_SET_TOP_SIDE_LEFTTop left channel.
CH_SET_TOP_SIDE_RIGHTTop right channel.
CH_SET_BOTTOM_FRONT_CENTERBottom center front channel.
CH_SET_BOTTOM_FRONT_LEFTBottom left front channel.
CH_SET_BOTTOM_FRONT_RIGHTBottom right front channel.

OH_AVCodecBufferFlags

enum OH_AVCodecBufferFlags

Description

Enumerates the flags for the buffer of an OH_AVCodec instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

ValueDescription
AVCODEC_BUFFER_FLAGS_NONECommon frame.
AVCODEC_BUFFER_FLAGS_EOSThe buffer is an end-of-stream frame.
AVCODEC_BUFFER_FLAGS_SYNC_FRAMEThe buffer contains key frames.
AVCODEC_BUFFER_FLAGS_INCOMPLETE_FRAMEThe data in the buffer is only part of the frame.
AVCODEC_BUFFER_FLAGS_CODEC_DATAThe buffer contains codec-specific data.
AVCODEC_BUFFER_FLAGS_DISCARDThe decoding process depends on the buffer, and the decoded data can be discarded.
Since: 12
AVCODEC_BUFFER_FLAGS_DISPOSABLEThe buffer can be disposed directly.
Since: 12

OH_AVErrCode

enum OH_AVErrCode

Description

Enumerates the error codes used by the media system.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

ValueDescription
AV_ERR_OKOperation successful.
AV_ERR_NO_MEMORYNo memory.
AV_ERR_OPERATE_NOT_PERMITOperation not allowed.
AV_ERR_INVALID_VALInvalid value.
AV_ERR_IOI/O error.
AV_ERR_TIMEOUTTimeout.
AV_ERR_UNKNOWNUnknown error.
AV_ERR_SERVICE_DIEDUnavailable service.
AV_ERR_INVALID_STATEUnsupported operation in this state.
AV_ERR_UNSUPPORTUnsupported feature.
AV_ERR_UNSUPPORTED_FORMATCoding format not supported.
Since: 18
AV_ERR_EXTEND_STARTInitial value for extended error codes.
AV_ERR_DRM_BASEDRM start error code.
Since: 12
AV_ERR_DRM_DECRYPT_FAILEDDRM decryption failed.
Since: 12
AV_ERR_VIDEO_BASEVideo start error code.
Since: 12
AV_ERR_VIDEO_UNSUPPORTED_COLOR_SPACE_CONVERSIONColor Space Conversion (CSC) is not supported.
Since: 12

OH_AVPixelFormat

enum OH_AVPixelFormat

Description

Enumerates the video pixel formats.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

ValueDescription
AV_PIXEL_FORMAT_YUVI420YUV 420 Planar.
AV_PIXEL_FORMAT_NV12NV12. YUV 420 semi-planar.
AV_PIXEL_FORMAT_NV21NV21. YVU 420 semi-planar.
AV_PIXEL_FORMAT_SURFACE_FORMATPixel format obtained from the surface. This value takes effect only in surface mode.
AV_PIXEL_FORMAT_RGBARGBA8888.

OH_Core_HdrType

enum OH_Core_HdrType

Description

Enumerates the HDR types.

System capability: SystemCapability.Multimedia.Media.Core

Since: 18

ValueDescription
OH_CORE_HDR_TYPE_NONENon-HDR type.
OH_CORE_HDR_TYPE_VIVIDHDR Vivid type.

Function Description

OH_AVBuffer_Create()

OH_AVBuffer* OH_AVBuffer_Create (int32_t capacity)

Description

Creates an OH_AVBuffer instance. You must call OH_AVBuffer_Destroy to manually release the OH_AVBuffer instance returned.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
capacitySize of the created memory, in bytes.

Returns

Returns the pointer to the OH_AVBuffer instance created if the operation is successful; returns NULL otherwise.

The possible causes of an operation failure are as follows:

  1. The value of capacity is less than or equal to 0.
  2. An internal error occurs, or the system does not have resources.

OH_AVBuffer_Destroy()

OH_AVErrCode OH_AVBuffer_Destroy (OH_AVBuffer *buffer)

Description

Releases an OH_AVBuffer instance. A buffer cannot be destroyed repeatedly.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.

Returns

Returns any of the following result code:

AV_ERR_OK: The operation is successful.

AV_ERR_INVALID_VAL: The passed-in value of buffer is a null pointer or fails parameter structure verification.

AV_ERR_OPERATE_NOT_PERMIT: The input buffer is not created by the user.

OH_AVBuffer_GetAddr()

uint8_t* OH_AVBuffer_GetAddr (OH_AVBuffer *buffer)

Description

Obtains the virtual address of a data buffer.

The capability to obtain virtual addresses varies in scenarios, as described in the table below.

Encoding

ModeData Filling ModeCapability to Obtain Virtual Addresses
SurfaceOnNeedInputBuffer inputNot supported
SurfaceOnNewOutputBuffer outputSupported
BufferOnNeedInputBuffer inputSupported
BufferOnNewOutputBuffer outputSupported

Decoding

ModeData Filling ModeCapability to Obtain Virtual Addresses
SurfaceOnNeedInputBuffer inputSupported
SurfaceOnNewOutputBuffer outputNot supported
BufferOnNeedInputBuffer inputSupported
BufferOnNewOutputBuffer outputSupported

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.

Returns

Returns the virtual address if the operation is successful; returns NULL otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of buffer is a null pointer.
  2. The passed-in value of OH_AVBuffer fails parameter structure verification.
  3. An internal error occurred.

OH_AVBuffer_GetBufferAttr()

OH_AVErrCode OH_AVBuffer_GetBufferAttr (OH_AVBuffer *buffer, OH_AVCodecBufferAttr *attr)

Description

Obtains the basic attributes, including pts, size, offset, and flags, of a buffer.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.
attrPointer to an OH_AVCodecBufferAttr instance.

Returns

Returns any of the following result code:

AV_ERR_OK: The operation is successful.

AV_ERR_INVALID_VAL: The operation fails.

Possible causes are as follows:
1. The passed-in value of **buffer** or **attr** is a null pointer.
2. The passed-in value of **buffer** fails parameter structure verification.

OH_AVBuffer_GetCapacity()

int32_t OH_AVBuffer_GetCapacity (OH_AVBuffer *buffer)

Description

Obtains the capacity (in bytes) of a buffer.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.

Returns

Returns the capacity if the operation is successful; returns -1 otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of buffer is a null pointer.
  2. The passed-in value of OH_AVBuffer fails parameter structure verification.
  3. An internal error occurred.

OH_AVBuffer_GetNativeBuffer()

OH_NativeBuffer* OH_AVBuffer_GetNativeBuffer (OH_AVBuffer *buffer)

Description

Obtains the pointer to an OH_NativeBuffer instance. You must call OH_NativeBuffer_Unreference to manually release the OH_NativeBuffer instance returned.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.

Returns

Returns the pointer to the OH_NativeBuffer instance created if the operation is successful; returns NULL otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of buffer is a null pointer.
  2. The passed-in value of OH_AVBuffer fails parameter structure verification.
  3. An internal error occurred.

OH_AVBuffer_GetParameter()

OH_AVFormat* OH_AVBuffer_GetParameter (OH_AVBuffer *buffer)

Description

Obtains parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance. You must call OH_AVFormat_Destroy to manually release the OH_AVFormat instance returned.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.

Returns

Returns any of the following result code:

AV_ERR_OK: The operation is successful.

AV_ERR_INVALID_VAL: The operation fails.

Possible causes are as follows:
1. The passed-in value of **buffer** is a null pointer.
2. The meta of the buffer is a null pointer.
3. The passed-in value of **buffer** fails parameter structure verification.

OH_AVBuffer_SetBufferAttr()

OH_AVErrCode OH_AVBuffer_SetBufferAttr (OH_AVBuffer *buffer, const OH_AVCodecBufferAttr *attr)

Description

Sets the basic attributes, including pts, size, offset, and flags, of a buffer.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.
attrPointer to an OH_AVCodecBufferAttr instance.

Returns

Returns any of the following result code:

AV_ERR_OK: The operation is successful.

AV_ERR_INVALID_VAL: The operation fails.

Possible causes are as follows:
1. The passed-in value of **buffer** or **attr** is a null pointer.
2. The passed-in value of **buffer** fails parameter structure verification.
3. The memory size or offset of the buffer is invalid.

OH_AVBuffer_SetParameter()

OH_AVErrCode OH_AVBuffer_SetParameter (OH_AVBuffer *buffer, const OH_AVFormat *format)

Description

Sets parameters except basic attributes of a buffer. The information is carried in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 11

Parameters

NameDescription
bufferPointer to an OH_AVBuffer instance.
formatPointer to an OH_AVFormat instance.

Returns

Returns any of the following result code:

AV_ERR_OK: The operation is successful.

AV_ERR_INVALID_VAL: The operation fails.

Possible causes are as follows:
1. The passed-in value of **buffer** or **format** is a null pointer.
2. The meta of the buffer is a null pointer.
3. The passed-in value of **buffer** fails parameter structure verification.

OH_AVFormat_Copy()

bool OH_AVFormat_Copy (struct OH_AVFormat *to, struct OH_AVFormat *from)

Description

Copies an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
toPointer to the OH_AVFormat instance to which the data will be copied.
fromPointer to the OH_AVFormat instance from which the data will be copied.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The input parameter is a null pointer.
  2. The passed-in value of OH_AVFormat fails parameter structure verification.

OH_AVFormat_Create()

struct OH_AVFormat* OH_AVFormat_Create (void)

Description

Create an OH_AVFormat instance for reading and writing data.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Returns

Returns the pointer to an OH_AVFormat instance; returns NULL if system resources are insufficient.

OH_AVFormat_CreateAudioFormat()

struct OH_AVFormat* OH_AVFormat_CreateAudioFormat (const char *mimeType, int32_t sampleRate, int32_t channelCount)

Description

Creates an audio OH_AVFormat instance with specified parameters for reading and writing data.

System capability: SystemCapability.Multimedia.Media.Core

Since: 10

Parameters

NameDescription
mimeTypePointer to a string that describes the MIME type. For details, see AVCODEC_MIMETYPE.
sampleRateSampling rate, in Hz.
channelCountNumber of audio channels. For example, 1 indicates mono and 2 indicates stereo.

Returns

Returns the pointer to an OH_AVFormat instance; returns NULL if the passed-in value of mimeType is NULL or system resources are insufficient.

OH_AVFormat_CreateVideoFormat()

struct OH_AVFormat* OH_AVFormat_CreateVideoFormat (const char *mimeType, int32_t width, int32_t height)

Description

Creates a video OH_AVFormat instance with specified parameters for reading and writing data.

System capability: SystemCapability.Multimedia.Media.Core

Since: 10

Parameters

NameDescription
mimeTypePointer to a string that describes the MIME type. For details, see AVCODEC_MIMETYPE.
widthLuminance width, in pixels.
heightLuminance height, in pixels.

Returns

Returns the pointer to an OH_AVFormat instance; returns NULL if the passed-in value of mimeType is NULL or system resources are insufficient.

OH_AVFormat_Destroy()

void OH_AVFormat_Destroy (struct OH_AVFormat *format)

Description

Destroys an OH_AVFormat instance. The instance cannot be destroyed repeatedly.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.

Returns

No return value.

OH_AVFormat_DumpInfo()

const char* OH_AVFormat_DumpInfo (struct OH_AVFormat *format)

Description

Returns a string consisting of key-value pairs contained in an OH_AVFormat instance. A string of up to 1024 bytes can be returned. The string pointer is released when the OH_AVFormat instance is destroyed.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.

Returns

Returns the pointer to a collection of strings, in the format of key-value pairs; returns NULL if the passed-in value of format is NULL or system resources are insufficient.

OH_AVFormat_GetBuffer()

bool OH_AVFormat_GetBuffer (struct OH_AVFormat *format, const char *key, uint8_t ** addr, size_t *size)

Description

Reads data blocks of a specified length from an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
addrDouble pointer to the address where the data read is stored. The data read is destroyed when the OH_AVFormat instance is destroyed. To hold the data for an extended period of time, copy it to the memory.
sizePointer to the size of the data read.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of addr is a null pointer.
  5. The passed-in value of size is a null pointer.
  6. The obtained key does not exist or is not set.

OH_AVFormat_GetDoubleValue()

bool OH_AVFormat_GetDoubleValue (struct OH_AVFormat *format, const char *key, double *out)

Description

Obtains the value of the double type of a key in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
outPointer to the value of the data read.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of out is a null pointer.
  5. The obtained key does not exist or is not set.

OH_AVFormat_GetFloatValue()

bool OH_AVFormat_GetFloatValue (struct OH_AVFormat *format, const char *key, float *out)

Description

Obtains the value of the float type of a key in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
outPointer to the value of the data read.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of out is a null pointer.
  5. The obtained key does not exist or is not set.

OH_AVFormat_GetIntValue()

bool OH_AVFormat_GetIntValue (struct OH_AVFormat *format, const char *key, int32_t *out)

Description

Obtains the value of the int type of a key in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
outPointer to the value of the data read.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of out is a null pointer.
  5. The obtained key does not exist or is not set.

OH_AVFormat_GetLongValue()

bool OH_AVFormat_GetLongValue (struct OH_AVFormat *format, const char *key, int64_t *out)

Description

Obtains the value of the long type of a key in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
outPointer to the value of the data read.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of out is a null pointer.
  5. The obtained key does not exist or is not set.

OH_AVFormat_GetStringValue()

bool OH_AVFormat_GetStringValue (struct OH_AVFormat *format, const char *key, const char ** out)

Description

Obtains the value of the string type of a key in an OH_AVFormat instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to read.
outDouble pointer to the string read. The lifecycle of the out data matches the string in format. To keep the out data for an extended period of time, you must copy it to the memory. The maximum length of the output string is 256 bytes. If the length exceeds 256 bytes, false is returned.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of out is a null pointer.
  5. The system resources are insufficient.
  6. The obtained key does not exist or is not set.
  7. The length of the out data exceeds 256 bytes.

OH_AVFormat_SetBuffer()

bool OH_AVFormat_SetBuffer (struct OH_AVFormat *format, const char *key, const uint8_t *addr, size_t size)

Description

Writes data blocks of a specified length to an OH_AVFormat instance. This function can be used to set only parameters of the buffer type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
addrDouble-pointer to the address to which data is written. The lifecycle is managed by the developer.
sizeLength of the data written, in MB. The value range is (0, 1].

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of addr is a null pointer.
  5. The size is 0 or exceeds the upper limit (1 MB).
  6. The value type corresponding to the key is incorrect.

OH_AVFormat_SetDoubleValue()

bool OH_AVFormat_SetDoubleValue (struct OH_AVFormat *format, const char *key, double value)

Description

Assigns a value of the double type to a key in an OH_AVFormat instance. This function can be used to set only parameters of the double type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
valueValue of the data to write.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The value type corresponding to the key is incorrect.

OH_AVFormat_SetFloatValue()

bool OH_AVFormat_SetFloatValue (struct OH_AVFormat *format, const char *key, float value)

Description

Assigns a value of the float type to a key in an OH_AVFormat instance. This function can be used to set only parameters of the float type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
valueValue of the data to write.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The value type corresponding to the key is incorrect.

OH_AVFormat_SetIntValue()

bool OH_AVFormat_SetIntValue (struct OH_AVFormat *format, const char *key, int32_t value)

Description

Assigns a value of the int type to a key in an OH_AVFormat instance. This function can be used to set only parameters of the int type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
valueValue of the data to write.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The value type corresponding to the key is incorrect.

OH_AVFormat_SetLongValue()

bool OH_AVFormat_SetLongValue (struct OH_AVFormat *format, const char *key, int64_t value)

Description

Assigns a value of the long type to a key in an OH_AVFormat instance. This function can be used to set only parameters of the long type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
valueValue of the data to write.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The value type corresponding to the key is incorrect.

OH_AVFormat_SetStringValue()

bool OH_AVFormat_SetStringValue (struct OH_AVFormat *format, const char *key, const char *value)

Description

Assigns a value of the string type to a key in an OH_AVFormat instance. This function can be used to set only parameters of the string type. For details, see CodecBase.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Parameters

NameDescription
formatPointer to an OH_AVFormat instance.
keyPointer to the key of the data to write.
valuePointer to the data to be written to the string. The length should not exceed 256 bytes.

Returns

Returns TRUE if the operation is successful; returns FALSE otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of format is a null pointer.
  2. The passed-in value of format fails parameter structure verification.
  3. The passed-in value of key is a null pointer.
  4. The passed-in value of value is a null pointer.
  5. The value type corresponding to the key is incorrect.

OH_AVMemory_Create()

OH_AVMemory* OH_AVMemory_Create (int32_t size)

Description

Creates an OH_AVMemory instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 10

Deprecated from: 11

Substitute: OH_AVBuffer_Create

Parameters

NameDescription
sizeSize of the created memory, in bytes.

Returns

Returns the pointer to the OH_AVMemory instance created if the operation is successful; returns NULL otherwise. The instance must be released by calling OH_AVMemory_Destroy when it is no longer required.

OH_AVMemory_Destroy()

OH_AVErrCode OH_AVMemory_Destroy (struct OH_AVMemory *mem)

Description

Releases an OH_AVMemory instance.

System capability: SystemCapability.Multimedia.Media.Core

Since: 10

Deprecated from: 11

Substitute: OH_AVBuffer_Destroy

Parameters

NameDescription
memPointer to an OH_AVMemory instance.

Returns

Returns AV_ERR_OK if the operation is successful; returns an error code defined in OH_AVErrCode otherwise.

OH_AVMemory_GetAddr()

uint8_t* OH_AVMemory_GetAddr (struct OH_AVMemory *mem)

Description

Obtains the virtual memory address.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Deprecated from: 11

Substitute: OH_AVBuffer_GetAddr

Parameters

NameDescription
memPointer to an OH_AVMemory instance.

Returns

Returns the pointer to the virtual memory address if the memory is valid; returns NULL otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of mem is a null pointer.
  2. The passed-in value of mem fails parameter structure verification.
  3. The memory in the passed-in value of mem is a null pointer.

OH_AVMemory_GetSize()

int32_t OH_AVMemory_GetSize (struct OH_AVMemory *mem)

Description

Obtains the memory length.

System capability: SystemCapability.Multimedia.Media.Core

Since: 9

Deprecated from: 11

Substitute: OH_AVBuffer_GetCapacity

Parameters

NameDescription
memPointer to an OH_AVMemory instance.

Returns

Returns the memory size if the memory is valid; returns -1 otherwise.

The possible causes of an operation failure are as follows:

  1. The passed-in value of mem is a null pointer.
  2. The passed-in value of mem fails parameter structure verification.
  3. The memory in the passed-in value of mem is a null pointer.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙AVCodec Kit

harmony 鸿蒙AVCapability

harmony 鸿蒙AVDemuxer

harmony 鸿蒙AVMuxer

harmony 鸿蒙AVSource

harmony 鸿蒙AudioCodec

harmony 鸿蒙AudioDecoder

harmony 鸿蒙AudioEncoder

harmony 鸿蒙CodecBase

harmony 鸿蒙DrmSubsample

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