From: Sjoerd Simons Date: Tue, 27 Sep 2011 18:25:53 +0000 (+0100) Subject: jpegdec: Implement upstream negotiation X-Git-Tag: RELEASE-0.11.1~7^2~252 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95db64851666bc3c5e852da77913764978588194;p=platform%2Fupstream%2Fgst-plugins-good.git jpegdec: Implement upstream negotiation Add upstream negotiation for jpegdec. Fixes #660275 --- diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index 23e8f23..2770696 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -113,6 +113,7 @@ static void gst_jpeg_dec_get_property (GObject * object, guint prop_id, static GstFlowReturn gst_jpeg_dec_chain (GstPad * pad, GstBuffer * buffer); static gboolean gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps); +static GstCaps *gst_jpeg_dec_getcaps (GstPad * pad); static gboolean gst_jpeg_dec_sink_event (GstPad * pad, GstEvent * event); static gboolean gst_jpeg_dec_src_event (GstPad * pad, GstEvent * event); static GstStateChangeReturn gst_jpeg_dec_change_state (GstElement * element, @@ -406,6 +407,8 @@ gst_jpeg_dec_init (GstJpegDec * dec) gst_element_add_pad (GST_ELEMENT (dec), dec->sinkpad); gst_pad_set_setcaps_function (dec->sinkpad, GST_DEBUG_FUNCPTR (gst_jpeg_dec_setcaps)); + gst_pad_set_getcaps_function (dec->sinkpad, + GST_DEBUG_FUNCPTR (gst_jpeg_dec_getcaps)); gst_pad_set_chain_function (dec->sinkpad, GST_DEBUG_FUNCPTR (gst_jpeg_dec_chain)); gst_pad_set_event_function (dec->sinkpad, @@ -769,6 +772,50 @@ gst_jpeg_dec_setcaps (GstPad * pad, GstCaps * caps) return TRUE; } +static GstCaps * +gst_jpeg_dec_getcaps (GstPad * pad) +{ + GstJpegDec *dec; + GstCaps *caps; + GstPad *peer; + + dec = GST_JPEG_DEC (GST_OBJECT_PARENT (pad)); + + if (GST_PAD_CAPS (pad)) + return gst_caps_ref (GST_PAD_CAPS (pad)); + + peer = gst_pad_get_peer (dec->srcpad); + + if (peer) { + GstCaps *peer_caps; + const GstCaps *templ_caps; + GstStructure *s; + guint i, n; + + peer_caps = gst_pad_get_caps (peer); + + /* Translate peercaps to image/jpeg */ + peer_caps = gst_caps_make_writable (peer_caps); + n = gst_caps_get_size (peer_caps); + for (i = 0; i < n; i++) { + s = gst_caps_get_structure (peer_caps, i); + + gst_structure_set_name (s, "image/jpeg"); + } + + templ_caps = gst_pad_get_pad_template_caps (pad); + caps = gst_caps_intersect_full (peer_caps, templ_caps, + GST_CAPS_INTERSECT_FIRST); + + gst_object_unref (peer); + } else { + caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); + } + + return caps; +} + + /* yuk */ static void hresamplecpy1 (guint8 * dest, const guint8 * src, guint len)