From 7ec0610594a0d73cd82a0a96fbacd0d18a66e7b0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 5 Feb 2002 20:56:11 +0000 Subject: [PATCH] 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 --- gst/autoplug/gstsearchfuncs.c | 35 ++++++++++++++++++++++++++++++++--- gst/autoplug/gstsearchfuncs.h | 1 + gst/autoplug/gstspider.c | 2 +- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gst/autoplug/gstsearchfuncs.c b/gst/autoplug/gstsearchfuncs.c index 936c0dcbf2..42d496d4d8 100644 --- a/gst/autoplug/gstsearchfuncs.c +++ b/gst/autoplug/gstsearchfuncs.c @@ -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", diff --git a/gst/autoplug/gstsearchfuncs.h b/gst/autoplug/gstsearchfuncs.h index e7e0970d57..37f507c617 100644 --- a/gst/autoplug/gstsearchfuncs.h +++ b/gst/autoplug/gstsearchfuncs.h @@ -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); diff --git a/gst/autoplug/gstspider.c b/gst/autoplug/gstspider.c index 3b4c811e1d..9e748778c8 100644 --- a/gst/autoplug/gstspider.c +++ b/gst/autoplug/gstspider.c @@ -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",