Auto merge of #23229 - georgeroman:implement_htmlmediaelement_canplaytype, r=ferjm

Finish the implementation of the HTMLMediaElement canPlayType method

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #22299

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/23229)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-05-07 13:57:46 -04:00 committed by GitHub
commit cd06c3450e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 62 deletions

View file

@ -62,7 +62,6 @@ use html5ever::{LocalName, Prefix};
use http::header::{self, HeaderMap, HeaderValue}; use http::header::{self, HeaderMap, HeaderValue};
use ipc_channel::ipc; use ipc_channel::ipc;
use ipc_channel::router::ROUTER; use ipc_channel::router::ROUTER;
use mime::{self, Mime};
use net_traits::image::base::Image; use net_traits::image::base::Image;
use net_traits::image_cache::ImageResponse; use net_traits::image_cache::ImageResponse;
use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder}; use net_traits::request::{CredentialsMode, Destination, Referrer, RequestBuilder};
@ -73,7 +72,7 @@ use servo_config::pref;
use servo_media::player::context::{GlContext, NativeDisplay, PlayerGLContext}; use servo_media::player::context::{GlContext, NativeDisplay, PlayerGLContext};
use servo_media::player::frame::{Frame, FrameRenderer}; use servo_media::player::frame::{Frame, FrameRenderer};
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType}; use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
use servo_media::ServoMedia; use servo_media::{ServoMedia, SupportsMediaType};
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::cell::Cell; use std::cell::Cell;
use std::collections::VecDeque; use std::collections::VecDeque;
@ -1674,20 +1673,10 @@ impl HTMLMediaElementMethods for HTMLMediaElement {
// https://html.spec.whatwg.org/multipage/#dom-navigator-canplaytype // https://html.spec.whatwg.org/multipage/#dom-navigator-canplaytype
fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult { fn CanPlayType(&self, type_: DOMString) -> CanPlayTypeResult {
match type_.parse::<Mime>() { match ServoMedia::get().unwrap().can_play_type(&type_) {
// XXX GStreamer is currently not very reliable playing OGG and most of SupportsMediaType::No => CanPlayTypeResult::_empty,
// the media related WPTs uses OGG if we report that we are able to SupportsMediaType::Maybe => CanPlayTypeResult::Maybe,
// play this type. So we report that we are unable to play it to force SupportsMediaType::Probably => CanPlayTypeResult::Probably,
// 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) ||
(mime.subtype() == mime::OGG) =>
{
CanPlayTypeResult::_empty
},
Err(_) => CanPlayTypeResult::_empty,
_ => CanPlayTypeResult::Maybe,
} }
} }

View file

@ -2,9 +2,6 @@
[video/mp4; codecs="mp4v.20.8" (optional)] [video/mp4; codecs="mp4v.20.8" (optional)]
expected: FAIL expected: FAIL
[video/webm with bogus codec]
expected: FAIL
[video/3gpp; codecs="samr" (optional)] [video/3gpp; codecs="samr" (optional)]
expected: FAIL expected: FAIL
@ -14,33 +11,18 @@
[audio/webm (optional)] [audio/webm (optional)]
expected: FAIL expected: FAIL
[audio/webm with and without codecs]
expected: FAIL
[audio/mp4; codecs="mp4a.40.2" (optional)] [audio/mp4; codecs="mp4a.40.2" (optional)]
expected: FAIL expected: FAIL
[audio/mp4 with bogus codec]
expected: FAIL
[audio/webm; codecs="vorbis" (optional)]
expected: FAIL
[video/webm; codecs="vp9" (optional)]
expected: FAIL
[video/ogg; codecs="theora" (optional)] [video/ogg; codecs="theora" (optional)]
expected: FAIL expected: FAIL
[video/mp4; codecs="avc1.64001E" (optional)] [video/mp4; codecs="avc1.64001E" (optional)]
expected: FAIL expected: FAIL
[video/ogg; codecs="opus" (optional)]
expected: FAIL
[fictional formats and codecs not supported]
expected: FAIL
[video/mp4 with bogus codec]
expected: FAIL
[video/mp4 (optional)] [video/mp4 (optional)]
expected: FAIL expected: FAIL
@ -50,10 +32,10 @@
[audio/ogg; codecs="opus" (optional)] [audio/ogg; codecs="opus" (optional)]
expected: FAIL expected: FAIL
[video/webm; codecs="vp8.0" (optional)] [video/webm (optional)]
expected: FAIL expected: FAIL
[video/webm (optional)] [video/webm with and without codecs]
expected: FAIL expected: FAIL
[video/mp4; codecs="avc1.4D401E" (optional)] [video/mp4; codecs="avc1.4D401E" (optional)]
@ -62,9 +44,6 @@
[audio/wav; codecs="1" (optional)] [audio/wav; codecs="1" (optional)]
expected: FAIL expected: FAIL
[video/3gpp with bogus codec]
expected: FAIL
[audio/wav (optional)] [audio/wav (optional)]
expected: FAIL expected: FAIL
@ -80,9 +59,6 @@
[audio/mp4 (optional)] [audio/mp4 (optional)]
expected: FAIL expected: FAIL
[video/webm; codecs="opus" (optional)]
expected: FAIL
[video/3gpp (optional)] [video/3gpp (optional)]
expected: FAIL expected: FAIL
@ -95,24 +71,8 @@
[audio/ogg; codecs="vorbis" (optional)] [audio/ogg; codecs="vorbis" (optional)]
expected: FAIL expected: FAIL
[audio/webm; codecs="opus" (optional)] [video/ogg; codecs="opus" (optional)]
expected: FAIL
[video/webm; codecs="vorbis" (optional)]
expected: FAIL
[audio/wav with bogus codec]
expected: FAIL expected: FAIL
[video/3gpp; codecs="mp4v.20.8" (optional)] [video/3gpp; codecs="mp4v.20.8" (optional)]
expected: FAIL expected: FAIL
[video/webm; codecs="vp9.0" (optional)]
expected: FAIL
[video/webm; codecs="vp8" (optional)]
expected: FAIL
[audio/webm with bogus codec]
expected: FAIL