capsnego fixes in adder, speed, and identity
authorAndy Wingo <wingo@pobox.com>
Sun, 17 Feb 2002 17:34:23 +0000 (17:34 +0000)
committerAndy Wingo <wingo@pobox.com>
Sun, 17 Feb 2002 17:34:23 +0000 (17:34 +0000)
Original commit message from CVS:
capsnego fixes in adder, speed, and identity

gst/elements/gstidentity.c
plugins/elements/gstidentity.c

index e456e13..66a43e1 100644 (file)
@@ -137,6 +137,22 @@ gst_identity_get_bufferpool (GstPad *pad)
   return gst_pad_get_bufferpool (identity->srcpad);
 }
 
+static GstPadConnectReturn
+gst_identity_connect_sink (GstPad *pad, GstCaps *caps)
+{
+  GstIdentity *identity;
+  
+  identity = GST_IDENTITY (gst_pad_get_parent (pad));
+
+  if (GST_CAPS_IS_FIXED (caps))
+    if (gst_pad_try_set_caps (identity->srcpad, caps))
+      return GST_PAD_CONNECT_OK;
+    else
+      return GST_PAD_CONNECT_REFUSED;
+  else
+    return GST_PAD_CONNECT_DELAYED;
+}
+
 static void 
 gst_identity_init (GstIdentity *identity) 
 {
@@ -144,6 +160,7 @@ 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);
   
   identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);
index e456e13..66a43e1 100644 (file)
@@ -137,6 +137,22 @@ gst_identity_get_bufferpool (GstPad *pad)
   return gst_pad_get_bufferpool (identity->srcpad);
 }
 
+static GstPadConnectReturn
+gst_identity_connect_sink (GstPad *pad, GstCaps *caps)
+{
+  GstIdentity *identity;
+  
+  identity = GST_IDENTITY (gst_pad_get_parent (pad));
+
+  if (GST_CAPS_IS_FIXED (caps))
+    if (gst_pad_try_set_caps (identity->srcpad, caps))
+      return GST_PAD_CONNECT_OK;
+    else
+      return GST_PAD_CONNECT_REFUSED;
+  else
+    return GST_PAD_CONNECT_DELAYED;
+}
+
 static void 
 gst_identity_init (GstIdentity *identity) 
 {
@@ -144,6 +160,7 @@ 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);
   
   identity->srcpad = gst_pad_new ("src", GST_PAD_SRC);
   gst_element_add_pad (GST_ELEMENT (identity), identity->srcpad);