Skip to main content

Config

Struct Config 

Source
#[non_exhaustive]
pub struct Config { pub sample_rate: u32, pub channel_count: u32, pub pre_skip: u16, pub output_gain: i16, pub mapping_family: u8, pub mapping: Option<Mapping>, }
Expand description

Typed Opus configuration mirroring the parsed fields of an OpusHead packet.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sample_rate: u32

Original input sample rate in Hz, or 0 when unknown.

Metadata only: Opus always runs on a 48 kHz clock, and this need not be a rate Opus can decode at (44.1 kHz is common).

§channel_count: u32

Number of output channels.

§pre_skip: u16

Number of decoded 48 kHz samples to discard at stream start.

§output_gain: i16

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

§mapping_family: u8

Channel mapping family; 0 is mono/stereo with no mapping table.

Always mapping’s family, or 0 without one.

§mapping: Option<Mapping>

The channel mapping table, or None for family 0 (mono/stereo, one stream).

Implementations§

Source§

impl Config

Source

pub fn new(sample_rate: u32, channel_count: u32) -> Self

Build a mono/stereo Opus config with no pre-skip or gain.

Source

pub fn with_pre_skip(self, pre_skip: u16) -> Self

Set the number of decoded 48 kHz samples to discard at stream start.

Source

pub fn parse<T: Buf>(buf: &mut T) -> Result<Self>

Parse an OpusHead buffer (RFC 7845 §5.1).

Accepts any minor version and refuses a new major version. Reads the channel mapping, refusing a channel count the family forbids or an inconsistent mapping table. Bytes after the header are left in buf.

Source

pub fn encode(&self) -> Result<Bytes>

Encode an OpusHead packet (RFC 7845 §5.1), followed by the channel mapping table when there is one.

Errors with Error::UnsupportedChannelCount when channel_count is not 1 or 2 without a mapping (family 0 is only defined for mono/stereo), or is not the mapping’s own channel count, and with Error::UnsupportedMappingFamily when mapping_family is not the mapping’s family.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

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 Config

Source§

impl Debug for Config

Source§

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

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

impl Eq for Config

Source§

impl From<Config> for AudioConfig

Source§

fn from(config: Config) -> Self

Build a catalog config from a config resolved out of band (e.g. gstreamer caps).

The catalog describes the decoder’s output: Opus always decodes at 48 kHz, whatever the informational input rate in Config::sample_rate claims.

Source§

impl PartialEq for Config

Source§

fn eq(&self, other: &Self) -> 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 Config

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

Source§

impl<T> MaybeSync for T
where T: Sync,

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 = !

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

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more