1 | mod traits; |
2 | pub use self::traits::{Gettable, Iterable, Settable, Target}; |
3 | |
4 | use ffi::AVOptionType::*; |
5 | use ffi::*; |
6 | |
7 | #[derive (PartialEq, Eq, Copy, Clone, Debug)] |
8 | pub enum Type { |
9 | Flags, |
10 | Int, |
11 | Int64, |
12 | Double, |
13 | Float, |
14 | String, |
15 | Rational, |
16 | Binary, |
17 | Dictionary, |
18 | Constant, |
19 | |
20 | ImageSize, |
21 | PixelFormat, |
22 | SampleFormat, |
23 | VideoRate, |
24 | Duration, |
25 | Color, |
26 | ChannelLayout, |
27 | c_ulong, |
28 | bool, |
29 | } |
30 | |
31 | impl From<AVOptionType> for Type { |
32 | fn from(value: AVOptionType) -> Self { |
33 | match value { |
34 | AV_OPT_TYPE_FLAGS => Type::Flags, |
35 | AV_OPT_TYPE_INT => Type::Int, |
36 | AV_OPT_TYPE_INT64 => Type::Int64, |
37 | AV_OPT_TYPE_DOUBLE => Type::Double, |
38 | AV_OPT_TYPE_FLOAT => Type::Float, |
39 | AV_OPT_TYPE_STRING => Type::String, |
40 | AV_OPT_TYPE_RATIONAL => Type::Rational, |
41 | AV_OPT_TYPE_BINARY => Type::Binary, |
42 | AV_OPT_TYPE_DICT => Type::Dictionary, |
43 | AV_OPT_TYPE_CONST => Type::Constant, |
44 | AV_OPT_TYPE_UINT64 => Type::c_ulong, |
45 | AV_OPT_TYPE_BOOL => Type::bool, |
46 | |
47 | AV_OPT_TYPE_IMAGE_SIZE => Type::ImageSize, |
48 | AV_OPT_TYPE_PIXEL_FMT => Type::PixelFormat, |
49 | AV_OPT_TYPE_SAMPLE_FMT => Type::SampleFormat, |
50 | AV_OPT_TYPE_VIDEO_RATE => Type::VideoRate, |
51 | AV_OPT_TYPE_DURATION => Type::Duration, |
52 | AV_OPT_TYPE_COLOR => Type::Color, |
53 | AV_OPT_TYPE_CHANNEL_LAYOUT => Type::ChannelLayout, |
54 | #[cfg (feature = "ffmpeg_5_1" )] |
55 | AV_OPT_TYPE_CHLAYOUT => Type::ChannelLayout, |
56 | } |
57 | } |
58 | } |
59 | |
60 | impl From<Type> for AVOptionType { |
61 | fn from(value: Type) -> AVOptionType { |
62 | match value { |
63 | Type::Flags => AV_OPT_TYPE_FLAGS, |
64 | Type::Int => AV_OPT_TYPE_INT, |
65 | Type::Int64 => AV_OPT_TYPE_INT64, |
66 | Type::Double => AV_OPT_TYPE_DOUBLE, |
67 | Type::Float => AV_OPT_TYPE_FLOAT, |
68 | Type::String => AV_OPT_TYPE_STRING, |
69 | Type::Rational => AV_OPT_TYPE_RATIONAL, |
70 | Type::Binary => AV_OPT_TYPE_BINARY, |
71 | Type::Dictionary => AV_OPT_TYPE_DICT, |
72 | Type::Constant => AV_OPT_TYPE_CONST, |
73 | Type::c_ulong => AV_OPT_TYPE_UINT64, |
74 | Type::bool => AV_OPT_TYPE_BOOL, |
75 | |
76 | Type::ImageSize => AV_OPT_TYPE_IMAGE_SIZE, |
77 | Type::PixelFormat => AV_OPT_TYPE_PIXEL_FMT, |
78 | Type::SampleFormat => AV_OPT_TYPE_SAMPLE_FMT, |
79 | Type::VideoRate => AV_OPT_TYPE_VIDEO_RATE, |
80 | Type::Duration => AV_OPT_TYPE_DURATION, |
81 | Type::Color => AV_OPT_TYPE_COLOR, |
82 | Type::ChannelLayout => AV_OPT_TYPE_CHANNEL_LAYOUT, |
83 | } |
84 | } |
85 | } |
86 | |