Agora RTC Objective-C API Reference Refactor

Instance Methods
AgoraMediaRecorder Class Reference

Inherits <NSObject>.

## Instance Methods
(int) | - setMediaRecorderDelegate:
(int) | - startRecording:
(int) | - stopRecording

## Method Documentation

## ◆ setMediaRecorderDelegate:

- (int) setMediaRecorderDelegate: |  | (id< AgoraMediaRecorderDelegate > _Nullable) | delegate |

Registers the AgoraMediaRecorderDelegate delegate.

Since
  v4.0.0

Note
  Call this method before the startRecording method.

Parameters

  delegate | The callbacks for recording audio and video streams. See AgoraMediaRecorderDelegate

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

## ◆ startRecording:

- (int) startRecording: |  | (AgoraMediaRecorderConfiguration *_Nonnull) | config |

Starts recording the local audio and video.

Since
  v4.0.0

After successfully calling createMediaRecorder: (AgoraRtcEngineKit) 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 stateDidChanged (AgoraMediaRecorderState, AgoraMediaRecorderReasonCode) callback.

Note
  Call this method after joining the channel.

Parameters

  config | The recording configurations. See AgoraMediaRecorderConfiguration object.

Returns
  - 0(ERR_OK): 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)`: 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 AgoraMediaRecorderDelegate object is registered.

## ◆ stopRecording

- (int) stopRecording |  |  |

Stops recording the audio and video.

Since
  v4.0.0

Note
  After calling startRecording: 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: Stop recording.
  0: Success. < 0: Failure.