Commit 4a9c72b8 authored by Shaun Ren's avatar Shaun Ren Committed by Alexandre Julliard

winegstreamer: Parse all tag events in query_tags.

Some gstreamer plugins, such as asfdemux, generate multiple tag events.
parent bdc67e95
...@@ -1276,47 +1276,61 @@ static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event) ...@@ -1276,47 +1276,61 @@ static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event)
static void query_tags(struct wg_parser_stream *stream) static void query_tags(struct wg_parser_stream *stream)
{ {
const gchar *struct_name; const gchar *struct_name;
GstTagList *tag_list;
GstEvent *tag_event; GstEvent *tag_event;
guint i, tag_count; guint i, j;
const GValue *val;
GstSample *sample;
GstBuffer *buf;
gsize size;
if (!(tag_event = gst_pad_get_sticky_event(stream->their_src, GST_EVENT_TAG, 0))) stream->tags[WG_PARSER_TAG_NAME] = NULL;
return; stream->tags[WG_PARSER_TAG_LANGUAGE] = NULL;
gst_event_parse_tag(tag_event, &tag_list);
gst_tag_list_get_string(tag_list, "language-code", &stream->tags[WG_PARSER_TAG_LANGUAGE]);
/* Extract stream name from Quick Time demuxer private tag where it puts unrecognized chunks. */ i = 0;
tag_count = gst_tag_list_get_tag_size(tag_list, "private-qt-tag"); while ((tag_event = gst_pad_get_sticky_event(stream->their_src, GST_EVENT_TAG, i++)))
for (i = 0; i < tag_count; ++i)
{ {
if (!(val = gst_tag_list_get_value_index(tag_list, "private-qt-tag", i))) GstTagList *tag_list;
continue;
if (!GST_VALUE_HOLDS_SAMPLE(val) || !(sample = gst_value_get_sample(val))) gst_event_parse_tag(tag_event, &tag_list);
continue;
struct_name = gst_structure_get_name(gst_sample_get_info(sample)); if (!stream->tags[WG_PARSER_TAG_NAME])
if (!struct_name || strcmp(struct_name, "application/x-gst-qt-name-tag")) {
continue; /* Extract stream name from Quick Time demuxer private tag where it puts unrecognized chunks. */
if (!(buf = gst_sample_get_buffer(sample))) const GValue *val;
continue; GstSample *sample;
if ((size = gst_buffer_get_size(buf)) < 8) GstBuffer *buf;
continue; gsize size;
size -= 8; guint tag_count = gst_tag_list_get_tag_size(tag_list, "private-qt-tag");
if (!(stream->tags[WG_PARSER_TAG_NAME] = g_malloc(size + 1)))
continue; for (j = 0; j < tag_count; ++j)
if (gst_buffer_extract(buf, 8, stream->tags[WG_PARSER_TAG_NAME], size) != size) {
if (!(val = gst_tag_list_get_value_index(tag_list, "private-qt-tag", j)))
continue;
if (!GST_VALUE_HOLDS_SAMPLE(val) || !(sample = gst_value_get_sample(val)))
continue;
struct_name = gst_structure_get_name(gst_sample_get_info(sample));
if (!struct_name || strcmp(struct_name, "application/x-gst-qt-name-tag"))
continue;
if (!(buf = gst_sample_get_buffer(sample)))
continue;
if ((size = gst_buffer_get_size(buf)) < 8)
continue;
size -= 8;
if (!(stream->tags[WG_PARSER_TAG_NAME] = g_malloc(size + 1)))
continue;
if (gst_buffer_extract(buf, 8, stream->tags[WG_PARSER_TAG_NAME], size) != size)
{
g_free(stream->tags[WG_PARSER_TAG_NAME]);
stream->tags[WG_PARSER_TAG_NAME] = NULL;
continue;
}
stream->tags[WG_PARSER_TAG_NAME][size] = 0;
}
}
if (!stream->tags[WG_PARSER_TAG_LANGUAGE])
{ {
g_free(stream->tags[WG_PARSER_TAG_NAME]); gst_tag_list_get_string(tag_list, GST_TAG_LANGUAGE_CODE, &stream->tags[WG_PARSER_TAG_LANGUAGE]);
stream->tags[WG_PARSER_TAG_NAME] = NULL;
continue;
} }
stream->tags[WG_PARSER_TAG_NAME][size] = 0;
gst_event_unref(tag_event);
} }
gst_event_unref(tag_event);
} }
static NTSTATUS wg_parser_connect(void *args) static NTSTATUS wg_parser_connect(void *args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment