| 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 | #[cfg (feature = "ffmpeg_7_0" )] |
| 28 | FlagArray, |
| 29 | c_ulong, |
| 30 | bool, |
| 31 | |
| 32 | #[cfg (feature = "ffmpeg_7_1" )] |
| 33 | UInt, |
| 34 | } |
| 35 | |
| 36 | impl From<AVOptionType> for Type { |
| 37 | fn from(value: AVOptionType) -> Self { |
| 38 | match value { |
| 39 | AV_OPT_TYPE_FLAGS => Type::Flags, |
| 40 | AV_OPT_TYPE_INT => Type::Int, |
| 41 | AV_OPT_TYPE_INT64 => Type::Int64, |
| 42 | AV_OPT_TYPE_DOUBLE => Type::Double, |
| 43 | AV_OPT_TYPE_FLOAT => Type::Float, |
| 44 | AV_OPT_TYPE_STRING => Type::String, |
| 45 | AV_OPT_TYPE_RATIONAL => Type::Rational, |
| 46 | AV_OPT_TYPE_BINARY => Type::Binary, |
| 47 | AV_OPT_TYPE_DICT => Type::Dictionary, |
| 48 | AV_OPT_TYPE_CONST => Type::Constant, |
| 49 | AV_OPT_TYPE_UINT64 => Type::c_ulong, |
| 50 | AV_OPT_TYPE_BOOL => Type::bool, |
| 51 | |
| 52 | AV_OPT_TYPE_IMAGE_SIZE => Type::ImageSize, |
| 53 | AV_OPT_TYPE_PIXEL_FMT => Type::PixelFormat, |
| 54 | AV_OPT_TYPE_SAMPLE_FMT => Type::SampleFormat, |
| 55 | AV_OPT_TYPE_VIDEO_RATE => Type::VideoRate, |
| 56 | AV_OPT_TYPE_DURATION => Type::Duration, |
| 57 | AV_OPT_TYPE_COLOR => Type::Color, |
| 58 | #[cfg (not(feature = "ffmpeg_7_0" ))] |
| 59 | AV_OPT_TYPE_CHANNEL_LAYOUT => Type::ChannelLayout, |
| 60 | #[cfg (feature = "ffmpeg_5_1" )] |
| 61 | AV_OPT_TYPE_CHLAYOUT => Type::ChannelLayout, |
| 62 | #[cfg (feature = "ffmpeg_7_0" )] |
| 63 | AV_OPT_TYPE_FLAG_ARRAY => Type::FlagArray, |
| 64 | |
| 65 | #[cfg (feature = "ffmpeg_7_1" )] |
| 66 | AV_OPT_TYPE_UINT => Type::UInt, |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | impl From<Type> for AVOptionType { |
| 72 | fn from(value: Type) -> AVOptionType { |
| 73 | match value { |
| 74 | Type::Flags => AV_OPT_TYPE_FLAGS, |
| 75 | Type::Int => AV_OPT_TYPE_INT, |
| 76 | Type::Int64 => AV_OPT_TYPE_INT64, |
| 77 | Type::Double => AV_OPT_TYPE_DOUBLE, |
| 78 | Type::Float => AV_OPT_TYPE_FLOAT, |
| 79 | Type::String => AV_OPT_TYPE_STRING, |
| 80 | Type::Rational => AV_OPT_TYPE_RATIONAL, |
| 81 | Type::Binary => AV_OPT_TYPE_BINARY, |
| 82 | Type::Dictionary => AV_OPT_TYPE_DICT, |
| 83 | Type::Constant => AV_OPT_TYPE_CONST, |
| 84 | Type::c_ulong => AV_OPT_TYPE_UINT64, |
| 85 | Type::bool => AV_OPT_TYPE_BOOL, |
| 86 | |
| 87 | Type::ImageSize => AV_OPT_TYPE_IMAGE_SIZE, |
| 88 | Type::PixelFormat => AV_OPT_TYPE_PIXEL_FMT, |
| 89 | Type::SampleFormat => AV_OPT_TYPE_SAMPLE_FMT, |
| 90 | Type::VideoRate => AV_OPT_TYPE_VIDEO_RATE, |
| 91 | Type::Duration => AV_OPT_TYPE_DURATION, |
| 92 | Type::Color => AV_OPT_TYPE_COLOR, |
| 93 | #[cfg (not(feature = "ffmpeg_7_0" ))] |
| 94 | Type::ChannelLayout => AV_OPT_TYPE_CHANNEL_LAYOUT, |
| 95 | #[cfg (feature = "ffmpeg_7_0" )] |
| 96 | Type::ChannelLayout => AV_OPT_TYPE_CHLAYOUT, |
| 97 | #[cfg (feature = "ffmpeg_7_0" )] |
| 98 | Type::FlagArray => AV_OPT_TYPE_FLAG_ARRAY, |
| 99 | |
| 100 | #[cfg (feature = "ffmpeg_7_1" )] |
| 101 | Type::UInt => AV_OPT_TYPE_UINT, |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |