Agora C++ API Reference for All Platforms

Public Member Functions | Protected Member Functions | List of all members
agora::rtc::IMediaRecorder Class Referenceabstract

Inherits agora::RefCountInterface.

Inherited by agora::rtc::IMediaRecorder2.

## Public Member Functions
virtual int | setMediaRecorderObserver (media::IMediaRecorderObserver *callback)=0
virtual int | startRecording (const media::MediaRecorderConfiguration &config)=0
virtual int | stopRecording ()=0
Public Member Functions inherited from agora::RefCountInterface
virtual void | AddRef () const =0
virtual RefCountReleaseStatus | Release () const =0
virtual bool | HasOneRef () const =0

## Protected Member Functions
virtual | ~IMediaRecorder ()
Protected Member Functions inherited from agora::RefCountInterface
virtual | ~RefCountInterface ()

## Constructor & Destructor Documentation

## ◆ ~IMediaRecorder()

virtual agora::rtc::IMediaRecorder::~IMediaRecorder | ( |  | ) |
| inline protected virtual

## Member Function Documentation

## ◆ setMediaRecorderObserver()

virtual int agora::rtc::IMediaRecorder::setMediaRecorderObserver | ( | media::IMediaRecorderObserver * | callback | ) |
| pure virtual

Registers the IMediaRecorderObserver object.

Since
  v4.0.0

Note
  Call this method before the startRecording method.

Parameters

  callback | The callbacks for recording audio and video streams. See IMediaRecorderObserver.

Returns
  - 0(ERR_OK): Success.
  - < 0: Failure:

## ◆ startRecording()

virtual int agora::rtc::IMediaRecorder::startRecording | ( | const media::MediaRecorderConfiguration & | config | ) |
| pure virtual

Starts recording the local or remote audio and video.

Since
  v4.0.0

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.
- 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.

Note
  Call this method after joining the channel.

Parameters

  config | The recording configurations. See MediaRecorderConfiguration.

Returns
  - 0(ERR_OK): Success.
  - < 0: Failure:
    - `-1(ERR_FAILED)`: IRtcEngine does not support the request because the remote user did not subscribe to the target channel or the media streams published by the local user during remote recording.
    - `-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)`: IRtcEngine does not support the request due to one of the following reasons:
      - The recording is ongoing.
      - The recording stops because an error occurs.
      - No IMediaRecorderObserver object is registered.

## ◆ stopRecording()

virtual int agora::rtc::IMediaRecorder::stopRecording | ( |  | ) |
| pure virtual

Stops recording the audio and video.

Since
  v4.0.0

Note
  After calling startRecording, if you want to stop the recording, you must call `stopRecording`; otherwise, the generated recording files might not be playable.

Returns
  - 0(ERR_OK): Success.
  - < 0: Failure: