Skip to main content

ffmpeg_the_third/util/channel_layout/
order.rs

1use crate::ffi::AVChannelOrder;
2
3use ChannelOrder::*;
4
5/// Specifies an order for audio channels.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum ChannelOrder {
8    /// No channel order. Only the channel count is specified.
9    Unspecified,
10
11    /// Native channel order, i.e. the channels are in the same order in which they
12    /// are defined in the [`Channel`][super::Channel] enum. This supports up to 63 channels.
13    Native,
14
15    /// The channel order does not correspond to any predefined order and is stored as an
16    /// explicit map. This can be used to support layouts with more than 64 channels or with
17    /// empty channels at arbitrary positions.
18    Custom,
19
20    /// The audio is represented as the decomposition of the sound field into spherical harmonics.
21    Ambisonic,
22}
23
24impl From<AVChannelOrder> for ChannelOrder {
25    fn from(value: AVChannelOrder) -> Self {
26        use AVChannelOrder as AV;
27
28        match value {
29            AV::UNSPEC => Unspecified,
30            AV::NATIVE => Native,
31            AV::CUSTOM => Custom,
32            AV::AMBISONIC => Ambisonic,
33
34            _ => unimplemented!(),
35        }
36    }
37}
38
39impl From<ChannelOrder> for AVChannelOrder {
40    fn from(value: ChannelOrder) -> Self {
41        use AVChannelOrder as AV;
42
43        match value {
44            Unspecified => AV::UNSPEC,
45            Native => AV::NATIVE,
46            Custom => AV::CUSTOM,
47            Ambisonic => AV::AMBISONIC,
48        }
49    }
50}