Interface RemoteAudioFrameListener

  • All Implemented Interfaces:

    
    public interface RemoteAudioFrameListener
    
                        

    Listener for remote audio playout events.

    Callbacks allow observing and modifying the decoded PCM audio received from the remote party before it is written to the audio output device.

    Register via AudioController.setRemoteAudioFrameListener.

    Threading: all callbacks are delivered on the same dedicated high-priority audio thread (THREAD_PRIORITY_URGENT_AUDIO), in the order onAudioPlayoutStarted, onAudioFrame, onAudioPlayoutStopped. Implementations must not block — any significant delay will cause audio glitches or jitter on the local end.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • onAudioPlayoutStarted

         Unit onAudioPlayoutStarted(AudioPlayoutInfo track)

        Called when remote audio playout has started, before the first onAudioFrame call.

        Optional — override to initialise per-session state that depends on the playout parameters (e.g. pre-computing per-sample phase increments for DSP, allocating format-specific buffers). A single listener may observe several playout sessions; this is invoked at the start of each one.

        Parameters:
        track - Playout configuration in use.
      • onAudioPlayoutStopped

         Unit onAudioPlayoutStopped(AudioPlayoutInfo track)

        Called when remote audio playout has stopped, after the final onAudioFrame call; no further buffers will be delivered for this session. Audio already handed to the output device may continue to play out briefly after this call.

        Optional — override to release any resources allocated in onAudioPlayoutStarted.

        Parameters:
        track - Playout configuration that was in use.
      • onAudioFrame

         abstract Boolean onAudioFrame(AudioPlayoutInfo track, Integer bytesAvailable, ByteBuffer byteBuffer)

        Called for every 10 ms audio buffer received from the remote party, before it is written to the audio output device.

        The byteBuffer may be modified in-place to transform the audio before it is played out (e.g. gain adjustment, filtering, ring modulation).

        The buffer contains interleaved PCM samples in the format and sample rate described by track. For android.media.AudioFormat.ENCODING_PCM_16BIT, each sample is a little-endian Short; use byteBuffer.order(ByteOrder.nativeOrder()).asShortBuffer() to iterate samples conveniently.

        Parameters:
        track - Playout configuration in use.
        bytesAvailable - Number of bytes populated in byteBuffer.
        byteBuffer - Buffer containing the decoded PCM samples.
        Returns:

        true to play out the buffer contents (as-is or modified); false to discard the buffer and play silence for this frame instead.