[EME][GStreamer] Add support for WebM encrypted caps "application/x-webm-enc"
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2018 13:25:02 +0000 (13:25 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 8 Oct 2018 13:25:02 +0000 (13:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189239

Patch by Yacine Bandou <yacine.bandou_ext@softathome.com> on 2018-10-08
Reviewed by Xabier Rodriguez-Calvar.

Add the support of GStreamer caps "application/x-webm-enc" in GStreamerCommon.

The DRM system id field in the encrypted event is set to GST_PROTECTION_UNSPECIFIED_SYSTEM_ID
in case of WebM, for details, see https://bugzilla.gnome.org/attachment.cgi?id=365211.

Tests: media/encrypted-media/clearKey/clearKey-encrypted-webm-eventmse.html
       media/encrypted-media/clearKey/clearKey-webm-video-playback-mse.html

* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::capsMediaType):
(WebCore::areEncryptedCaps):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
(WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered):
* platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
* platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
(webkitMediaCommonEncryptionDecryptTransformCaps):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp
Source/WebCore/platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp

index 3aa5eba..55f5cc8 100644 (file)
@@ -1,3 +1,27 @@
+2018-10-08  Yacine Bandou  <yacine.bandou_ext@softathome.com>
+
+        [EME][GStreamer] Add support for WebM encrypted caps "application/x-webm-enc"
+        https://bugs.webkit.org/show_bug.cgi?id=189239
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        Add the support of GStreamer caps "application/x-webm-enc" in GStreamerCommon.
+
+        The DRM system id field in the encrypted event is set to GST_PROTECTION_UNSPECIFIED_SYSTEM_ID
+        in case of WebM, for details, see https://bugzilla.gnome.org/attachment.cgi?id=365211.
+
+        Tests: media/encrypted-media/clearKey/clearKey-encrypted-webm-eventmse.html
+               media/encrypted-media/clearKey/clearKey-webm-video-playback-mse.html
+
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::capsMediaType):
+        (WebCore::areEncryptedCaps):
+        * platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
+        (WebCore::MediaPlayerPrivateGStreamerBase::initializationDataEncountered):
+        * platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp:
+        * platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp:
+        (webkitMediaCommonEncryptionDecryptTransformCaps):
+
 2018-10-07  Dan Bernstein  <mitz@apple.com>
 
         Fixed building with the latest macOS SDK
index 605d672..b961062 100644 (file)
@@ -151,7 +151,7 @@ const char* capsMediaType(const GstCaps* caps)
         return nullptr;
     }
 #if ENABLE(ENCRYPTED_MEDIA)
-    if (gst_structure_has_name(structure, "application/x-cenc"))
+    if (gst_structure_has_name(structure, "application/x-cenc") || gst_structure_has_name(structure, "application/x-webm-enc"))
         return gst_structure_get_string(structure, "original-media-type");
 #endif
     return gst_structure_get_name(structure);
@@ -176,7 +176,7 @@ bool areEncryptedCaps(const GstCaps* caps)
         GST_WARNING("caps are empty");
         return false;
     }
-    return gst_structure_has_name(structure, "application/x-cenc");
+    return gst_structure_has_name(structure, "application/x-cenc") || gst_structure_has_name(structure, "application/x-webm-enc");
 #else
     UNUSED_PARAM(caps);
     return false;
index 792660b..d94c70d 100644 (file)
@@ -1274,7 +1274,7 @@ void MediaPlayerPrivateGStreamerBase::initializationDataEncountered(GstEvent* ev
     // Check if the system key of the protection event is the same of the CDM instance.
     // For example: we can receive a new Widevine protection event but the CDM instance initialized with
     // Playready, so we ignore this event.
-    if (m_cdmInstance && g_strcmp0(GStreamerEMEUtilities::keySystemToUuid(m_cdmInstance->keySystem()), eventKeySystemUUID)) {
+    if (m_cdmInstance && g_strcmp0(eventKeySystemUUID, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) && g_strcmp0(GStreamerEMEUtilities::keySystemToUuid(m_cdmInstance->keySystem()), eventKeySystemUUID)) {
         GST_DEBUG("The protection event with UUID %s is ignored because it isn't supported by the CDM %s", eventKeySystemUUID, m_cdmInstance->keySystem().utf8().data());
         return;
     }
@@ -1296,7 +1296,8 @@ void MediaPlayerPrivateGStreamerBase::initializationDataEncountered(GstEvent* ev
 
         GST_DEBUG("scheduling initializationDataEncountered event for %s with init data size of %u", eventKeySystemUUID.utf8().data(), initData.sizeInBytes());
         GST_MEMDUMP("init datas", reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes());
-        weakThis->m_player->initializationDataEncountered("cenc"_s, ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
+        weakThis->m_player->initializationDataEncountered((eventKeySystemUUID == GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "webm"_s : "cenc"_s,
+            ArrayBuffer::create(reinterpret_cast<const uint8_t*>(initData.characters8()), initData.sizeInBytes()));
     });
 }
 
index 7665ad6..8ae3a56 100644 (file)
@@ -56,12 +56,14 @@ 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)" WEBCORE_GSTREAMER_EME_UTILITIES_CLEARKEY_UUID "; "
-    "application/x-cenc, original-media-type=(string)audio/mpeg, 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";"
+    "application/x-webm-enc, original-media-type=(string)video/x-vp8;"
+    "application/x-webm-enc, original-media-type=(string)video/x-vp9;"));
 
 static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src",
     GST_PAD_SRC,
     GST_PAD_ALWAYS,
-    GST_STATIC_CAPS("video/x-h264; audio/mpeg"));
+    GST_STATIC_CAPS("video/x-h264; audio/mpeg; video/x-vp8; video/x-vp9"));
 
 #define webkit_media_clear_key_decrypt_parent_class parent_class
 G_DEFINE_TYPE(WebKitMediaClearKeyDecrypt, webkit_media_clear_key_decrypt, WEBKIT_TYPE_MEDIA_CENC_DECRYPT);
index f3ee3fa..7e711c6 100644 (file)
@@ -127,7 +127,10 @@ static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform
                 const gchar* fieldName = gst_structure_nth_field_name(incomingStructure, j);
 
                 if (g_str_has_prefix(fieldName, "protection-system")
-                    || g_str_has_prefix(fieldName, "original-media-type"))
+                    || g_str_has_prefix(fieldName, "original-media-type")
+                    || g_str_has_prefix(fieldName, "encryption-algorithm")
+                    || g_str_has_prefix(fieldName, "encoding-scope")
+                    || g_str_has_prefix(fieldName, "cipher-mode"))
                     gst_structure_remove_field(outgoingStructure.get(), fieldName);
             }
         } else {
@@ -156,7 +159,8 @@ static GstCaps* webkitMediaCommonEncryptionDecryptTransformCaps(GstBaseTransform
             gst_structure_set(outgoingStructure.get(), "protection-system", G_TYPE_STRING, klass->protectionSystemId,
                 "original-media-type", G_TYPE_STRING, gst_structure_get_name(incomingStructure), nullptr);
 
-            gst_structure_set_name(outgoingStructure.get(), "application/x-cenc");
+            gst_structure_set_name(outgoingStructure.get(),
+                !g_strcmp0(klass->protectionSystemId, GST_PROTECTION_UNSPECIFIED_SYSTEM_ID) ? "application/x-webm-enc" : "application/x-cenc");
         }
 
         bool duplicate = false;