mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
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 -->
This commit is contained in:
commit
4ac5b8a3ae
189 changed files with 914 additions and 351 deletions
|
@ -130,7 +130,7 @@ use style::values::specified::Length;
|
|||
use tendril::fmt::UTF8;
|
||||
use tendril::stream::LossyDecoder;
|
||||
use tendril::{StrTendril, TendrilSink};
|
||||
use time::Duration;
|
||||
use time::{Duration, Timespec};
|
||||
use uuid::Uuid;
|
||||
use webrender_api::{DocumentId, ImageKey, RenderApiSender};
|
||||
use webvr_traits::WebVRGamepadHand;
|
||||
|
@ -488,6 +488,7 @@ unsafe_no_jsmanaged_fields!(dyn Player<Error = ServoMediaError>);
|
|||
unsafe_no_jsmanaged_fields!(Mutex<MediaFrameRenderer>);
|
||||
unsafe_no_jsmanaged_fields!(RenderApiSender);
|
||||
unsafe_no_jsmanaged_fields!(ResourceFetchTiming);
|
||||
unsafe_no_jsmanaged_fields!(Timespec);
|
||||
|
||||
unsafe impl<'a> JSTraceable for &'a str {
|
||||
#[inline]
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue