• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# avrecorder.h
2
3
4## Overview
5
6The **avrecorder.h** file declares the AVRecorder APIs. Applications can use the APIs to record media data.
7
8**Library**: libavrecorder.so
9
10**File to include**: <multimedia/player_framework/avrecorder.h>
11
12**System capability**: SystemCapability.Multimedia.Media.AVRecorder
13
14**Since**: 18
15
16**Related module**: [AVRecorder](_a_v_recorder.md)
17
18
19## Summary
20
21
22### Functions
23
24| Name| Description|
25| -------- | -------- |
26| [OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \* [OH_AVRecorder_Create](_a_v_recorder.md#oh_avrecorder_create) (void) | Creates an AVRecorder instance. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_IDLE state.|
27| OH_AVErrCode [OH_AVRecorder_Prepare](_a_v_recorder.md#oh_avrecorder_prepare) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_Config](_o_h___a_v_recorder___config.md) \*config) | Sets AVRecorder parameters to prepare for recording. This function must be called after [OH_AVRecorder_Start](_a_v_recorder.md#oh_avrecorder_start) is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_PREPARED state.|
28| OH_AVErrCode [OH_AVRecorder_GetAVRecorderConfig](_a_v_recorder.md#oh_avrecorder_getavrecorderconfig) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_Config](_o_h___a_v_recorder___config.md) \*\*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.|
29| OH_AVErrCode [OH_AVRecorder_GetInputSurface](_a_v_recorder.md#oh_avrecorder_getinputsurface) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, OHNativeWindow \*\*window) | Obtains an input surface. This function must be called after [OH_AVRecorder_Prepare](_a_v_recorder.md#oh_avrecorder_prepare) is successfully triggered and before [OH_AVRecorder_Start](_a_v_recorder.md#oh_avrecorder_start) is called.|
30| OH_AVErrCode [OH_AVRecorder_UpdateRotation](_a_v_recorder.md#oh_avrecorder_updaterotation) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, int32_t rotation) | Updates the video rotation angle. This function must be called after [OH_AVRecorder_Prepare](_a_v_recorder.md#oh_avrecorder_prepare) is successfully triggered and before [OH_AVRecorder_Start](_a_v_recorder.md#oh_avrecorder_start) is called.|
31| OH_AVErrCode [OH_AVRecorder_Start](_a_v_recorder.md#oh_avrecorder_start) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder) | Starts recording. This function must be called after [OH_AVRecorder_Prepare](_a_v_recorder.md#oh_avrecorder_prepare) is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_STARTED state.|
32| OH_AVErrCode [OH_AVRecorder_Pause](_a_v_recorder.md#oh_avrecorder_pause) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder) | Pauses recording. This function must be called after [OH_AVRecorder_Start](_a_v_recorder.md#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.|
33| OH_AVErrCode [OH_AVRecorder_Resume](_a_v_recorder.md#oh_avrecorder_resume) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder) | Resumes recording. This function must be called after [OH_AVRecorder_Pause](_a_v_recorder.md#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.|
34| OH_AVErrCode [OH_AVRecorder_Stop](_a_v_recorder.md#oh_avrecorder_stop) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder) | Stops recording. This function must be called after [OH_AVRecorder_Start](_a_v_recorder.md#oh_avrecorder_start) is successfully triggered. After this function is successfully called, the AVRecorder transitions to the AVRECORDER_STOPPED state.|
35| OH_AVErrCode [OH_AVRecorder_Reset](_a_v_recorder.md#oh_avrecorder_reset) ([OH_AVRecorder](_a_v_recorder.md#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.|
36| OH_AVErrCode [OH_AVRecorder_Release](_a_v_recorder.md#oh_avrecorder_release) ([OH_AVRecorder](_a_v_recorder.md#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.|
37| OH_AVErrCode [OH_AVRecorder_GetAvailableEncoder](_a_v_recorder.md#oh_avrecorder_getavailableencoder) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_EncoderInfo](_o_h___a_v_recorder___encoder_info.md) \*\*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.|
38| OH_AVErrCode [OH_AVRecorder_SetStateCallback](_a_v_recorder.md#oh_avrecorder_setstatecallback) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_OnStateChange](_a_v_recorder.md#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](_a_v_recorder.md#oh_avrecorder_start) is called.|
39| OH_AVErrCode [OH_AVRecorder_SetErrorCallback](_a_v_recorder.md#oh_avrecorder_seterrorcallback) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_OnError](_a_v_recorder.md#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](_a_v_recorder.md#oh_avrecorder_start) is called.|
40| OH_AVErrCode [OH_AVRecorder_SetUriCallback](_a_v_recorder.md#oh_avrecorder_seturicallback) ([OH_AVRecorder](_a_v_recorder.md#oh_avrecorder) \*recorder, [OH_AVRecorder_OnUri](_a_v_recorder.md#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](_a_v_recorder.md#oh_avrecorder_start) is called.|
41