1
0
Fork 0
mirror of https://github.com/sile/hls_m3u8.git synced 2024-06-02 05:02:43 +00:00
hls_m3u8/src/types/hdcp_level.rs

42 lines
1.4 KiB
Rust
Raw Normal View History

2019-09-22 18:33:40 +00:00
use strum::{Display, EnumString};
2019-09-06 11:20:40 +00:00
/// HDCP ([`High-bandwidth Digital Content Protection`]) level.
2019-09-06 11:20:40 +00:00
///
/// [`High-bandwidth Digital Content Protection`]:
/// https://www.digital-cp.com/sites/default/files/specifications/HDCP%20on%20HDMI%20Specification%20Rev2_2_Final1.pdf
2020-02-10 12:21:48 +00:00
#[non_exhaustive]
2019-09-22 18:33:40 +00:00
#[derive(Ord, PartialOrd, Debug, Clone, Copy, PartialEq, Eq, Hash, Display, EnumString)]
#[strum(serialize_all = "SCREAMING-KEBAB-CASE")]
2019-09-06 11:20:40 +00:00
pub enum HdcpLevel {
/// The associated [`VariantStream`] could fail to play unless the output is
/// protected by High-bandwidth Digital Content Protection ([`HDCP`]) Type 0
/// or equivalent.
///
/// [`VariantStream`]: crate::tags::VariantStream
/// [`HDCP`]: https://www.digital-cp.com/sites/default/files/specifications/HDCP%20on%20HDMI%20Specification%20Rev2_2_Final1.pdf
2019-09-22 18:33:40 +00:00
#[strum(serialize = "TYPE-0")]
2019-09-06 11:20:40 +00:00
Type0,
/// The content does not require output copy protection.
2019-09-06 11:20:40 +00:00
None,
}
2019-09-06 11:46:21 +00:00
#[cfg(test)]
mod tests {
use super::*;
use pretty_assertions::assert_eq;
2019-09-06 11:46:21 +00:00
#[test]
fn test_display() {
assert_eq!(HdcpLevel::Type0.to_string(), "TYPE-0".to_string());
assert_eq!(HdcpLevel::None.to_string(), "NONE".to_string());
2019-09-06 11:46:21 +00:00
}
#[test]
2019-09-21 11:24:05 +00:00
fn test_parser() {
assert_eq!(HdcpLevel::Type0, "TYPE-0".parse().unwrap());
assert_eq!(HdcpLevel::None, "NONE".parse().unwrap());
2019-09-22 18:33:40 +00:00
assert!("unk".parse::<HdcpLevel>().is_err());
2019-09-06 11:46:21 +00:00
}
}