aboutsummaryrefslogtreecommitdiff
path: root/stream/src
diff options
context:
space:
mode:
Diffstat (limited to 'stream/src')
-rw-r--r--stream/src/dash.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/stream/src/dash.rs b/stream/src/dash.rs
index bfec78c..d2adf3f 100644
--- a/stream/src/dash.rs
+++ b/stream/src/dash.rs
@@ -183,6 +183,7 @@ struct Timeline<'a>(&'a [Range<f64>]);
impl Display for Timeline<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "<SegmentTimeline>")?;
+ let mut c = 0;
let mut last_t = 0;
let mut last_d = 0;
let mut r = 0;
@@ -190,7 +191,6 @@ impl Display for Timeline<'_> {
for seg in self.0 {
let t = (seg.end * 1000.) as i64;
let d = t - last_t;
- r += 1;
if d != last_d && last_d != 0 {
match (r, first) {
(1, true) => write!(f, r#"<S t="0" d="{last_d}" />"#)?,
@@ -199,16 +199,22 @@ impl Display for Timeline<'_> {
(_, false) => write!(f, r#"<S d="{last_d}" r="{r}" />"#)?,
}
first = false;
- r = 0;
+ c += r;
+ r = 1;
+ } else {
+ r += 1;
}
last_t = t;
last_d = d;
}
- if r > 1 {
- write!(f, r#"<S d="{last_d}" r="{r}" />"#)?;
- } else {
- write!(f, r#"<S d="{last_d}" />"#)?;
+ c += r;
+ match (r, first) {
+ (1, true) => write!(f, r#"<S t="0" d="{last_d}" />"#)?,
+ (1, false) => write!(f, r#"<S d="{last_d}" />"#)?,
+ (_, true) => write!(f, r#"<S t="0" d="{last_d}" r="{r}" />"#)?,
+ (_, false) => write!(f, r#"<S d="{last_d}" r="{r}" />"#)?,
}
+ assert_eq!(c, self.0.len());
write!(f, "</SegmentTimeline>")?;
Ok(())
}