Introduction
The Symphonia core API provides the fundamental building blocks for audio decoding and media format demuxing in pure Rust. The core consists of several key components that work together to detect, read, and decode audio files.Core Components
Probe
TheProbe is responsible for auto-detecting media formats from arbitrary streams. It uses format descriptors and byte markers to identify the container format and instantiate the appropriate reader.
Key features:
- Automatic format detection from stream data
- Support for format hints (file extensions, MIME types)
- Progressive metadata discovery
- Registration-based format support
FormatReader
TheFormatReader trait defines the interface for container demuxers. It provides methods to read tracks, extract packets, seek within the media, and access metadata.
Key features:
- Track enumeration and selection
- Packet extraction from interleaved streams
- Sample-accurate seeking with multiple modes
- Metadata and cue point access
- Gapless playback support
Decoder
TheDecoder trait implements codec decode algorithms. Decoders consume packets from a FormatReader and produce decoded audio buffers.
Key features:
- Codec-specific decoding implementations
- Audio buffer generation
- Verification and validation support
- Reset capability for seeking
CodecRegistry
TheCodecRegistry manages codec registration and instantiation. It maps codec types to decoder implementations and provides a factory interface.
Key features:
- Dynamic codec registration
- Codec descriptor queries
- Decoder instantiation
- Multi-codec support
Typical Workflow
Type Hierarchy
Format Detection Flow
- Hint - Optional format hints (extension, MIME type)
- Probe - Scans stream for format markers
- Descriptor - Format metadata and instantiation function
- FormatReader - Instantiated demuxer for the detected format
Decoding Flow
- Track - Represents an encoded audio stream with codec parameters
- CodecParameters - Describes codec configuration and properties
- CodecRegistry - Maps codec types to decoder implementations
- Decoder - Decodes packets into audio buffers
- Packet - Encoded data from the format reader
- AudioBuffer - Decoded PCM audio samples
Related Types
Core Data Structures
- Track - Describes an independently coded media bitstream
- Packet - Contains a discrete amount of encoded data
- CodecParameters - Codec configuration and stream properties
- CodecType - Unique identifier for codecs
- Cue - Designated point of time within a media stream
Configuration
- FormatOptions - Options for format readers
- DecoderOptions - Options for decoders
- MetadataOptions - Options for metadata parsing
Seeking
- SeekTo - Specifies a position to seek to
- SeekedTo - Result of a seek operation
- SeekMode - Precision level for seeking
See Also
- Probe API - Format detection and probing
- FormatReader API - Container demuxing
- Decoder API - Audio decoding
- CodecRegistry API - Codec management