mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-22 08:58:15 +00:00
examples/dash_vod: compare durations to the millisecond
Otherwise when the segment durations aren't as clean cut as in the example, multiple segments with the exact same duration in milliseconds will get output, even though they could have been repeated. Fix this so that people copying this code don't encounter the bug. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1574>
This commit is contained in:
parent
9a7f37e2b7
commit
c282bc1bca
1 changed files with 14 additions and 15 deletions
|
@ -179,11 +179,10 @@ fn main() -> Result<(), Error> {
|
|||
// Write the whole segment timeline out here, compressing multiple segments with
|
||||
// the same duration to a repeated segment.
|
||||
let mut segments = vec![];
|
||||
let mut write_segment =
|
||||
|start: gst::ClockTime, duration: gst::ClockTime, repeat: usize| {
|
||||
let mut write_segment = |start: gst::ClockTime, duration: u64, repeat: usize| {
|
||||
let mut s = dash_mpd::S {
|
||||
t: Some(start.mseconds()),
|
||||
d: duration.mseconds(),
|
||||
d: duration,
|
||||
..Default::default()
|
||||
};
|
||||
if repeat > 0 {
|
||||
|
@ -201,15 +200,15 @@ fn main() -> Result<(), Error> {
|
|||
start = Some(segment.start_time);
|
||||
}
|
||||
if last_duration.is_none() {
|
||||
last_duration = Some(segment.duration);
|
||||
last_duration = Some(segment.duration.mseconds());
|
||||
}
|
||||
|
||||
// If the duration of this segment is different from the previous one then we
|
||||
// have to write out the segment now.
|
||||
if last_duration != Some(segment.duration) {
|
||||
if last_duration != Some(segment.duration.mseconds()) {
|
||||
write_segment(start.unwrap(), last_duration.unwrap(), num_segments - 1);
|
||||
start = Some(segment.start_time);
|
||||
last_duration = Some(segment.duration);
|
||||
last_duration = Some(segment.duration.mseconds());
|
||||
num_segments = 1;
|
||||
} else {
|
||||
num_segments += 1;
|
||||
|
|
Loading…
Reference in a new issue