enableAudioFrameCallback method

Future<int?> enableAudioFrameCallback({
  1. required AudioFrameCallbackMethod method,
  2. required AudioFormat format,
})

@detail api @author gongzhengduo @brief Enable audio frames callback and set the format for the specified type of audio frames. @param method Audio data callback method. See AudioFrameCallbackMethod{@link #AudioFrameCallbackMethod}.
If method is set as AUDIO_FRAME_CALLBACK_RECORD(0), AUDIO_FRAME_CALLBACK_PLAYBACK(1), AUDIO_FRAME_CALLBACK_MIXED(2), or AUDIO_FRAME_CALLBACK_CAPTURE_MIXED(5), set format to the accurate value listed in the audio parameters format.
If method is set as AUDIO_FRAME_CALLBACK_REMOTE_USER(3), set format to auto. @param format Audio parameters format. See AudioFormat{@link #AudioFormat}. @return - 0: Success. - < 0 : Fail. See ReturnStatus{@link #ReturnStatus} for more details @note After calling this API and registerAudioFrameObserver{@link #RTCEngine#registerAudioFrameObserver}, IAudioFrameObserver{@link #IAudioFrameObserver} will receive the corresponding audio data callback. However, these two APIs are independent of each other and the calling order is not restricted.

Implementation

Future<int?> enableAudioFrameCallback(
    {required AudioFrameCallbackMethod method,
    required AudioFormat format}) async {
  $a() => ($instance as $p_a.RTCEngine).enableAudioFrameCallback(
      t_AudioFrameCallbackMethod.code_to_android(method),
      unpackObject<$p_a.AudioFormat>(format));
  $i() => ($instance as $p_i.ByteRTCEngine).enableAudioFrameCallback(
      t_AudioFrameCallbackMethod.code_to_ios(method),
      unpackObject<$p_i.ByteRTCAudioFormat>(format));

  if (Platform.isAndroid) {
    return $a();
  } else if (Platform.isIOS) {
    return $i();
  } else {
    throw UnsupportedError(
        'Not Support Platform ${Platform.operatingSystem}');
  }
}