YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.audio.MediaCodecOpusEncoder Class Reference

Opus through the platform's audio/opus encoder (MediaCodec, synchronous mode, API 29 and newer, no new dependency). More...

Inheritance diagram for de.yaacc.audio.MediaCodecOpusEncoder:
Inheritance graph
Collaboration diagram for de.yaacc.audio.MediaCodecOpusEncoder:
Collaboration graph

Public Member Functions

synchronized byte[] encode (byte[] pcm)
 
synchronized void close ()
 Frees the encoder.
 
- Public Member Functions inherited from de.yaacc.audio.OpusPacketEncoder

Static Public Member Functions

static OpusEncoderFactory factory ()
 The factory for the Snapcast server and the Sendspin hub: it checks that the device has an Opus encoder.
 

Detailed Description

Opus through the platform's audio/opus encoder (MediaCodec, synchronous mode, API 29 and newer, no new dependency).

One call takes one chunk of 20 ms and gives the first packet the encoder has ready; the packet of the first call may come later (the encoder has a look-ahead), which shifts the packets by one chunk at most and is no problem: the stamp of a chunk is the production time, and a missing packet is a hole that the clients fill. Thin glue, not unit tested.

Guesses that need a device: that the first output buffer is the configuration (flagged as such) and is skipped, that one input buffer of 20 ms gives one packet of 20 ms, and that 128 kbit/s stereo is what the encoder accepts.

Member Function Documentation

◆ close()

synchronized void de.yaacc.audio.MediaCodecOpusEncoder.close ( )

Frees the encoder.

Safe to call twice.

Implements de.yaacc.audio.OpusPacketEncoder.

◆ encode()

synchronized byte[] de.yaacc.audio.MediaCodecOpusEncoder.encode ( byte[] pcm)
Parameters
pcmone chunk: 960 frames of 16 bit stereo, little endian (20 ms at 48000 Hz)
Returns
the Opus packet for it, or null when the encoder gave none (the chunk is then left out)

Implements de.yaacc.audio.OpusPacketEncoder.


The documentation for this class was generated from the following file: