opus_dart library

Classes

BufferedOpusDecoder
An implementation of OpusDecoder that uses preallocated buffers. Don't forget to call destroy once you are done with it.
BufferedOpusEncoder
An implementation of OpusEncoder that uses preallocated buffers. Don't forget to call destroy once you are done with it.
OpusDecoder
Abstract base class for opus decoders.
OpusEncoder
Abstract base class for opus encoders.
OpusPacketUtils
Bundles utility functions to examine opus packets.
SimpleOpusDecoder
An easy to use implementation of OpusDecoder. Don't forget to call destroy once you are done with it.
SimpleOpusEncoder
An easy to use implementation of OpusEncoder. Don't forget to call destroy once you are done with it.
StreamOpusDecoder
Used to decode a stream of opus packets to pcm data. Each element in the input stream MUST contain a whole opus packet. A null element in the input stream is interpreted as packet loss.
StreamOpusEncoder<T>
Used to encode a stream of pcm data to opus frames of constant time. Each StreamOpusEncoder MUST ONLY be used once!

Enums

Application
Represents the different application types an OpusEncoder supports. Setting the right application type when creating an encoder can improve quality.
FrameTime
Represents different frame times supported by opus.

Constants

bytesPerFloatSample → const int
Byte width of a single float PCM sample (Float32).
bytesPerInt16Sample → const int
Byte width of a single s16le PCM sample (Int16).
maxDataBytes → const int
Max bitstream size of a single opus packet.
maxStringLength → const int
Upper bound for null-terminated string scans to prevent unbounded loops when a pointer is invalid or lacks a terminator.

Functions

getOpusVersion() String
Returns the version of the native libopus library.
initOpus(Object opusLib) → void
Must be called to initialize this library.
maxSamplesPerPacket(int sampleRate, int channels) int
Calculates, how many samples a single opus packet at sampleRate with channels may contain.
pcmSoftClip({required Float32List input, required int channels}) Float32List
Soft clips the input to a range from -1 to 1 and returns the result.

Exceptions / Errors

OpusDestroyedError
Thrown when attempting to call a method on an already destroyed encoder or decoder.
OpusException
Thrown when a native exception occurs.
UnfinishedFrameException
Thrown if an StreamOpusEncoder finished with insufficient samples left to produce a final frame.