Title: [272369] trunk
Revision
272369
Author
ph...@webkit.org
Date
2021-02-04 08:36:33 -0800 (Thu, 04 Feb 2021)

Log Message

[GStreamer] Misc Thunder nitpicks
https://bugs.webkit.org/show_bug.cgi?id=221398

Reviewed by Xabier Rodriguez-Calvar.

.:

* Source/cmake/FindThunder.cmake: Look-up Thunder through pkg-config before attempting a
direct libocdm lookup.

Source/WebCore:

* platform/UserAgentQuirks.cpp:
(WebCore::urlRequiresFirefoxBrowser): For Netflix we should use a Firefox User-Agent, when
Thunder is enabled.
* platform/graphics/gstreamer/eme/CDMThunder.cpp:
(WebCore::CDMFactoryThunder::singleton): Use a dedicated gst debug category for this module,
in order to decouple from the decryptor.
(WebCore::CDMFactoryThunder::supportedKeySystems const): Use explicit return value, removing
possible misunderstandings.
(WebCore::CDMPrivateThunder::CDMPrivateThunder):
(WebCore::CDMPrivateThunder::supportedRobustnesses const): Thunder supports secure decode/crypto in software.
(WebCore::CDMPrivateThunder::supportsServerCertificates const): Plumb to new
opencdm_system_supports_certificate API.
(WebCore::CDMInstanceThunder::setStorageDirectory): Ensure storage directory exists.
(WebCore::ParsedResponseMessage::hasType const): Simplify a bit.
(WebCore::CDMInstanceSessionThunder::updateLicense):
* platform/graphics/gstreamer/eme/CDMThunder.h:
* platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:
(webkit_media_thunder_decrypt_class_init): Use a more explicit name for the debug category.

Tools:

* TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
(TestWebKitAPI::TEST): Add test for Netflix WPE/GTK UA quirk.

Modified Paths

Diff

Modified: trunk/ChangeLog (272368 => 272369)


--- trunk/ChangeLog	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/ChangeLog	2021-02-04 16:36:33 UTC (rev 272369)
@@ -1,3 +1,13 @@
+2021-02-04  Philippe Normand  <pnorm...@igalia.com>
+
+        [GStreamer] Misc Thunder nitpicks
+        https://bugs.webkit.org/show_bug.cgi?id=221398
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * Source/cmake/FindThunder.cmake: Look-up Thunder through pkg-config before attempting a
+        direct libocdm lookup.
+
 2021-02-01  Saam Barati  <sbar...@apple.com>
 
         Lazily create m_windowCloseWatchpoints so we don't mistakenly think we have a frame when re-associating a document to a given cached frame

Modified: trunk/Source/WebCore/ChangeLog (272368 => 272369)


--- trunk/Source/WebCore/ChangeLog	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/WebCore/ChangeLog	2021-02-04 16:36:33 UTC (rev 272369)
@@ -1,3 +1,29 @@
+2021-02-04  Philippe Normand  <pnorm...@igalia.com>
+
+        [GStreamer] Misc Thunder nitpicks
+        https://bugs.webkit.org/show_bug.cgi?id=221398
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * platform/UserAgentQuirks.cpp:
+        (WebCore::urlRequiresFirefoxBrowser): For Netflix we should use a Firefox User-Agent, when
+        Thunder is enabled.
+        * platform/graphics/gstreamer/eme/CDMThunder.cpp:
+        (WebCore::CDMFactoryThunder::singleton): Use a dedicated gst debug category for this module,
+        in order to decouple from the decryptor.
+        (WebCore::CDMFactoryThunder::supportedKeySystems const): Use explicit return value, removing
+        possible misunderstandings.
+        (WebCore::CDMPrivateThunder::CDMPrivateThunder):
+        (WebCore::CDMPrivateThunder::supportedRobustnesses const): Thunder supports secure decode/crypto in software.
+        (WebCore::CDMPrivateThunder::supportsServerCertificates const): Plumb to new
+        opencdm_system_supports_certificate API.
+        (WebCore::CDMInstanceThunder::setStorageDirectory): Ensure storage directory exists.
+        (WebCore::ParsedResponseMessage::hasType const): Simplify a bit.
+        (WebCore::CDMInstanceSessionThunder::updateLicense):
+        * platform/graphics/gstreamer/eme/CDMThunder.h:
+        * platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp:
+        (webkit_media_thunder_decrypt_class_init): Use a more explicit name for the debug category.
+
 2021-02-04  Aditya Keerthi  <akeer...@apple.com>
 
         [macOS] Selecting a date on datetime-local inputs unexpectedly adds second and millisecond fields

Modified: trunk/Source/WebCore/platform/UserAgentQuirks.cpp (272368 => 272369)


--- trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/WebCore/platform/UserAgentQuirks.cpp	2021-02-04 16:36:33 UTC (rev 272369)
@@ -98,6 +98,11 @@
     if (domain == "bugzilla.redhat.com")
         return true;
 
+#if ENABLE(THUNDER)
+    if (domain == "www.netflix.com")
+        return true;
+#endif
+
     return false;
 }
 

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.cpp	2021-02-04 16:36:33 UTC (rev 272369)
@@ -48,10 +48,8 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/Base64.h>
 
-#if (!defined(GST_DISABLE_GST_DEBUG))
-GST_DEBUG_CATEGORY_EXTERN(webkitMediaThunderDecryptDebugCategory);
-#define GST_CAT_DEFAULT webkitMediaThunderDecryptDebugCategory
-#endif
+GST_DEBUG_CATEGORY(webkitMediaThunderDebugCategory);
+#define GST_CAT_DEFAULT webkitMediaThunderDebugCategory
 
 namespace {
 
@@ -93,6 +91,11 @@
 
 CDMFactoryThunder& CDMFactoryThunder::singleton()
 {
+    static std::once_flag onceFlag;
+    std::call_once(onceFlag, [] {
+        ensureGStreamerInitialized();
+        GST_DEBUG_CATEGORY_INIT(webkitMediaThunderDebugCategory, "webkitthunder", 0, "Thunder");
+    });
     static NeverDestroyed<CDMFactoryThunder> s_factory;
     return s_factory;
 }
@@ -115,8 +118,7 @@
     static Vector<String> supportedKeySystems;
     std::call_once(onceFlag, [] {
         std::string emptyString;
-        // Yes, this is right, 0 means supported, hence something else means not supported.
-        if (!opencdm_is_type_supported(GStreamerEMEUtilities::s_WidevineKeySystem, emptyString.c_str()))
+        if (opencdm_is_type_supported(GStreamerEMEUtilities::s_WidevineKeySystem, emptyString.c_str()) == ERROR_NONE)
             supportedKeySystems.append(GStreamerEMEUtilities::s_WidevineKeySystem);
 #ifndef NDEBUG
         if (supportedKeySystems.isEmpty() && isThunderRanked()) {
@@ -133,6 +135,12 @@
     return CDMFactoryThunder::singleton().supportedKeySystems().contains(keySystem);
 }
 
+CDMPrivateThunder::CDMPrivateThunder(const String& keySystem)
+    : m_keySystem(keySystem)
+    , m_thunderSystem(opencdm_create_system(keySystem.utf8().data()))
+{
+};
+
 Vector<AtomString> CDMPrivateThunder::supportedInitDataTypes() const
 {
     static std::once_flag onceFlag;
@@ -162,7 +170,9 @@
 
 Vector<AtomString> CDMPrivateThunder::supportedRobustnesses() const
 {
-    return { emptyAtom() };
+    return { emptyAtom(),
+        "SW_SECURE_DECODE",
+        "SW_SECURE_CRYPTO" };
 }
 
 CDMRequirement CDMPrivateThunder::distinctiveIdentifiersRequirement(const CDMKeySystemConfiguration&, const CDMRestrictions&) const
@@ -192,8 +202,9 @@
 
 bool CDMPrivateThunder::supportsServerCertificates() const
 {
-    // Server certificates are not supported.
-    return false;
+    bool isSupported = opencdm_system_supports_server_certificate(m_thunderSystem.get());
+    GST_DEBUG("server certificate supported %s", boolForPrinting(isSupported));
+    return isSupported;
 }
 
 bool CDMPrivateThunder::supportsSessions() const
@@ -258,9 +269,9 @@
     callback(!error ? Succeeded : Failed);
 }
 
-void CDMInstanceThunder::setStorageDirectory(const String&)
+void CDMInstanceThunder::setStorageDirectory(const String& storageDirectory)
 {
-    notImplemented();
+    FileSystem::makeAllDirectories(storageDirectory);
 }
 
 CDMInstanceSessionThunder::CDMInstanceSessionThunder(CDMInstanceThunder& instance)
@@ -346,7 +357,7 @@
     bool hasPayload() const { return static_cast<bool>(m_payload); }
     const Ref<SharedBuffer>& payload() const& { ASSERT(m_payload); return m_payload.value(); }
     Ref<SharedBuffer>& payload() & { ASSERT(m_payload); return m_payload.value(); }
-    bool hasType() const { return static_cast<bool>(m_type); }
+    bool hasType() const { return m_type.hasValue(); }
     WebCore::MediaKeyMessageType type() const { ASSERT(m_type); return m_type.value(); }
     WebCore::MediaKeyMessageType typeOr(WebCore::MediaKeyMessageType alternate) const { return m_type ? m_type.value() : alternate; }
     explicit operator bool() const { return m_isValid; }
@@ -546,10 +557,9 @@
     m_sessionChangedCallbacks.append([this, callback = WTFMove(callback)](bool success, RefPtr<SharedBuffer>&& responseMessage) mutable {
         ASSERT(isMainThread());
         if (success) {
-            if (!responseMessage) {
-                ASSERT(!m_keyStore.isEmpty());
+            if (!responseMessage)
                 callback(false, m_keyStore.convertToJSKeyStatusVector(), WTF::nullopt, WTF::nullopt, SuccessValue::Succeeded);
-            } else {
+            else {
                 // FIXME: Using JSON reponse messages is much cleaner than using string prefixes, I believe there
                 // will even be other parts of the spec where not having structured data will be bad.
                 ParsedResponseMessage parsedResponseMessage(responseMessage);

Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.h (272368 => 272369)


--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.h	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/CDMThunder.h	2021-02-04 16:36:33 UTC (rev 272369)
@@ -73,7 +73,7 @@
 class CDMPrivateThunder final : public CDMPrivate {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    CDMPrivateThunder(const String& keySystem) : m_keySystem(keySystem) { };
+    CDMPrivateThunder(const String& keySystem);
     virtual ~CDMPrivateThunder() = default;
 
     Vector<AtomString> supportedInitDataTypes() const final;
@@ -101,6 +101,7 @@
 
 private:
     String m_keySystem;
+    Thunder::UniqueThunderSystem m_thunderSystem;
 };
 
 class CDMInstanceThunder final : public CDMInstanceProxy {

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


--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/WebKitThunderDecryptorGStreamer.cpp	2021-02-04 16:36:33 UTC (rev 272369)
@@ -106,7 +106,7 @@
 
 static void webkit_media_thunder_decrypt_class_init(WebKitMediaThunderDecryptClass* klass)
 {
-    GST_DEBUG_CATEGORY_INIT(webkitMediaThunderDecryptDebugCategory, "webkitthunder", 0, "Thunder decrypt");
+    GST_DEBUG_CATEGORY_INIT(webkitMediaThunderDecryptDebugCategory, "webkitthunderdecrypt", 0, "Thunder decrypt");
 
     GstElementClass* elementClass = GST_ELEMENT_CLASS(klass);
     GRefPtr<GstCaps> gstSinkPadTemplateCaps = createSinkPadTemplateCaps();

Modified: trunk/Source/cmake/FindThunder.cmake (272368 => 272369)


--- trunk/Source/cmake/FindThunder.cmake	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Source/cmake/FindThunder.cmake	2021-02-04 16:36:33 UTC (rev 272369)
@@ -41,23 +41,37 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-find_library(THUNDER_LIBRARY
-  NAMES libocdm.so
-)
+# The libocdm provided by RDK's Thunder framework is not discoverable with pkg-config because the
+# framework doesn't provide a .pc file. But alternate (swap-in) implementations might, so try with
+# pkg-config first.
+
+find_package(PkgConfig)
+pkg_check_modules(PC_THUNDER QUIET thunder)
+
 find_path(THUNDER_INCLUDE_DIR
-  NAMES open_cdm.h
-  PATH_SUFFIXES "WPEFramework/ocdm/"
+    NAMES open_cdm.h
+    HINTS ${PC_THUNDER_INCLUDEDIR}
+          ${PC_THUNDER_INCLUDE_DIRS}
+    PATH_SUFFIXES "WPEFramework/ocdm/"
 )
 
+find_library(THUNDER_LIBRARY
+    NAMES ocdm
+    HINTS ${PC_THUNDER_LIBDIR}
+          ${PC_THUNDER_LIBRARY_DIRS}
+)
+
 include(FindPackageHandleStandardArgs)
 
 find_package_handle_standard_args(Thunder
-    FOUND_VAR THUNDER_FOUND
-    REQUIRED_VARS THUNDER_LIBRARY THUNDER_INCLUDE_DIR
+  FOUND_VAR THUNDER_FOUND
+  REQUIRED_VARS THUNDER_LIBRARY THUNDER_INCLUDE_DIR
 )
+
 if (THUNDER_FOUND)
-    set(THUNDER_LIBRARIES ${THUNDER_LIBRARY})
-    set(THUNDER_INCLUDE_DIRS ${THUNDER_INCLUDE_DIR})
+  set(THUNDER_LIBRARIES ${THUNDER_LIBRARY})
+  set(THUNDER_INCLUDE_DIRS ${THUNDER_INCLUDE_DIR})
+  set(THUNDER_VERSION ${PC_THUNDER_VERSION})
 endif ()
 
 mark_as_advanced(THUNDER_LIBRARY THUNDER_INCLUDE_DIR)
@@ -65,5 +79,4 @@
 include(FeatureSummary)
 set_package_properties(Thunder PROPERTIES
     DESCRIPTION "Thunder DRM framework"
-    URL "https://github.com/rdkcentral/Thunder"
 )

Modified: trunk/Tools/ChangeLog (272368 => 272369)


--- trunk/Tools/ChangeLog	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Tools/ChangeLog	2021-02-04 16:36:33 UTC (rev 272369)
@@ -1,3 +1,13 @@
+2021-02-04  Philippe Normand  <pnorm...@igalia.com>
+
+        [GStreamer] Misc Thunder nitpicks
+        https://bugs.webkit.org/show_bug.cgi?id=221398
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        * TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp:
+        (TestWebKitAPI::TEST): Add test for Netflix WPE/GTK UA quirk.
+
 2021-02-04  Aditya Keerthi  <akeer...@apple.com>
 
         [macOS] Selecting a date on datetime-local inputs unexpectedly adds second and millisecond fields

Modified: trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp (272368 => 272369)


--- trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2021-02-04 14:59:24 UTC (rev 272368)
+++ trunk/Tools/TestWebKitAPI/Tests/WebCore/UserAgentQuirks.cpp	2021-02-04 16:36:33 UTC (rev 272369)
@@ -123,6 +123,10 @@
 
     assertUserAgentForURLHasFirefoxBrowserQuirk("http://bugzilla.redhat.com/");
 
+#if ENABLE(THUNDER)
+    assertUserAgentForURLHasFirefoxBrowserQuirk("http://www.netflix.com/");
+#endif
+
     assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://accounts.youtube.com/");
     assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://docs.google.com/");
     assertUserAgentForURLHasInternetExplorerBrowserQuirk("http://drive.google.com/");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to