LibWeb: Report support for WebM (VP9/Opus) in MediaSource
This commit is contained in:
parent
59bc23f309
commit
4dba9f0a0d
3 changed files with 39 additions and 13 deletions
|
|
@ -80,16 +80,40 @@ bool MediaSource::is_type_supported(JS::VM&, String const& type)
|
|||
if (!mime_type.has_value())
|
||||
return false;
|
||||
|
||||
// FIXME: 3. If type contains a media type or media subtype that the MediaSource does not support, then
|
||||
// FIXME: Ask LibMedia about what it supports instead of hardcoding this.
|
||||
|
||||
// 3. If type contains a media type or media subtype that the MediaSource does not support, then
|
||||
// return false.
|
||||
return false;
|
||||
auto type_and_subtype_are_supported = [&] {
|
||||
if (mime_type->type() == "video" && mime_type->subtype() == "webm")
|
||||
return true;
|
||||
if (mime_type->type() == "audio" && mime_type->subtype() == "webm")
|
||||
return true;
|
||||
return false;
|
||||
}();
|
||||
if (!type_and_subtype_are_supported)
|
||||
return false;
|
||||
|
||||
// FIXME: 4. If type contains a codec that the MediaSource does not support, then return false.
|
||||
|
||||
// FIXME: 5. If the MediaSource does not support the specified combination of media type, media
|
||||
// 4. If type contains a codec that the MediaSource does not support, then return false.
|
||||
// 5. If the MediaSource does not support the specified combination of media type, media
|
||||
// subtype, and codecs then return false.
|
||||
auto codecs_iter = mime_type->parameters().find("codecs"sv);
|
||||
if (codecs_iter == mime_type->parameters().end())
|
||||
return false;
|
||||
auto codecs = codecs_iter->value.bytes_as_string_view();
|
||||
auto had_unsupported_codec = false;
|
||||
codecs.for_each_split_view(',', SplitBehavior::Nothing, [&](auto const& codec) {
|
||||
if (!codec.starts_with("vp9"sv) && !codec.starts_with("vp09"sv) && !codec.starts_with("opus"sv)) {
|
||||
had_unsupported_codec = true;
|
||||
return IterationDecision::Break;
|
||||
}
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
if (had_unsupported_codec)
|
||||
return false;
|
||||
|
||||
// 6. Return true.
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
FAIL: isTypeSupported: video/webm;codecs="vp9,opus" not supported
|
||||
PASS: isTypeSupported
|
||||
PASS: created MediaSource
|
||||
FAIL: setup: TypeError: No union types matched
|
||||
|
|
|
|||
|
|
@ -2,17 +2,17 @@ Harness status: OK
|
|||
|
||||
Found 55 tests
|
||||
|
||||
33 Pass
|
||||
22 Fail
|
||||
32 Pass
|
||||
23 Fail
|
||||
Pass Test invalid MIME format "video"
|
||||
Pass Test invalid MIME format "video/"
|
||||
Pass Test invalid MIME format "video/webm"
|
||||
Pass Test invalid MIME format "video/webm;"
|
||||
Pass Test invalid MIME format "video/webm;codecs"
|
||||
Pass Test invalid MIME format "video/webm;codecs="
|
||||
Pass Test invalid MIME format "video/webm;codecs=""
|
||||
Pass Test invalid MIME format "video/webm;codecs="""
|
||||
Pass Test invalid MIME format "video/webm;codecs=",""
|
||||
Fail Test invalid MIME format "video/webm;codecs=""
|
||||
Fail Test invalid MIME format "video/webm;codecs="""
|
||||
Fail Test invalid MIME format "video/webm;codecs=",""
|
||||
Pass Test invalid MIME format "audio/webm;aaacodecsbbb=opus"
|
||||
Pass Test invalid MIME format "unsupported_mediatype"
|
||||
Pass Test invalid MIME format ""
|
||||
|
|
@ -44,8 +44,8 @@ Fail Test valid WebM type "video/webm;codecs="vorbis, vp8""
|
|||
Fail Test valid WebM type "audio/webm;codecs="vorbis""
|
||||
Fail Test valid WebM type "AUDIO/WEBM;CODECS="vorbis""
|
||||
Fail Test valid WebM type "audio/webm;codecs=vorbis;test="6""
|
||||
Fail Test valid WebM type "audio/webm;codecs="opus""
|
||||
Fail Test valid WebM type "video/webm;codecs="opus""
|
||||
Pass Test valid WebM type "audio/webm;codecs="opus""
|
||||
Pass Test valid WebM type "video/webm;codecs="opus""
|
||||
Fail Test valid MP4 type "video/mp4;codecs="avc1.4d001e""
|
||||
Fail Test valid MP4 type "video/mp4;codecs="avc1.42001e""
|
||||
Fail Test valid MP4 type "audio/mp4;codecs="mp4a.40.2""
|
||||
|
|
|
|||
Loading…
Reference in a new issue