diff options
author | Alex Ashley <bugzilla@ashley-family.net> | 2021-08-24 14:33:42 +0100 |
---|---|---|
committer | Vivia Nikolaidou <vivia@ahiru.eu> | 2021-08-27 10:47:06 +0000 |
commit | fd1e75900db48fc008899c5712a39ca16a0681b0 (patch) | |
tree | f5decd75a2833bbed2ed268a681d45313a37ac0c /ext | |
parent | 43199bc883d68b1935b51b07a5c464f9f80c605a (diff) | |
download | gstreamer-plugins-bad-fd1e75900db48fc008899c5712a39ca16a0681b0.tar.gz |
dashdemux: copy ContentProtection element including xml namespaces
Commit bc09d8cc changed gstmpdparser to put the entire
<ContentProtection> element in the "value" field, so that DRMs
other than PlayReady could make use of the data inside this
element.
However, the data in the "value" field does not include any
XML namespace declarations that are used within the element. This
causes problems for a namespace aware XML parser that wants to
make use of this data.
This commit modifies the way the XML is converted to a string
so that XML namespaces are preserved in the output.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2487>
Diffstat (limited to 'ext')
-rw-r--r-- | ext/dash/gstxmlhelper.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/dash/gstxmlhelper.c b/ext/dash/gstxmlhelper.c index ee7aa661c..d4db559c8 100644 --- a/ext/dash/gstxmlhelper.c +++ b/ext/dash/gstxmlhelper.c @@ -975,11 +975,24 @@ gst_xml_helper_get_node_as_string (xmlNode * a_node, gchar ** content) gboolean exists = FALSE; const char *txt_encoding; xmlOutputBufferPtr out_buf; + xmlNode *ncopy = NULL; txt_encoding = (const char *) a_node->doc->encoding; out_buf = xmlAllocOutputBuffer (NULL); g_assert (out_buf != NULL); - xmlNodeDumpOutput (out_buf, a_node->doc, a_node, 0, 0, txt_encoding); + + /* Need to make a copy of XML element so that it includes namespaces + in the output, so that the resulting string can be parsed by an XML parser + that is namespace aware. + Use extended=1 for recursive copy (properties, namespaces and children) */ + ncopy = xmlDocCopyNode (a_node, a_node->doc, 1); + + if (!ncopy) { + GST_WARNING ("Failed to clone XML node"); + goto done; + } + xmlNodeDumpOutput (out_buf, ncopy->doc, ncopy, 0, 0, txt_encoding); + (void) xmlOutputBufferFlush (out_buf); #ifdef LIBXML2_NEW_BUFFER if (xmlOutputBufferGetSize (out_buf) > 0) { @@ -999,6 +1012,8 @@ gst_xml_helper_get_node_as_string (xmlNode * a_node, gchar ** content) exists = TRUE; } #endif // LIBXML2_NEW_BUFFER + xmlFreeNode (ncopy); +done: (void) xmlOutputBufferClose (out_buf); if (exists) { |