Title: [224107] trunk
Revision
224107
Author
[email protected]
Date
2017-10-27 02:35:53 -0700 (Fri, 27 Oct 2017)

Log Message

[GStreamer][MSE] Trim space between codecs
https://bugs.webkit.org/show_bug.cgi?id=178160

Patch by Alicia Boya García <[email protected]> on 2017-10-27
Reviewed by Xabier Rodriguez-Calvar.

Source/WebCore:

Modify supportsCodecs() to accept a Vector<String> instead of
receiving a string and parsing itself.

This improves passrate for `mediasource-is-type-supported` as it
ensures that whitespace between codecs is now trimmed and codec
strings such as `video/webm;codecs="opus, vp9"` are matched as a valid
type, as required by the spec.

This patch also renames supportCodecs() to supportAllCodecs() and adds
a new variant, supportCodec(), that checks for support of an
individual codec.

* platform/graphics/gstreamer/mse/AppendPipeline.cpp:
(WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
(WebCore::MediaPlayerPrivateGStreamerMSE::supportsCodec):
(WebCore::MediaPlayerPrivateGStreamerMSE::supportsAllCodecs):
(WebCore::MediaPlayerPrivateGStreamerMSE::supportsType):
* platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:

LayoutTests:

Update expected test output.

* platform/gtk/imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224106 => 224107)


--- trunk/LayoutTests/ChangeLog	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/LayoutTests/ChangeLog	2017-10-27 09:35:53 UTC (rev 224107)
@@ -1,3 +1,14 @@
+2017-10-27  Alicia Boya García  <[email protected]>
+
+        [GStreamer][MSE] Trim space between codecs
+        https://bugs.webkit.org/show_bug.cgi?id=178160
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Update expected test output.
+
+        * platform/gtk/imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported-expected.txt:
+
 2017-10-27  Ryosuke Niwa  <[email protected]>
 
         Skip some copy & paste tests I wrote on GTK since they're are known to timeout/slow.

Modified: trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported-expected.txt (224106 => 224107)


--- trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported-expected.txt	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/LayoutTests/platform/gtk/imported/w3c/web-platform-tests/media-source/mediasource-is-type-supported-expected.txt	2017-10-27 09:35:53 UTC (rev 224107)
@@ -7,7 +7,7 @@
 FAIL Test invalid MIME format "video/webm;codecs=" assert_equals: supported expected false but got true
 PASS Test invalid MIME format "video/webm;codecs="" 
 FAIL Test invalid MIME format "video/webm;codecs=""" assert_equals: supported expected false but got true
-FAIL Test invalid MIME format "video/webm;codecs=","" assert_equals: supported expected false but got true
+PASS Test invalid MIME format "video/webm;codecs=","" 
 PASS Test invalid MIME format "" 
 PASS Test invalid MIME format "null" 
 PASS Test invalid MSE MIME media type "xxx" 
@@ -27,7 +27,7 @@
 PASS Test valid WebM type "video/webm;codecs="vp8"" 
 PASS Test valid WebM type "video/webm;codecs="vorbis"" 
 PASS Test valid WebM type "video/webm;codecs="vp8,vorbis"" 
-FAIL Test valid WebM type "video/webm;codecs="vorbis, vp8"" assert_equals: supported expected true but got false
+PASS Test valid WebM type "video/webm;codecs="vorbis, vp8"" 
 PASS Test valid WebM type "audio/webm;codecs="vorbis"" 
 PASS Test valid WebM type "AUDIO/WEBM;CODECS="vorbis"" 
 PASS Test valid MP4 type "video/mp4;codecs="avc1.4d001e"" 
@@ -37,6 +37,6 @@
 PASS Test valid MP4 type "audio/mp4;codecs="mp4a.67"" 
 PASS Test valid MP4 type "video/mp4;codecs="mp4a.40.2"" 
 PASS Test valid MP4 type "video/mp4;codecs="avc1.4d001e,mp4a.40.2"" 
-FAIL Test valid MP4 type "video/mp4;codecs="mp4a.40.2 , avc1.4d001e "" assert_equals: supported expected true but got false
+PASS Test valid MP4 type "video/mp4;codecs="mp4a.40.2 , avc1.4d001e "" 
 PASS Test valid MP4 type "video/mp4;codecs="avc1.4d001e,mp4a.40.5"" 
 

Modified: trunk/Source/WebCore/ChangeLog (224106 => 224107)


--- trunk/Source/WebCore/ChangeLog	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/Source/WebCore/ChangeLog	2017-10-27 09:35:53 UTC (rev 224107)
@@ -1,3 +1,30 @@
+2017-10-27  Alicia Boya García  <[email protected]>
+
+        [GStreamer][MSE] Trim space between codecs
+        https://bugs.webkit.org/show_bug.cgi?id=178160
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Modify supportsCodecs() to accept a Vector<String> instead of
+        receiving a string and parsing itself.
+
+        This improves passrate for `mediasource-is-type-supported` as it
+        ensures that whitespace between codecs is now trimmed and codec
+        strings such as `video/webm;codecs="opus, vp9"` are matched as a valid
+        type, as required by the spec.
+
+        This patch also renames supportCodecs() to supportAllCodecs() and adds
+        a new variant, supportCodec(), that checks for support of an
+        individual codec.
+
+        * platform/graphics/gstreamer/mse/AppendPipeline.cpp:
+        (WebCore::AppendPipeline::parseDemuxerSrcPadCaps):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerMSE::supportsCodec):
+        (WebCore::MediaPlayerPrivateGStreamerMSE::supportsAllCodecs):
+        (WebCore::MediaPlayerPrivateGStreamerMSE::supportsType):
+        * platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h:
+
 2017-10-27  Michael Catanzaro  <[email protected]>
 
         [GTK] Crash in WebCore::SelectionRangeData::apply

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp (224106 => 224107)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/AppendPipeline.cpp	2017-10-27 09:35:53 UTC (rev 224107)
@@ -599,7 +599,7 @@
 
         const gchar* originalMediaType = gst_structure_get_string(structure, "original-media-type");
 
-        if (!MediaPlayerPrivateGStreamerMSE::supportsCodecs(originalMediaType)) {
+        if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(originalMediaType)) {
             m_presentationSize = WebCore::FloatSize();
             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Invalid;
         } else if (g_str_has_prefix(originalMediaType, "video/")) {
@@ -632,7 +632,7 @@
         const char* structureName = gst_structure_get_name(structure);
         GstVideoInfo info;
 
-        if (!MediaPlayerPrivateGStreamerMSE::supportsCodecs(structureName)) {
+        if (!MediaPlayerPrivateGStreamerMSE::supportsCodec(structureName)) {
             m_presentationSize = WebCore::FloatSize();
             m_streamType = WebCore::MediaSourceStreamTypeGStreamer::Invalid;
         } else if (g_str_has_prefix(structureName, "video/") && gst_video_info_from_caps(&info, demuxerSrcPadCaps)) {

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp (224106 => 224107)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.cpp	2017-10-27 09:35:53 UTC (rev 224107)
@@ -837,26 +837,26 @@
     return codecTypes;
 }
 
-bool MediaPlayerPrivateGStreamerMSE::supportsCodecs(const String& codecs)
+bool MediaPlayerPrivateGStreamerMSE::supportsCodec(String codec)
 {
-    Vector<String> codecEntries;
-    codecs.split(',', false, codecEntries);
+    // If the codec is named like a mimetype (eg: video/avc) remove the "video/" part.
+    size_t slashIndex = codec.find('/');
+    if (slashIndex != WTF::notFound)
+        codec = codec.substring(slashIndex+1);
 
-    for (String codec : codecEntries) {
-        bool isCodecSupported = false;
+    for (const auto& pattern : codecSet()) {
+        bool codecMatchesPattern = !fnmatch(pattern.string().utf8().data(), codec.utf8().data(), 0);
+        if (codecMatchesPattern)
+            return true;
+    }
 
-        // If the codec is named like a mimetype (eg: video/avc) remove the "video/" part.
-        size_t slashIndex = codec.find('/');
-        if (slashIndex != WTF::notFound)
-            codec = codec.substring(slashIndex+1);
+    return false;
+}
 
-        const char* codecData = codec.utf8().data();
-        for (const auto& pattern : codecSet()) {
-            isCodecSupported = !fnmatch(pattern.string().utf8().data(), codecData, 0);
-            if (isCodecSupported)
-                break;
-        }
-        if (!isCodecSupported)
+bool MediaPlayerPrivateGStreamerMSE::supportsAllCodecs(const Vector<String>& codecs)
+{
+    for (String codec : codecs) {
+        if (!supportsCodec(codec))
             return false;
     }
 
@@ -879,11 +879,11 @@
 
     // Spec says we should not return "probably" if the codecs string is empty.
     if (mimeTypeCache().contains(containerType)) {
-        String codecs = parameters.type.parameter(ContentType::codecsParameter());
+        Vector<String> codecs = parameters.type.codecs();
         if (codecs.isEmpty())
             result = MediaPlayer::MayBeSupported;
         else
-            result = supportsCodecs(codecs) ? MediaPlayer::IsSupported : MediaPlayer::IsNotSupported;
+            result = supportsAllCodecs(codecs) ? MediaPlayer::IsSupported : MediaPlayer::IsNotSupported;
     }
 
     return extendedSupportsType(parameters, result);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h (224106 => 224107)


--- trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-10-27 09:31:13 UTC (rev 224106)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/mse/MediaPlayerPrivateGStreamerMSE.h	2017-10-27 09:35:53 UTC (rev 224107)
@@ -83,7 +83,8 @@
     void trackDetected(RefPtr<AppendPipeline>, RefPtr<WebCore::TrackPrivateBase>, bool firstTrackDetected);
     void notifySeekNeedsDataForTime(const MediaTime&);
 
-    static bool supportsCodecs(const String& codecs);
+    static bool supportsCodec(String codec);
+    static bool supportsAllCodecs(const Vector<String>& codecs);
 
 #if ENABLE(ENCRYPTED_MEDIA)
     void attemptToDecryptWithInstance(const CDMInstance&) final;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to