1use ffi::*;
2use libc::c_ulonglong;
3
4bitflags! {
5 pub struct ChannelLayout: c_ulonglong {
6 const FRONT_LEFT = AV_CH_FRONT_LEFT;
7 const FRONT_RIGHT = AV_CH_FRONT_RIGHT;
8 const FRONT_CENTER = AV_CH_FRONT_CENTER;
9 const LOW_FREQUENCY = AV_CH_LOW_FREQUENCY;
10 const BACK_LEFT = AV_CH_BACK_LEFT;
11 const BACK_RIGHT = AV_CH_BACK_RIGHT;
12 const FRONT_LEFT_OF_CENTER = AV_CH_FRONT_LEFT_OF_CENTER;
13 const FRONT_RIGHT_OF_CENTER = AV_CH_FRONT_RIGHT_OF_CENTER;
14 const BACK_CENTER = AV_CH_BACK_CENTER;
15 const SIDE_LEFT = AV_CH_SIDE_LEFT;
16 const SIDE_RIGHT = AV_CH_SIDE_RIGHT;
17 const TOP_CENTER = AV_CH_TOP_CENTER;
18 const TOP_FRONT_LEFT = AV_CH_TOP_FRONT_LEFT;
19 const TOP_FRONT_CENTER = AV_CH_TOP_FRONT_CENTER;
20 const TOP_FRONT_RIGHT = AV_CH_TOP_FRONT_RIGHT;
21 const TOP_BACK_LEFT = AV_CH_TOP_BACK_LEFT;
22 const TOP_BACK_CENTER = AV_CH_TOP_BACK_CENTER;
23 const TOP_BACK_RIGHT = AV_CH_TOP_BACK_RIGHT;
24 const STEREO_LEFT = AV_CH_STEREO_LEFT;
25 const STEREO_RIGHT = AV_CH_STEREO_RIGHT;
26 const WIDE_LEFT = AV_CH_WIDE_LEFT;
27 const WIDE_RIGHT = AV_CH_WIDE_RIGHT;
28 const SURROUND_DIRECT_LEFT = AV_CH_SURROUND_DIRECT_LEFT;
29 const SURROUND_DIRECT_RIGHT = AV_CH_SURROUND_DIRECT_RIGHT;
30 const LOW_FREQUENCY_2 = AV_CH_LOW_FREQUENCY_2;
31 const NATIVE = AV_CH_LAYOUT_NATIVE;
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 }
73}
74
75impl ChannelLayout {
76 #[inline]
77 pub fn channels(&self) -> i32 {
78 unsafe { av_get_channel_layout_nb_channels(self.bits()) }
79 }
80
81 pub fn default(number: i32) -> ChannelLayout {
82 unsafe {
83 ChannelLayout::from_bits_truncate(bits:av_get_default_channel_layout(number) as c_ulonglong)
84 }
85 }
86}
87