Skip to main content

OpusTocByte

Struct OpusTocByte 

Source
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: u8

Raw config value (0..31).

§mode: Mode

Operating mode selected by config.

§bandwidth: Bandwidth

Audio bandwidth selected by config.

§frame_size_tenths_ms: u16

Per-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: ChannelMapping

Channel mapping signalled by s.

§frame_count_code: FrameCountCode

Frame-packing code signalled by c.

Implementations§

Source§

impl OpusTocByte

Source

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.

Source

pub fn from_byte(byte: u8) -> Self

Decode an isolated TOC byte. Total function — every u8 is a valid TOC byte.

Source

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).

Source

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

Source§

fn clone(&self) -> OpusTocByte

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for OpusTocByte

Source§

impl Debug for OpusTocByte

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for OpusTocByte

Source§

impl PartialEq for OpusTocByte

Source§

fn eq(&self, other: &OpusTocByte) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for OpusTocByte

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.