Voice SDK v3.7.1 API Reference for All Platforms (C++)
agora::rtc::IMediaRecorder Class Referenceabstract

Public Member Functions

virtual int startRecording (const MediaRecorderConfiguration &config)=0
 
virtual int stopRecording ()=0
 
virtual void releaseRecorder ()=0
 

Static Public Member Functions

static AGORA_CPP_API IMediaRecordergetMediaRecorder (IRtcEngine *engine, IMediaRecorderObserver *callback)
 

Detailed Description

The IMediaRecorder class, for recording the audio and video on the client. IMediaRecorder 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.
Since
v3.5.2
Note
In the COMMUNICATION channel profile, this function is unavailable when there are users using versions of the SDK earlier than v3.0.0 in the channel.

Member Function Documentation

◆ getMediaRecorder()

static AGORA_CPP_API IMediaRecorder* agora::rtc::IMediaRecorder::getMediaRecorder ( IRtcEngine engine,
IMediaRecorderObserver callback 
)
static

Gets the IMediaRecorder object.

Since
v3.5.2
Note
Call this method after initializing the IRtcEngine object.
Parameters
engineIRtcEngine
callbackIMediaRecorderObserver
Returns
IMediaRecorder

◆ startRecording()

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

Starts recording the local audio and video.

Since
v3.5.2

After successfully getting the 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 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
configThe recording configurations. See MediaRecorderConfiguration.
Returns
  • 0(ERR_OK): Success.
  • < 0: Failure:
    • -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.
    • -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.
    • -7(ERR_NOT_INITIALIZED): This method is called before the initialization of IRtcEngine. Ensure that you have called getMediaRecorder before calling startRecording.

◆ stopRecording()

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

Stops recording the local audio and video.

Since
v3.5.2
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:
    • -7(ERR_NOT_INITIALIZED): This method is called before the initialization of IRtcEngine. Ensure that you have called getMediaRecorder before calling stopRecording.

◆ releaseRecorder()

virtual void agora::rtc::IMediaRecorder::releaseRecorder ( )
pure virtual

Releases the IMediaRecorder object.

Since
v3.5.2

This method releases the IRtcEngine object and all other resources used by the IMediaRecorder object. After calling this method, if you want to enable the recording again, you must call getMediaRecorder to get the IMediaRecorder object.