Skip to main content

OpusHead

Struct OpusHead 

Source
pub struct OpusHead {
    pub version: u8,
    pub channel_count: u8,
    pub pre_skip: u16,
    pub input_sample_rate: u32,
    pub output_gain_q8: i16,
    pub channel_mapping: ChannelMapping,
}
Expand description

The identification header of an Ogg Opus stream (RFC 7845 §5.1).

Fields§

§version: u8

Encapsulation version; 1 for this specification, with the upper four bits as a compatible major version.

§channel_count: u8

Output channel count C; never zero.

§pre_skip: u16

Samples (at 48 kHz) to discard from decoder output at startup, and the offset subtracted from granule positions to obtain PCM positions.

§input_sample_rate: u32

Sample rate of the original input in Hz - metadata only, not the playback rate. Zero means unspecified.

§output_gain_q8: i16

Output gain in Q7.8 dB, applied by players on top of decoder output.

§channel_mapping: ChannelMapping

Stream-to-channel mapping.

Implementations§

Source§

impl OpusHead

Source

pub fn parse(data: &[u8]) -> Result<Self, OggOpusError>

Parses an OpusHead packet.

§Errors

OggOpusError::InvalidIdHeader for structural problems; OggOpusError::UnsupportedVersion when the major version is not 0 (i.e., the version octet is 16 or greater).

Source

pub fn to_bytes(&self) -> Vec<u8>

Serialises this header into an OpusHead packet.

Source

pub fn family0(channels: u8, pre_skip: u16, input_sample_rate: u32) -> Self

A standard family-0 header for mono or stereo.

§Panics

Panics if channels is not 1 or 2.

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

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

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