harmony 鸿蒙avrecorder.h

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

avrecorder.h

Overview

The avrecorder.h file declares the AVRecorder APIs. Applications can use the APIs to record media data.

Library: libavrecorder.so

File to include: <multimedia/player_framework/avrecorder.h>

System capability: SystemCapability.Multimedia.Media.AVRecorder

Since: 18

Related module: AVRecorder

Summary

Functions

Name Description
OH_AVRecorder * OH_AVRecorder_Create (void) Creates an AVRecorder instance. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_IDLE state.
OH_AVErrCode OH_AVRecorder_Prepare (OH_AVRecorder *recorder, OH_AVRecorder_Config *config) Sets AVRecorder parameters to prepare for recording. This function must be called after OH_AVRecorder_Start is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_PREPARED state.
OH_AVErrCode OH_AVRecorder_GetAVRecorderConfig (OH_AVRecorder *recorder, OH_AVRecorder_Config **config) Obtains the AVRecorder configuration. This function must be called after the recording preparation is complete. config must be set to a null pointer. The framework layer allocates and releases the memory in a unified manner to avoid issues with memory management, such as leaks or double freeing.
OH_AVErrCode OH_AVRecorder_GetInputSurface (OH_AVRecorder *recorder, OHNativeWindow **window) Obtains an input surface. This function must be called after OH_AVRecorder_Prepare is successfully triggered and before OH_AVRecorder_Start is called.
OH_AVErrCode OH_AVRecorder_UpdateRotation (OH_AVRecorder *recorder, int32_t rotation) Updates the video rotation angle. This function must be called after OH_AVRecorder_Prepare is successfully triggered and before OH_AVRecorder_Start is called.
OH_AVErrCode OH_AVRecorder_Start (OH_AVRecorder *recorder) Starts recording. This function must be called after OH_AVRecorder_Prepare is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_STARTED state.
OH_AVErrCode OH_AVRecorder_Pause (OH_AVRecorder *recorder) Pauses recording. This function must be called after OH_AVRecorder_Start is successfully triggered and the AVRecorder is in the AVRECORDER_STARTED state. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_PAUSED state.
OH_AVErrCode OH_AVRecorder_Resume (OH_AVRecorder *recorder) Resumes recording. This function must be called after OH_AVRecorder_Pause is successfully triggered and the AVRecorder is in the AVRECORDER_PAUSED state. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_STARTED state.
OH_AVErrCode OH_AVRecorder_Stop (OH_AVRecorder *recorder) Stops recording. This function must be called after OH_AVRecorder_Start is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_STOPPED state.
OH_AVErrCode OH_AVRecorder_Reset (OH_AVRecorder *recorder) Resets the recording state. This function must be called when the AVRecorder is not in the AVRECORDER_RELEASED state. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_IDLE state.
OH_AVErrCode OH_AVRecorder_Release (OH_AVRecorder *recorder) Releases recording resources. After this API is successfully called, the AVRecorder transitions to the AVRECORDER_RELEASED state. The recorder memory will be released. The application layer must explicitly set the recorder to a null pointer to avoid access to wild pointers.
OH_AVErrCode OH_AVRecorder_GetAvailableEncoder (OH_AVRecorder *recorder, OH_AVRecorder_EncoderInfo **info, int32_t *length) Obtains the available encoders and encoder information of the AVRecorder. info must be set to a null pointer. The framework layer allocates and releases the memory in a unified manner to avoid issues with memory management, such as leaks or double freeing.
OH_AVErrCode OH_AVRecorder_SetStateCallback (OH_AVRecorder *recorder, OH_AVRecorder_OnStateChange callback, void *userData) Sets a state callback so that the application can respond to state change events generated by the AVRecorder. This function must be called before OH_AVRecorder_Start is called.
OH_AVErrCode OH_AVRecorder_SetErrorCallback (OH_AVRecorder *recorder, OH_AVRecorder_OnError callback, void *userData) Sets an error callback so that the application can respond to error events generated by the AVRecorder. This function must be called before OH_AVRecorder_Start is called.
OH_AVErrCode OH_AVRecorder_SetUriCallback (OH_AVRecorder *recorder, OH_AVRecorder_OnUri callback, void *userData) Sets a URI callback so that the application can respond to URI events generated by the AVRecorder. This function must be called before OH_AVRecorder_Start is called.

你可能感兴趣的鸿蒙文章

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

0  赞