Package io.agora.rtc2

Class AgoraMediaRecorder

java.lang.Object
io.agora.rtc2.AgoraMediaRecorder

public class AgoraMediaRecorder extends Object
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
  • 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_START
      2: The audio and video recording is started.
      See Also:
    • RECORDER_STATE_STOP

      public static final int RECORDER_STATE_STOP
      3: The audio and video recording is stopped.
      See Also:
    • RECORDER_REASON_NONE

      public static final int RECORDER_REASON_NONE
      0: No error occurs.
      See Also:
    • RECORDER_REASON_WRITE_FAILED

      public static final int RECORDER_REASON_WRITE_FAILED
      1: The SDK fails to write the recorded data to a file.
      See Also:
    • RECORDER_REASON_NO_STREAM

      public static final int RECORDER_REASON_NO_STREAM
      2: 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_DURATION
      3: The recording duration exceeds the upper limit.
      See Also:
    • RECORDER_REASON_CONFIG_CHANGED

      public static final int RECORDER_REASON_CONFIG_CHANGED
      4: The recording configuration changes.
      See Also:
    • STREAM_TYPE_AUDIO

      public static final int STREAM_TYPE_AUDIO
      1: Record audio only.
      See Also:
    • STREAM_TYPE_VIDEO

      public static final int STREAM_TYPE_VIDEO
      2: Record video only.
      See Also:
    • STREAM_TYPE_BOTH

      public static final int STREAM_TYPE_BOTH
      3: Record both audio and video.
      See Also:
    • CONTAINER_MP4

      public static final int CONTAINER_MP4
      1: MP4 format.
      See Also:
  • Constructor Details

    • AgoraMediaRecorder

      public AgoraMediaRecorder(io.agora.rtc2.internal.RtcEngineImpl engine, RecorderStreamInfo info)
  • Method Details

    • setMediaRecorderObserver

      public int setMediaRecorderObserver(IMediaRecorderCallback callback)
      Registers the IMediaRecorderCallback object.
      Parameters:
      callback - The callbacks for recording audio and video streams. See IMediaRecorderCallback.
      Returns:
      IMediaRecorder
      Since:
      v4.0.0
    • startRecording

      public int startRecording(AgoraMediaRecorder.MediaRecorderConfiguration config)
      Starts recording the local or remote audio and video. After successfully calling createMediaRecorder to 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 the onRecorderStateChanged(RECORDER_STATE_ERROR, RECORDER_ERROR_NO_STREAM) callback.
      Parameters:
      config - The recording configurations. See MediaRecorderConfiguration.
      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 IMediaRecorderCallback object 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 getMediaRecorder before calling `startRecording`.
    • release

      public void release()