Example #1
0
        /** Pulls the remote audio data.
         *
         * Before calling this method, call the {@link agora_gaming_rtc.IRtcEngine.SetExternalAudioSink SetExternalAudioSink(enabled: true)} method to enable and set the external audio sink.
         *
         * After a successful method call, the app pulls the decoded and mixed audio data for playback.
         *
         * @note
         * - Once you call the `PullAudioFrame` method successfully, the app will not retrieve any audio data from the {@link agora_gaming_rtc.AudioRawDataManager.OnPlaybackAudioFrameHandler OnPlaybackAudioFrameHandler} callback.
         * - The difference between the `OnPlaybackAudioFrameHandler` callback and the `PullAudioFrame` method is as follows:
         *   - `OnPlaybackAudioFrameHandler`: The SDK sends the audio data to the app through this callback. Any delay in processing the audio frames may result in audio jitter.
         *   - `PullAudioFrame`: The app pulls the remote audio data. After setting the audio data parameters, the SDK adjusts the frame buffer and avoids problems caused by jitter in the external audio playback.
         *
         * @param audioBuffer The data buffer of the audio frame. When the audio frame uses a stereo channel, the data buffer is interleaved. The size of the data buffer is as follows: `audioBuffer` = `samples` × `channels` × `bytesPerSample`.
         * @param type The type of the audio frame. See #AUDIO_FRAME_TYPE.
         * @param samples The number of samples per channel in the audio frame.
         * @param bytesPerSample The number of bytes per audio sample, which is usually 16-bit (2-byte).
         * @param channels The number of audio channels.
         * - 1: Mono
         * - 2: Stereo (the data is interleaved)
         * @param samplesPerSec The sample rate.
         * @param renderTimeMs The timestamp of the external audio frame. You can use this parameter for the following purposes:
         * - Restore the order of the captured audio frame.
         * - Synchronize audio and video frames in video-related scenarios, including where external video sources are used.
         * @param avsync_type The reserved parameter.
         *
         * @return
         * - 0: Success.
         * - < 0: Failure.
         */
        public override int PullAudioFrame(IntPtr audioBuffer, int type, int samples, int bytesPerSample, int channels, int samplesPerSec, long renderTimeMs, int avsync_type)
        {
            if (_irtcEngine == null)
            {
                return((int)ERROR_CODE.ERROR_NOT_INIT_ENGINE);
            }

            return(IRtcEngineNative.pullAudioFrame_(audioBuffer, type, samples, bytesPerSample, channels, samplesPerSec, renderTimeMs, avsync_type));
        }