changes to spider: add padtemplates so the connect functions can connect two request-pad elements add a hack in gstel...

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
This commit is contained in:
Andy Wingo 2002-02-19 05:59:07 +00:00
parent 2cb0dd9d9b
commit 3114e54dc4
4 changed files with 48 additions and 17 deletions

View 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 = {
};

View 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));

View 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);

View 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));