Interface LocalAudioFrameListener
-
- All Implemented Interfaces:
public interface LocalAudioFrameListenerListener for local audio recording events.
Callbacks allow observing and modifying the raw PCM audio captured from the microphone before it is passed to the WebRTC engine for encoding and transmission.
Register via AudioController.setLocalAudioFrameListener.
Threading: all callbacks are delivered on the same dedicated high-priority audio thread (
THREAD_PRIORITY_URGENT_AUDIO), in the order onAudioRecordingStarted, onAudioFrame, onAudioRecordingStopped. Implementations must not block — any significant delay will cause audio glitches.
-
-
Method Summary
Modifier and Type Method Description UnitonAudioRecordingStarted(AudioRecordInfo record)Called when audio recording has started, before the first onAudioFrame call. UnitonAudioRecordingStopped(AudioRecordInfo record)Called when audio recording has stopped, after the final onAudioFrame call. abstract BooleanonAudioFrame(AudioRecordInfo record, Integer bytesRead, ByteBuffer byteBuffer)Called for every 10 ms audio buffer captured from the microphone, before it is handed to the WebRTC engine. -
-
Method Detail
-
onAudioRecordingStarted
Unit onAudioRecordingStarted(AudioRecordInfo record)
Called when audio recording has started, before the first onAudioFrame call.
Optional — override to initialise per-session state that depends on the recording parameters (e.g. pre-computing per-sample phase increments for DSP, allocating format-specific buffers). A single listener may observe several recording sessions; this is invoked at the start of each one.
- Parameters:
record- Recording configuration in use.
-
onAudioRecordingStopped
Unit onAudioRecordingStopped(AudioRecordInfo record)
Called when audio recording has stopped, after the final onAudioFrame call.
Optional — override to release any resources allocated in onAudioRecordingStarted.
- Parameters:
record- Recording configuration that was in use.
-
onAudioFrame
abstract Boolean onAudioFrame(AudioRecordInfo record, Integer bytesRead, ByteBuffer byteBuffer)
Called for every 10 ms audio buffer captured from the microphone, before it is handed to the WebRTC engine.
The byteBuffer may be modified in-place to transform the audio before it reaches WebRTC (e.g. gain adjustment, filtering, ring modulation).
The buffer contains interleaved PCM samples in the format and sample rate described by record. 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:
record- Recording configuration in use.bytesRead- Number of bytes populated in byteBuffer.byteBuffer- Buffer containing the raw PCM samples.- Returns:
trueto pass the buffer contents (as-is or modified) to WebRTC;falseto discard the buffer and send silence for this frame instead.
-
-
-
-