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 ipc_channel::ipc;
use ipc_channel::router::ROUTER;
use mime::{self, Mime};
use net_traits::image::base::Image;
use net_traits::image_cache::ImageResponse;
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::frame::{Frame, FrameRenderer};
use servo_media::player::{PlaybackState, Player, PlayerError, PlayerEvent, StreamType};
use servo_media::ServoMedia;
use servo_media::{ServoMedia, SupportsMediaType};
use servo_url::ServoUrl;
use std::cell::Cell;
use std::collections::VecDeque;
@ -1674,20 +1673,10 @@ 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) ||
(mime.subtype() == mime::OGG) =>
{
CanPlayTypeResult::_empty
},
Err(_) => CanPlayTypeResult::_empty,
_ => CanPlayTypeResult::Maybe,
match ServoMedia::get().unwrap().can_play_type(&type_) {
SupportsMediaType::No => CanPlayTypeResult::_empty,
SupportsMediaType::Maybe => CanPlayTypeResult::Maybe,
SupportsMediaType::Probably => CanPlayTypeResult::Probably,
}
}