mirror of
https://github.com/sile/hls_m3u8.git
synced 2024-11-25 00:20:59 +00:00
fix backwards compatibility
This commit is contained in:
parent
c8020ede8e
commit
e75153ec5e
3 changed files with 44 additions and 0 deletions
|
@ -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 {
|
||||
|
|
|
@ -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<T: RequiredVersion> RequiredVersion for Vec<T> {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue