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)
      Parameters:
      callback - The callback for audio and video stream recording. See `IMediaRecorderCallback` for details.
      Returns:
      - 0: The method call succeeds. - < 0: The method call fails. See `Error Codes` for details and troubleshooting suggestions.
      Since:
      v4.0.0
    • startRecording

      public int startRecording(AgoraMediaRecorder.MediaRecorderConfiguration config)
      Parameters:
      config - The configuration for audio and video stream recording. See `MediaRecorderConfiguration`.
      Returns:
      - 0: The method call succeeds. - < 0: The method call fails. See `Error Codes` for details and troubleshooting. - -2: Invalid parameter. Make sure that: - The specified file path for saving the recording is correct and writable. - The specified recording file format is correct. - The maximum recording duration is set correctly. - -4: The current state of `RtcEngine` does not support this operation. This may occur if recording is already in progress or if it stopped due to an error. - -7: The method is called before `RtcEngine` is initialized. Make sure you have created the `AgoraMediaRecorder` object before calling this method.
    • stopRecording

      public int stopRecording()
      Returns:
      - 0: The method call succeeds. - < 0: The method call fails: - -7: The method is called before the `RtcEngine` is initialized. Make sure that the `Recorder` object has been created before calling this method.
    • release

      public void release()