From: Benjamin Otte Date: Mon, 22 Dec 2003 18:06:22 +0000 (+0000) Subject: gst/autoplug/: Fix autoplugging in spider element, so it works with new caps. X-Git-Tag: BRANCH-RELEASE-0_7_4-ROOT~242 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d136495dd960a2f3834b935d082208bda4d464d5;p=platform%2Fupstream%2Fgstreamer.git gst/autoplug/: Fix autoplugging in spider element, so it works with new caps. Original commit message from CVS: 2003-12-22 Benjamin Otte * gst/autoplug/gstsearchfuncs.c: (gst_autoplug_caps_intersect): * gst/autoplug/gstspideridentity.c: (gst_spider_identity_link), (gst_spider_identity_getcaps), (gst_spider_identity_change_state), (gst_spider_identity_sink_loop_type_finding): * gst/autoplug/gstspideridentity.h: Fix autoplugging in spider element, so it works with new caps. This was mainly caused by identifying empty caps incorrectly. --- diff --git a/ChangeLog b/ChangeLog index 6012d69..ddbe9d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-12-22 Benjamin Otte + + * gst/autoplug/gstsearchfuncs.c: (gst_autoplug_caps_intersect): + * gst/autoplug/gstspideridentity.c: (gst_spider_identity_link), + (gst_spider_identity_getcaps), (gst_spider_identity_change_state), + (gst_spider_identity_sink_loop_type_finding): + * gst/autoplug/gstspideridentity.h: + Fix autoplugging in spider element, so it works with new caps. + This was mainly caused by identifying empty caps incorrectly. + 2003-12-22 David Schleef * gststructure.c, gstvalue.c, gstvalue.h: Add diff --git a/gst/autoplug/gstsearchfuncs.c b/gst/autoplug/gstsearchfuncs.c index 7e41e30..832cb34 100644 --- a/gst/autoplug/gstsearchfuncs.c +++ b/gst/autoplug/gstsearchfuncs.c @@ -28,10 +28,8 @@ #include "gstsearchfuncs.h" /* FIXME: "evil hack" alarm, we need a better way to get a category in here */ -#ifndef GST_DISABLE_GST_DEBUG -extern GstDebugCategory *GST_CAT_AUTOPLUG_ATTEMPT; +GST_DEBUG_CATEGORY_EXTERN (GST_CAT_AUTOPLUG_ATTEMPT); #define GST_CAT_DEFAULT GST_CAT_AUTOPLUG_ATTEMPT -#endif /* function that really misses in GLib * though the GLib version should take a function as argument... @@ -62,16 +60,14 @@ gst_autoplug_caps_intersect (const GstCaps *src, const GstCaps *sink) { GstCaps *caps; - /* if there are no caps, we can link */ - if ((src == NULL) && (sink == NULL)) - return TRUE; - /* get an intersection */ caps = gst_caps_intersect (src, sink); /* if the caps can't link, there is no intersection */ - if (caps == NULL) + if (gst_caps_is_empty (caps)) { + gst_caps_free (caps); return FALSE; + } /* hurrah, we can link, now remove the intersection */ gst_caps_free (caps); diff --git a/gst/autoplug/gstspideridentity.c b/gst/autoplug/gstspideridentity.c index c8cc6bc..cb4b5de 100644 --- a/gst/autoplug/gstspideridentity.c +++ b/gst/autoplug/gstspideridentity.c @@ -232,30 +232,40 @@ gst_spider_identity_link (GstPad *pad, const GstCaps *caps) else otherpad = spider_identity->src; - if (otherpad != NULL) - return gst_pad_proxy_link (otherpad, caps); - - return GST_PAD_LINK_OK; + g_return_val_if_fail (otherpad != NULL, GST_PAD_LINK_REFUSED); + if (GST_PAD_PEER (otherpad) == NULL) + return GST_PAD_LINK_DELAYED; + + return gst_pad_try_set_caps (otherpad, gst_caps_copy (caps)); } static GstCaps* gst_spider_identity_getcaps (GstPad *pad) { - GstSpiderIdentity *spider_identity = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); + GstSpiderIdentity *ident = GST_SPIDER_IDENTITY (gst_pad_get_parent (pad)); GstPad *otherpad; - GstPad *peer; - if (pad == spider_identity->src) - otherpad = spider_identity->sink; + if (pad == ident->src) + otherpad = ident->sink; else - otherpad = spider_identity->src; + otherpad = ident->src; if (otherpad != NULL) { - peer = GST_PAD_PEER (otherpad); - - if (peer) - return gst_pad_get_caps (peer); + GstPad *peer = GST_PAD_PEER (otherpad); + + if (peer) { + GstCaps *ret = gst_pad_get_caps (peer); + if (ident->caps) { + GstCaps *ret2 = gst_caps_intersect (ident->caps, ret); + gst_caps_free (ret); + ret = ret2; + } + return ret; + } } + if (ident->caps) + return gst_caps_copy (ident->caps); + return gst_caps_new_any (); } @@ -318,6 +328,9 @@ gst_spider_identity_change_state (GstElement *element) g_return_val_if_fail (GST_IS_SPIDER_IDENTITY (ident), GST_STATE_FAILURE); switch (GST_STATE_TRANSITION (element)) { + case GST_STATE_PAUSED_TO_READY: + gst_caps_replace (&ident->caps, NULL); + break; case GST_STATE_PAUSED_TO_PLAYING: /* autoplugger check */ spider = GST_SPIDER (GST_ELEMENT_PARENT (ident)); @@ -327,13 +340,16 @@ gst_spider_identity_change_state (GstElement *element) /* start typefinding or plugging */ if ((GST_RPAD_PEER (ident->sink) != NULL) && (GST_RPAD_PEER (ident->src) == NULL)) { - if (gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)) == NULL) + GstCaps *caps = gst_pad_get_caps ((GstPad *) GST_PAD_PEER (ident->sink)); + if (gst_caps_is_any (caps) || gst_caps_is_empty (caps)) { gst_spider_identity_start_type_finding (ident); + gst_caps_free (caps); break; } else { gst_spider_identity_plug (ident); } + gst_caps_free (caps); } /* autoplug on src */ if ((GST_RPAD_PEER (ident->src) != NULL) && (GST_RPAD_PEER (ident->sink) == NULL)) @@ -461,8 +477,11 @@ gst_spider_identity_sink_loop_type_finding (GstSpiderIdentity *ident) find.buffer = GST_BUFFER (data); /* maybe there are already valid caps now? */ find.caps = gst_pad_get_caps (ident->sink); - if (find.caps != NULL) { + if (! gst_caps_is_empty (find.caps) && !gst_caps_is_any (find.caps)) { goto plug; + } else { + gst_caps_free (find.caps); + find.caps = NULL; } /* now do the actual typefinding with the supplied buffer */ @@ -499,9 +518,13 @@ end: plug: GST_INFO ("typefind function found caps"); + ident->caps = find.caps; g_assert (gst_pad_try_set_caps (ident->src, find.caps) > 0); - gst_caps_debug (find.caps, "spider starting caps"); - gst_caps_free (find.caps); + { + gchar *str = gst_caps_to_string (find.caps); + GST_LOG_OBJECT (ident, "spider starting caps: %s", str); + g_free (str); + } if (type_list) g_list_free (type_list); diff --git a/gst/autoplug/gstspideridentity.h b/gst/autoplug/gstspideridentity.h index 4731553..1e09aba 100644 --- a/gst/autoplug/gstspideridentity.h +++ b/gst/autoplug/gstspideridentity.h @@ -54,7 +54,6 @@ struct _GstSpiderIdentity { /* Caps from typefinding */ GstCaps *caps; - }; struct _GstSpiderIdentityClass {