pub struct OpusTocByte {
pub config: u8,
pub mode: Mode,
pub bandwidth: Bandwidth,
pub frame_size_tenths_ms: u16,
pub channels: ChannelMapping,
pub frame_count_code: FrameCountCode,
}Expand description
Decoded interpretation of a single Opus packet TOC byte.
This does not consume any bytes beyond the TOC byte itself — frame packing (the second byte for code 3, the length sequence for code 2, etc.) is the §3.2 layer and lives elsewhere.
Fields§
§config: u8Raw config value (0..31).
mode: ModeOperating mode selected by config.
bandwidth: BandwidthAudio bandwidth selected by config.
frame_size_tenths_ms: u16Per-frame duration in tenths of a millisecond.
Encoded in tenths because RFC 6716 allows 2.5 ms (= 25) which is not representable in whole milliseconds. The legal values per Table 2 are 25, 50, 100, 200, 400, 600.
channels: ChannelMappingChannel mapping signalled by s.
frame_count_code: FrameCountCodeFrame-packing code signalled by c.
Implementations§
Source§impl OpusTocByte
impl OpusTocByte
Sourcepub fn parse(packet: &[u8]) -> Result<Self, Error>
pub fn parse(packet: &[u8]) -> Result<Self, Error>
Parse the TOC byte from the front of an Opus packet.
Returns Error::EmptyPacket if packet is empty (RFC 6716
§3.1 requirement R1). Any non-empty packet has a syntactically
valid TOC byte by construction (every five-bit config value
is assigned, every s and c value is assigned), so the only
failure mode is the empty-packet case.
Sourcepub fn from_byte(byte: u8) -> Self
pub fn from_byte(byte: u8) -> Self
Decode an isolated TOC byte. Total function — every u8 is a
valid TOC byte.
Sourcepub fn compose_byte(
mode: Mode,
bandwidth: Bandwidth,
frame_size_tenths_ms: u16,
stereo: bool,
frame_count_code: FrameCountCode,
) -> Result<u8, Error>
pub fn compose_byte( mode: Mode, bandwidth: Bandwidth, frame_size_tenths_ms: u16, stereo: bool, frame_count_code: FrameCountCode, ) -> Result<u8, Error>
Compose the TOC byte for a (mode, bandwidth, frame size)
triple plus the channel flag and frame-count code — the inverse
of Self::from_byte (RFC 6716 §3.1).
Returns Error::MalformedPacket when the triple does not
correspond to any Table-2 config row (e.g. SILK-only SWB, or
a CELT-only 40 ms frame).
Sourcepub fn frame_count_range(self) -> (u8, u8)
pub fn frame_count_range(self) -> (u8, u8)
Minimum and maximum frame count the TOC byte implies without
consulting subsequent bytes. Codes 0/1/2 have a known frame
count; code 3 needs the §3.2.5 frame-count byte to resolve and
returns the legal (1, 48) range here.
Trait Implementations§
Source§impl Clone for OpusTocByte
impl Clone for OpusTocByte
Source§fn clone(&self) -> OpusTocByte
fn clone(&self) -> OpusTocByte
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for OpusTocByte
Source§impl Debug for OpusTocByte
impl Debug for OpusTocByte
impl Eq for OpusTocByte
Source§impl PartialEq for OpusTocByte
impl PartialEq for OpusTocByte
Source§fn eq(&self, other: &OpusTocByte) -> bool
fn eq(&self, other: &OpusTocByte) -> bool
self and other values to be equal, and is used by ==.