mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
audio: Always keep a complete taglist around
Otherwise updates to the tags will cause non-updated tags to be lost downstream.
This commit is contained in:
parent
6e5bee2d1a
commit
7f0e65bb46
2 changed files with 32 additions and 24 deletions
|
@ -247,6 +247,7 @@ struct _GstAudioDecoderPrivate
|
||||||
gint error_count;
|
gint error_count;
|
||||||
/* codec id tag */
|
/* codec id tag */
|
||||||
GstTagList *taglist;
|
GstTagList *taglist;
|
||||||
|
gboolean taglist_changed;
|
||||||
|
|
||||||
/* whether circumstances allow output aggregation */
|
/* whether circumstances allow output aggregation */
|
||||||
gint agg;
|
gint agg;
|
||||||
|
@ -477,6 +478,7 @@ gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full)
|
||||||
gst_tag_list_free (dec->priv->taglist);
|
gst_tag_list_free (dec->priv->taglist);
|
||||||
dec->priv->taglist = NULL;
|
dec->priv->taglist = NULL;
|
||||||
}
|
}
|
||||||
|
dec->priv->taglist_changed = FALSE;
|
||||||
|
|
||||||
gst_segment_init (&dec->input_segment, GST_FORMAT_TIME);
|
gst_segment_init (&dec->input_segment, GST_FORMAT_TIME);
|
||||||
gst_segment_init (&dec->output_segment, GST_FORMAT_TIME);
|
gst_segment_init (&dec->output_segment, GST_FORMAT_TIME);
|
||||||
|
@ -706,11 +708,12 @@ gst_audio_decoder_sink_setcaps (GstAudioDecoder * dec, GstCaps * caps)
|
||||||
/* NOTE pbutils only needed here */
|
/* NOTE pbutils only needed here */
|
||||||
/* TODO maybe (only) upstream demuxer/parser etc should handle this ? */
|
/* TODO maybe (only) upstream demuxer/parser etc should handle this ? */
|
||||||
#if 0
|
#if 0
|
||||||
if (dec->priv->taglist)
|
if (!dec->priv->taglist)
|
||||||
gst_tag_list_free (dec->priv->taglist);
|
dec->priv->taglist = gst_tag_list_new ();
|
||||||
dec->priv->taglist = gst_tag_list_new ();
|
dec->priv->taglist = gst_tag_list_make_writable (dec->priv->taglist);
|
||||||
gst_pb_utils_add_codec_description_to_tag_list (dec->priv->taglist,
|
gst_pb_utils_add_codec_description_to_tag_list (dec->priv->taglist,
|
||||||
GST_TAG_AUDIO_CODEC, caps);
|
GST_TAG_AUDIO_CODEC, caps);
|
||||||
|
dec->priv->taglist_changed = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (klass->set_format)
|
if (klass->set_format)
|
||||||
|
@ -1070,14 +1073,12 @@ gst_audio_decoder_finish_frame (GstAudioDecoder * dec, GstBuffer * buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* delayed one-shot stuff until confirmed data */
|
/* delayed one-shot stuff until confirmed data */
|
||||||
if (priv->taglist) {
|
if (priv->taglist && priv->taglist_changed) {
|
||||||
GST_DEBUG_OBJECT (dec, "codec tag %" GST_PTR_FORMAT, priv->taglist);
|
GST_DEBUG_OBJECT (dec, "codec tag %" GST_PTR_FORMAT, priv->taglist);
|
||||||
if (gst_tag_list_is_empty (priv->taglist)) {
|
if (!gst_tag_list_is_empty (priv->taglist))
|
||||||
gst_tag_list_free (priv->taglist);
|
gst_audio_decoder_push_event (dec,
|
||||||
} else {
|
gst_event_new_tag (gst_tag_list_ref (priv->taglist)));
|
||||||
gst_audio_decoder_push_event (dec, gst_event_new_tag (priv->taglist));
|
priv->taglist_changed = FALSE;
|
||||||
}
|
|
||||||
priv->taglist = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = gst_buffer_make_writable (buf);
|
buf = gst_buffer_make_writable (buf);
|
||||||
|
@ -2862,7 +2863,8 @@ gst_audio_decoder_merge_tags (GstAudioDecoder * dec,
|
||||||
otags = dec->priv->taglist;
|
otags = dec->priv->taglist;
|
||||||
dec->priv->taglist = gst_tag_list_merge (dec->priv->taglist, tags, mode);
|
dec->priv->taglist = gst_tag_list_merge (dec->priv->taglist, tags, mode);
|
||||||
if (otags)
|
if (otags)
|
||||||
gst_tag_list_free (otags);
|
gst_tag_list_unref (otags);
|
||||||
|
dec->priv->taglist_changed = TRUE;
|
||||||
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -255,6 +255,7 @@ struct _GstAudioEncoderPrivate
|
||||||
|
|
||||||
/* pending tags */
|
/* pending tags */
|
||||||
GstTagList *tags;
|
GstTagList *tags;
|
||||||
|
gboolean tags_changed;
|
||||||
/* pending serialized sink events, will be sent from finish_frame() */
|
/* pending serialized sink events, will be sent from finish_frame() */
|
||||||
GList *pending_events;
|
GList *pending_events;
|
||||||
};
|
};
|
||||||
|
@ -467,6 +468,7 @@ gst_audio_encoder_reset (GstAudioEncoder * enc, gboolean full)
|
||||||
if (enc->priv->tags)
|
if (enc->priv->tags)
|
||||||
gst_tag_list_free (enc->priv->tags);
|
gst_tag_list_free (enc->priv->tags);
|
||||||
enc->priv->tags = NULL;
|
enc->priv->tags = NULL;
|
||||||
|
enc->priv->tags_changed = FALSE;
|
||||||
|
|
||||||
g_list_foreach (enc->priv->pending_events, (GFunc) gst_event_unref, NULL);
|
g_list_foreach (enc->priv->pending_events, (GFunc) gst_event_unref, NULL);
|
||||||
g_list_free (enc->priv->pending_events);
|
g_list_free (enc->priv->pending_events);
|
||||||
|
@ -641,24 +643,26 @@ gst_audio_encoder_finish_frame (GstAudioEncoder * enc, GstBuffer * buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* send after pending events, which likely includes newsegment event */
|
/* send after pending events, which likely includes newsegment event */
|
||||||
if (G_UNLIKELY (enc->priv->tags)) {
|
if (G_UNLIKELY (enc->priv->tags && enc->priv->tags_changed)) {
|
||||||
GstTagList *tags;
|
|
||||||
#if 0
|
#if 0
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* add codec info to pending tags */
|
/* add codec info to pending tags */
|
||||||
tags = enc->priv->tags;
|
|
||||||
/* no more pending */
|
|
||||||
enc->priv->tags = NULL;
|
|
||||||
#if 0
|
#if 0
|
||||||
|
if (!enc->priv->tags)
|
||||||
|
enc->priv->tags = gst_tag_list_new ();
|
||||||
|
enc->priv->tags = gst_tag_list_make_writable (enc->priv->tags);
|
||||||
caps = gst_pad_get_current_caps (enc->srcpad);
|
caps = gst_pad_get_current_caps (enc->srcpad);
|
||||||
gst_pb_utils_add_codec_description_to_tag_list (tags, GST_TAG_CODEC, caps);
|
gst_pb_utils_add_codec_description_to_tag_list (enc->priv->tags,
|
||||||
gst_pb_utils_add_codec_description_to_tag_list (tags, GST_TAG_AUDIO_CODEC,
|
GST_TAG_CODEC, caps);
|
||||||
caps);
|
gst_pb_utils_add_codec_description_to_tag_list (enc->priv->tags,
|
||||||
|
GST_TAG_AUDIO_CODEC, caps);
|
||||||
#endif
|
#endif
|
||||||
GST_DEBUG_OBJECT (enc, "sending tags %" GST_PTR_FORMAT, tags);
|
GST_DEBUG_OBJECT (enc, "sending tags %" GST_PTR_FORMAT, enc->priv->tags);
|
||||||
gst_audio_encoder_push_event (enc, gst_event_new_tag (tags));
|
gst_audio_encoder_push_event (enc,
|
||||||
|
gst_event_new_tag (gst_tag_list_ref (enc->priv->tags)));
|
||||||
|
enc->priv->tags_changed = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove corresponding samples from input */
|
/* remove corresponding samples from input */
|
||||||
|
@ -1962,6 +1966,7 @@ gst_audio_encoder_activate (GstAudioEncoder * enc, gboolean active)
|
||||||
if (enc->priv->tags)
|
if (enc->priv->tags)
|
||||||
gst_tag_list_free (enc->priv->tags);
|
gst_tag_list_free (enc->priv->tags);
|
||||||
enc->priv->tags = gst_tag_list_new_empty ();
|
enc->priv->tags = gst_tag_list_new_empty ();
|
||||||
|
enc->priv->tags_changed = FALSE;
|
||||||
|
|
||||||
if (!enc->priv->active && klass->start)
|
if (!enc->priv->active && klass->start)
|
||||||
result = klass->start (enc);
|
result = klass->start (enc);
|
||||||
|
@ -2502,14 +2507,15 @@ gst_audio_encoder_merge_tags (GstAudioEncoder * enc,
|
||||||
g_return_if_fail (GST_IS_AUDIO_ENCODER (enc));
|
g_return_if_fail (GST_IS_AUDIO_ENCODER (enc));
|
||||||
g_return_if_fail (tags == NULL || GST_IS_TAG_LIST (tags));
|
g_return_if_fail (tags == NULL || GST_IS_TAG_LIST (tags));
|
||||||
|
|
||||||
GST_OBJECT_LOCK (enc);
|
GST_AUDIO_ENCODER_STREAM_LOCK (enc);
|
||||||
if (tags)
|
if (tags)
|
||||||
GST_DEBUG_OBJECT (enc, "merging tags %" GST_PTR_FORMAT, tags);
|
GST_DEBUG_OBJECT (enc, "merging tags %" GST_PTR_FORMAT, tags);
|
||||||
otags = enc->priv->tags;
|
otags = enc->priv->tags;
|
||||||
enc->priv->tags = gst_tag_list_merge (enc->priv->tags, tags, mode);
|
enc->priv->tags = gst_tag_list_merge (enc->priv->tags, tags, mode);
|
||||||
if (otags)
|
if (otags)
|
||||||
gst_tag_list_free (otags);
|
gst_tag_list_unref (otags);
|
||||||
GST_OBJECT_UNLOCK (enc);
|
enc->priv->tags_changed = TRUE;
|
||||||
|
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue