Interface RemoteAudioFrameListener
-
- All Implemented Interfaces:
public interface RemoteAudioFrameListenerListener 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.
-
-
Method Summary
Modifier and Type Method Description UnitonAudioPlayoutStarted(AudioPlayoutInfo track)Called when remote audio playout has started, before the first onAudioFrame call. UnitonAudioPlayoutStopped(AudioPlayoutInfo track)Called when remote audio playout has stopped, after the final onAudioFrame call; no further buffers will be delivered for this session. abstract BooleanonAudioFrame(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. -
-
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:
trueto play out the buffer contents (as-is or modified);falseto discard the buffer and play silence for this frame instead.
-
-
-
-