Title: [273311] trunk/Source/WebCore
Revision
273311
Author
[email protected]
Date
2021-02-23 09:09:50 -0800 (Tue, 23 Feb 2021)

Log Message

[GStreamer][EME][Thunder] Initialize decryptor lazily
https://bugs.webkit.org/show_bug.cgi?id=222314

Reviewed by Philippe Normand.

In some cases, WebKit can be run before Thunder nano services are
up and without PSON, the result can be that you end up with WebKit
thinking there is no DRM system available.

First thing this patch does it removing the once flag so we keep
asking if there are DRM systems available if we are asked about
them from JS.

Second thing is that if we are queried from JS about the
availability of DRM systems and there are some available, we
initialize the decryptor.

* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::registerWebKitGStreamerElements):
* platform/graphics/gstreamer/eme/CDMThunder.cpp:
(WebCore::CDMFactoryThunder::supportedKeySystems const):
* platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273310 => 273311)


--- trunk/Source/WebCore/ChangeLog	2021-02-23 17:08:46 UTC (rev 273310)
+++ trunk/Source/WebCore/ChangeLog	2021-02-23 17:09:50 UTC (rev 273311)
@@ -1,3 +1,28 @@
+2021-02-23  Xabier Rodriguez Calvar  <[email protected]>
+
+        [GStreamer][EME][Thunder] Initialize decryptor lazily
+        https://bugs.webkit.org/show_bug.cgi?id=222314
+
+        Reviewed by Philippe Normand.
+
+        In some cases, WebKit can be run before Thunder nano services are
+        up and without PSON, the result can be that you end up with WebKit
+        thinking there is no DRM system available.
+
+        First thing this patch does it removing the once flag so we keep
+        asking if there are DRM systems available if we are asked about
+        them from JS.
+
+        Second thing is that if we are queried from JS about the
+        availability of DRM systems and there are some available, we
+        initialize the decryptor.
+
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::registerWebKitGStreamerElements):
+        * platform/graphics/gstreamer/eme/CDMThunder.cpp:
+        (WebCore::CDMFactoryThunder::supportedKeySystems const):
+        * platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:
+
 2021-02-23  Don Olmstead  <[email protected]>
 
         Only files in WebCore/testing should be in WebCoreTestSupport

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (273310 => 273311)


--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2021-02-23 17:08:46 UTC (rev 273310)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp	2021-02-23 17:09:50 UTC (rev 273311)
@@ -311,11 +311,7 @@
 
 #if ENABLE(ENCRYPTED_MEDIA)
         gst_element_register(nullptr, "webkitclearkey", GST_RANK_PRIMARY + 200, WEBKIT_TYPE_MEDIA_CK_DECRYPT);
-#if ENABLE(THUNDER)
-        unsigned thunderRank = isThunderRanked() ? 300 : 100;
-        gst_element_register(nullptr, "webkitthunder", GST_RANK_PRIMARY + thunderRank, WEBKIT_TYPE_MEDIA_THUNDER_DECRYPT);
 #endif
-#endif
 
 #if ENABLE(MEDIA_STREAM)
         gst_element_register(nullptr, "mediastreamsrc", GST_RANK_PRIMARY, WEBKIT_TYPE_MEDIA_STREAM_SRC);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp (273310 => 273311)


--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp	2021-02-23 17:08:46 UTC (rev 273310)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp	2021-02-23 17:09:50 UTC (rev 273311)
@@ -42,6 +42,7 @@
 #include "MediaKeyStatus.h"
 #include "NotImplemented.h"
 #include "SharedBuffer.h"
+#include "WebKitThunderDecryptorGStreamer.h"
 #include <algorithm>
 #include <iterator>
 #include <wtf/MainThread.h>
@@ -114,19 +115,24 @@
 
 const Vector<String>& CDMFactoryThunder::supportedKeySystems() const
 {
-    static std::once_flag onceFlag;
+    ASSERT(isMainThread());
+
     static Vector<String> supportedKeySystems;
-    std::call_once(onceFlag, [] {
+    if (supportedKeySystems.isEmpty()) {
         std::string emptyString;
         if (opencdm_is_type_supported(GStreamerEMEUtilities::s_WidevineKeySystem, emptyString.c_str()) == ERROR_NONE)
             supportedKeySystems.append(GStreamerEMEUtilities::s_WidevineKeySystem);
+        if (!supportedKeySystems.isEmpty()) {
+            unsigned thunderRank = isThunderRanked() ? 300 : 100;
+            gst_element_register(nullptr, "webkitthunder", GST_RANK_PRIMARY + thunderRank, WEBKIT_TYPE_MEDIA_THUNDER_DECRYPT);
+        }
 #ifndef NDEBUG
-        if (supportedKeySystems.isEmpty() && isThunderRanked()) {
-            ASSERT_NOT_REACHED_WITH_MESSAGE("Thunder is up-ranked as preferred decryptor but Thunder is not supporting any encryption system. Is "
+        else if (isThunderRanked())
+            GST_WARNING("Thunder is up-ranked as preferred decryptor but Thunder is not supporting any encryption system. Is "
                 "Thunder running? Are the plugins built?");
-        }
 #endif
-    });
+        GST_DEBUG("%u supported key systems", supportedKeySystems.size());
+    };
     return supportedKeySystems;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp (273310 => 273311)


--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp	2021-02-23 17:08:46 UTC (rev 273310)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp	2021-02-23 17:09:50 UTC (rev 273311)
@@ -70,7 +70,9 @@
 {
     GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_empty());
 
-    if (CDMFactoryThunder::singleton().supportedKeySystems().isEmpty()) {
+    auto& supportedKeySystems = CDMFactoryThunder::singleton().supportedKeySystems();
+
+    if (supportedKeySystems.isEmpty()) {
         GST_WARNING("no supported key systems in Thunder, we won't be able to decrypt anything with the its decryptor");
         return caps;
     }
@@ -79,7 +81,7 @@
         gst_caps_append_structure(caps.get(), gst_structure_new("application/x-cenc", "original-media-type", G_TYPE_STRING,
             cencEncryptionMediaTypes[i], nullptr));
     }
-    for (const auto& keySystem : CDMFactoryThunder::singleton().supportedKeySystems()) {
+    for (const auto& keySystem : supportedKeySystems) {
         for (int i = 0; cencEncryptionMediaTypes[i]; ++i) {
             gst_caps_append_structure(caps.get(), gst_structure_new("application/x-cenc", "original-media-type", G_TYPE_STRING,
                 cencEncryptionMediaTypes[i], "protection-system", G_TYPE_STRING, GStreamerEMEUtilities::keySystemToUuid(keySystem), nullptr));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to