GError *current_error;
GstStructure *current_topology;
+ GstTagList *all_tags;
+ GstTagList *global_tags;
+
/* List of private streams */
GList *streams;
dc->priv->target_state = GST_STATE_NULL;
dc->priv->no_more_pads = FALSE;
+ dc->priv->all_tags = NULL;
+ dc->priv->global_tags = NULL;
+
GST_LOG ("Creating pipeline");
dc->priv->pipeline = (GstBin *) gst_pipeline_new ("Discoverer");
GST_LOG_OBJECT (dc, "Creating uridecodebin");
GstEvent *event = GST_PAD_PROBE_INFO_EVENT (info);
switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_TAG:{
- GstTagList *tl = NULL, *tmp;
- GstTagScope scope;
-
- gst_event_parse_tag (event, &tl);
- scope = gst_tag_list_get_scope (tl);
- GST_DEBUG_OBJECT (pad, "tags %" GST_PTR_FORMAT, tl);
-
- if (scope != GST_TAG_SCOPE_STREAM) {
- GST_DEBUG_OBJECT (pad, "Ignoring non-stream tags");
- break;
- }
-
- DISCO_LOCK (ps->dc);
- /* If preroll is complete, drop these tags - the collected information is
- * possibly already being processed and adding more tags would be racy */
- if (G_LIKELY (ps->dc->priv->processing)) {
- GST_DEBUG_OBJECT (pad, "private stream %p old tags %" GST_PTR_FORMAT,
- ps, ps->tags);
- tmp = gst_tag_list_merge (ps->tags, tl, GST_TAG_MERGE_APPEND);
- if (ps->tags)
- gst_tag_list_unref (ps->tags);
- ps->tags = tmp;
- GST_DEBUG_OBJECT (pad, "private stream %p new tags %" GST_PTR_FORMAT,
- ps, tmp);
- } else
- GST_DEBUG_OBJECT (pad, "Dropping tags since preroll is done");
- DISCO_UNLOCK (ps->dc);
- break;
- }
case GST_EVENT_TOC:{
GstToc *tmp;
} else if (GST_VALUE_HOLDS_LIST (nval)) {
guint i, len;
GstDiscovererContainerInfo *cont;
- GstTagList *tags;
GstPad *srcpad;
if (gst_structure_id_get (topology, _ELEMENT_SRCPAD_QUARK, GST_TYPE_PAD,
cont = (GstDiscovererContainerInfo *)
g_object_new (GST_TYPE_DISCOVERER_CONTAINER_INFO, NULL);
cont->parent.caps = caps;
+ cont->tags = gst_tag_list_ref (dc->priv->global_tags);
res = (GstDiscovererStreamInfo *) cont;
- if (gst_structure_id_has_field (topology, _TAGS_QUARK)) {
- GstTagList *tmp;
-
- gst_structure_id_get (topology, _TAGS_QUARK,
- GST_TYPE_TAG_LIST, &tags, NULL);
-
- GST_DEBUG ("Merge tags %" GST_PTR_FORMAT, tags);
-
- tmp =
- gst_tag_list_merge (cont->parent.tags, (GstTagList *) tags,
- GST_TAG_MERGE_APPEND);
- gst_tag_list_unref (tags);
- if (cont->parent.tags)
- gst_tag_list_unref (cont->parent.tags);
- cont->parent.tags = tmp;
- GST_DEBUG ("Container info tags %" GST_PTR_FORMAT, tmp);
- }
-
for (i = 0; i < len; i++) {
const GValue *subv = gst_value_list_get_value (nval, i);
const GstStructure *subst = gst_value_get_structure (subv);
}
}
+static GstDiscovererInfo *
+_ensure_info_tags (GstDiscoverer * dc)
+{
+ GstDiscovererInfo *info = dc->priv->current_info;
+
+ if (dc->priv->all_tags)
+ info->tags = dc->priv->all_tags;
+ dc->priv->all_tags = NULL;
+ return info;
+}
static void
emit_discovererd (GstDiscoverer * dc)
{
- GST_DEBUG_OBJECT (dc, "Emitting 'discoverered' %s",
- dc->priv->current_info->uri);
+ GstDiscovererInfo *info = _ensure_info_tags (dc);
+ GST_DEBUG_OBJECT (dc, "Emitting 'discoverered' %s", info->uri);
g_signal_emit (dc, gst_discoverer_signals[SIGNAL_DISCOVERED], 0,
- dc->priv->current_info, dc->priv->current_error);
+ info, dc->priv->current_error);
/* Clients get a copy of current_info since it is a boxed type */
gst_discoverer_info_unref (dc->priv->current_info);
dc->priv->current_info = NULL;
scope = gst_tag_list_get_scope (tl);
GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Got tags %" GST_PTR_FORMAT, tl);
- if (scope != GST_TAG_SCOPE_GLOBAL) {
- GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Ignoring non-global tags");
- gst_tag_list_unref (tl);
- break;
+ tmp = gst_tag_list_merge (dc->priv->all_tags, tl, GST_TAG_MERGE_APPEND);
+ if (dc->priv->all_tags)
+ gst_tag_list_unref (dc->priv->all_tags);
+ dc->priv->all_tags = tmp;
+
+ if (scope == GST_TAG_SCOPE_STREAM) {
+ for (GList * curr = dc->priv->streams; curr; curr = curr->next) {
+ PrivateStream *ps = (PrivateStream *) curr->data;
+ if (GST_MESSAGE_SRC (msg) == GST_OBJECT_CAST (ps->sink)) {
+ tmp = gst_tag_list_merge (ps->tags, tl, GST_TAG_MERGE_APPEND);
+ if (ps->tags)
+ gst_tag_list_unref (ps->tags);
+ ps->tags = tmp;
+ GST_DEBUG_OBJECT (ps->pad, "tags %" GST_PTR_FORMAT, ps->tags);
+ break;
+ }
+ }
+ } else {
+ tmp =
+ gst_tag_list_merge (dc->priv->global_tags, tl,
+ GST_TAG_MERGE_APPEND);
+ if (dc->priv->global_tags)
+ gst_tag_list_unref (dc->priv->global_tags);
+ dc->priv->global_tags = tmp;
}
-
- /* Merge with current tags */
- tmp =
- gst_tag_list_merge (dc->priv->current_info->tags, tl,
- GST_TAG_MERGE_APPEND);
gst_tag_list_unref (tl);
- if (dc->priv->current_info->tags)
- gst_tag_list_unref (dc->priv->current_info->tags);
- dc->priv->current_info->tags = tmp;
- GST_DEBUG_OBJECT (GST_MESSAGE_SRC (msg), "Current info %p, tags %"
- GST_PTR_FORMAT, dc->priv->current_info, tmp);
}
break;
-
case GST_MESSAGE_TOC:
{
GstToc *tmp;
dc->priv->current_info = NULL;
+ if (dc->priv->all_tags) {
+ gst_tag_list_unref (dc->priv->all_tags);
+ dc->priv->all_tags = NULL;
+ }
+
+ if (dc->priv->global_tags) {
+ gst_tag_list_unref (dc->priv->global_tags);
+ dc->priv->global_tags = NULL;
+ }
+
dc->priv->pending_subtitle_pads = 0;
dc->priv->current_state = GST_STATE_NULL;
GstDiscovererContainerInfo *cinfo = GST_DISCOVERER_CONTAINER_INFO (sinfo);
g_variant_iter_init (&iter, specific);
+ cinfo->tags = sinfo->tags;
while ((child = g_variant_iter_next_value (&iter))) {
GstDiscovererStreamInfo *child_info;
child_info = _parse_discovery (g_variant_get_variant (child), info);
discoverer->priv->current_info->result);
discoverer->priv->current_info->result = res;
}
- info = discoverer->priv->current_info;
+ info = _ensure_info_tags (discoverer);
discoverer_cleanup (discoverer);