| 1 | use ffi::*; |
| 2 | use libc::c_int; |
| 3 | |
| 4 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
| 5 | pub struct Config { |
| 6 | pub kind: Type, |
| 7 | pub count: usize, |
| 8 | #[cfg (not(feature = "ffmpeg_6_0" ))] |
| 9 | pub safe: bool, |
| 10 | } |
| 11 | |
| 12 | impl Config { |
| 13 | pub fn kind(value: Type) -> Self { |
| 14 | Config { |
| 15 | kind: value, |
| 16 | ..Default::default() |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | pub fn count(value: usize) -> Self { |
| 21 | Config { |
| 22 | count: value, |
| 23 | ..Default::default() |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | #[cfg (not(feature = "ffmpeg_6_0" ))] |
| 28 | pub fn safe(value: bool) -> Self { |
| 29 | Config { |
| 30 | safe: value, |
| 31 | ..Default::default() |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | impl Default for Config { |
| 37 | fn default() -> Self { |
| 38 | Config { |
| 39 | kind: Type::None, |
| 40 | count: 0, |
| 41 | #[cfg (not(feature = "ffmpeg_6_0" ))] |
| 42 | safe: false, |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
| 48 | pub enum Type { |
| 49 | None, |
| 50 | Frame, |
| 51 | Slice, |
| 52 | } |
| 53 | |
| 54 | impl From<c_int> for Type { |
| 55 | fn from(value: c_int) -> Type { |
| 56 | match value { |
| 57 | FF_THREAD_FRAME: i32 => Type::Frame, |
| 58 | FF_THREAD_SLICE: i32 => Type::Slice, |
| 59 | |
| 60 | _ => Type::None, |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | impl From<Type> for c_int { |
| 66 | fn from(value: Type) -> c_int { |
| 67 | match value { |
| 68 | Type::None => 0, |
| 69 | Type::Frame => FF_THREAD_FRAME, |
| 70 | Type::Slice => FF_THREAD_SLICE, |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |