#[non_exhaustive]pub struct Config {
pub sample_rate: u32,
pub channel_count: u32,
pub pre_skip: u16,
pub output_gain: i16,
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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sample_rate: u32Original 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: u32Number of output channels.
pre_skip: u16Number of decoded 48 kHz samples to discard at stream start.
output_gain: i16Gain to apply to the decoded output, in Q7.8 dB.
mapping: Option<Mapping>The channel mapping table, carrying its family; None is family 0.
Implementations§
Source§impl Config
impl Config
Sourcepub fn new(sample_rate: u32, channel_count: u32) -> Self
pub fn new(sample_rate: u32, channel_count: u32) -> Self
Build a mono/stereo Opus config with no pre-skip or gain.
Sourcepub fn with_pre_skip(self, pre_skip: u16) -> Self
pub fn with_pre_skip(self, pre_skip: u16) -> Self
Set the number of decoded 48 kHz samples to discard at stream start.
Sourcepub fn parse<T: Buf>(buf: &mut T) -> Result<Self>
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.
Sourcepub fn encode(&self) -> Result<Bytes>
pub fn encode(&self) -> Result<Bytes>
Encode an OpusHead packet (RFC 7845 §5.1), followed by the channel mapping table when there is one.
The family byte is the mapping’s, or 0 when there is none. 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.
Trait Implementations§
impl Copy for Config
impl Eq for Config
Source§impl From<Config> for AudioConfig
impl From<Config> for AudioConfig
Source§fn from(config: Config) -> Self
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.
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.