moosicbox_opus 0.3.0

MoosicBox Opus codec decoder implementation for Symphonia
Documentation

MoosicBox Opus Codec

RFC 6716 compliant Opus audio codec decoder for Symphonia.

Overview

The MoosicBox Opus package provides an Opus audio codec decoder that integrates with the Symphonia multimedia framework. It implements RFC 6716 packet parsing in Rust and uses libopus (via the audiopus crate) for audio decoding.

Features

  • ✅ Complete RFC 6716 packet structure parsing (all code types 0-3)
  • ✅ TOC (Table of Contents) byte interpretation
  • ✅ Frame length decoding with VBR and CBR support
  • ✅ Padding extraction and handling
  • ✅ DTX (Discontinuous Transmission) frame detection
  • ✅ Symphonia Decoder trait implementation
  • ✅ Support for all Opus modes (SILK, CELT, Hybrid) via libopus
  • ✅ Codec registry integration

Installation

[dependencies]
moosicbox_opus = "0.1.1"

Usage

Register the Opus decoder with a Symphonia codec registry:

use symphonia::core::codecs::CodecRegistry;
use moosicbox_opus::register_opus_codec;

let mut registry = CodecRegistry::new();
register_opus_codec(&mut registry);

Or create a registry with default Symphonia codecs plus Opus:

use moosicbox_opus::create_opus_registry;

let registry = create_opus_registry();

Parse Opus packets directly when you need RFC 6716 packet inspection:

use moosicbox_opus::OpusPacket;

let packet_bytes: &[u8] = &[0b0000_0000];
let packet = OpusPacket::parse(packet_bytes)?;
let toc = packet.toc;
let frame_count = packet.frames.len();
let padding_len = packet.padding.len();

Core public API items:

  • register_opus_codec and create_opus_registry for Symphonia integration
  • OpusDecoder (symphonia::core::codecs::Decoder implementation for Opus)
  • OpusPacket and OpusPacket::parse for packet/frame parsing
  • TocByte, OpusMode, and Bandwidth for TOC and mode/bandwidth interpretation
  • OpusFrame, FramePacking, and decode_frame_length for frame-level packet handling

Implementation

This package implements:

  • Packet parsing (packet.rs) - Pure Rust parsing of Opus packet structures
  • TOC handling (toc.rs) - Configuration and mode extraction
  • Frame processing (frame.rs) - Frame length decoding and packing modes
  • Decoder integration (decoder.rs) - Symphonia codec interface with libopus backend
  • Registry (registry.rs) - Codec registration helpers

Audio decoding is performed by libopus through the audiopus crate.

License

Licensed under the same terms as the MoosicBox project.

See Also