Skip to main content

ChannelLayout

Struct ChannelLayout 

Source
pub struct ChannelLayout {
    pub mapping_family: u8,
    pub nb_channels: usize,
    pub nb_streams: usize,
    pub nb_coupled_streams: usize,
    pub mapping: Vec<u8>,
}
Expand description

How a set of Opus streams becomes a set of output channels.

A multistream packet is several ordinary Opus streams concatenated. Some are coded as coupled stereo pairs and carry two channels each, the rest carry one, and the mapping says which of the resulting channels goes where in the output. Coupled streams always come first, so the channels a decoder produces are the coupled pairs in order, then the mono streams in order.

surround builds the standard layout for a channel count and mapping family, which is how OpusMSEncoder and OpusMSDecoder obtain theirs. The fields are public so a caller can read what a given channel count works out to, which is what the OpusHead for such a stream has to declare.

Fields§

§mapping_family: u8

The mapping family this layout came from: 0 for mono/stereo, 1 for the Vorbis surround orders. Kept so the layout can describe itself to an OpusHead without being asked twice.

§nb_channels: usize

Output channels this layout produces, which is what a caller interleaves.

§nb_streams: usize

Opus streams in the packet, coupled and uncoupled together.

§nb_coupled_streams: usize

How many of those streams are coupled stereo pairs. They are the first nb_coupled_streams of them, and each carries two channels, so the streams carry nb_coupled_streams + nb_streams channels in total.

§mapping: Vec<u8>

For each output channel, which of the streams’ channels feeds it.

Indices 0..2 * nb_coupled_streams are the coupled pairs, left then right; the rest are the mono streams in order. The value 255 marks a channel that is left silent. Length is nb_channels.

Implementations§

Source§

impl ChannelLayout

Source

pub fn surround(channels: usize, mapping_family: u8) -> Result<Self>

Standard layout for a channel count + mapping family (0 = mono/stereo, 1 = Vorbis surround for 1..=8 channels).

Trait Implementations§

Source§

impl Clone for ChannelLayout

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 Debug for ChannelLayout

Source§

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

Formats the value using the given formatter. Read more

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

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.