diff --git a/src/tags/media_segment/map.rs b/src/tags/media_segment/map.rs index 4c7bf31..be2138a 100644 --- a/src/tags/media_segment/map.rs +++ b/src/tags/media_segment/map.rs @@ -138,7 +138,12 @@ impl Encrypted for ExtXMap { /// This tag requires [`ProtocolVersion::V6`]. impl RequiredVersion for ExtXMap { + // this should return ProtocolVersion::V5, if it does not contain an + // EXT-X-I-FRAMES-ONLY! + // http://alexzambelli.com/blog/2016/05/04/understanding-hls-versions-and-client-compatibility/ fn required_version(&self) -> ProtocolVersion { ProtocolVersion::V6 } + + fn introduced_version(&self) -> ProtocolVersion { ProtocolVersion::V5 } } impl fmt::Display for ExtXMap { diff --git a/src/traits.rs b/src/traits.rs index c47defc..af8c5ca 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -120,7 +120,14 @@ pub trait Encrypted { /// ``` pub trait RequiredVersion { /// Returns the protocol compatibility version that this tag requires. + /// + /// # Note + /// This is for the latest working [`ProtocolVersion`] and a client, that + /// only supports an older version would break. fn required_version(&self) -> ProtocolVersion; + + /// The protocol version, in which the tag has been introduced. + fn introduced_version(&self) -> ProtocolVersion { self.required_version() } } impl RequiredVersion for Vec { diff --git a/src/types/decryption_key.rs b/src/types/decryption_key.rs index 7aa745d..5b04e3d 100644 --- a/src/types/decryption_key.rs +++ b/src/types/decryption_key.rs @@ -482,6 +482,38 @@ mod test { ProtocolVersion::V1 ); + assert_eq!( + DecryptionKey::builder() + .method(EncryptionMethod::Aes128) + .uri("https://www.example.com/") + .key_format(KeyFormat::Identity) + .key_format_versions(vec![1, 2, 3]) + .build() + .unwrap() + .required_version(), + ProtocolVersion::V1 + ); + + assert_eq!( + DecryptionKey::builder() + .method(EncryptionMethod::Aes128) + .uri("https://www.example.com/") + .iv([1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7]) + .build() + .unwrap() + .required_version(), + ProtocolVersion::V2 + ); + } + + #[test] + fn test_introduced_version() { + assert_eq!( + DecryptionKey::new(EncryptionMethod::Aes128, "https://www.example.com/") + .required_version(), + ProtocolVersion::V1 + ); + assert_eq!( DecryptionKey::builder() .method(EncryptionMethod::Aes128)