playa_ffmpeg/util/
legacy_channel_layout.rs

1use crate::ffi::*;
2use libc::c_ulonglong;
3
4bitflags! {
5    #[derive(Copy, Clone, Debug, PartialEq, Eq)]
6    pub struct ChannelLayout: c_ulonglong {
7        const FRONT_LEFT            = AV_CH_FRONT_LEFT;
8        const FRONT_RIGHT           = AV_CH_FRONT_RIGHT;
9        const FRONT_CENTER          = AV_CH_FRONT_CENTER;
10        const LOW_FREQUENCY         = AV_CH_LOW_FREQUENCY;
11        const BACK_LEFT             = AV_CH_BACK_LEFT;
12        const BACK_RIGHT            = AV_CH_BACK_RIGHT;
13        const FRONT_LEFT_OF_CENTER  = AV_CH_FRONT_LEFT_OF_CENTER;
14        const FRONT_RIGHT_OF_CENTER = AV_CH_FRONT_RIGHT_OF_CENTER;
15        const BACK_CENTER           = AV_CH_BACK_CENTER;
16        const SIDE_LEFT             = AV_CH_SIDE_LEFT;
17        const SIDE_RIGHT            = AV_CH_SIDE_RIGHT;
18        const TOP_CENTER            = AV_CH_TOP_CENTER;
19        const TOP_FRONT_LEFT        = AV_CH_TOP_FRONT_LEFT;
20        const TOP_FRONT_CENTER      = AV_CH_TOP_FRONT_CENTER;
21        const TOP_FRONT_RIGHT       = AV_CH_TOP_FRONT_RIGHT;
22        const TOP_BACK_LEFT         = AV_CH_TOP_BACK_LEFT;
23        const TOP_BACK_CENTER       = AV_CH_TOP_BACK_CENTER;
24        const TOP_BACK_RIGHT        = AV_CH_TOP_BACK_RIGHT;
25        const STEREO_LEFT           = AV_CH_STEREO_LEFT;
26        const STEREO_RIGHT          = AV_CH_STEREO_RIGHT;
27        const WIDE_LEFT             = AV_CH_WIDE_LEFT;
28        const WIDE_RIGHT            = AV_CH_WIDE_RIGHT;
29        const SURROUND_DIRECT_LEFT  = AV_CH_SURROUND_DIRECT_LEFT;
30        const SURROUND_DIRECT_RIGHT = AV_CH_SURROUND_DIRECT_RIGHT;
31        const LOW_FREQUENCY_2       = AV_CH_LOW_FREQUENCY_2;
32
33        const MONO               = AV_CH_LAYOUT_MONO;
34        const STEREO             = AV_CH_LAYOUT_STEREO;
35        const _2POINT1           = AV_CH_LAYOUT_2POINT1;
36        const _2_1               = AV_CH_LAYOUT_2_1;
37        const SURROUND           = AV_CH_LAYOUT_SURROUND;
38        const _3POINT1           = AV_CH_LAYOUT_3POINT1;
39        const _4POINT0           = AV_CH_LAYOUT_4POINT0;
40        const _4POINT1           = AV_CH_LAYOUT_4POINT1;
41        const _2_2               = AV_CH_LAYOUT_2_2;
42        const QUAD               = AV_CH_LAYOUT_QUAD;
43        const _5POINT0           = AV_CH_LAYOUT_5POINT0;
44        const _5POINT1           = AV_CH_LAYOUT_5POINT1;
45        const _5POINT0_BACK      = AV_CH_LAYOUT_5POINT0_BACK;
46        const _5POINT1_BACK      = AV_CH_LAYOUT_5POINT1_BACK;
47        const _6POINT0           = AV_CH_LAYOUT_6POINT0;
48        const _6POINT0_FRONT     = AV_CH_LAYOUT_6POINT0_FRONT;
49        const HEXAGONAL          = AV_CH_LAYOUT_HEXAGONAL;
50        const _6POINT1           = AV_CH_LAYOUT_6POINT1;
51        const _6POINT1_BACK      = AV_CH_LAYOUT_6POINT1_BACK;
52        const _6POINT1_FRONT     = AV_CH_LAYOUT_6POINT1_FRONT;
53        const _7POINT0           = AV_CH_LAYOUT_7POINT0;
54        const _7POINT0_FRONT     = AV_CH_LAYOUT_7POINT0_FRONT;
55        const _7POINT1           = AV_CH_LAYOUT_7POINT1;
56        const _7POINT1_WIDE      = AV_CH_LAYOUT_7POINT1_WIDE;
57        const _7POINT1_WIDE_BACK = AV_CH_LAYOUT_7POINT1_WIDE_BACK;
58        const OCTAGONAL          = AV_CH_LAYOUT_OCTAGONAL;
59        const HEXADECAGONAL      = AV_CH_LAYOUT_HEXADECAGONAL;
60        const STEREO_DOWNMIX     = AV_CH_LAYOUT_STEREO_DOWNMIX;
61
62        #[cfg(feature = "ffmpeg_6_1")]
63        const _3POINT1POINT2      = AV_CH_LAYOUT_3POINT1POINT2;
64        #[cfg(feature = "ffmpeg_6_1")]
65        const _5POINT1POINT2_BACK = AV_CH_LAYOUT_5POINT1POINT2_BACK;
66        #[cfg(feature = "ffmpeg_6_1")]
67        const _5POINT1POINT4_BACK = AV_CH_LAYOUT_5POINT1POINT4_BACK;
68        #[cfg(feature = "ffmpeg_6_1")]
69        const _7POINT1POINT2      = AV_CH_LAYOUT_7POINT1POINT2;
70        #[cfg(feature = "ffmpeg_6_1")]
71        const _7POINT1POINT4_BACK = AV_CH_LAYOUT_7POINT1POINT4_BACK;
72        #[cfg(feature = "ffmpeg_6_1")]
73        const CUBE = AV_CH_LAYOUT_CUBE;
74    }
75}
76
77impl ChannelLayout {
78    #[inline]
79    pub fn channels(&self) -> i32 {
80        unsafe { av_get_channel_layout_nb_channels(self.bits()) }
81    }
82
83    pub fn default(number: i32) -> ChannelLayout {
84        unsafe { ChannelLayout::from_bits_truncate(av_get_default_channel_layout(number) as c_ulonglong) }
85    }
86}