Local Audio and Video Recording
Introduces the methods and callbacks used when recording local audio and video streams.
release
Release the IMediaRecorder object.
virtual void release() = 0;
This method releases the IMediaRecorder object and all resources used by the IRtcEngine object.
setMediaRecorderObserver
Registers one IMediaRecorderObserver object.
virtual int setMediaRecorderObserver(const RtcConnection& connection, media::IMediaRecorderObserver* callback) = 0;
Make sure the IRtcEngine is initialized before you call this method.
Parameters
- connection
- The connection information. See RtcConnection.
- callback
- The callbacks for recording local audio and video streams. See IMediaRecorderObserver.
Returns
- 0: Success.
- < 0: Failure.
startRecording
Starts recording the local audio and video.
virtual int startRecording(const RtcConnection& connection, const media::MediaRecorderConfiguration& config) = 0;
After successfully getting the IMediaRecorder object by calling queryInterface, you can call this method to enable the recoridng of the local audio and video.
This method can record the audio captured by the local microphone and encoded in AAC format, and the video captured by the local camera and encoded in H.264 format. The SDK can generate a recording file only when it detects 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 the recording and triggers the onRecorderStateChanged(RECORDER_STATE_ERROR, RECORDER_ERROR_NO_STREAM)
callback.
Once the recording is started, if the video resolution is changed, the SDK stops the recording; if the sampling rate and audio channel changes, the SDK continues recording and generates audio files respectively.
Parameters
- connection
- The connection information. See RtcConnection.
- config
- The recording configuration. See MediaRecorderConfiguration.
Returns
- 0: Success.
- < 0: Failure.
- 2: 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: IRtcEngine does not support the request. The recording is ongoing or the recording stops because an error occurs.
- 7: A method is called before IRtcEngine is initialized. .
- 2: The parameter is invalid. Ensure the following:
stopRecording
Stops recording the local audio and video.
virtual int stopRecording(const RtcConnection& connection) = 0;
Parameters
- connection
- The connection information. See RtcConnection.
Returns
- 0: Success.
- < 0: Failure.
- -7: A method is called before IRtcEngine is initialized.
onRecorderInfoUpdated
Occurs when the recording information is updated.
virtual void onRecorderInfoUpdated(const RecorderInfo& info){};
After you successfully enable the local audio and video recording, the SDK periodically triggers this callback based on the value of recorderInfoUpdateInterval set in MediaRecorderConfiguration. This callback reports the file name, duration, and size of the current recording file.
Parameters
- info
- The information about the file that is recorded. See RecorderInfo.
onRecorderStateChanged
Occurs when the recording state changes.
virtual void onRecorderStateChanged(RecorderState state, RecorderErrorCode error) = 0;
When the local audio or video recording state changes, the SDK triggers this callback to report the current recording state and the reason for the change.
Parameters
- state
- The current recording state. See RecorderState.
- error
- The reason for the state change. See RecorderErrorCode.