summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorThiago Santos <thiagoss@osg.samsung.com>2015-03-27 18:58:31 -0300
committerThiago Santos <thiagoss@osg.samsung.com>2015-03-28 11:20:39 -0300
commitd56b11af56b53157fca03e9b21aa827164d10a00 (patch)
tree0b4241828ce255c0d3a3df6097fdf3fc0818721e /gst
parent7b2b619a8f9a9329a979dd7d96a339a8740c57d0 (diff)
matroska: store stream tags and push as updated
New tags can be found on different parts of the file, so this patch keeps the stream taglists around for the life cycle of the pad and adds those new tags as found. Then a new tag is found, the pad's is marked with a tags changed flag, making the element push a new tag event on the next check. Before this, we were sending only the newly found tags, as the element was losing its taglist when pushing the event.
Diffstat (limited to 'gst')
-rw-r--r--gst/matroska/matroska-demux.c30
-rw-r--r--gst/matroska/matroska-ids.c4
-rw-r--r--gst/matroska/matroska-ids.h6
-rw-r--r--gst/matroska/matroska-read-common.c9
4 files changed, 24 insertions, 25 deletions
diff --git a/gst/matroska/matroska-demux.c b/gst/matroska/matroska-demux.c
index 1e35f0315..317bb9fb9 100644
--- a/gst/matroska/matroska-demux.c
+++ b/gst/matroska/matroska-demux.c
@@ -401,7 +401,6 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
GstFlowReturn ret;
guint32 id, riff_fourcc = 0;
guint16 riff_audio_fmt = 0;
- GstTagList *list = NULL;
GstEvent *stream_start;
gchar *codec = NULL;
gchar *stream_id;
@@ -434,6 +433,7 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
context->alignment = 1;
context->dts_only = FALSE;
context->intra_only = FALSE;
+ context->tags = gst_tag_list_new_empty ();
demux->common.num_streams++;
g_assert (demux->common.src->len == demux->common.num_streams);
@@ -1094,7 +1094,9 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
context->codec_priv_size, &codec, &riff_fourcc);
if (codec) {
- list = gst_tag_list_new (GST_TAG_VIDEO_CODEC, codec, NULL);
+ gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_VIDEO_CODEC, codec, NULL);
+ context->tags_changed = TRUE;
g_free (codec);
}
break;
@@ -1111,7 +1113,9 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
&codec, &riff_audio_fmt);
if (codec) {
- list = gst_tag_list_new (GST_TAG_AUDIO_CODEC, codec, NULL);
+ gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,
+ GST_TAG_AUDIO_CODEC, codec, NULL);
+ context->tags_changed = TRUE;
g_free (codec);
}
break;
@@ -1147,13 +1151,11 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
if (context->language) {
const gchar *lang;
- if (!list)
- list = gst_tag_list_new_empty ();
-
/* Matroska contains ISO 639-2B codes, we want ISO 639-1 */
lang = gst_tag_get_language_code (context->language);
- gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
+ gst_tag_list_add (context->tags, GST_TAG_MERGE_REPLACE,
GST_TAG_LANGUAGE_CODE, (lang) ? lang : context->language, NULL);
+ context->tags_changed = TRUE;
}
if (caps == NULL) {
@@ -1203,8 +1205,6 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux, GstEbmlRead * ebml)
GST_INFO_OBJECT (demux, "Adding pad '%s' with caps %" GST_PTR_FORMAT,
padname, caps);
- context->pending_tags = list;
-
gst_pad_set_element_private (context->pad, context);
gst_pad_use_fixed_caps (context->pad);
@@ -1451,13 +1451,13 @@ gst_matroska_demux_send_tags (GstMatroskaDemux * demux)
stream = g_ptr_array_index (demux->common.src, i);
- if (G_UNLIKELY (stream->pending_tags != NULL)) {
- GST_DEBUG_OBJECT (demux, "Sending pending_tags %p for pad %s:%s : %"
- GST_PTR_FORMAT, stream->pending_tags,
- GST_DEBUG_PAD_NAME (stream->pad), stream->pending_tags);
+ if (G_UNLIKELY (stream->tags_changed)) {
+ GST_DEBUG_OBJECT (demux, "Sending tags %p for pad %s:%s : %"
+ GST_PTR_FORMAT, stream->tags,
+ GST_DEBUG_PAD_NAME (stream->pad), stream->tags);
gst_pad_push_event (stream->pad,
- gst_event_new_tag (stream->pending_tags));
- stream->pending_tags = NULL;
+ gst_event_new_tag (gst_tag_list_copy (stream->tags)));
+ stream->tags_changed = FALSE;
}
}
}
diff --git a/gst/matroska/matroska-ids.c b/gst/matroska/matroska-ids.c
index 444084b95..65af1cc4c 100644
--- a/gst/matroska/matroska-ids.c
+++ b/gst/matroska/matroska-ids.c
@@ -331,8 +331,8 @@ gst_matroska_track_free (GstMatroskaTrackContext * track)
g_array_free (track->encodings, TRUE);
}
- if (track->pending_tags)
- gst_tag_list_unref (track->pending_tags);
+ if (track->tags)
+ gst_tag_list_unref (track->tags);
if (track->index_table)
g_array_free (track->index_table, TRUE);
diff --git a/gst/matroska/matroska-ids.h b/gst/matroska/matroska-ids.h
index dc098dd5c..41315a052 100644
--- a/gst/matroska/matroska-ids.h
+++ b/gst/matroska/matroska-ids.h
@@ -540,8 +540,10 @@ struct _GstMatroskaTrackContext {
GstMatroskaTrackContext *context,
GstBuffer **buffer);
- /* Tags to send after newsegment event */
- GstTagList *pending_tags;
+ /* List of tags for this stream */
+ GstTagList *tags;
+ /* Tags changed and should be pushed again */
+ gboolean tags_changed;
/* A GArray of GstMatroskaTrackEncoding structures which contain the
* encoding (compression/encryption) settings for this track, if any */
diff --git a/gst/matroska/matroska-read-common.c b/gst/matroska/matroska-read-common.c
index 8d3569037..679cefbf0 100644
--- a/gst/matroska/matroska-read-common.c
+++ b/gst/matroska/matroska-read-common.c
@@ -2388,16 +2388,13 @@ gst_matroska_read_common_parse_metadata_id_tag (GstMatroskaReadCommon * common,
GstMatroskaTrackContext *stream = g_ptr_array_index (common->src, j);
if (stream->uid == tgt) {
- if (stream->pending_tags == NULL)
- stream->pending_tags = gst_tag_list_new_empty ();
-
- gst_tag_list_insert (stream->pending_tags, taglist,
- GST_TAG_MERGE_REPLACE);
+ gst_tag_list_insert (stream->tags, taglist, GST_TAG_MERGE_REPLACE);
+ stream->tags_changed = TRUE;
found = TRUE;
}
}
if (!found) {
- GST_WARNING_OBJECT (common->sinkpad,
+ GST_FIXME_OBJECT (common->sinkpad,
"Found track-specific tag(s), but track %" G_GUINT64_FORMAT
" is not known (yet?)", tgt);
}