From dc2c61faf5ef285fd82faa8bfbb553a5c895421d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 24 Nov 2011 10:14:06 +0100 Subject: [PATCH] mpegvideoparse: Implement ::get_sink_caps vfunc to propagate downstream caps constraints upstream --- gst/videoparsers/gstmpegvideoparse.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gst/videoparsers/gstmpegvideoparse.c b/gst/videoparsers/gstmpegvideoparse.c index 66a8929..ca392a7 100644 --- a/gst/videoparsers/gstmpegvideoparse.c +++ b/gst/videoparsers/gstmpegvideoparse.c @@ -71,6 +71,7 @@ static gboolean gst_mpegv_parse_check_valid_frame (GstBaseParse * parse, static GstFlowReturn gst_mpegv_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame); static gboolean gst_mpegv_parse_set_caps (GstBaseParse * parse, GstCaps * caps); +static GstCaps *gst_mpegv_parse_get_caps (GstBaseParse * parse); static GstFlowReturn gst_mpegv_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame); @@ -166,6 +167,7 @@ gst_mpegv_parse_class_init (GstMpegvParseClass * klass) GST_DEBUG_FUNCPTR (gst_mpegv_parse_check_valid_frame); parse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_mpegv_parse_parse_frame); parse_class->set_sink_caps = GST_DEBUG_FUNCPTR (gst_mpegv_parse_set_caps); + parse_class->get_sink_caps = GST_DEBUG_FUNCPTR (gst_mpegv_parse_get_caps); parse_class->pre_push_frame = GST_DEBUG_FUNCPTR (gst_mpegv_parse_pre_push_frame); } @@ -762,3 +764,35 @@ gst_mpegv_parse_set_caps (GstBaseParse * parse, GstCaps * caps) /* let's not interfere and accept regardless of config parsing success */ return TRUE; } + +static GstCaps * +gst_mpegv_parse_get_caps (GstBaseParse * parse) +{ + GstCaps *peercaps; + GstCaps *res; + + peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse)); + if (peercaps) { + guint i, n; + + /* Remove the parsed field */ + peercaps = gst_caps_make_writable (peercaps); + n = gst_caps_get_size (peercaps); + for (i = 0; i < n; i++) { + GstStructure *s = gst_caps_get_structure (peercaps, i); + gst_structure_remove_field (s, "parsed"); + } + + res = + gst_caps_intersect_full (peercaps, + gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse)), + GST_CAPS_INTERSECT_FIRST); + gst_caps_unref (peercaps); + } else { + res = + gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD + (parse))); + } + + return res; +} -- 2.7.4