use std::hash::Hash;
pub mod audio;
pub mod registry;
pub mod subtitle;
pub mod video;
use crate::codecs::audio::{AudioCodecId, AudioCodecParameters};
use crate::codecs::subtitle::{SubtitleCodecId, SubtitleCodecParameters};
use crate::codecs::video::{VideoCodecId, VideoCodecParameters};
#[repr(transparent)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CodecProfile(u32);
impl CodecProfile {
pub const fn new(code: u32) -> Self {
Self(code)
}
pub const fn get(&self) -> u32 {
self.0
}
}
impl From<u32> for CodecProfile {
fn from(value: u32) -> Self {
Self(value)
}
}
#[derive(Copy, Clone, Debug)]
pub struct CodecProfileInfo {
pub profile: CodecProfile,
pub short_name: &'static str,
pub long_name: &'static str,
}
#[derive(Copy, Clone, Debug)]
pub struct CodecInfo {
pub short_name: &'static str,
pub long_name: &'static str,
pub profiles: &'static [CodecProfileInfo],
}
#[non_exhaustive]
#[derive(Clone, Debug)]
pub enum CodecParameters {
Audio(AudioCodecParameters),
Video(VideoCodecParameters),
Subtitle(SubtitleCodecParameters),
}
impl CodecParameters {
pub fn is_audio(&self) -> bool {
matches!(self, CodecParameters::Audio(_))
}
pub fn audio(&self) -> Option<&AudioCodecParameters> {
match self {
CodecParameters::Audio(params) => Some(params),
_ => None,
}
}
pub fn audio_mut(&mut self) -> Option<&mut AudioCodecParameters> {
match self {
CodecParameters::Audio(params) => Some(params),
_ => None,
}
}
pub fn is_video(&self) -> bool {
matches!(self, CodecParameters::Video(_))
}
pub fn video(&self) -> Option<&VideoCodecParameters> {
match self {
CodecParameters::Video(params) => Some(params),
_ => None,
}
}
pub fn video_mut(&mut self) -> Option<&mut VideoCodecParameters> {
match self {
CodecParameters::Video(params) => Some(params),
_ => None,
}
}
pub fn is_subtitle(&self) -> bool {
matches!(self, CodecParameters::Subtitle(_))
}
pub fn subtitle(&self) -> Option<&SubtitleCodecParameters> {
match self {
CodecParameters::Subtitle(params) => Some(params),
_ => None,
}
}
pub fn subtitle_mut(&mut self) -> Option<&mut SubtitleCodecParameters> {
match self {
CodecParameters::Subtitle(params) => Some(params),
_ => None,
}
}
}
impl From<AudioCodecParameters> for CodecParameters {
fn from(value: AudioCodecParameters) -> Self {
CodecParameters::Audio(value)
}
}
impl From<VideoCodecParameters> for CodecParameters {
fn from(value: VideoCodecParameters) -> Self {
CodecParameters::Video(value)
}
}
impl From<SubtitleCodecParameters> for CodecParameters {
fn from(value: SubtitleCodecParameters) -> Self {
CodecParameters::Subtitle(value)
}
}
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum CodecId {
Audio(AudioCodecId),
Video(VideoCodecId),
Subtitle(SubtitleCodecId),
}
impl From<AudioCodecId> for CodecId {
fn from(value: AudioCodecId) -> Self {
CodecId::Audio(value)
}
}
impl From<VideoCodecId> for CodecId {
fn from(value: VideoCodecId) -> Self {
CodecId::Video(value)
}
}
impl From<SubtitleCodecId> for CodecId {
fn from(value: SubtitleCodecId) -> Self {
CodecId::Subtitle(value)
}
}