SinchLocalAudioFrameDelegate
public protocol SinchLocalAudioFrameDelegate : AnyObject
The delegate for local audio recording events.
The callbacks allow observing and modifying the raw PCM audio captured from the microphone before it is handed to the WebRTC engine for processing, encoding and transmission.
Assign via SinchAudioController.localAudioFrameDelegate.
Important
All callbacks are delivered synchronously on the SDK’s internal real-time audio threads, in the orderaudioRecordingDidStart(with:),
onLocalAudioFrame(_:), audioRecordingDidStop(with:). Implementations
must not block — any significant delay will cause audio glitches.
-
Called for every 10 ms audio buffer captured from the microphone, before it is handed to the WebRTC engine.
The frame contains interleaved 16-bit PCM samples; the sample rate and the number of channels are described by
frame.format. The samples may be modified in-place (viaframe.int16ChannelData) to transform the audio before it reaches WebRTC (e.g. gain adjustment, filtering).Important
The frame buffer is only valid for the duration of this method call and must not be retained or accessed afterwards.
Declaration
Swift
func onLocalAudioFrame(_ frame: AVAudioPCMBuffer) -> BoolParameters
frameBuffer containing the raw PCM samples. Safe to read and modify in-place.
Return Value
trueto pass the frame contents (as-is or modified) to WebRTC;falseto discard the frame and send silence instead. -
audioRecordingDidStart(with:Default implementation) Called when audio recording has started, before the first
onLocalAudioFrame(_:)call.Optional — implement to initialize per-session state that depends on the recording format. A single delegate may observe several recording sessions; this is invoked at the start of each one.
Default Implementation
Declaration
Swift
func audioRecordingDidStart(with format: AVAudioFormat)Parameters
formatRecording format in use.
-
audioRecordingDidStop(with:Default implementation) Called when audio recording has stopped, after the final
onLocalAudioFrame(_:)call.Optional — implement to release any resources allocated in
audioRecordingDidStart(with:).Default Implementation
Declaration
Swift
func audioRecordingDidStop(with format: AVAudioFormat)Parameters
formatRecording format that was in use.