#[cfg(test)]
mod av1_test;
use super::*;
#[derive(Debug, PartialEq)]
pub(crate) struct Av1Fmtp {
pub(crate) parameters: HashMap<String, String>,
}
impl Av1Fmtp {
fn number(&self, key: &str, absent: u8) -> Option<u8> {
match self.parameters.get(key) {
None => Some(absent),
Some(value) => value.trim().parse().ok(),
}
}
pub(crate) fn profile(&self) -> Option<u8> {
self.number("profile", 0)
}
pub(crate) fn level_idx(&self) -> Option<u8> {
self.number("level-idx", 5)
}
pub(crate) fn tier(&self) -> Option<u8> {
self.number("tier", 0)
}
}
impl Fmtp for Av1Fmtp {
fn mime_type(&self) -> &str {
"video/av1"
}
fn match_fmtp(&self, f: &dyn Fmtp) -> bool {
let Some(c) = f.as_any().downcast_ref::<Av1Fmtp>() else {
return false;
};
matches!((self.profile(), c.profile()), (Some(a), Some(b)) if a == b)
}
fn parameter(&self, key: &str) -> Option<&String> {
self.parameters.get(key)
}
fn equal(&self, other: &dyn Fmtp) -> bool {
other.as_any().downcast_ref::<Av1Fmtp>() == Some(self)
}
fn as_any(&self) -> &dyn Any {
self
}
}