OpusCodec

class OpusCodec(val rate: Int = 16000, val bitrate: Int = 32000, complexity: Int = 3) : VoiceCodec(source)

Opus through Concentus (a pure-Java port of libopus): encode/decode are synchronous calls on the audio thread, so a frame leaves the moment it is encoded. MediaCodec added 5–6 ms of IPC per frame and could hand back a frame one call late (a full extra 20 ms), and it exposes none of the voice settings.

Settings: VOIP application (speech-tuned, high-pass + noise shaping), voice signal hint, wideband (the cellular codec is AMR-WB / EVS-WB: nothing above 8 kHz comes down the line), 32 kbps constrained VBR (transparent for wideband speech), complexity 3: paced like a call (one frame per 20 ms, release build compiled ahead of time) it costs 3.7 ms per frame on the Android phone vs 5.2 ms at 5 (codec_bench_paced); speech quality at 32 kbps wideband barely changes. No DTX (a playout buffer reads DTX gaps as underruns) and no in-band FEC: L2CAP is a reliable channel, frames only go missing when we drop them for lateness.

Constructors

Link copied to clipboard
constructor(rate: Int = 16000, bitrate: Int = 32000, complexity: Int = 3)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
open override val id: Int
Link copied to clipboard
open override val name: String
Link copied to clipboard
open override val rate: Int

Functions

Link copied to clipboard
open override fun conceal(): ShortArray?

Packet-loss concealment: a synthetic frame for a missing one (null = play nothing).

Link copied to clipboard
open override fun decode(frame: ByteArray): ShortArray?
Link copied to clipboard
open override fun encode(pcm: ShortArray): List<ByteArray>
Link copied to clipboard
open fun release()