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: u8The number of output channels.
pre_skip: u16Samples at 48 kHz to discard from the start of the decoded stream: the encoder’s delay.
input_sample_rate: u32The sample rate of the audio before it was encoded, for information
only; Opus decodes at OPUS_SAMPLE_RATE regardless. Zero when
unknown.
output_gain: i16Gain to apply to the decoded output, in Q7.8 decibels.
channel_mapping_family: u8The 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: u8The number of Opus streams in each packet.
coupled_count: u8How 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
impl OpusHead
Sourcepub fn new(
channels: u8,
pre_skip: u16,
input_sample_rate: u32,
) -> Result<OpusHead, Error>
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.
Sourcepub fn from_dops(dops: &[u8]) -> Result<OpusHead, Error>
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).
Sourcepub fn to_dops(&self) -> Vec<u8> ⓘ
pub fn to_dops(&self) -> Vec<u8> ⓘ
Writes this header as a complete dOps box, size and type included.
Sourcepub fn from_identification_header(packet: &[u8]) -> Result<OpusHead, Error>
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.
Sourcepub fn to_identification_header(&self) -> Vec<u8> ⓘ
pub fn to_identification_header(&self) -> Vec<u8> ⓘ
Writes this header as an RFC 7845 OpusHead identification header
packet (version 1).
Sourcepub fn output_gain_factor(&self) -> f32
pub fn output_gain_factor(&self) -> f32
The linear factor Self::output_gain scales decoded samples by.