From b6529e9d6084e42329a9a487d9237bb6442dca41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 27 Feb 2008 13:18:57 +0000 Subject: [PATCH] Cache all events except EOS if we still have to send a NEWSEGMENT event. This will let TAG events be forwarded until ... Original commit message from CVS: * ext/mad/gstmad.c: (gst_mad_dispose), (gst_mad_sink_event), (gst_mad_chain): * ext/mad/gstmad.h: * gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_dispose), (gst_mp3parse_sink_event), (gst_mp3parse_emit_frame): * gst/mpegaudioparse/gstmpegaudioparse.h: Cache all events except EOS if we still have to send a NEWSEGMENT event. This will let TAG events be forwarded until after decodebin to an encoder for example as decodebin only links the pads after NEWSEGMENT. Fixes bug #518933. --- ChangeLog | 13 +++++++++ ext/mad/gstmad.c | 37 +++++++++++++++++++++++--- ext/mad/gstmad.h | 2 ++ gst/mpegaudioparse/gstmpegaudioparse.c | 27 +++++++++++++++++-- gst/mpegaudioparse/gstmpegaudioparse.h | 2 ++ 5 files changed, 76 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8228447745..4ab077673e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-02-27 Sebastian Dröge + + * ext/mad/gstmad.c: (gst_mad_dispose), (gst_mad_sink_event), + (gst_mad_chain): + * ext/mad/gstmad.h: + * gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_dispose), + (gst_mp3parse_sink_event), (gst_mp3parse_emit_frame): + * gst/mpegaudioparse/gstmpegaudioparse.h: + Cache all events except EOS if we still have to send a NEWSEGMENT + event. This will let TAG events be forwarded until after decodebin + to an encoder for example as decodebin only links the pads + after NEWSEGMENT. Fixes bug #518933. + 2008-02-27 Sebastian Dröge * gst/mpegaudioparse/gstxingmux.c: (get_xing_offset): diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 98fb739721..7dfa6f5962 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -284,6 +284,10 @@ gst_mad_dispose (GObject * object) g_free (mad->tempbuffer); mad->tempbuffer = NULL; + g_list_foreach (mad->pending_events, (GFunc) gst_mini_object_unref, NULL); + g_list_free (mad->pending_events); + mad->pending_events = NULL; + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -988,7 +992,14 @@ gst_mad_sink_event (GstPad * pad, GstEvent * event) break; default: - result = gst_pad_event_default (pad, event); + if (mad->restart) { + /* Cache all events except EOS if we still have to send a NEWSEGMENT */ + if (GST_EVENT_TYPE (event) != GST_EVENT_EOS) + mad->pending_events = g_list_append (mad->pending_events, event); + result = TRUE; + } else { + result = gst_pad_event_default (pad, event); + } break; } return result; @@ -1409,7 +1420,12 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) } else { mad->tags = gst_tag_list_copy (list); } - gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); + if (mad->need_newsegment) + mad->pending_events = + g_list_append (mad->pending_events, + gst_event_new_tag (list)); + else + gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); } } } @@ -1449,7 +1465,12 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) GST_TAG_BITRATE, bitrate, NULL); gst_element_post_message (GST_ELEMENT (mad), gst_message_new_tag (GST_OBJECT (mad), gst_tag_list_copy (list))); - gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); + + if (mad->need_newsegment) + mad->pending_events = + g_list_append (mad->pending_events, gst_event_new_tag (list)); + else + gst_pad_push_event (mad->srcpad, gst_event_new_tag (list)); goto next_no_samples; } @@ -1542,6 +1563,16 @@ gst_mad_chain (GstPad * pad, GstBuffer * buffer) mad->need_newsegment = FALSE; } + if (mad->pending_events) { + GList *l; + + for (l = mad->pending_events; l != NULL; l = l->next) { + gst_pad_push_event (mad->srcpad, GST_EVENT (l->data)); + } + g_list_free (mad->pending_events); + mad->pending_events = NULL; + } + /* will attach the caps to the buffer */ result = gst_pad_alloc_buffer_and_set_caps (mad->srcpad, 0, diff --git a/ext/mad/gstmad.h b/ext/mad/gstmad.h index ce8c9565c0..3f0177f77a 100644 --- a/ext/mad/gstmad.h +++ b/ext/mad/gstmad.h @@ -92,6 +92,8 @@ struct _GstMad gboolean xing_found; gboolean framed; /* whether there is a demuxer in front of us */ + + GList *pending_events; }; struct _GstMadClass diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index e5fcf22255..5657aaa2fd 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -401,13 +401,18 @@ gst_mp3parse_dispose (GObject * object) g_mutex_free (mp3parse->pending_accurate_seeks_lock); mp3parse->pending_accurate_seeks_lock = NULL; + g_list_foreach (mp3parse->pending_events, (GFunc) gst_mini_object_unref, + NULL); + g_list_free (mp3parse->pending_events); + mp3parse->pending_events = NULL; + G_OBJECT_CLASS (parent_class)->dispose (object); } static gboolean gst_mp3parse_sink_event (GstPad * pad, GstEvent * event) { - gboolean res; + gboolean res = TRUE; GstMPEGAudioParse *mp3parse; GstEvent **eventp; @@ -535,7 +540,16 @@ gst_mp3parse_sink_event (GstPad * pad, GstEvent * event) res = gst_pad_push_event (mp3parse->srcpad, event); break; default: - res = gst_pad_push_event (mp3parse->srcpad, event); + GST_PAD_STREAM_LOCK (pad); + if (mp3parse->pending_segment) { + /* Cache all events except EOS if we have a pending segment */ + if (GST_EVENT_TYPE (event) != GST_EVENT_EOS) + mp3parse->pending_events = + g_list_append (mp3parse->pending_events, event); + } else { + res = gst_pad_push_event (mp3parse->srcpad, event); + } + GST_PAD_STREAM_UNLOCK (pad); break; } @@ -765,6 +779,15 @@ gst_mp3parse_emit_frame (GstMPEGAudioParse * mp3parse, guint size, gst_pad_push_event (mp3parse->srcpad, mp3parse->pending_segment); mp3parse->pending_segment = NULL; } + if (mp3parse->pending_events) { + GList *l; + + for (l = mp3parse->pending_events; l != NULL; l = l->next) { + gst_pad_push_event (mp3parse->srcpad, GST_EVENT (l->data)); + } + g_list_free (mp3parse->pending_events); + mp3parse->pending_events = NULL; + } ret = gst_pad_push (mp3parse->srcpad, outbuf); } diff --git a/gst/mpegaudioparse/gstmpegaudioparse.h b/gst/mpegaudioparse/gstmpegaudioparse.h index 086a00e201..8be1951c8e 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.h +++ b/gst/mpegaudioparse/gstmpegaudioparse.h @@ -121,6 +121,8 @@ struct _GstMPEGAudioParse { /* pending segment */ GstEvent *pending_segment; + /* pending events */ + GList *pending_events; }; struct _GstMPEGAudioParseClass {