dcaparse: Post AUDIO_CODEC tag

This commit is contained in:
Sebastian Dröge 2013-12-16 09:56:29 +01:00
parent d2ab5199bc
commit 29f2cae129
2 changed files with 36 additions and 2 deletions

View file

@ -48,8 +48,8 @@
#include <string.h> #include <string.h>
#include "gstdcaparse.h" #include "gstdcaparse.h"
#include <gst/base/gstbytereader.h> #include <gst/base/base.h>
#include <gst/base/gstbitreader.h> #include <gst/pbutils/pbutils.h>
GST_DEBUG_CATEGORY_STATIC (dca_parse_debug); GST_DEBUG_CATEGORY_STATIC (dca_parse_debug);
#define GST_CAT_DEFAULT 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 gboolean gst_dca_parse_stop (GstBaseParse * parse);
static GstFlowReturn gst_dca_parse_handle_frame (GstBaseParse * parse, static GstFlowReturn gst_dca_parse_handle_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, gint * skipsize); 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, static GstCaps *gst_dca_parse_get_sink_caps (GstBaseParse * parse,
GstCaps * filter); GstCaps * filter);
static gboolean gst_dca_parse_set_sink_caps (GstBaseParse * parse, 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->start = GST_DEBUG_FUNCPTR (gst_dca_parse_start);
parse_class->stop = GST_DEBUG_FUNCPTR (gst_dca_parse_stop); parse_class->stop = GST_DEBUG_FUNCPTR (gst_dca_parse_stop);
parse_class->handle_frame = GST_DEBUG_FUNCPTR (gst_dca_parse_handle_frame); 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->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); 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->block_size = -1;
dcaparse->frame_size = -1; dcaparse->frame_size = -1;
dcaparse->last_sync = 0; dcaparse->last_sync = 0;
dcaparse->sent_codec_tag = FALSE;
} }
static void static void
@ -543,3 +548,30 @@ gst_dca_parse_set_sink_caps (GstBaseParse * parse, GstCaps * caps)
} }
return TRUE; 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;
}

View file

@ -58,6 +58,8 @@ struct _GstDcaParse {
gint block_size; gint block_size;
gint frame_size; gint frame_size;
gboolean sent_codec_tag;
guint32 last_sync; guint32 last_sync;
GstPadChainFunction baseparse_chainfunc; GstPadChainFunction baseparse_chainfunc;