From: Zaheer Abbas Merali Date: Wed, 19 Dec 2001 01:17:54 +0000 (+0000) Subject: Added capsnego to the Tee Element X-Git-Tag: RELEASE-0_3_1-BELGIANBEER~148 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eb45d89cfb4aaeca4a08c0a32c42b2c495de4bc0;p=platform%2Fupstream%2Fgstreamer.git Added capsnego to the Tee Element Original commit message from CVS: Added capsnego to the Tee Element --- diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index cc271b9..6c6f83e 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -65,6 +65,8 @@ static void gst_tee_get_property (GObject *object, guint prop_id, static void gst_tee_chain (GstPad *pad, GstBuffer *buf); +static GstPadNegotiateReturn gst_tee_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data); + static GstElementClass *parent_class = NULL; /*static guint gst_tee_signals[LAST_SIGNAL] = { 0 };*/ @@ -120,6 +122,7 @@ gst_tee_init (GstTee *tee) tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); + gst_pad_set_negotiate_function (tee->sinkpad, GST_DEBUG_FUNCPTR(gst_tee_handle_negotiate_sink)); tee->numsrcpads = 0; tee->srcpads = NULL; @@ -146,7 +149,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar srcpad = gst_pad_new_from_template (templ, name); gst_element_add_pad (GST_ELEMENT (tee), srcpad); - + tee->srcpads = g_slist_prepend (tee->srcpads, srcpad); tee->numsrcpads++; @@ -239,3 +242,23 @@ gst_tee_factory_init (GstElementFactory *factory) return TRUE; } +static GstPadNegotiateReturn +gst_tee_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer* data) +{ + GstCaps* tempcaps; + gint i; + GstTee* tee=GST_TEE (GST_OBJECT_PARENT (pad)); + + if (*caps==NULL) + return GST_PAD_NEGOTIATE_FAIL; + + // go through all the src pads + for(i=0;inumsrcpads;i++) { + + if (!(gst_pad_set_caps (GST_PAD(g_slist_nth_data(tee->srcpads,i)), + *caps))) { + return GST_PAD_NEGOTIATE_FAIL; + } + } + return GST_PAD_NEGOTIATE_AGREE; +} diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index cc271b9..6c6f83e 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -65,6 +65,8 @@ static void gst_tee_get_property (GObject *object, guint prop_id, static void gst_tee_chain (GstPad *pad, GstBuffer *buf); +static GstPadNegotiateReturn gst_tee_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer *data); + static GstElementClass *parent_class = NULL; /*static guint gst_tee_signals[LAST_SIGNAL] = { 0 };*/ @@ -120,6 +122,7 @@ gst_tee_init (GstTee *tee) tee->sinkpad = gst_pad_new ("sink", GST_PAD_SINK); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); + gst_pad_set_negotiate_function (tee->sinkpad, GST_DEBUG_FUNCPTR(gst_tee_handle_negotiate_sink)); tee->numsrcpads = 0; tee->srcpads = NULL; @@ -146,7 +149,7 @@ gst_tee_request_new_pad (GstElement *element, GstPadTemplate *templ, const gchar srcpad = gst_pad_new_from_template (templ, name); gst_element_add_pad (GST_ELEMENT (tee), srcpad); - + tee->srcpads = g_slist_prepend (tee->srcpads, srcpad); tee->numsrcpads++; @@ -239,3 +242,23 @@ gst_tee_factory_init (GstElementFactory *factory) return TRUE; } +static GstPadNegotiateReturn +gst_tee_handle_negotiate_sink (GstPad *pad, GstCaps **caps, gpointer* data) +{ + GstCaps* tempcaps; + gint i; + GstTee* tee=GST_TEE (GST_OBJECT_PARENT (pad)); + + if (*caps==NULL) + return GST_PAD_NEGOTIATE_FAIL; + + // go through all the src pads + for(i=0;inumsrcpads;i++) { + + if (!(gst_pad_set_caps (GST_PAD(g_slist_nth_data(tee->srcpads,i)), + *caps))) { + return GST_PAD_NEGOTIATE_FAIL; + } + } + return GST_PAD_NEGOTIATE_AGREE; +}