Skip to main content

OpusHead

Struct OpusHead 

Source
pub struct OpusHead {
    pub channels: u8,
    pub pre_skip: u16,
    pub input_sample_rate: u32,
    pub output_gain: i16,
    pub channel_mapping_family: u8,
    pub stream_count: u8,
    pub coupled_count: u8,
    pub channel_mapping: Vec<u8>,
}
Expand description

The Opus identification header: the decoder configuration of an Opus stream (RFC 7845 section 5.1).

MP4 carries it as the fields of a dOps box (Self::from_dops, Self::to_dops); Ogg, Matroska and WebM CodecPrivate, and a WebCodecs AudioDecoderConfig.description carry the OpusHead packet itself (Self::from_identification_header, Self::to_identification_header).

Fields§

§channels: u8

The number of output channels.

§pre_skip: u16

Samples at 48 kHz to discard from the start of the decoded stream: the encoder’s delay.

§input_sample_rate: u32

The sample rate of the audio before it was encoded, for information only; Opus decodes at OPUS_SAMPLE_RATE regardless. Zero when unknown.

§output_gain: i16

Gain to apply to the decoded output, in Q7.8 decibels.

§channel_mapping_family: u8

The channel mapping family: 0 for mono or stereo in one stream, 1 for the Vorbis channel orders of up to eight channels in several streams.

§stream_count: u8

The number of Opus streams in each packet.

§coupled_count: u8

How many of those streams are coupled stereo pairs.

§channel_mapping: Vec<u8>

For each output channel, the decoded stream channel that feeds it, or 255 for silence.

Implementations§

Source§

impl OpusHead

Source

pub fn new( channels: u8, pre_skip: u16, input_sample_rate: u32, ) -> Result<OpusHead, Error>

A mapping-family-0 header for a mono or stereo stream.

Source

pub fn from_dops(dops: &[u8]) -> Result<OpusHead, Error>

Parses a complete dOps box, size and type included, as the Opus sample entry of an MP4 carries it (“Encapsulation of Opus in ISO Base Media File Format”, section 4.3.2).

Source

pub fn to_dops(&self) -> Vec<u8> ⓘ

Writes this header as a complete dOps box, size and type included.

Source

pub fn from_identification_header(packet: &[u8]) -> Result<OpusHead, Error>

Parses an RFC 7845 OpusHead identification header packet, the little-endian form Ogg pages and Matroska or WebM CodecPrivate carry.

Source

pub fn to_identification_header(&self) -> Vec<u8> ⓘ

Writes this header as an RFC 7845 OpusHead identification header packet (version 1).

Source

pub fn output_gain_factor(&self) -> f32

The linear factor Self::output_gain scales decoded samples by.

Trait Implementations§

Source§

impl Clone for OpusHead

Source§

fn clone(&self) -> OpusHead

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 Debug for OpusHead

Source§

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

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

impl Eq for OpusHead

Source§

impl PartialEq for OpusHead

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for OpusHead

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.