baseparse: add getcaps function

Adds a getcaps function to the sink pad to make parsers propagate
downstream caps restrictions to upstream.

The pipeline "audiotestsrc num-buffers=100 ! faac ! aacparse !
"audio/mpeg, version=(int)4, stream-format=(string)adts" ! filesink"
wouldn't work because aacparse wouldn't propagate the adts restriction
upstream to faac.

This patch adds a default getcaps to the sink pad to simply proxy
downstream caps and also adds a 'get_sink_caps' function pointer
to GstBaseParseClass for subclasses that need more refined getcaps.

https://bugzilla.gnome.org/show_bug.cgi?id=661874
This commit is contained in:
Thiago Santos 2011-10-17 14:42:08 -03:00
parent f08b2203c8
commit e3f2d7db71
2 changed files with 30 additions and 1 deletions

View file

@ -379,6 +379,7 @@ static gboolean gst_base_parse_src_event (GstPad * pad, GstEvent * event);
static gboolean gst_base_parse_sink_event (GstPad * pad, GstEvent * event);
static gboolean gst_base_parse_query (GstPad * pad, GstQuery * query);
static gboolean gst_base_parse_sink_setcaps (GstPad * pad, GstCaps * caps);
static GstCaps *gst_base_parse_sink_getcaps (GstPad * pad);
static const GstQueryType *gst_base_parse_get_querytypes (GstPad * pad);
static GstFlowReturn gst_base_parse_chain (GstPad * pad, GstBuffer * buffer);
@ -512,6 +513,8 @@ gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
GST_DEBUG_FUNCPTR (gst_base_parse_sink_event));
gst_pad_set_setcaps_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_sink_setcaps));
gst_pad_set_getcaps_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_sink_getcaps));
gst_pad_set_chain_function (parse->sinkpad,
GST_DEBUG_FUNCPTR (gst_base_parse_chain));
gst_pad_set_activate_function (parse->sinkpad,
@ -3856,6 +3859,29 @@ gst_base_parse_sink_setcaps (GstPad * pad, GstCaps * caps)
return res;
}
static GstCaps *
gst_base_parse_sink_getcaps (GstPad * pad)
{
GstBaseParse *parse;
GstBaseParseClass *klass;
GstCaps *caps;
parse = GST_BASE_PARSE (gst_pad_get_parent (pad));
klass = GST_BASE_PARSE_GET_CLASS (parse);
g_assert (pad == GST_BASE_PARSE_SINK_PAD (parse));
if (klass->get_sink_caps)
caps = klass->get_sink_caps (parse);
else
caps = gst_pad_proxy_getcaps (pad);
gst_object_unref (parse);
GST_LOG_OBJECT (parse, "sink getcaps returning caps %" GST_PTR_FORMAT, caps);
return caps;
}
static void
gst_base_parse_set_index (GstElement * element, GstIndex * index)
{

View file

@ -191,6 +191,7 @@ struct _GstBaseParse {
* Called when the element stops processing.
* Allows closing external resources.
* @set_sink_caps: allows the subclass to be notified of the actual caps set.
* @get_sink_caps: allows the subclass to do its own sink get caps if needed.
* @check_valid_frame: Check if the given piece of data contains a valid
* frame.
* @parse_frame: Parse the already checked frame. Subclass need to
@ -252,8 +253,10 @@ struct _GstBaseParseClass {
gboolean (*src_event) (GstBaseParse * parse,
GstEvent * event);
GstCaps * (*get_sink_caps) (GstBaseParse * parse);
/*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE];
gpointer _gst_reserved[GST_PADDING_LARGE - 1];
};
GType gst_base_parse_get_type (void);