]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/commitdiff
changes to spider: add padtemplates so the connect functions can connect two request...
authorAndy Wingo <wingo@pobox.com>
Tue, 19 Feb 2002 05:59:07 +0000 (05:59 +0000)
committerAndy Wingo <wingo@pobox.com>
Tue, 19 Feb 2002 05:59:07 +0000 (05:59 +0000)
Original commit message from CVS:
* changes to spider:
* add padtemplates so the connect functions can connect two request-pad
elements
* add a hack in gstelement.c. please look at this, Company, and see how
we can get around this
* add backwards caps-propagation support in identity, int2float, float2int,
adder, speed, volume

gst/autoplug/gstspider.c
gst/elements/gstidentity.c
gst/gstelement.c
plugins/elements/gstidentity.c

index 91f7822e30fe9073604060c1a7c01093d212c84b..9f51adc181c36e3aa0627265a72642a725500228 100644 (file)
@@ -112,6 +112,20 @@ static                          GstElementClass    *                       parent_class = NULL;
 /* no signals yet
 static guint gst_spider_signals[LAST_SIGNAL] = { 0 };*/
 
+/* let gstreamer know that we have some request pads available */
+GST_PADTEMPLATE_FACTORY (gst_spider_sink_template_factory,
+  "sink%d",
+  GST_PAD_SINK,
+  GST_PAD_REQUEST,
+  NULL
+);  
+GST_PADTEMPLATE_FACTORY (gst_spider_src_template_factory,
+  "src%d",
+  GST_PAD_SRC,
+  GST_PAD_REQUEST,
+  NULL
+);  
+
 /* GObject and GStreamer init functions */
 GType
 gst_spider_get_type(void)
@@ -154,6 +168,9 @@ gst_spider_class_init (GstSpiderClass *klass)
   gobject_class->get_property = gst_spider_get_property;
   gobject_class->dispose = gst_spider_dispose;
 
+  gst_element_class_add_padtemplate (gstelement_class, gst_spider_src_template_factory());
+  gst_element_class_add_padtemplate (gstelement_class, gst_spider_sink_template_factory());
+  
   gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR(gst_spider_request_new_pad);
 }
 static void 
@@ -688,4 +705,4 @@ GstPluginDesc plugin_desc = {
 };
 
   
-  
\ No newline at end of file
+  
index 66a43e10571b4767b44f33bfc39a9b337125edfa..19418f0a6f5b9c757010d3d5ca878f09e45e8e73 100644 (file)
@@ -138,14 +138,16 @@ gst_identity_get_bufferpool (GstPad *pad)
 }
 
 static GstPadConnectReturn
-gst_identity_connect_sink (GstPad *pad, GstCaps *caps)
+gst_identity_connect (GstPad *pad, GstCaps *caps)
 {
   GstIdentity *identity;
+  GstPad *otherpad;
   
   identity = GST_IDENTITY (gst_pad_get_parent (pad));
+  otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
 
   if (GST_CAPS_IS_FIXED (caps))
-    if (gst_pad_try_set_caps (identity->srcpad, caps))
+    if (gst_pad_try_set_caps (otherpad, caps))
       return GST_PAD_CONNECT_OK;
     else
       return GST_PAD_CONNECT_REFUSED;
@@ -160,10 +162,11 @@ gst_identity_init (GstIdentity *identity)
   gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
   gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
   gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
-  gst_pad_set_connect_function (identity->sinkpad, gst_identity_connect_sink);
+  gst_pad_set_connect_function (identity->sinkpad, gst_identity_connect);
   
   identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
+  gst_pad_set_connect_function (identity->srcpad, gst_identity_connect);
 
   identity->loop_based = FALSE;
   identity->sleep_time = 0;
@@ -227,7 +230,6 @@ gst_identity_loop (GstElement *element)
 {
   GstIdentity *identity;
   GstBuffer *buf;
-  guint i;
 
   g_return_if_fail (element != NULL);
   g_return_if_fail (GST_IS_IDENTITY (element));
index 76a1d0cf09cfef9b24d13b9f8111f01547679d96..7b9a9e1324a81d087c7e3dce1908d3d2dbcc8826 100644 (file)
@@ -764,7 +764,7 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, GstCa
 {
   GList *pads;
   GstPadTemplate *templ;
-  GstCaps *intersection;
+  GstCaps *intersection, *templcaps;
   GstPad *foundpad = NULL;
   
   /* checks */
@@ -792,16 +792,26 @@ gst_element_get_compatible_pad_filtered (GstElement *element, GstPad *pad, GstCa
   /* try to create a new one */
   /* requesting is a little crazy, we need a template. Let's create one */
   if (filtercaps != NULL) {
-    filtercaps = gst_caps_intersect (filtercaps, (GstCaps *) GST_RPAD_CAPS (pad));
-    if (filtercaps == NULL)
+    templcaps = gst_caps_intersect (filtercaps, (GstCaps *) GST_RPAD_CAPS (pad));
+    if (templcaps == NULL)
       return NULL;
+  } else {
+    templcaps = gst_caps_copy (gst_pad_get_caps (pad));
   }
+  
   templ = gst_padtemplate_new ((gchar *) GST_PAD_NAME (pad), GST_RPAD_DIRECTION (pad),
-                    GST_PAD_ALWAYS, filtercaps);
+                               GST_PAD_ALWAYS, templcaps, NULL);
   foundpad = gst_element_request_compatible_pad (element, templ);
-  gst_object_unref (GST_OBJECT (templ));
-  if (filtercaps != NULL)
-    gst_caps_unref (filtercaps);
+  gst_object_unref (GST_OBJECT (templ)); /* this will take care of the caps too */
+  
+  /* FIXME: this is broken, but it's in here so autoplugging elements that don't
+     have caps on their source padtemplates (spider) can connect... */
+  if (!foundpad && !filtercaps) {
+    templ = gst_padtemplate_new ((gchar *) GST_PAD_NAME (pad), GST_RPAD_DIRECTION (pad),
+                                 GST_PAD_ALWAYS, NULL, NULL);
+    foundpad = gst_element_request_compatible_pad (element, templ);
+    gst_object_unref (GST_OBJECT (templ));
+  }
   
   return foundpad;
 }
@@ -887,7 +897,7 @@ gst_element_connect_elements_filtered (GstElement *src, GstElement *dest,
     }
   }
 
-  GST_DEBUG (GST_CAT_ELEMENT_PADS, "we might have request pads on both sides, checking...");
+  GST_DEBUG (GST_CAT_ELEMENT_PADS, "we might have request pads on both sides, checking...\n");
   srctempls = gst_element_get_padtemplate_list (src);
   desttempls = gst_element_get_padtemplate_list (dest);
   
index 66a43e10571b4767b44f33bfc39a9b337125edfa..19418f0a6f5b9c757010d3d5ca878f09e45e8e73 100644 (file)
@@ -138,14 +138,16 @@ gst_identity_get_bufferpool (GstPad *pad)
 }
 
 static GstPadConnectReturn
-gst_identity_connect_sink (GstPad *pad, GstCaps *caps)
+gst_identity_connect (GstPad *pad, GstCaps *caps)
 {
   GstIdentity *identity;
+  GstPad *otherpad;
   
   identity = GST_IDENTITY (gst_pad_get_parent (pad));
+  otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
 
   if (GST_CAPS_IS_FIXED (caps))
-    if (gst_pad_try_set_caps (identity->srcpad, caps))
+    if (gst_pad_try_set_caps (otherpad, caps))
       return GST_PAD_CONNECT_OK;
     else
       return GST_PAD_CONNECT_REFUSED;
@@ -160,10 +162,11 @@ gst_identity_init (GstIdentity *identity)
   gst_element_add_pad (GST_ELEMENT (identity), identity->sinkpad);
   gst_pad_set_chain_function (identity->sinkpad, GST_DEBUG_FUNCPTR (gst_identity_chain));
   gst_pad_set_bufferpool_function (identity->sinkpad, gst_identity_get_bufferpool);
-  gst_pad_set_connect_function (identity->sinkpad, gst_identity_connect_sink);
+  gst_pad_set_connect_function (identity->sinkpad, gst_identity_connect);
   
   identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
+  gst_pad_set_connect_function (identity->srcpad, gst_identity_connect);
 
   identity->loop_based = FALSE;
   identity->sleep_time = 0;
@@ -227,7 +230,6 @@ gst_identity_loop (GstElement *element)
 {
   GstIdentity *identity;
   GstBuffer *buf;
-  guint i;
 
   g_return_if_fail (element != NULL);
   g_return_if_fail (GST_IS_IDENTITY (element));