bugfixing; use the right function to check probable caps compatibility

Original commit message from CVS:
bugfixing; use the right function to check probable caps compatibility
This commit is contained in:
Benjamin Otte 2002-02-05 20:56:11 +00:00
parent 07e4199418
commit 7ec0610594
3 changed files with 34 additions and 4 deletions

View file

@ -38,6 +38,35 @@ g_list_free_list_and_elements (GList *list)
}
g_list_free (list);
}
/**
* gst_autoplug_can_connect_src:
* @src: caps of the source
* @sink: caps of the sink
*
* Checks if a factory's sink can connect to the given caps
*
* Return: TRUE, if both caps intersect.
*/
gboolean
gst_autoplag_caps_intersect (GstCaps *src, GstCaps *sink)
{
GstCaps *caps;
/* if there are no caps, we can connect */
if ((src == NULL) && (sink == NULL))
return TRUE;
/* get an interection */
caps = gst_caps_intersect (src, sink);
/* if the caps can't connect, there is no intersection */
if (caps == NULL)
return FALSE;
/* hurrah, we can connect, now remove the intersection */
gst_caps_unref (GST_OBJECT (caps));
return TRUE;
}
/**
* gst_autoplug_can_connect_src:
@ -57,7 +86,7 @@ gst_autoplug_can_connect_src (GstElementFactory *fac, GstCaps *src)
while (templs)
{
if ((GST_PADTEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && gst_caps_check_compatibility(src, GST_PADTEMPLATE_CAPS (templs->data)))
if ((GST_PADTEMPLATE_DIRECTION (templs->data) == GST_PAD_SINK) && gst_autoplag_caps_intersect (src, GST_PADTEMPLATE_CAPS (templs->data)))
{
return GST_PADTEMPLATE (templs->data);
}
@ -84,7 +113,7 @@ gst_autoplug_can_connect_sink (GstElementFactory *fac, GstCaps *sink)
while (templs)
{
if ((GST_PADTEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) && gst_caps_check_compatibility(GST_PADTEMPLATE_CAPS (templs->data), sink))
if ((GST_PADTEMPLATE_DIRECTION (templs->data) == GST_PAD_SRC) && gst_autoplag_caps_intersect (GST_PADTEMPLATE_CAPS (templs->data), sink))
{
return GST_PADTEMPLATE (templs->data);
}
@ -110,7 +139,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
if (srctemp->direction == GST_PAD_SRC &&
desttemp->direction == GST_PAD_SINK) {
if (gst_caps_check_compatibility (gst_padtemplate_get_caps (srctemp),
if (gst_autoplag_caps_intersect (gst_padtemplate_get_caps (srctemp),
gst_padtemplate_get_caps (desttemp))) {
GST_DEBUG (GST_CAT_AUTOPLUG_ATTEMPT,
"factory \"%s\" can connect with factory \"%s\"\n",

View file

@ -40,6 +40,7 @@ struct _GstAutoplugNode {
};
/* helper functions */
gboolean gst_autoplag_caps_intersect (GstCaps *src, GstCaps *sink);
GstPadTemplate * gst_autoplug_can_connect_src (GstElementFactory *fac, GstCaps *src);
GstPadTemplate * gst_autoplug_can_connect_sink (GstElementFactory *fac, GstCaps *sink);
GstPadTemplate * gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest);

View file

@ -336,7 +336,7 @@ gst_spider_create_and_plug (GstSpider *spider, GstElement *src, GstElement *sink
if ((GST_PADTEMPLATE_DIRECTION (templ) == GST_PAD_SRC) && (GST_PADTEMPLATE_PRESENCE(templ) == GST_PAD_SOMETIMES))
{
GstSpiderConnectSometimes *data = g_new (GstSpiderConnectSometimes, 1);
GST_DEBUG (GST_CAT_AUTOPLUG_ATTEMPT, "adding callback to connect element %s to %s\n", GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (element));
GST_DEBUG (GST_CAT_AUTOPLUG_ATTEMPT, "adding callback to connect element %s to %s\n", GST_ELEMENT_NAME (src), GST_ELEMENT_NAME (sink));
data->spider = spider;
data->sink = sink;
data->signal_id = g_signal_connect (G_OBJECT (src), "new_pad",