ffmpeg_the_third/util/channel_layout/
mask.rs

1use crate::ffi::*;
2use libc::c_ulonglong;
3
4bitflags::bitflags! {
5    #[derive(Eq, PartialEq, Copy, Clone, Debug)]
6    pub struct ChannelLayoutMask: 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        #[cfg(not(feature = "ffmpeg_7_0"))]
33        const NATIVE                = AV_CH_LAYOUT_NATIVE;
34
35        const MONO                = AV_CH_LAYOUT_MONO;
36        const STEREO              = AV_CH_LAYOUT_STEREO;
37        const _2POINT1            = AV_CH_LAYOUT_2POINT1;
38        const _2_1                = AV_CH_LAYOUT_2_1;
39        const SURROUND            = AV_CH_LAYOUT_SURROUND;
40        const _3POINT1            = AV_CH_LAYOUT_3POINT1;
41        const _4POINT0            = AV_CH_LAYOUT_4POINT0;
42        const _4POINT1            = AV_CH_LAYOUT_4POINT1;
43        const _2_2                = AV_CH_LAYOUT_2_2;
44        const QUAD                = AV_CH_LAYOUT_QUAD;
45        const _5POINT0            = AV_CH_LAYOUT_5POINT0;
46        const _5POINT1            = AV_CH_LAYOUT_5POINT1;
47        const _5POINT0_BACK       = AV_CH_LAYOUT_5POINT0_BACK;
48        const _5POINT1_BACK       = AV_CH_LAYOUT_5POINT1_BACK;
49        const _6POINT0            = AV_CH_LAYOUT_6POINT0;
50        const _6POINT0_FRONT      = AV_CH_LAYOUT_6POINT0_FRONT;
51        const HEXAGONAL           = AV_CH_LAYOUT_HEXAGONAL;
52        #[cfg(feature = "ffmpeg_5_1")]
53        const _3POINT1POINT2      = AV_CH_LAYOUT_3POINT1POINT2;
54        const _6POINT1            = AV_CH_LAYOUT_6POINT1;
55        const _6POINT1_BACK       = AV_CH_LAYOUT_6POINT1_BACK;
56        const _6POINT1_FRONT      = AV_CH_LAYOUT_6POINT1_FRONT;
57        const _7POINT0            = AV_CH_LAYOUT_7POINT0;
58        const _7POINT0_FRONT      = AV_CH_LAYOUT_7POINT0_FRONT;
59        const _7POINT1            = AV_CH_LAYOUT_7POINT1;
60        const _7POINT1_WIDE       = AV_CH_LAYOUT_7POINT1_WIDE;
61        const _7POINT1_WIDE_BACK  = AV_CH_LAYOUT_7POINT1_WIDE_BACK;
62        #[cfg(feature = "ffmpeg_5_1")]
63        const _5POINT1POINT2_BACK = AV_CH_LAYOUT_5POINT1POINT2_BACK;
64        const OCTAGONAL           = AV_CH_LAYOUT_OCTAGONAL;
65        #[cfg(feature = "ffmpeg_5_1")]
66        const CUBE                = AV_CH_LAYOUT_CUBE;
67        #[cfg(feature = "ffmpeg_5_1")]
68        const _5POINT1POINT4_BACK = AV_CH_LAYOUT_5POINT1POINT4_BACK;
69        #[cfg(feature = "ffmpeg_5_1")]
70        const _7POINT1POINT2      = AV_CH_LAYOUT_7POINT1POINT2;
71        #[cfg(feature = "ffmpeg_5_1")]
72        const _7POINT1POINT4_BACK = AV_CH_LAYOUT_7POINT1POINT4_BACK;
73        #[cfg(feature = "ffmpeg_7_0")]
74        const _7POINT2POINT3      = AV_CH_LAYOUT_7POINT2POINT3;
75        #[cfg(feature = "ffmpeg_7_0")]
76        const _9POINT1POINT4_BACK = AV_CH_LAYOUT_9POINT1POINT4_BACK;
77        const HEXADECAGONAL       = AV_CH_LAYOUT_HEXADECAGONAL;
78        const STEREO_DOWNMIX      = AV_CH_LAYOUT_STEREO_DOWNMIX;
79        #[cfg(feature = "ffmpeg_5_1")]
80        const _22POINT2           = AV_CH_LAYOUT_22POINT2;
81    }
82}
83
84#[cfg(not(feature = "ffmpeg_7_0"))]
85impl ChannelLayoutMask {
86    #[inline]
87    pub fn channels(&self) -> i32 {
88        unsafe { av_get_channel_layout_nb_channels(self.bits()) }
89    }
90
91    pub fn default(number: i32) -> ChannelLayoutMask {
92        unsafe {
93            ChannelLayoutMask::from_bits_truncate(
94                av_get_default_channel_layout(number) as c_ulonglong
95            )
96        }
97    }
98}