dash: mpdclient: Don't pass terminating NUL to adapter
libxml2 will complain if it detects any characters after the valid XML, including a NUL byte. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8734>
This commit is contained in:
parent
8eb5e3771b
commit
9a04896293
@ -1140,15 +1140,15 @@ gst_mpd_client_fetch_external_periods (GstMPDClient * client,
|
||||
GstMPDPeriodNode * period_node)
|
||||
{
|
||||
GstFragment *download;
|
||||
GstAdapter *adapter;
|
||||
GstBuffer *period_buffer;
|
||||
GError *err = NULL;
|
||||
|
||||
GstUri *base_uri, *uri;
|
||||
gchar *query = NULL;
|
||||
gchar *uri_string, *wrapper;
|
||||
gchar *uri_string;
|
||||
GList *new_periods = NULL;
|
||||
const gchar *data;
|
||||
gsize alloc_size, buffer_size;
|
||||
GString *data;
|
||||
|
||||
/* ISO/IEC 23009-1:2014 5.5.3 4)
|
||||
* Remove nodes that resolve to nothing when resolving
|
||||
@ -1199,28 +1199,24 @@ gst_mpd_client_fetch_external_periods (GstMPDClient * client,
|
||||
/* external xml could have multiple period without root xmlNode.
|
||||
* To avoid xml parsing error caused by no root node, wrapping it with
|
||||
* custom root node */
|
||||
adapter = gst_adapter_new ();
|
||||
buffer_size = gst_buffer_get_size (period_buffer);
|
||||
alloc_size =
|
||||
buffer_size + sizeof (CUSTOM_WRAPPER_START) +
|
||||
sizeof (CUSTOM_WRAPPER_END) - 2;
|
||||
data = g_string_sized_new (alloc_size);
|
||||
g_string_append_len (data, CUSTOM_WRAPPER_START,
|
||||
sizeof (CUSTOM_WRAPPER_START) - 1);
|
||||
|
||||
wrapper = g_new (gchar, strlen (CUSTOM_WRAPPER_START));
|
||||
memcpy (wrapper, CUSTOM_WRAPPER_START, strlen (CUSTOM_WRAPPER_START));
|
||||
gst_adapter_push (adapter,
|
||||
gst_buffer_new_wrapped (wrapper, strlen (CUSTOM_WRAPPER_START)));
|
||||
gst_buffer_extract (period_buffer, 0, data->str + data->len, buffer_size);
|
||||
gst_buffer_unref (period_buffer);
|
||||
data->len += buffer_size;
|
||||
|
||||
gst_adapter_push (adapter, period_buffer);
|
||||
g_string_append_len (data, CUSTOM_WRAPPER_END,
|
||||
sizeof (CUSTOM_WRAPPER_END) - 1);
|
||||
|
||||
wrapper = g_strdup (CUSTOM_WRAPPER_END);
|
||||
gst_adapter_push (adapter,
|
||||
gst_buffer_new_wrapped (wrapper, strlen (CUSTOM_WRAPPER_END) + 1));
|
||||
new_periods = gst_mpdparser_get_external_periods (data->str, alloc_size);
|
||||
|
||||
data = gst_adapter_map (adapter, gst_adapter_available (adapter));
|
||||
|
||||
new_periods =
|
||||
gst_mpdparser_get_external_periods (data,
|
||||
gst_adapter_available (adapter));
|
||||
|
||||
gst_adapter_unmap (adapter);
|
||||
gst_adapter_clear (adapter);
|
||||
gst_object_unref (adapter);
|
||||
g_string_free (data, TRUE);
|
||||
|
||||
return new_periods;
|
||||
}
|
||||
|
@ -1136,9 +1136,8 @@ gst_mpd_client2_fetch_external_periods (GstMPDClient2 * client,
|
||||
|
||||
GstUri *base_uri, *uri;
|
||||
gchar *query = NULL;
|
||||
gchar *uri_string, *wrapper;
|
||||
gchar *uri_string;
|
||||
GList *new_periods = NULL;
|
||||
const gchar *data;
|
||||
|
||||
/* ISO/IEC 23009-1:2014 5.5.3 4)
|
||||
* Remove nodes that resolve to nothing when resolving
|
||||
@ -1188,32 +1187,31 @@ gst_mpd_client2_fetch_external_periods (GstMPDClient2 * client,
|
||||
download_request_unref (download);
|
||||
|
||||
if (period_buffer) {
|
||||
GstAdapter *adapter;
|
||||
gsize alloc_size, buffer_size;
|
||||
GString *data;
|
||||
|
||||
/* external xml could have multiple period without root xmlNode.
|
||||
* To avoid xml parsing error caused by no root node, wrapping it with
|
||||
* custom root node */
|
||||
adapter = gst_adapter_new ();
|
||||
|
||||
wrapper = g_new (gchar, strlen (CUSTOM_WRAPPER_START));
|
||||
memcpy (wrapper, CUSTOM_WRAPPER_START, strlen (CUSTOM_WRAPPER_START));
|
||||
gst_adapter_push (adapter,
|
||||
gst_buffer_new_wrapped (wrapper, strlen (CUSTOM_WRAPPER_START)));
|
||||
buffer_size = gst_buffer_get_size (period_buffer);
|
||||
alloc_size =
|
||||
buffer_size + sizeof (CUSTOM_WRAPPER_START) +
|
||||
sizeof (CUSTOM_WRAPPER_END) - 2;
|
||||
data = g_string_sized_new (alloc_size);
|
||||
g_string_append_len (data, CUSTOM_WRAPPER_START,
|
||||
sizeof (CUSTOM_WRAPPER_START) - 1);
|
||||
|
||||
gst_adapter_push (adapter, period_buffer);
|
||||
gst_buffer_extract (period_buffer, 0, data->str + data->len, buffer_size);
|
||||
gst_buffer_unref (period_buffer);
|
||||
data->len += buffer_size;
|
||||
|
||||
wrapper = g_strdup (CUSTOM_WRAPPER_END);
|
||||
gst_adapter_push (adapter,
|
||||
gst_buffer_new_wrapped (wrapper, strlen (CUSTOM_WRAPPER_END) + 1));
|
||||
g_string_append_len (data, CUSTOM_WRAPPER_END,
|
||||
sizeof (CUSTOM_WRAPPER_END) - 1);
|
||||
|
||||
data = gst_adapter_map (adapter, gst_adapter_available (adapter));
|
||||
new_periods = gst_mpdparser_get_external_periods (data->str, alloc_size);
|
||||
|
||||
new_periods =
|
||||
gst_mpdparser_get_external_periods (data,
|
||||
gst_adapter_available (adapter));
|
||||
|
||||
gst_adapter_unmap (adapter);
|
||||
gst_adapter_clear (adapter);
|
||||
gst_object_unref (adapter);
|
||||
g_string_free (data, TRUE);
|
||||
}
|
||||
|
||||
return new_periods;
|
||||
|
Loading…
x
Reference in New Issue
Block a user