Package io.agora.rtc2
Class AgoraMediaRecorder
java.lang.Object
io.agora.rtc2.AgoraMediaRecorder
The `AgoraMediaRecorder` class, for recording the audio and video on the client.
`AgoraMediaRecorder` can record the following content:
- The audio captured by the local microphone and encoded in AAC format by the SDK.
- The video captured by the local camera and encoded by the SDK.
- Since:
- v3.5.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfigurations for the local audio and video recording. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int1: MP4 format.static final int4: The recording configuration changes.static final int2: The SDK does not detect audio and video streams to be recorded, or audio and video streams are interrupted for more than five seconds during recording.static final int0: No error occurs.static final int3: The recording duration exceeds the upper limit.static final int1: The SDK fails to write the recorded data to a file.static final int-1: An error occurs during the recording.static final int2: The audio and video recording is started.static final int3: The audio and video recording is stopped.static final int1: Record audio only.static final int3: Record both audio and video.static final int2: Record video only. -
Constructor Summary
ConstructorsConstructorDescriptionAgoraMediaRecorder(io.agora.rtc2.internal.RtcEngineImpl engine, RecorderStreamInfo info) -
Method Summary
Modifier and TypeMethodDescriptionvoidrelease()intRegisters the IMediaRecorderCallback object.intStarts recording the local or remote audio and video.intStops recording the audio and video.
-
Field Details
-
RECORDER_STATE_ERROR
public static final int RECORDER_STATE_ERROR-1: An error occurs during the recording. See `error` message for the reason.- See Also:
-
RECORDER_STATE_START
public static final int RECORDER_STATE_START2: The audio and video recording is started.- See Also:
-
RECORDER_STATE_STOP
public static final int RECORDER_STATE_STOP3: The audio and video recording is stopped.- See Also:
-
RECORDER_REASON_NONE
public static final int RECORDER_REASON_NONE0: No error occurs.- See Also:
-
RECORDER_REASON_WRITE_FAILED
public static final int RECORDER_REASON_WRITE_FAILED1: The SDK fails to write the recorded data to a file.- See Also:
-
RECORDER_REASON_NO_STREAM
public static final int RECORDER_REASON_NO_STREAM2: The SDK does not detect audio and video streams to be recorded, or audio and video streams are interrupted for more than five seconds during recording.- See Also:
-
RECORDER_REASON_OVER_MAX_DURATION
public static final int RECORDER_REASON_OVER_MAX_DURATION3: The recording duration exceeds the upper limit.- See Also:
-
RECORDER_REASON_CONFIG_CHANGED
public static final int RECORDER_REASON_CONFIG_CHANGED4: The recording configuration changes.- See Also:
-
STREAM_TYPE_AUDIO
public static final int STREAM_TYPE_AUDIO1: Record audio only.- See Also:
-
STREAM_TYPE_VIDEO
public static final int STREAM_TYPE_VIDEO2: Record video only.- See Also:
-
STREAM_TYPE_BOTH
public static final int STREAM_TYPE_BOTH3: Record both audio and video.- See Also:
-
CONTAINER_MP4
public static final int CONTAINER_MP41: MP4 format.- See Also:
-
-
Constructor Details
-
AgoraMediaRecorder
-
-
Method Details
-
setMediaRecorderObserver
Registers the IMediaRecorderCallback object.- Parameters:
callback- The callbacks for recording audio and video streams. SeeIMediaRecorderCallback.- Returns:
- IMediaRecorder
- Since:
- v4.0.0
-
startRecording
Starts recording the local or remote audio and video. After successfully callingcreateMediaRecorderto get the media recorder object, you can call this method to enable the recording of the local audio and video. This method can record the following content: - The audio captured by the local microphone and encoded in AAC format. - The video captured by the local camera and encoded by the SDK. This method can record the following content: - The audio received from remote users and encoded in AAC format. - The video received from remote users. The SDK can generate a recording file only when it detects the recordable audio and video streams; when there are no audio and video streams to be recorded or the audio and video streams are interrupted for more than five seconds, the SDK stops recording and triggers theonRecorderStateChanged(RECORDER_STATE_ERROR, RECORDER_ERROR_NO_STREAM)callback.- Parameters:
config- The recording configurations. SeeMediaRecorderConfiguration.- Returns:
- - 0: Success.
- < 0: Failure:
- `-1(ERR_FAILED)`: IRtcEngine does not support the request due to one of the following
reasons:
- During remote recording, There is no subscription to the target channel or user。
- -2(`ERR_INVALID_ARGUMENT`): The parameter is invalid. Ensure the following:
- The specified path of the recording file exists and is writable.
- The specified format of the recording file is supported.
- The maximum recording duration is correctly set.
- During remote recording, ensure the user whose media streams you want record did join
the channel.
- -4(`ERR_NOT_SUPPORTED`): `RtcEngine` does not support the request due to one of the
following reasons:
- The recording is ongoing.
- The recording stops because an error occurs.
- No
IMediaRecorderCallbackobject is registered.
-
stopRecording
public int stopRecording()Stops recording the audio and video.- Returns:
- - 0: Success.
- < 0: Failure:
- -7(`ERR_NOT_INITIALIZED`): This method is called before the initialization of
`RtcEngine`. Ensure that you have called
getMediaRecorderbefore calling `startRecording`.
-
release
public void release()
-