- Revision
- 281183
- Author
- [email protected]
- Date
- 2021-08-18 01:26:33 -0700 (Wed, 18 Aug 2021)
Log Message
[GStreamer][EME] Try to parse XML init datas that could possibly come from MPD manifests
https://bugs.webkit.org/show_bug.cgi?id=229145
Reviewed by Alicia Boya Garcia.
Source/WebCore:
Added GStreamerEMEUtilities to include implementation of
InitData::extractCencIfNeeded. This tries to parse the possible
XML inside an init data that could come from MPD manifests. If it
succeeds, it keeps the parsed init data, if not, it returns the
original one.
Based on a patch by Philippe Normand.
* platform/GStreamer.cmake:
* platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp: Added.
(WebCore::markupStartElement):
(WebCore::markupEndElement):
(WebCore::markupText):
(WebCore::markupPassthrough):
(WebCore::markupError):
(WebCore::InitData::extractCencIfNeeded):
* platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h:
(WebCore::InitData::InitData):
Source/WTF:
* wtf/glib/GUniquePtr.h: Added deleter for GMarkupParseContext.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (281182 => 281183)
--- trunk/Source/WTF/ChangeLog 2021-08-18 06:50:16 UTC (rev 281182)
+++ trunk/Source/WTF/ChangeLog 2021-08-18 08:26:33 UTC (rev 281183)
@@ -1,3 +1,12 @@
+2021-08-18 Xabier Rodriguez Calvar <[email protected]>
+
+ [GStreamer][EME] Try to parse XML init datas that could possibly come from MPD manifests
+ https://bugs.webkit.org/show_bug.cgi?id=229145
+
+ Reviewed by Alicia Boya Garcia.
+
+ * wtf/glib/GUniquePtr.h: Added deleter for GMarkupParseContext.
+
2021-08-16 Alex Christensen <[email protected]>
Enable PerformanceNavigationAPI by default
Modified: trunk/Source/WTF/wtf/glib/GUniquePtr.h (281182 => 281183)
--- trunk/Source/WTF/wtf/glib/GUniquePtr.h 2021-08-18 06:50:16 UTC (rev 281182)
+++ trunk/Source/WTF/wtf/glib/GUniquePtr.h 2021-08-18 08:26:33 UTC (rev 281183)
@@ -47,7 +47,8 @@
macro(GKeyFile, g_key_file_free) \
macro(char*, g_strfreev) \
macro(GVariantIter, g_variant_iter_free) \
- macro(GVariantType, g_variant_type_free)
+ macro(GVariantType, g_variant_type_free) \
+ macro(GMarkupParseContext, g_markup_parse_context_free)
#define WTF_DEFINE_GPTR_DELETER(typeName, deleterFunc) \
template<> struct GPtrDeleter<typeName> \
Modified: trunk/Source/WebCore/ChangeLog (281182 => 281183)
--- trunk/Source/WebCore/ChangeLog 2021-08-18 06:50:16 UTC (rev 281182)
+++ trunk/Source/WebCore/ChangeLog 2021-08-18 08:26:33 UTC (rev 281183)
@@ -1,3 +1,29 @@
+2021-08-18 Xabier Rodriguez Calvar <[email protected]>
+
+ [GStreamer][EME] Try to parse XML init datas that could possibly come from MPD manifests
+ https://bugs.webkit.org/show_bug.cgi?id=229145
+
+ Reviewed by Alicia Boya Garcia.
+
+ Added GStreamerEMEUtilities to include implementation of
+ InitData::extractCencIfNeeded. This tries to parse the possible
+ XML inside an init data that could come from MPD manifests. If it
+ succeeds, it keeps the parsed init data, if not, it returns the
+ original one.
+
+ Based on a patch by Philippe Normand.
+
+ * platform/GStreamer.cmake:
+ * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp: Added.
+ (WebCore::markupStartElement):
+ (WebCore::markupEndElement):
+ (WebCore::markupText):
+ (WebCore::markupPassthrough):
+ (WebCore::markupError):
+ (WebCore::InitData::extractCencIfNeeded):
+ * platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h:
+ (WebCore::InitData::InitData):
+
2021-08-17 Devin Rousso <[email protected]>
Web Inspector: match the undocked tab bar style when docked bottom/side
Modified: trunk/Source/WebCore/platform/GStreamer.cmake (281182 => 281183)
--- trunk/Source/WebCore/platform/GStreamer.cmake 2021-08-18 06:50:16 UTC (rev 281182)
+++ trunk/Source/WebCore/platform/GStreamer.cmake 2021-08-18 08:26:33 UTC (rev 281183)
@@ -29,6 +29,7 @@
platform/graphics/gstreamer/WebKitAudioSinkGStreamer.cpp
platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
+ platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp
platform/graphics/gstreamer/eme/WebKitClearKeyDecryptorGStreamer.cpp
platform/graphics/gstreamer/eme/WebKitCommonEncryptionDecryptorGStreamer.cpp
Added: trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp (0 => 281183)
--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.cpp 2021-08-18 08:26:33 UTC (rev 281183)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 Igalia S.L
+ * Copyright (C) 2021 Metrological Group B.V.
+ *
+ * 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
+ * aint with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "GStreamerEMEUtilities.h"
+
+#include <wtf/text/Base64.h>
+
+#if ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
+
+GST_DEBUG_CATEGORY_EXTERN(webkit_media_common_encryption_decrypt_debug_category);
+#define GST_CAT_DEFAULT webkit_media_common_encryption_decrypt_debug_category
+
+namespace WebCore {
+
+struct GMarkupParseContextUserData {
+ bool isParsingPssh { false };
+ RefPtr<SharedBuffer> pssh;
+};
+
+static void markupStartElement(GMarkupParseContext*, const gchar* elementName, const gchar**, const gchar**, gpointer userDataPtr, GError**)
+{
+ GMarkupParseContextUserData* userData = static_cast<GMarkupParseContextUserData*>(userDataPtr);
+ if (g_str_has_suffix(elementName, "pssh"))
+ userData->isParsingPssh = true;
+}
+
+static void markupEndElement(GMarkupParseContext*, const gchar* elementName, gpointer userDataPtr, GError**)
+{
+ GMarkupParseContextUserData* userData = static_cast<GMarkupParseContextUserData*>(userDataPtr);
+ if (g_str_has_suffix(elementName, "pssh")) {
+ ASSERT(userData->isParsingPssh);
+ userData->isParsingPssh = false;
+ }
+}
+
+static void markupText(GMarkupParseContext*, const gchar* text, gsize textLength, gpointer userDataPtr, GError**)
+{
+ GMarkupParseContextUserData* userData = static_cast<GMarkupParseContextUserData*>(userDataPtr);
+ if (userData->isParsingPssh) {
+ std::optional<Vector<uint8_t>> pssh = base64Decode(text, textLength);
+ if (pssh.has_value())
+ userData->pssh = SharedBuffer::create(WTFMove(*pssh));
+ }
+}
+
+static void markupPassthrough(GMarkupParseContext*, const gchar*, gsize, gpointer, GError**)
+{
+}
+
+static void markupError(GMarkupParseContext*, GError*, gpointer)
+{
+}
+
+static GMarkupParser markupParser { markupStartElement, markupEndElement, markupText, markupPassthrough, markupError };
+
+RefPtr<SharedBuffer> InitData::extractCencIfNeeded(RefPtr<SharedBuffer>&& unparsedPayload)
+{
+ RefPtr<SharedBuffer> payload = WTFMove(unparsedPayload);
+ if (!payload || !payload->size())
+ return payload;
+
+ GMarkupParseContextUserData userData;
+ GUniquePtr<GMarkupParseContext> markupParseContext(g_markup_parse_context_new(&markupParser, (GMarkupParseFlags) 0, &userData, nullptr));
+
+ if (g_markup_parse_context_parse(markupParseContext.get(), payload->dataAsCharPtr(), payload->size(), nullptr)) {
+ if (userData.pssh)
+ payload = WTFMove(userData.pssh);
+ else
+ GST_WARNING("XML was parsed but we could not find a viable base64 encoded pssh box");
+ }
+
+ return payload;
+}
+
+}
+#endif // ENABLE(ENCRYPTED_MEDIA) && USE(GSTREAMER)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h (281182 => 281183)
--- trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h 2021-08-18 06:50:16 UTC (rev 281182)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/eme/GStreamerEMEUtilities.h 2021-08-18 08:26:33 UTC (rev 281183)
@@ -50,12 +50,12 @@
GST_CAT_LEVEL_LOG(webkit_media_common_encryption_decrypt_debug_category, GST_LEVEL_ERROR, nullptr, "cannot map %s protection data", systemId.utf8().data());
ASSERT_NOT_REACHED();
}
- m_payload = mappedInitData->createSharedBuffer();
+ m_payload = extractCencIfNeeded(mappedInitData->createSharedBuffer());
}
InitData(const String& systemId, RefPtr<SharedBuffer>&& payload)
: m_systemId(systemId)
- , m_payload(WTFMove(payload))
+ , m_payload(extractCencIfNeeded(WTFMove(payload)))
{
}
@@ -86,6 +86,8 @@
return "cenc"_s;
}
+ static RefPtr<SharedBuffer> extractCencIfNeeded(RefPtr<SharedBuffer>&&);
+
private:
String m_systemId;
RefPtr<SharedBuffer> m_payload;