diff --git a/src/tags/master_playlist/i_frame_stream_inf.rs b/src/tags/master_playlist/i_frame_stream_inf.rs index 50e75bd..1567c07 100644 --- a/src/tags/master_playlist/i_frame_stream_inf.rs +++ b/src/tags/master_playlist/i_frame_stream_inf.rs @@ -13,22 +13,37 @@ use crate::Error; /// /// [4.3.4.3. EXT-X-I-FRAME-STREAM-INF]: https://tools.ietf.org/html/rfc8216#section-4.3.4.3 #[derive(Getters, Setters, MutGetters, Debug, Clone, PartialEq, Eq, Hash)] -#[get = "pub"] -#[set = "pub"] -#[get_mut = "pub"] pub struct ExtXIFrameStreamInf { + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// The URI, that identifies the associated media playlist. uri: String, + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// The peak segment bit rate of the variant stream. bandwidth: u64, + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// The average segment bit rate of the variant stream. average_bandwidth: Option, + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// A string that represents the list of codec types contained the variant stream. codecs: Option, /// The optimal pixel resolution at which to display all the video in the variant stream. resolution: Option, + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// The HDCP level of the variant stream. hdcp_level: Option, + #[get = "pub"] + #[set = "pub"] + #[get_mut = "pub"] /// The group identifier for the video in the variant stream. video: Option, } @@ -49,6 +64,25 @@ impl ExtXIFrameStreamInf { } } + /// The optimal pixel resolution at which to display all the video in the variant stream. + pub fn resolution(&self) -> Option<(usize, usize)> { + if let Some(res) = &self.resolution { + Some((res.width(), res.height())) + } else { + None + } + } + + /// Sets the optimal pixel resolution at which to display all the video in the variant stream. + pub fn set_resolution(&mut self, width: usize, height: usize) -> &mut Self { + if let Some(res) = &mut self.resolution { + res.set_width(width); + res.set_height(height); + } else { + self.resolution = Some(DecimalResolution::new(width, height)); + } + self + } /// Returns the protocol compatibility version that this tag requires. pub const fn requires_version(&self) -> ProtocolVersion { ProtocolVersion::V1 diff --git a/src/tags/master_playlist/stream_inf.rs b/src/tags/master_playlist/stream_inf.rs index 296fba0..d613d6a 100644 --- a/src/tags/master_playlist/stream_inf.rs +++ b/src/tags/master_playlist/stream_inf.rs @@ -67,9 +67,14 @@ impl ExtXStreamInf { self.codecs.as_ref() } - /// Returns the optimal pixel resolution at which to display all the video in the variant stream. - pub const fn resolution(&self) -> Option { - self.resolution + /// Returns the optimal pixel resolution at which to display all the video in the variant + /// stream. + pub fn resolution(&self) -> Option<(usize, usize)> { + if let Some(res) = &self.resolution { + Some((res.width(), res.height())) + } else { + None + } } /// Returns the maximum frame rate for all the video in the variant stream. diff --git a/src/types/decimal_resolution.rs b/src/types/decimal_resolution.rs index 4df01a2..7d225c6 100644 --- a/src/types/decimal_resolution.rs +++ b/src/types/decimal_resolution.rs @@ -9,7 +9,7 @@ use crate::Error; /// /// [4.2. Attribute Lists]: https://tools.ietf.org/html/rfc8216#section-4.2 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] -pub struct DecimalResolution { +pub(crate) struct DecimalResolution { width: usize, height: usize, } diff --git a/src/types/mod.rs b/src/types/mod.rs index 90ff14c..4e2e6a1 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -18,7 +18,7 @@ mod single_line_string; pub use byte_range::*; pub use closed_captions::*; pub use decimal_floating_point::*; -pub use decimal_resolution::*; +pub(crate) use decimal_resolution::*; pub use decryption_key::*; pub use encryption_method::*; pub use hdcp_level::*;