diff --git a/gst/audioparsers/gstdcaparse.c b/gst/audioparsers/gstdcaparse.c index ef28612c64..4b1a6ea987 100644 --- a/gst/audioparsers/gstdcaparse.c +++ b/gst/audioparsers/gstdcaparse.c @@ -48,8 +48,8 @@ #include #include "gstdcaparse.h" -#include -#include +#include +#include GST_DEBUG_CATEGORY_STATIC (dca_parse_debug); #define GST_CAT_DEFAULT dca_parse_debug @@ -76,6 +76,8 @@ static gboolean gst_dca_parse_start (GstBaseParse * parse); static gboolean gst_dca_parse_stop (GstBaseParse * parse); static GstFlowReturn gst_dca_parse_handle_frame (GstBaseParse * parse, GstBaseParseFrame * frame, gint * skipsize); +static GstFlowReturn gst_dca_parse_pre_push_frame (GstBaseParse * parse, + GstBaseParseFrame * frame); static GstCaps *gst_dca_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter); static gboolean gst_dca_parse_set_sink_caps (GstBaseParse * parse, @@ -99,6 +101,8 @@ gst_dca_parse_class_init (GstDcaParseClass * klass) parse_class->start = GST_DEBUG_FUNCPTR (gst_dca_parse_start); parse_class->stop = GST_DEBUG_FUNCPTR (gst_dca_parse_stop); parse_class->handle_frame = GST_DEBUG_FUNCPTR (gst_dca_parse_handle_frame); + parse_class->pre_push_frame = + GST_DEBUG_FUNCPTR (gst_dca_parse_pre_push_frame); parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_dca_parse_get_sink_caps); parse_class->set_sink_caps = GST_DEBUG_FUNCPTR (gst_dca_parse_set_sink_caps); @@ -122,6 +126,7 @@ gst_dca_parse_reset (GstDcaParse * dcaparse) dcaparse->block_size = -1; dcaparse->frame_size = -1; dcaparse->last_sync = 0; + dcaparse->sent_codec_tag = FALSE; } static void @@ -543,3 +548,30 @@ gst_dca_parse_set_sink_caps (GstBaseParse * parse, GstCaps * caps) } return TRUE; } + +static GstFlowReturn +gst_dca_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) +{ + GstDcaParse *dcaparse = GST_DCA_PARSE (parse); + + if (!dcaparse->sent_codec_tag) { + GstTagList *taglist; + GstCaps *caps; + + taglist = gst_tag_list_new_empty (); + + /* codec tag */ + caps = gst_pad_get_current_caps (GST_BASE_PARSE_SRC_PAD (parse)); + gst_pb_utils_add_codec_description_to_tag_list (taglist, + GST_TAG_AUDIO_CODEC, caps); + gst_caps_unref (caps); + + gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (dcaparse), + gst_event_new_tag (taglist)); + + /* also signals the end of first-frame processing */ + dcaparse->sent_codec_tag = TRUE; + } + + return GST_FLOW_OK; +} diff --git a/gst/audioparsers/gstdcaparse.h b/gst/audioparsers/gstdcaparse.h index b1ac76dfa8..9198a06b8e 100644 --- a/gst/audioparsers/gstdcaparse.h +++ b/gst/audioparsers/gstdcaparse.h @@ -58,6 +58,8 @@ struct _GstDcaParse { gint block_size; gint frame_size; + gboolean sent_codec_tag; + guint32 last_sync; GstPadChainFunction baseparse_chainfunc;