[GStreamer][EME] Rework handling key systems and UUIDs
authorcalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 08:25:45 +0000 (08:25 +0000)
committercalvaris@igalia.com <calvaris@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Aug 2017 08:25:45 +0000 (08:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175567

Reviewed by Žan Doberšek.

The UUIDs and key system strings were moved to the
GStreamerEMEUtilities class because so far they were managed by
the decryptors and that was ugly.

* platform/GStreamer.cmake:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::supportsKeySystem):
* platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp: Added.
* platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h: Added.
(WebCore::GStreamerEMEUtilities::isClearKeyKeySystem):
(WebCore::GStreamerEMEUtilities::keySystemToUuid):
* platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
(webkit_media_clear_key_decrypt_class_init):
* platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220790 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/GStreamer.cmake
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h [new file with mode: 0644]
Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.h

index 803afb1..cb372f3 100644 (file)
@@ -1,3 +1,25 @@
+2017-08-16  Xabier Rodriguez Calvar  <calvaris@igalia.com>
+
+        [GStreamer][EME] Rework handling key systems and UUIDs
+        https://bugs.webkit.org/show_bug.cgi?id=175567
+
+        Reviewed by Žan Doberšek.
+
+        The UUIDs and key system strings were moved to the
+        GStreamerEMEUtilities class because so far they were managed by
+        the decryptors and that was ugly.
+
+        * platform/GStreamer.cmake:
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::supportsKeySystem):
+        * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp: Added.
+        * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h: Added.
+        (WebCore::GStreamerEMEUtilities::isClearKeyKeySystem):
+        (WebCore::GStreamerEMEUtilities::keySystemToUuid):
+        * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
+        (webkit_media_clear_key_decrypt_class_init):
+        * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.h:
+
 2017-08-16  Andy Estes  <aestes@apple.com>
 
         [Payment Request] Add an ENABLE flag and an experimental feature preference
index f72fde9..99cf5ff 100644 (file)
@@ -42,6 +42,7 @@ if (ENABLE_VIDEO OR ENABLE_WEB_AUDIO)
         platform/graphics/gstreamer/VideoTrackPrivateGStreamer.cpp
         platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
 
+        platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp
         platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp
         platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp
 
index d9b762b..f7d2cd1 100644 (file)
 #endif // USE(TEXTURE_MAPPER_GL)
 
 #if ENABLE(ENCRYPTED_MEDIA)
+#include "GStreamerEMEUtilities.h"
 #include "SharedBuffer.h"
 #include "WebKitClearKeyDecryptorGStreamer.h"
 #endif
@@ -1048,8 +1049,7 @@ bool MediaPlayerPrivateGStreamerBase::supportsKeySystem(const String& keySystem,
     bool result = false;
 
 #if ENABLE(ENCRYPTED_MEDIA)
-    if (equalLettersIgnoringASCIICase(keySystem, "org.w3.clearkey"))
-        result = true;
+    result = GStreamerEMEUtilities::isClearKeyKeySystem(keySystem);
 #endif
 
     GST_DEBUG("checking for KeySystem support with %s and type %s: %s", keySystem.utf8().data(), mimeType.utf8().data(), boolForPrinting(result));
diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp b/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp
new file mode 100644 (file)
index 0000000..2ffad42
--- /dev/null
@@ -0,0 +1,34 @@
+/* GStreamer EME Utilities class
+ *
+ * Copyright (C) 2017 Metrological
+ * Copyright (C) 2017 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "GStreamerEMEUtilities.h"
+
+#if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
+
+namespace WebCore {
+
+const char* GStreamerEMEUtilities::s_ClearKeyUUID = WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID;
+const char* GStreamerEMEUtilities::s_ClearKeyKeySystem = "org.w3.clearkey";
+
+}
+
+#endif // ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
diff --git a/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h b/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h
new file mode 100644 (file)
index 0000000..fad3c4f
--- /dev/null
@@ -0,0 +1,55 @@
+/* GStreamer EME Utilities class
+ *
+ * Copyright (C) 2017 Metrological
+ * Copyright (C) 2017 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
+
+#include <wtf/text/WTFString.h>
+
+#define WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID "58147ec8-0423-4659-92e6-f52c5ce8c3cc"
+
+namespace WebCore {
+
+class GStreamerEMEUtilities {
+
+public:
+    static const char* s_ClearKeyUUID;
+    static const char* s_ClearKeyKeySystem;
+
+    static bool isClearKeyKeySystem(const String& keySystem)
+    {
+        return equalIgnoringASCIICase(keySystem, s_ClearKeyKeySystem);
+    }
+
+    static const char* keySystemToUuid(const String& keySystem)
+    {
+        if (isClearKeyKeySystem(keySystem))
+            return s_ClearKeyUUID;
+
+        ASSERT_NOT_REACHED();
+        return { };
+    }
+};
+
+}
+
+#endif // ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
index 56543ad..7f23b6f 100644 (file)
@@ -25,6 +25,7 @@
 #if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
 
 #include "GRefPtrGStreamer.h"
+#include "GStreamerEMEUtilities.h"
 #include <gcrypt.h>
 #include <gst/base/gstbytereader.h>
 #include <wtf/RunLoop.h>
@@ -54,8 +55,8 @@ GST_DEBUG_CATEGORY_STATIC(webkit_media_clear_key_decrypt_debug_category);
 static GstStaticPadTemplate sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink",
     GST_PAD_SINK,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS("application/x-cenc, original-media-type=(string)video/x-h264, protection-system=(string)" CLEAR_KEY_PROTECTION_SYSTEM_UUID "; "
-    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" CLEAR_KEY_PROTECTION_SYSTEM_UUID));
+    GST_STATIC_CAPS("application/x-cenc, original-media-type=(string)video/x-h264, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID "; "
+    "application/x-cenc, original-media-type=(string)audio/mpeg, protection-system=(string)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID));
 
 static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src",
     GST_PAD_SRC,
@@ -84,7 +85,7 @@ static void webkit_media_clear_key_decrypt_class_init(WebKitMediaClearKeyDecrypt
         "webkitclearkey", 0, "ClearKey decryptor");
 
     WebKitMediaCommonEncryptionDecryptClass* cencClass = WEBKIT_MEDIA_CENC_DECRYPT_CLASS(klass);
-    cencClass->protectionSystemId = CLEAR_KEY_PROTECTION_SYSTEM_UUID;
+    cencClass->protectionSystemId = WebCore::GStreamerEMEUtilities::s_ClearKeyUUID;
     cencClass->handleKeyResponse = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorHandleKeyResponse);
     cencClass->setupCipher = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorSetupCipher);
     cencClass->decrypt = GST_DEBUG_FUNCPTR(webKitMediaClearKeyDecryptorDecrypt);
index 8138497..9321517 100644 (file)
@@ -25,9 +25,6 @@
 
 #include "WebKitCommonEncryptionDecryptorGStreamer.h"
 
-#define CLEAR_KEY_PROTECTION_SYSTEM_UUID "58147ec8-0423-4659-92e6-f52c5ce8c3cc"
-#define CLEAR_KEY_PROTECTION_SYSTEM_ID "org.w3.clearkey"
-
 G_BEGIN_DECLS
 
 #define WEBKIT_TYPE_MEDIA_CK_DECRYPT          (webkit_media_clear_key_decrypt_get_type())