aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlmediaelement.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-01-10 06:52:57 -0500
committerGitHub <noreply@github.com>2019-01-10 06:52:57 -0500
commit4ac5b8a3aea5df3bf374dcfdb22c34f5ff0bafe8 (patch)
treec2bbc5bb591ad39b9695b183b1a82e63eebcab03 /components/script/dom/htmlmediaelement.rs
parentd8b025c6ccefd4a81b0dfccb2f4e342b621741cc (diff)
parent4d9fb872fbcbfe19b689bd045bf49c8d0b5ff63e (diff)
downloadservo-4ac5b8a3aea5df3bf374dcfdb22c34f5ff0bafe8.tar.gz
servo-4ac5b8a3aea5df3bf374dcfdb22c34f5ff0bafe8.zip
Auto merge of #22477 - ferjm:media_time_marches_on_step_6, r=jdm
Implement step 6 of media `time marches on` algorithm. Improves stability of media WPTs - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes This should help with the WPTs problems observed in https://github.com/servo/servo/pull/22348#issuecomment-446369831 Unfortunately, GStreamer does not seem to be very reliable with Ogg (check https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/520) and most of the media-element WPTs uses a short ogv file, so I had to make our `canPlayType` report that it is not able to play this type to make the tests pick the alternative mp4 version of the same files. Once Ogg support for GStreamer improves, we should be able to revert this change. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22477) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlmediaelement.rs')
-rw-r--r--components/script/dom/htmlmediaelement.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 880ba8ea49c..b751e176fb4 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -204,6 +204,9 @@ pub struct HTMLMediaElement {
text_tracks_list: MutNullableDom<TextTrackList>,
/// Expected content length of the media asset being fetched or played.
content_length: Cell<Option<u64>>,
+ /// Time of last timeupdate notification.
+ #[ignore_malloc_size_of = "Defined in time"]
+ next_timeupdate_event: Cell<Timespec>,
}
/// <https://html.spec.whatwg.org/multipage/#dom-media-networkstate>
@@ -261,6 +264,7 @@ impl HTMLMediaElement {
played: Rc::new(DomRefCell::new(TimeRangesContainer::new())),
text_tracks_list: Default::default(),
content_length: Cell::new(None),
+ next_timeupdate_event: Cell::new(time::get_time() + Duration::milliseconds(250)),
}
}
@@ -303,7 +307,16 @@ impl HTMLMediaElement {
/// https://html.spec.whatwg.org/multipage/#time-marches-on
fn time_marches_on(&self) {
- // TODO: implement this.
+ // Step 6.
+ if time::get_time() > self.next_timeupdate_event.get() {
+ let window = window_from_node(self);
+ window
+ .task_manager()
+ .media_element_task_source()
+ .queue_simple_event(self.upcast(), atom!("timeupdate"), &window);
+ self.next_timeupdate_event
+ .set(time::get_time() + Duration::milliseconds(350));
+ }
}
/// <https://html.spec.whatwg.org/multipage/#internal-pause-steps>
@@ -1173,6 +1186,7 @@ impl HTMLMediaElement {
.borrow_mut()
.add(self.playback_position.get(), position);
self.playback_position.set(position);
+ self.time_marches_on();
},
PlayerEvent::StateChanged(ref state) => match *state {
PlaybackState::Paused => {
@@ -1270,8 +1284,14 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-navigator-canplaytype
fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult {
match type_.parse::<Mime>() {
+ // XXX GStreamer is currently not very reliable playing OGG and most of
+ // the media related WPTs uses OGG if we report that we are able to
+ // play this type. So we report that we are unable to play it to force
+ // the usage of other types.
+ // https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/520
Ok(ref mime)
- if (mime.type_() == mime::APPLICATION && mime.subtype() == mime::OCTET_STREAM) =>
+ if (mime.type_() == mime::APPLICATION && mime.subtype() == mime::OCTET_STREAM) ||
+ (mime.subtype() == mime::OGG) =>
{
CanPlayTypeResult::_empty
},