BufferAudioSource

class BufferAudioSource(bufferCapacityMs: Int = 1000, latencyMs: Int = 100) : AudioSource, GetMicrophoneData

Created by pedro on 17/7/26.

Audio source backed by a synthetic PCM buffer (silence) consumed at fixed intervals. Use setBuffer to replace parts of the synthetic buffer with real PCM data. Consumed regions are restored to silence, so if no data is provided silence is streamed.

Parameters

bufferCapacityMs

capacity of the synthetic buffer in milliseconds.

latencyMs

extra buffering applied to setBuffer data to absorb producer jitter. Higher values avoid dropped data and glitches with irregular producers at the cost of latency. The delay is compensated in the frame timestamps, so it produces no av desync.

Constructors

Link copied to clipboard
constructor(bufferCapacityMs: Int = 1000, latencyMs: Int = 100)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun init(sampleRate: Int, isStereo: Boolean, echoCanceler: Boolean, noiseSuppressor: Boolean): Boolean
Link copied to clipboard
open override fun inputPCMData(frame: Frame)
Link copied to clipboard
open override fun isRunning(): Boolean
Link copied to clipboard
open override fun release()
Link copied to clipboard
fun setBuffer(pcmBuffer: ByteArray, offset: Int = 0, size: Int = pcmBuffer.size): Int

Replace the corresponding part of the synthetic buffer with PCM data. Data exceeding the buffer capacity is discarded.

fun setBuffer(pcmBuffer: ByteArray, timestampMicro: Long, offset: Int = 0, size: Int = pcmBuffer.size): Int

Replace the part of the synthetic buffer matching the provided timestamp.

Link copied to clipboard
open override fun start(getMicrophoneData: GetMicrophoneData)
Link copied to clipboard
open override fun stop()