#[cfg(test)]
mod vp9_test;
use super::*;
const DEFAULT_PROFILE_ID: &str = "0";
#[derive(Debug, PartialEq)]
pub(crate) struct Vp9Fmtp {
pub(crate) parameters: HashMap<String, String>,
}
impl Vp9Fmtp {
fn profile_id(&self) -> &str {
self.parameters
.get("profile-id")
.map(|v| v.trim())
.unwrap_or(DEFAULT_PROFILE_ID)
}
}
impl Fmtp for Vp9Fmtp {
fn mime_type(&self) -> &str {
"video/vp9"
}
fn match_fmtp(&self, f: &dyn Fmtp) -> bool {
let Some(c) = f.as_any().downcast_ref::<Vp9Fmtp>() else {
return false;
};
let (a, b) = (self.profile_id(), c.profile_id());
match (a.parse::<u32>(), b.parse::<u32>()) {
(Ok(a), Ok(b)) => a == b,
_ => a.eq_ignore_ascii_case(b),
}
}
fn parameter(&self, key: &str) -> Option<&String> {
self.parameters.get(key)
}
fn equal(&self, other: &dyn Fmtp) -> bool {
other.as_any().downcast_ref::<Vp9Fmtp>() == Some(self)
}
fn as_any(&self) -> &dyn Any {
self
}
}