From 1e0d2d67b47de96783a97af0baa926dd8f857b2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 29 Apr 2011 09:19:19 +0200 Subject: [PATCH] mad: Post bitrate tag whenever the bitrate changes Also send the layer/mode/emphasis/bitrate tags as an event too. --- ext/mad/gstmad.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/ext/mad/gstmad.c b/ext/mad/gstmad.c index 664ab1b403..4d51d71c1b 100644 --- a/ext/mad/gstmad.c +++ b/ext/mad/gstmad.c @@ -889,6 +889,7 @@ gst_mad_update_info (GstMad * mad) { struct mad_header *header = &mad->frame.header; gboolean changed = FALSE; + GstTagList *list = NULL; #define CHECK_HEADER(h1,str) \ G_STMT_START{ \ @@ -911,11 +912,9 @@ G_STMT_START{ \ CHECK_HEADER (layer, "layer"); CHECK_HEADER (mode, "mode"); CHECK_HEADER (emphasis, "emphasis"); - mad->header.bitrate = header->bitrate; mad->new_header = FALSE; if (changed) { - GstTagList *list; GEnumValue *mode; GEnumValue *emphasis; @@ -938,15 +937,29 @@ G_STMT_START{ \ GST_TAG_AUDIO_CODEC, str, NULL); g_free (str); } - if (!mad->xing_found) { - gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, - GST_TAG_BITRATE, mad->header.bitrate, NULL); - } - gst_element_post_message (GST_ELEMENT (mad), - gst_message_new_tag (GST_OBJECT (mad), list)); } + + changed = FALSE; + CHECK_HEADER (bitrate, "bitrate"); + if (!mad->xing_found && changed) { + if (!list) + list = gst_tag_list_new (); + gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, + GST_TAG_BITRATE, mad->header.bitrate, NULL); + } + mad->header.bitrate = header->bitrate; #undef CHECK_HEADER + if (list) { + gst_element_post_message (GST_ELEMENT (mad), + gst_message_new_tag (GST_OBJECT (mad), gst_tag_list_copy (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)); + } } static gboolean