#[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
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_family: u8Channel 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
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.
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§
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.