openharmony 鸿蒙 capi-avrecorder-base-h

2025-06-12 浏览 (1)

avrecorder_base.h

Overview

The avrecorder_base.h file declares the struct and enums used by the AVRecorder.

File to include: avrecorder.h

Library: libavrecorder.so

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Related module: AVRecorder

Summary

Structs

Nametypedef KeywordDescription
OH_AVRecorder_ProfileOH_AVRecorder_ProfileDescribes the parameters used for audio and video recording.
OH_AVRecorderOH_AVRecorderDescribes an initialized AVRecorder.
OH_AVRecorder_LocationOH_AVRecorder_LocationDescribes the geographical location information about a media asset.
OH_AVRecorder_MetadataTemplateOH_AVRecorder_MetadataTemplateDescribes the basic template of metadata.
OH_AVRecorder_MetadataOH_AVRecorder_MetadataDescribes the metadata.
OH_AVRecorder_ConfigOH_AVRecorder_ConfigDescribes the AVRecorder configuration.
OH_AVRecorder_RangeOH_AVRecorder_RangeDescribes the range.
OH_AVRecorder_EncoderInfoOH_AVRecorder_EncoderInfoDescribes the encoder information.

Enums

Nametypedef KeywordDescription
OH_AVRecorder_AudioSourceTypeOH_AVRecorder_AudioSourceTypeEnumerates the audio source types of the AVRecorder.
OH_AVRecorder_VideoSourceTypeOH_AVRecorder_VideoSourceTypeEnumerates the video source types of the AVRecorder.
OH_AVRecorder_CodecMimeTypeOH_AVRecorder_CodecMimeTypeEnumerates the MIME types of the encoder.
OH_AVRecorder_ContainerFormatTypeOH_AVRecorder_ContainerFormatTypeEnumerates the Container Format Types (CFTs).
OH_AVRecorder_StateOH_AVRecorder_StateEnumerates the AVRecorder states.
OH_AVRecorder_StateChangeReasonOH_AVRecorder_StateChangeReasonEnumerates the reasons for AVRecorder state changes.
OH_AVRecorder_FileGenerationModeOH_AVRecorder_FileGenerationModeEnumerates the modes available for creating a recording file.

Functions

Nametypedef KeywordDescription
typedef void (*OH_AVRecorder_OnStateChange)(OH_AVRecorder *recorder,OH_AVRecorder_State state, OH_AVRecorder_StateChangeReason reason, void *userData)OH_AVRecorder_OnStateChangeCalled when the AVRecorder state changes.
typedef void (*OH_AVRecorder_OnError)(OH_AVRecorder *recorder, int32_t errorCode, const char *errorMsg,void *userData)OH_AVRecorder_OnErrorCalled when an error occurs during recording.
typedef void (*OH_AVRecorder_OnUri)(OH_AVRecorder *recorder, OH_MediaAsset *asset, void *userData)OH_AVRecorder_OnUriCalled when the recording is in OH_AVRecorder_FileGenerationMode.AVRECORDER_AUTO_CREATE_CAMERA_SCENE mode.

Enum Description

OH_AVRecorder_AudioSourceType

enum OH_AVRecorder_AudioSourceType

Description

Enumerates the audio source types of the AVRecorder.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_DEFAULT = 0Default audio source.
AVRECORDER_MIC = 1Microphone audio source.
AVRECORDER_VOICE_RECOGNITION = 2Audio source in speech recognition scenarios.
AVRECORDER_VOICE_COMMUNICATION = 7Voice communication source.
AVRECORDER_VOICE_MESSAGE = 10Voice message source.
AVRECORDER_CAMCORDER = 13Audio source in camera recording scenarios.

OH_AVRecorder_VideoSourceType

enum OH_AVRecorder_VideoSourceType

Description

Enumerates the video source types of the AVRecorder.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_SURFACE_YUV = 0Raw data surface.
AVRECORDER_SURFACE_ES = 1ES data surface.

OH_AVRecorder_CodecMimeType

enum OH_AVRecorder_CodecMimeType

Description

Enumerates the MIME types of the encoder.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_VIDEO_AVC = 2MIME type of the H.264 encoder.
AVRECORDER_AUDIO_AAC = 3MIME type of the AAC encoder.
AVRECORDER_AUDIO_MP3 = 4MIME type of the MP3 encoder.
AVRECORDER_AUDIO_G711MU = 5MIME type of the G711-mulaw encoder.
AVRECORDER_VIDEO_MPEG4 = 6MIME type of the MPEG4 encoder.
AVRECORDER_VIDEO_HEVC = 8MIME type of the H.265 encoder.
AVRECORDER_AUDIO_AMR_NB = 9MIME type of the AMR-NB codec.
AVRECORDER_AUDIO_AMR_WB = 10MIME type of the AMR-WB codec.

OH_AVRecorder_ContainerFormatType

enum OH_AVRecorder_ContainerFormatType

Description

Enumerates the Container Format Types (CFTs).

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_CFT_MPEG_4 = 2Video container format mp4.
AVRECORDER_CFT_MPEG_4A = 6Audio container format m4a.
AVRECORDER_CFT_AMR = 8Audio container format amr.
AVRECORDER_CFT_MP3 = 9Audio container format mp3.
AVRECORDER_CFT_WAV = 10Audio container format wav.
AVRECORDER_CFT_AAC = 11Audio container format aac (with ADTS header).
Since: 20

OH_AVRecorder_State

enum OH_AVRecorder_State

Description

Enumerates the AVRecorder states.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_IDLE = 0Idle. In this state, you can call OH_AVRecorder_Prepare to set recording parameters, and the AVRecorder transitions to the AVRECORDER_PREPARED state.
AVRECORDER_PREPARED = 1Prepared. After the parameters are set, you can call OH_AVRecorder_Start to start recording, and the AVRecorder transitions to the AVRECORDER_STARTED state.
AVRECORDER_STARTED = 2Started. Recording is in progress. In this case, you can call OH_AVRecorder_Pause to pause recording, and the AVRecorder transitions to the AVRECORDER_PAUSED state.
You can also call OH_AVRecorder_Stop to stop recording, and the AVRecorder transitions to the AVRECORDER_STOPPED state.
AVRECORDER_PAUSED = 3Paused. In this state, you can call OH_AVRecorder_Resume to resume recording, and the AVRecorder transitions to the AVRECORDER_STARTED state.
You can also call OH_AVRecorder_Stop to stop recording, and the AVRecorder transitions to the AVRECORDER_STOPPED state.
AVRECORDER_STOPPED = 4Stopped. In this state, you can call OH_AVRecorder_Prepare to set recording parameters, and the AVRecorder transitions to the AVRECORDER_PREPARED state again.
AVRECORDER_RELEASED = 5Released. The recording resources are released. No operation can be performed at this time. In any other state, you can call OH_AVRecorder_Release to transition to the AVRECORDER_RELEASED state.
AVRECORDER_ERROR = 6Error state. The AVRecorder transitions to this state when an irreversible error occurs in the instance.
In this state, the OH_AVRecorder_OnError event is reported, with the detailed error cause.
You should call OH_AVRecorder_Reset to reset the AVRecorder instance or call OH_AVRecorder_Release to release resources.

OH_AVRecorder_StateChangeReason

enum OH_AVRecorder_StateChangeReason

Description

Enumerates the reasons for AVRecorder state changes.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_USER = 0The state change is caused by user operations.
AVRECORDER_BACKGROUND = 1The state change is caused by background operations.

OH_AVRecorder_FileGenerationMode

enum OH_AVRecorder_FileGenerationMode

Description

Enumerates the modes available for creating a recording file.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Enum ItemDescription
AVRECORDER_APP_CREATE = 0The application creates a media file in the sandbox.
AVRECORDER_AUTO_CREATE_CAMERA_SCENE = 1The system creates a media file. This value is valid only in camera recording scenarios.

Function Description

OH_AVRecorder_OnStateChange()

typedef void (*OH_AVRecorder_OnStateChange)(OH_AVRecorder *recorder,OH_AVRecorder_State state, OH_AVRecorder_StateChangeReason reason, void *userData)

Description

Called when the AVRecorder state changes.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Parameters

ParameterDescription
OH_AVRecorder *recorderPointer to the OH_AVRecorder instance.
OH_AVRecorder_State stateAVRecorder state.
OH_AVRecorder_StateChangeReason reasonReason for the AVRecorder state change.
void *userDataPointer to user-defined data.

OH_AVRecorder_OnError()

typedef void (*OH_AVRecorder_OnError)(OH_AVRecorder *recorder, int32_t errorCode, const char *errorMsg,void *userData)

Description

Called when an error occurs during recording.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Parameters

ParameterDescription
OH_AVRecorder *recorderPointer to the OH_AVRecorder instance.
int32_t errorCodeError code. For details, see AVErrorCode.
const char *errorMsgPointer to the error message.
void *userDataPointer to user-defined data.

OH_AVRecorder_OnUri()

typedef void (*OH_AVRecorder_OnUri)(OH_AVRecorder *recorder, OH_MediaAsset *asset, void *userData)

Description

Called when the recording is in OH_AVRecorder_FileGenerationMode.AVRECORDER_AUTO_CREATE_CAMERA_SCENE mode.

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Parameters

ParameterDescription
OH_AVRecorder *recorderPointer to the OH_AVRecorder instance.
OH_MediaAsset *assetPointer to the OH_MediaAsset instance.
void *userDataPointer to user-defined data.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙Media Kit

harmony 鸿蒙AVImageGenerator

harmony 鸿蒙AVMetadataExtractor

harmony 鸿蒙AVPlayer

harmony 鸿蒙AVPlayerCallback

harmony 鸿蒙AVRecorder

harmony 鸿蒙AVScreenCapture

harmony 鸿蒙OH_AVRecorder_Config

harmony 鸿蒙OH_AVRecorder_EncoderInfo

harmony 鸿蒙OH_AVRecorder_Location

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