pullExternalAudioFrame method

Future<int?> pullExternalAudioFrame(
  1. AudioFrame audioFrame
)

@detail api @author gongzhengduo @brief Pulls audio data for external playback.
After calling this method, the SDK will actively fetch the audio data to play, including the decoded and mixed audio data from the remote source, for external playback. @param audioFrame Audio data frame. See AudioFrame{@link #AudioFrame} @return Method call result
- 0: Setup succeeded - < 0: Setup failed @note - Before pulling external audio data, setAudioRenderType{@link #RTCEngine#setAudioRenderType} must be called Enable custom audio rendering. - You should pull audio data every 10 milliseconds since the duration of a RTC SDK audio frame is 10 milliseconds. Samples x call frequency = audioFrame's sample rate. Assume that the sampling rate is set to 48000, call this API every 10 ms, so that 480 sampling points should be pulled each time. - The audio sampling format is S16. The data format in the audio buffer is PCM data, and its capacity size is audioFrame.samples × audioFrame.channel × 2.

Implementation

Future<int?> pullExternalAudioFrame(AudioFrame audioFrame) async {
  $a() => ($instance as $p_a.RTCEngine)
      .pullExternalAudioFrame(unpackObject<$p_a.AudioFrame>(audioFrame));
  $i() => ($instance as $p_i.ByteRTCEngine).pullExternalAudioFrame(
      unpackObject<$p_i.ByteRTCAudioFrame>(audioFrame));

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