Title: [282055] trunk/Source/WebCore
Revision
282055
Author
[email protected]
Date
2021-09-06 04:47:32 -0700 (Mon, 06 Sep 2021)

Log Message

[GStreamer][MSE] Check ContentType parameters when checking supported types
https://bugs.webkit.org/show_bug.cgi?id=229859

Reviewed by Xabier Rodriguez-Calvar.

Some services like YouTube TV or Apple TV use ContentType parameters (channels, features, width, height,
framerate) to check for extra features or device maximum capabilities and just don't work if they're not
honored.

This patch checks that those parameters don't go over reasonable limits and reject support for the type
if they do.

This patch is an adaptation of the following downstream patches:

- https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/12c726290ac3395a0b7dd09861355e97be42e434 (authored by me)
- https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/b33dfe9fea5f991cf98884ef3bb3e3d9c660bc6b (authored by Pawel Lampe)

* platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
(WebCore::GStreamerRegistryScanner::supportsFeatures const): Check the features parameter. Factored out as a method with the idea to add more checks it in the future.
(WebCore::GStreamerRegistryScanner::isContentTypeSupported const): Check the channels, features, width, height and framerate parameters against sane maximum values.
* platform/graphics/gstreamer/GStreamerRegistryScanner.h: Added supportsFeatures() method.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282054 => 282055)


--- trunk/Source/WebCore/ChangeLog	2021-09-06 08:49:02 UTC (rev 282054)
+++ trunk/Source/WebCore/ChangeLog	2021-09-06 11:47:32 UTC (rev 282055)
@@ -1,3 +1,27 @@
+2021-09-06  Enrique Ocaña González  <[email protected]>
+
+        [GStreamer][MSE] Check ContentType parameters when checking supported types
+        https://bugs.webkit.org/show_bug.cgi?id=229859
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Some services like YouTube TV or Apple TV use ContentType parameters (channels, features, width, height,
+        framerate) to check for extra features or device maximum capabilities and just don't work if they're not
+        honored.
+
+        This patch checks that those parameters don't go over reasonable limits and reject support for the type
+        if they do.
+
+        This patch is an adaptation of the following downstream patches:
+
+        - https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/12c726290ac3395a0b7dd09861355e97be42e434 (authored by me)
+        - https://github.com/WebPlatformForEmbedded/WPEWebKit/commit/b33dfe9fea5f991cf98884ef3bb3e3d9c660bc6b (authored by Pawel Lampe)
+
+        * platform/graphics/gstreamer/GStreamerRegistryScanner.cpp:
+        (WebCore::GStreamerRegistryScanner::supportsFeatures const): Check the features parameter. Factored out as a method with the idea to add more checks it in the future.
+        (WebCore::GStreamerRegistryScanner::isContentTypeSupported const): Check the channels, features, width, height and framerate parameters against sane maximum values.
+        * platform/graphics/gstreamer/GStreamerRegistryScanner.h: Added supportsFeatures() method.
+
 2021-09-06  Youenn Fablet  <[email protected]>
 
         Implement libwebrtc network manager GetMdnsResponder

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp (282054 => 282055)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp	2021-09-06 08:49:02 UTC (rev 282054)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.cpp	2021-09-06 11:47:32 UTC (rev 282055)
@@ -28,6 +28,7 @@
 #include <gst/pbutils/codec-utils.h>
 #include <wtf/PrintStream.h>
 #include <wtf/WeakPtr.h>
+#include <wtf/text/StringToIntegerConversion.h>
 
 namespace WebCore {
 
@@ -34,6 +35,15 @@
 GST_DEBUG_CATEGORY_STATIC(webkit_media_gst_registry_scanner_debug);
 #define GST_CAT_DEFAULT webkit_media_gst_registry_scanner_debug
 
+// We shouldn't accept media that the player can't actually play.
+// AAC supports up to 96 channels.
+#define MEDIA_MAX_AAC_CHANNELS 96
+
+// Assume hardware video decoding acceleration up to 8K@60fps for the generic case. Some embedded platforms might want to tune this.
+#define MEDIA_MAX_WIDTH 7680.0f
+#define MEDIA_MAX_HEIGHT 4320.0f
+#define MEDIA_MAX_FRAMERATE 60.0f
+
 GStreamerRegistryScanner& GStreamerRegistryScanner::singleton()
 {
     static NeverDestroyed<GStreamerRegistryScanner> sharedInstance;
@@ -501,6 +511,16 @@
     return supported;
 }
 
+bool GStreamerRegistryScanner::supportsFeatures(const String& features) const
+{
+    // Apple TV requires this one for DD+.
+    constexpr auto dolbyDigitalPlusJOC = "joc";
+    if (features == dolbyDigitalPlusJOC)
+        return true;
+
+    return false;
+}
+
 MediaPlayerEnums::SupportsType GStreamerRegistryScanner::isContentTypeSupported(Configuration configuration, const ContentType& contentType, const Vector<ContentType>& contentTypesRequiringHardwareSupport) const
 {
     using SupportsType = MediaPlayerEnums::SupportsType;
@@ -509,6 +529,15 @@
     if (!isContainerTypeSupported(configuration, containerType))
         return SupportsType::IsNotSupported;
 
+    int channels = parseInteger<int>(contentType.parameter("channels"_s)).value_or(1);
+    String features = contentType.parameter("features"_s);
+    if (channels > MEDIA_MAX_AAC_CHANNELS || channels <= 0
+        || !(features.isEmpty() || supportsFeatures(features))
+        || parseInteger<unsigned>(contentType.parameter("width"_s)).value_or(0) > MEDIA_MAX_WIDTH
+        || parseInteger<unsigned>(contentType.parameter("height"_s)).value_or(0) > MEDIA_MAX_HEIGHT
+        || parseInteger<unsigned>(contentType.parameter("framerate"_s)).value_or(0) > MEDIA_MAX_FRAMERATE)
+        return SupportsType::IsNotSupported;
+
     const auto& codecs = contentType.codecs();
 
     // Spec says we should not return "probably" if the codecs string is empty.

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h (282054 => 282055)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h	2021-09-06 08:49:02 UTC (rev 282054)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerRegistryScanner.h	2021-09-06 11:47:32 UTC (rev 282055)
@@ -114,6 +114,7 @@
 
 private:
     const char* configurationNameForLogging(Configuration) const;
+    bool supportsFeatures(const String& features) const;
 
     bool m_isMediaSource { false };
     HashSet<String, ASCIICaseInsensitiveHash> m_decoderMimeTypeSet;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to