From bdfaf62a4ab0c828ae0641bdebf1c7f906f4acea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 16 Dec 2013 10:16:14 +0100 Subject: [PATCH] h263parse: Post VIDEO_CODEC tag --- gst/videoparsers/gsth263parse.c | 36 +++++++++++++++++++++++++++++++++++- gst/videoparsers/gsth263parse.h | 1 + 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/gst/videoparsers/gsth263parse.c b/gst/videoparsers/gsth263parse.c index e8dfdfb..5493211 100644 --- a/gst/videoparsers/gsth263parse.c +++ b/gst/videoparsers/gsth263parse.c @@ -29,7 +29,8 @@ # include "config.h" #endif -#include +#include +#include #include "gsth263parse.h" #include @@ -59,6 +60,8 @@ static gboolean gst_h263_parse_sink_event (GstBaseParse * parse, GstEvent * event); static GstFlowReturn gst_h263_parse_handle_frame (GstBaseParse * parse, GstBaseParseFrame * frame, gint * skipsize); +static GstFlowReturn gst_h263_parse_pre_push_frame (GstBaseParse * parse, + GstBaseParseFrame * frame); static GstCaps *gst_h263_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter); @@ -85,6 +88,8 @@ gst_h263_parse_class_init (GstH263ParseClass * klass) parse_class->stop = GST_DEBUG_FUNCPTR (gst_h263_parse_stop); parse_class->sink_event = GST_DEBUG_FUNCPTR (gst_h263_parse_sink_event); parse_class->handle_frame = GST_DEBUG_FUNCPTR (gst_h263_parse_handle_frame); + parse_class->pre_push_frame = + GST_DEBUG_FUNCPTR (gst_h263_parse_pre_push_frame); parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_h263_parse_get_sink_caps); } @@ -107,6 +112,8 @@ gst_h263_parse_start (GstBaseParse * parse) h263parse->state = PARSING; + h263parse->sent_codec_tag = FALSE; + gst_base_parse_set_min_frame_size (parse, 4); return TRUE; @@ -414,3 +421,30 @@ gst_h263_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter) return res; } + +static GstFlowReturn +gst_h263_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) +{ + GstH263Parse *h263parse = GST_H263_PARSE (parse); + + if (!h263parse->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_VIDEO_CODEC, caps); + gst_caps_unref (caps); + + gst_pad_push_event (GST_BASE_PARSE_SRC_PAD (h263parse), + gst_event_new_tag (taglist)); + + /* also signals the end of first-frame processing */ + h263parse->sent_codec_tag = TRUE; + } + + return GST_FLOW_OK; +} diff --git a/gst/videoparsers/gsth263parse.h b/gst/videoparsers/gsth263parse.h index 899b6ec..e407065 100644 --- a/gst/videoparsers/gsth263parse.h +++ b/gst/videoparsers/gsth263parse.h @@ -60,6 +60,7 @@ struct _GstH263Parse guint bitrate; H263ParseState state; + gboolean sent_codec_tag; }; struct _GstH263ParseClass -- 2.7.4