Files
ffmpeg-the-third/src/util/media.rs
FreezyLemon 7a8643f2cc Migrate crates to Rust edition 2021 (#24)
* Migrate ffmpeg-sys to Edition 2021

* Migrate ffmpeg to Edition 2021

* Remove now-redundant imports

* Reorder imports after edition migration
2024-04-06 21:31:36 -04:00

48 lines
1.3 KiB
Rust

use crate::ffi::AVMediaType::*;
use crate::ffi::*;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
#[derive(Eq, PartialEq, Clone, Copy, Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum Type {
Unknown,
Video,
Audio,
Data,
Subtitle,
Attachment,
}
impl From<AVMediaType> for Type {
#[inline(always)]
fn from(value: AVMediaType) -> Self {
match value {
AVMEDIA_TYPE_UNKNOWN => Type::Unknown,
AVMEDIA_TYPE_VIDEO => Type::Video,
AVMEDIA_TYPE_AUDIO => Type::Audio,
AVMEDIA_TYPE_DATA => Type::Data,
AVMEDIA_TYPE_SUBTITLE => Type::Subtitle,
AVMEDIA_TYPE_ATTACHMENT => Type::Attachment,
AVMEDIA_TYPE_NB => Type::Unknown,
#[cfg(feature = "non-exhaustive-enums")]
_ => unimplemented!(),
}
}
}
impl From<Type> for AVMediaType {
#[inline(always)]
fn from(value: Type) -> AVMediaType {
match value {
Type::Unknown => AVMEDIA_TYPE_UNKNOWN,
Type::Video => AVMEDIA_TYPE_VIDEO,
Type::Audio => AVMEDIA_TYPE_AUDIO,
Type::Data => AVMEDIA_TYPE_DATA,
Type::Subtitle => AVMEDIA_TYPE_SUBTITLE,
Type::Attachment => AVMEDIA_TYPE_ATTACHMENT,
}
}
}