/* 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)
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
};
-
\ No newline at end of file
+
}
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;
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;
{
GstIdentity *identity;
GstBuffer *buf;
- guint i;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_IDENTITY (element));
{
GList *pads;
GstPadTemplate *templ;
- GstCaps *intersection;
+ GstCaps *intersection, *templcaps;
GstPad *foundpad = NULL;
/* checks */
/* 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;
}
}
}
- 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);
}
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;
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;
{
GstIdentity *identity;
GstBuffer *buf;
- guint i;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_IDENTITY (element));