Skip to content

Commit 4931a4b

Browse files
authored
seekable: Do validation of stream duration (#437)
Some seekable stream may not always have a duration so need to do validation of "metadata.duration" before using it to calculate seekable time ranges. Fixes: servo/servo#36748 Fixes: servo/servo#36809 Co-authored-by: Mitchel Stewart Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
1 parent eb96030 commit 4931a4b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

backends/gstreamer/player.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -805,10 +805,12 @@ impl Player for GStreamerPlayer {
805805
// if the servosrc is seekable, we should return the duration of the media
806806
if let Some(metadata) = inner.last_metadata.as_ref() {
807807
if metadata.is_seekable {
808-
return Ok(vec![Range {
809-
start: 0.0,
810-
end: metadata.duration.unwrap().as_secs_f64(),
811-
}]);
808+
if let Some(duration) = metadata.duration {
809+
return Ok(vec![Range {
810+
start: 0.0,
811+
end: duration.as_secs_f64(),
812+
}]);
813+
}
812814
}
813815
}
814816
// if the servosrc is not seekable, we should return the buffered range

0 commit comments

Comments
 (0)