Struct ChannelLayout

Source
pub struct ChannelLayout { /* private fields */ }

Implementations§

Source§

impl ChannelLayout

Source

pub const FRONT_LEFT: ChannelLayout

Source

pub const FRONT_RIGHT: ChannelLayout

Source

pub const FRONT_CENTER: ChannelLayout

Source

pub const LOW_FREQUENCY: ChannelLayout

Source

pub const BACK_LEFT: ChannelLayout

Source

pub const BACK_RIGHT: ChannelLayout

Source

pub const FRONT_LEFT_OF_CENTER: ChannelLayout

Source

pub const FRONT_RIGHT_OF_CENTER: ChannelLayout

Source

pub const BACK_CENTER: ChannelLayout

Source

pub const SIDE_LEFT: ChannelLayout

Source

pub const SIDE_RIGHT: ChannelLayout

Source

pub const TOP_CENTER: ChannelLayout

Source

pub const TOP_FRONT_LEFT: ChannelLayout

Source

pub const TOP_FRONT_CENTER: ChannelLayout

Source

pub const TOP_FRONT_RIGHT: ChannelLayout

Source

pub const TOP_BACK_LEFT: ChannelLayout

Source

pub const TOP_BACK_CENTER: ChannelLayout

Source

pub const TOP_BACK_RIGHT: ChannelLayout

Source

pub const STEREO_LEFT: ChannelLayout

Source

pub const STEREO_RIGHT: ChannelLayout

Source

pub const WIDE_LEFT: ChannelLayout

Source

pub const WIDE_RIGHT: ChannelLayout

Source

pub const SURROUND_DIRECT_LEFT: ChannelLayout

Source

pub const SURROUND_DIRECT_RIGHT: ChannelLayout

Source

pub const LOW_FREQUENCY_2: ChannelLayout

Source

pub const NATIVE: ChannelLayout

Source

pub const MONO: ChannelLayout

Source

pub const STEREO: ChannelLayout

Source

pub const _2POINT1: ChannelLayout

Source

pub const _2_1: ChannelLayout

Source

pub const SURROUND: ChannelLayout

Source

pub const _3POINT1: ChannelLayout

Source

pub const _4POINT0: ChannelLayout

Source

pub const _4POINT1: ChannelLayout

Source

pub const _2_2: ChannelLayout

Source

pub const QUAD: ChannelLayout

Source

pub const _5POINT0: ChannelLayout

Source

pub const _5POINT1: ChannelLayout

Source

pub const _5POINT0_BACK: ChannelLayout

Source

pub const _5POINT1_BACK: ChannelLayout

Source

pub const _6POINT0: ChannelLayout

Source

pub const _6POINT0_FRONT: ChannelLayout

Source

pub const HEXAGONAL: ChannelLayout

Source

pub const _6POINT1: ChannelLayout

Source

pub const _6POINT1_BACK: ChannelLayout

Source

pub const _6POINT1_FRONT: ChannelLayout

Source

pub const _7POINT0: ChannelLayout

Source

pub const _7POINT0_FRONT: ChannelLayout

Source

pub const _7POINT1: ChannelLayout

Source

pub const _7POINT1_WIDE: ChannelLayout

Source

pub const _7POINT1_WIDE_BACK: ChannelLayout

Source

pub const OCTAGONAL: ChannelLayout

Source

pub const HEXADECAGONAL: ChannelLayout

Source

pub const STEREO_DOWNMIX: ChannelLayout

Source

pub const fn empty() -> ChannelLayout

Returns an empty set of flags

Source

pub const fn all() -> ChannelLayout

Returns the set containing all flags.

Source

pub const fn bits(&self) -> c_ulonglong

Returns the raw value of the flags currently stored.

Examples found in repository?
examples/transcode-audio.rs (line 21)
9fn filter(
10    spec: &str,
11    decoder: &codec::decoder::Audio,
12    encoder: &codec::encoder::Audio,
13) -> Result<filter::Graph, ffmpeg::Error> {
14    let mut filter = filter::Graph::new();
15
16    let args = format!(
17        "time_base={}:sample_rate={}:sample_fmt={}:channel_layout=0x{:x}",
18        decoder.time_base(),
19        decoder.rate(),
20        decoder.format().name(),
21        decoder.channel_layout().bits()
22    );
23
24    filter.add(&filter::find("abuffer").unwrap(), "in", &args)?;
25    filter.add(&filter::find("abuffersink").unwrap(), "out", "")?;
26
27    {
28        let mut out = filter.get("out").unwrap();
29
30        out.set_sample_format(encoder.format());
31        out.set_channel_layout(encoder.channel_layout());
32        out.set_sample_rate(encoder.rate());
33    }
34
35    filter.output("in", 0)?.input("out", 0)?.parse(spec)?;
36    filter.validate()?;
37
38    println!("{}", filter.dump());
39
40    if let Some(codec) = encoder.codec() {
41        if !codec
42            .capabilities()
43            .contains(ffmpeg::codec::capabilities::Capabilities::VARIABLE_FRAME_SIZE)
44        {
45            filter
46                .get("out")
47                .unwrap()
48                .sink()
49                .set_frame_size(encoder.frame_size());
50        }
51    }
52
53    Ok(filter)
54}
Source

pub fn from_bits(bits: c_ulonglong) -> Option<ChannelLayout>

Convert from underlying bit representation, unless that representation contains bits that do not correspond to a flag.

Source

pub const fn from_bits_truncate(bits: c_ulonglong) -> ChannelLayout

Convert from underlying bit representation, dropping any bits that do not correspond to flags.

Source

pub const unsafe fn from_bits_unchecked(bits: c_ulonglong) -> ChannelLayout

Convert from underlying bit representation, preserving all bits (even those not corresponding to a defined flag).

Source

pub const fn is_empty(&self) -> bool

Returns true if no flags are currently stored.

Source

pub const fn is_all(&self) -> bool

Returns true if all flags are currently set.

Source

pub const fn intersects(&self, other: ChannelLayout) -> bool

Returns true if there are flags common to both self and other.

Source

pub const fn contains(&self, other: ChannelLayout) -> bool

Returns true all of the flags in other are contained within self.

Source

pub fn insert(&mut self, other: ChannelLayout)

Inserts the specified flags in-place.

Source

pub fn remove(&mut self, other: ChannelLayout)

Removes the specified flags in-place.

Source

pub fn toggle(&mut self, other: ChannelLayout)

Toggles the specified flags in-place.

Source

pub fn set(&mut self, other: ChannelLayout, value: bool)

Inserts or removes the specified flags depending on the passed value.

Source§

impl ChannelLayout

Source

pub fn channels(&self) -> i32

Examples found in repository?
examples/transcode-audio.rs (line 89)
63fn transcoder<P: AsRef<Path>>(
64    ictx: &mut format::context::Input,
65    octx: &mut format::context::Output,
66    path: &P,
67    filter_spec: &str,
68) -> Result<Transcoder, ffmpeg::Error> {
69    let input = ictx
70        .streams()
71        .best(media::Type::Audio)
72        .expect("could not find best audio stream");
73    let mut decoder = input.codec().decoder().audio()?;
74    let codec = ffmpeg::encoder::find(octx.format().codec(path, media::Type::Audio))
75        .expect("failed to find encoder")
76        .audio()?;
77    let global = octx
78        .format()
79        .flags()
80        .contains(ffmpeg::format::flag::Flags::GLOBAL_HEADER);
81
82    decoder.set_parameters(input.parameters())?;
83
84    let mut output = octx.add_stream(codec)?;
85    let mut encoder = output.codec().encoder().audio()?;
86
87    let channel_layout = codec
88        .channel_layouts()
89        .map(|cls| cls.best(decoder.channel_layout().channels()))
90        .unwrap_or(ffmpeg::channel_layout::ChannelLayout::STEREO);
91
92    if global {
93        encoder.set_flags(ffmpeg::codec::flag::Flags::GLOBAL_HEADER);
94    }
95
96    encoder.set_rate(decoder.rate() as i32);
97    encoder.set_channel_layout(channel_layout);
98    encoder.set_channels(channel_layout.channels());
99    encoder.set_format(
100        codec
101            .formats()
102            .expect("unknown supported formats")
103            .next()
104            .unwrap(),
105    );
106    encoder.set_bit_rate(decoder.bit_rate());
107    encoder.set_max_bit_rate(decoder.max_bit_rate());
108
109    encoder.set_time_base((1, decoder.rate() as i32));
110    output.set_time_base((1, decoder.rate() as i32));
111
112    let encoder = encoder.open_as(codec)?;
113    output.set_parameters(&encoder);
114
115    let filter = filter(filter_spec, &decoder, &encoder)?;
116
117    Ok(Transcoder {
118        stream: input.index(),
119        filter: filter,
120        decoder: decoder,
121        encoder: encoder,
122    })
123}
Source

pub fn default(number: i32) -> ChannelLayout

Trait Implementations§

Source§

impl Binary for ChannelLayout

Source§

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

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

impl BitAnd for ChannelLayout

Source§

fn bitand(self, other: ChannelLayout) -> ChannelLayout

Returns the intersection between the two sets of flags.

Source§

type Output = ChannelLayout

The resulting type after applying the & operator.
Source§

impl BitAndAssign for ChannelLayout

Source§

fn bitand_assign(&mut self, other: ChannelLayout)

Disables all flags disabled in the set.

Source§

impl BitOr for ChannelLayout

Source§

fn bitor(self, other: ChannelLayout) -> ChannelLayout

Returns the union of the two sets of flags.

Source§

type Output = ChannelLayout

The resulting type after applying the | operator.
Source§

impl BitOrAssign for ChannelLayout

Source§

fn bitor_assign(&mut self, other: ChannelLayout)

Adds the set of flags.

Source§

impl BitXor for ChannelLayout

Source§

fn bitxor(self, other: ChannelLayout) -> ChannelLayout

Returns the left flags, but with all the right flags toggled.

Source§

type Output = ChannelLayout

The resulting type after applying the ^ operator.
Source§

impl BitXorAssign for ChannelLayout

Source§

fn bitxor_assign(&mut self, other: ChannelLayout)

Toggles the set of flags.

Source§

impl Clone for ChannelLayout

Source§

fn clone(&self) -> ChannelLayout

Returns a copy of the value. Read more
1.0.0 · 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
Source§

impl Extend<ChannelLayout> for ChannelLayout

Source§

fn extend<T: IntoIterator<Item = ChannelLayout>>(&mut self, iterator: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl FromIterator<ChannelLayout> for ChannelLayout

Source§

fn from_iter<T: IntoIterator<Item = ChannelLayout>>( iterator: T, ) -> ChannelLayout

Creates a value from an iterator. Read more
Source§

impl Hash for ChannelLayout

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LowerHex for ChannelLayout

Source§

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

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

impl Not for ChannelLayout

Source§

fn not(self) -> ChannelLayout

Returns the complement of this set of flags.

Source§

type Output = ChannelLayout

The resulting type after applying the ! operator.
Source§

impl Octal for ChannelLayout

Source§

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

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

impl Ord for ChannelLayout

Source§

fn cmp(&self, other: &ChannelLayout) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for ChannelLayout

Source§

fn eq(&self, other: &ChannelLayout) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for ChannelLayout

Source§

fn partial_cmp(&self, other: &ChannelLayout) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub for ChannelLayout

Source§

fn sub(self, other: ChannelLayout) -> ChannelLayout

Returns the set difference of the two sets of flags.

Source§

type Output = ChannelLayout

The resulting type after applying the - operator.
Source§

impl SubAssign for ChannelLayout

Source§

fn sub_assign(&mut self, other: ChannelLayout)

Disables all flags enabled in the set.

Source§

impl UpperHex for ChannelLayout

Source§

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

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

impl Copy for ChannelLayout

Source§

impl Eq for ChannelLayout

Source§

impl StructuralPartialEq for ChannelLayout

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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.