code cleanup and API change (gst_caps_check_compatibility -> gst_caps_is_always_compatible)

Original commit message from CVS:
code cleanup and API change
(gst_caps_check_compatibility -> gst_caps_is_always_compatible)
This commit is contained in:
Thomas Vander Stichele 2002-10-02 07:51:54 +00:00
parent 8ad5175c2c
commit 731b554fd8
7 changed files with 40 additions and 28 deletions

View file

@ -122,7 +122,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_pad_template_get_caps (srctemp),
if (gst_caps_is_always_compatible (gst_pad_template_get_caps (srctemp),
gst_pad_template_get_caps (desttemp))) {
GST_DEBUG (GST_CAT_AUTOPLUG_ATTEMPT,
"factory \"%s\" can connect with factory \"%s\"\n", GST_OBJECT_NAME (src),
@ -158,7 +158,7 @@ gst_autoplug_pads_autoplug_func (GstElement *src, GstPad *pad, GstElement *sink)
if (gst_pad_get_direction(sinkpad) == GST_PAD_SINK &&
!GST_PAD_IS_CONNECTED(sinkpad))
{
if (gst_caps_check_compatibility (gst_pad_get_caps(pad), gst_pad_get_caps(sinkpad))) {
if (gst_caps_is_always_compatible (gst_pad_get_caps(pad), gst_pad_get_caps(sinkpad))) {
gst_pad_connect(pad, sinkpad);
GST_DEBUG (0,"gstpipeline: autoconnect pad \"%s\" in element %s <-> ", GST_PAD_NAME (pad),
GST_ELEMENT_NAME(src));
@ -200,7 +200,7 @@ autoplug_dynamic_pad (GstElement *element, GstPad *pad, gpointer data)
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
pads = g_list_next (pads);
if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (templ), info->endcap)) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (templ), info->endcap)) {
gchar *name;
name = g_strdup_printf ("src_%02d", info->i);
@ -258,7 +258,7 @@ gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
gboolean res;
if (IS_CAPS (src) && IS_CAPS (dest)) {
res = gst_caps_check_compatibility ((GstCaps *)src, (GstCaps *)dest);
res = gst_caps_is_always_compatible ((GstCaps *)src, (GstCaps *)dest);
}
else if (IS_CAPS (src)) {
res = gst_element_factory_can_sink_caps ((GstElementFactory *)dest, (GstCaps *)src);
@ -399,7 +399,7 @@ gst_static_autoplug_to_caps (GstAutoplug *autoplug, GstCaps *srccaps, GstCaps *s
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
if (gst_caps_check_compatibility (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
if (gst_caps_is_always_compatible (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
gst_element_add_ghost_pad (result, pad, "sink");
break;
}
@ -464,7 +464,7 @@ differ:
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
pads = g_list_next (pads);
if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (templ), endcap)) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (templ), endcap)) {
gchar *name;
name = g_strdup_printf ("src_%02d", i);

View file

@ -119,11 +119,11 @@ gst_autoplug_match_caps (GstElementFactory *factory, GstPadDirection direction,
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == direction && direction == GST_PAD_SRC) {
if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (template), caps))
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
return template;
}
else if (template->direction == direction && direction == GST_PAD_SINK) {
if (gst_caps_check_compatibility (caps, GST_PAD_TEMPLATE_CAPS (template)))
if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
return template;
}
templates = g_list_next (templates);
@ -152,7 +152,7 @@ gst_autoplug_can_match (GstElementFactory *src, GstElementFactory *dest)
desttemps = g_list_next (desttemps);
if (desttemp->direction == GST_PAD_SINK && desttemp->presence != GST_PAD_REQUEST) {
if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (srctemp), GST_PAD_TEMPLATE_CAPS (desttemp))) {
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (srctemp), GST_PAD_TEMPLATE_CAPS (desttemp))) {
GST_DEBUG (GST_CAT_AUTOPLUG_ATTEMPT,
"factory \"%s\" can connect with factory \"%s\"",
GST_OBJECT_NAME (src), GST_OBJECT_NAME (dest));
@ -256,7 +256,7 @@ gst_autoplug_caps_find_cost (gpointer src, gpointer dest, gpointer data)
gboolean res;
if (IS_CAPS (src) && IS_CAPS (dest)) {
res = gst_caps_check_compatibility ((GstCaps *)src, (GstCaps *)dest);
res = gst_caps_is_always_compatible ((GstCaps *)src, (GstCaps *)dest);
/*GST_INFO (GST_CAT_AUTOPLUG_ATTEMPT,"caps %d to caps %d %d", ((GstCaps *)src)->id, ((GstCaps *)dest)->id, res); */
}
else if (IS_CAPS (src)) {
@ -414,7 +414,7 @@ next:
GstPad *pad = GST_PAD (pads->data);
GstPadTemplate *templ = GST_PAD_PAD_TEMPLATE (pad);
if (gst_caps_check_compatibility (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
if (gst_caps_is_always_compatible (srccaps, GST_PAD_TEMPLATE_CAPS (templ))) {
gst_element_add_ghost_pad (result, pad, "sink");
break;
}

View file

@ -613,30 +613,36 @@ gst_caps_check_compatibility_func (GstCaps *fromcaps, GstCaps *tocaps)
}
/**
* gst_caps_check_compatibility:
* @fromcaps: a capabilty
* @tocaps: a capabilty
* gst_caps_is_always_compatible:
* @fromcaps: a #GstCaps capability to check compatibility of.
* @tocaps: the #GstCaps capabilty to check compatibility with.
*
* Checks whether two capabilities are compatible.
* Checks if a connection is always possible from fromcaps to tocaps, for all
* possible capabilities.
*
* Returns: TRUE if compatible, FALSE otherwise
* Returns: TRUE if compatible under all circumstances, FALSE otherwise.
*/
gboolean
gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps)
gst_caps_is_always_compatible (GstCaps *fromcaps, GstCaps *tocaps)
{
if (fromcaps == NULL) {
if (tocaps == NULL) {
GST_DEBUG (GST_CAT_CAPS,"no caps");
/* if both are NULL, they can always connect. Think filesrc ! filesink */
GST_DEBUG (GST_CAT_CAPS, "both caps NULL, compatible");
return TRUE;
}
else {
GST_DEBUG (GST_CAT_CAPS,"no source but destination caps");
/* if source caps are NULL, it could be sending anything, so the
* destination can't know if it can accept this. Think filesrc ! mad */
GST_DEBUG (GST_CAT_CAPS, "source caps NULL, not guaranteed compatible");
return FALSE;
}
}
else {
if (tocaps == NULL) {
GST_DEBUG (GST_CAT_CAPS,"source caps and no destination caps");
/* if the dest caps are NULL, the element can accept anything, always,
* so they're compatible by definition. Think mad ! filesink */
GST_DEBUG (GST_CAT_CAPS,"destination caps NULL");
return TRUE;
}
}

View file

@ -127,7 +127,7 @@ GstCaps* gst_caps_chain (GstCaps *caps, ...);
GstCaps* gst_caps_append (GstCaps *caps, GstCaps *capstoadd);
GstCaps* gst_caps_prepend (GstCaps *caps, GstCaps *capstoadd);
gboolean gst_caps_check_compatibility (GstCaps *fromcaps, GstCaps *tocaps);
gboolean gst_caps_is_always_compatible (GstCaps *fromcaps, GstCaps *tocaps);
GstCaps* gst_caps_intersect (GstCaps *caps1, GstCaps *caps2);
GstCaps* gst_caps_normalize (GstCaps *caps);

View file

@ -1331,13 +1331,13 @@ gst_element_get_compatible_pad_template (GstElement *element,
if (padtempl->direction == GST_PAD_SRC &&
compattempl->direction == GST_PAD_SINK) {
GST_DEBUG (GST_CAT_CAPS, "compatible direction: found src pad template");
comp = gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (padtempl),
comp = gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (padtempl),
GST_PAD_TEMPLATE_CAPS (compattempl));
GST_DEBUG(GST_CAT_CAPS, "caps are %scompatible", (comp ? "" : "not "));
} else if (padtempl->direction == GST_PAD_SINK &&
compattempl->direction == GST_PAD_SRC) {
GST_DEBUG (GST_CAT_CAPS, "compatible direction: found sink pad template");
comp = gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (compattempl),
comp = gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (compattempl),
GST_PAD_TEMPLATE_CAPS (padtempl));
GST_DEBUG (GST_CAT_CAPS, "caps are %scompatible", (comp ? "" : "not "));
}
@ -1507,10 +1507,13 @@ gst_element_connect_filtered (GstElement *src, GstElement *dest,
destpads = gst_element_get_pad_list (dest);
if (srcpads || destpads) {
GST_DEBUG (GST_CAT_ELEMENT_PADS, "looping through src and dest pads");
/* loop through the existing pads in the source, trying to find a
* compatible destination pad */
while (srcpads) {
srcpad = (GstPad *) GST_PAD_REALIZE (srcpads->data);
GST_DEBUG (GST_CAT_ELEMENT_PADS, "trying src pad %s:%s",
GST_DEBUG_PAD_NAME (srcpad));
if ((GST_RPAD_DIRECTION (srcpad) == GST_PAD_SRC) &&
(GST_PAD_PEER (srcpad) == NULL)) {
destpad = gst_element_get_compatible_pad_filtered (dest, srcpad,
@ -1527,6 +1530,8 @@ gst_element_connect_filtered (GstElement *src, GstElement *dest,
/* loop through the existing pads in the destination */
while (destpads) {
destpad = (GstPad *) GST_PAD_REALIZE (destpads->data);
GST_DEBUG (GST_CAT_ELEMENT_PADS, "trying dest pad %s:%s",
GST_DEBUG_PAD_NAME (destpad));
if ((GST_RPAD_DIRECTION (destpad) == GST_PAD_SINK) &&
(GST_PAD_PEER (destpad) == NULL)) {
srcpad = gst_element_get_compatible_pad_filtered (src, destpad,
@ -1554,7 +1559,7 @@ gst_element_connect_filtered (GstElement *src, GstElement *dest,
desttempl = (GstPadTemplate*) desttempls->data;
if (desttempl->presence == GST_PAD_REQUEST &&
desttempl->direction != srctempl->direction) {
if (gst_caps_check_compatibility (gst_pad_template_get_caps (srctempl),
if (gst_caps_is_always_compatible (gst_pad_template_get_caps (srctempl),
gst_pad_template_get_caps (desttempl))) {
srcpad = gst_element_get_request_pad (src,
srctempl->name_template);

View file

@ -347,7 +347,7 @@ gst_element_factory_can_src_caps (GstElementFactory *factory,
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == GST_PAD_SRC) {
if (gst_caps_check_compatibility (GST_PAD_TEMPLATE_CAPS (template), caps))
if (gst_caps_is_always_compatible (GST_PAD_TEMPLATE_CAPS (template), caps))
return TRUE;
}
templates = g_list_next (templates);
@ -380,7 +380,7 @@ gst_element_factory_can_sink_caps (GstElementFactory *factory,
GstPadTemplate *template = (GstPadTemplate *)templates->data;
if (template->direction == GST_PAD_SINK) {
if (gst_caps_check_compatibility (caps, GST_PAD_TEMPLATE_CAPS (template)))
if (gst_caps_is_always_compatible (caps, GST_PAD_TEMPLATE_CAPS (template)))
return TRUE;
}
templates = g_list_next (templates);

View file

@ -1464,6 +1464,7 @@ gst_pad_try_reconnect_filtered_func (GstRealPad *srcpad, GstRealPad *sinkpad,
/* first take the intersection of the pad caps */
intersection = gst_caps_intersect (srccaps, sinkcaps);
gst_caps_debug (intersection, "caps of intersection");
/* if we have no intersection but one of the caps was not NULL.. */
if (!intersection && (srccaps || sinkcaps)) {
@ -1774,8 +1775,8 @@ gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad)
g_return_val_if_fail (GST_IS_PAD (sinkpad), FALSE);
if (GST_PAD_CAPS (srcpad) && GST_PAD_CAPS (sinkpad)) {
if (!gst_caps_check_compatibility (GST_PAD_CAPS (srcpad),
GST_PAD_CAPS (sinkpad))) {
if (!gst_caps_is_always_compatible (GST_PAD_CAPS (srcpad),
GST_PAD_CAPS (sinkpad))) {
return FALSE;
}
else {