1 | use ffi::AVMediaType::*; |
2 | use ffi::*; |
3 | |
4 | #[derive (Eq, PartialEq, Clone, Copy, Debug)] |
5 | pub enum Type { |
6 | Unknown, |
7 | Video, |
8 | Audio, |
9 | Data, |
10 | Subtitle, |
11 | Attachment, |
12 | } |
13 | |
14 | impl From<AVMediaType> for Type { |
15 | #[inline (always)] |
16 | fn from(value: AVMediaType) -> Self { |
17 | match value { |
18 | AVMEDIA_TYPE_UNKNOWN => Type::Unknown, |
19 | AVMEDIA_TYPE_VIDEO => Type::Video, |
20 | AVMEDIA_TYPE_AUDIO => Type::Audio, |
21 | AVMEDIA_TYPE_DATA => Type::Data, |
22 | AVMEDIA_TYPE_SUBTITLE => Type::Subtitle, |
23 | AVMEDIA_TYPE_ATTACHMENT => Type::Attachment, |
24 | AVMEDIA_TYPE_NB => Type::Unknown, |
25 | } |
26 | } |
27 | } |
28 | |
29 | impl From<Type> for AVMediaType { |
30 | #[inline (always)] |
31 | fn from(value: Type) -> AVMediaType { |
32 | match value { |
33 | Type::Unknown => AVMEDIA_TYPE_UNKNOWN, |
34 | Type::Video => AVMEDIA_TYPE_VIDEO, |
35 | Type::Audio => AVMEDIA_TYPE_AUDIO, |
36 | Type::Data => AVMEDIA_TYPE_DATA, |
37 | Type::Subtitle => AVMEDIA_TYPE_SUBTITLE, |
38 | Type::Attachment => AVMEDIA_TYPE_ATTACHMENT, |
39 | } |
40 | } |
41 | } |
42 | |