From 5b5274daf2940038e71fe5ff6e1844243509f3ec Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 10 Sep 2002 08:52:58 +0000 Subject: [PATCH] This changes an important part of the plugin API, gst_pad_try_set_caps() no longer returns a boolean, it now returns ... Original commit message from CVS: This changes an important part of the plugin API, gst_pad_try_set_caps() no longer returns a boolean, it now returns a GstPadConnectReturn, which makes much more sense than a boolean. All plugins have also been changed, so don't worry ;) --- gst/elements/gstidentity.c | 5 +---- gst/elements/gsttee.c | 5 +++-- gst/gstpad.c | 30 ++++++++++++++++-------------- gst/gstpad.h | 2 +- gst/gsttypefind.c | 2 +- plugins/elements/gstidentity.c | 5 +---- plugins/elements/gsttee.c | 5 +++-- tests/old/testsuite/elements/tee.c | 2 +- testsuite/elements/tee.c | 2 +- 9 files changed, 28 insertions(+), 30 deletions(-) diff --git a/gst/elements/gstidentity.c b/gst/elements/gstidentity.c index be94816..61ba4eb 100644 --- a/gst/elements/gstidentity.c +++ b/gst/elements/gstidentity.c @@ -163,10 +163,7 @@ gst_identity_connect (GstPad *pad, GstCaps *caps) otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad); if (GST_CAPS_IS_FIXED (caps)) - if (gst_pad_try_set_caps (otherpad, caps)) - return GST_PAD_CONNECT_OK; - else - return GST_PAD_CONNECT_REFUSED; + return gst_pad_try_set_caps (otherpad, caps); else return GST_PAD_CONNECT_DELAYED; } diff --git a/gst/elements/gsttee.c b/gst/elements/gsttee.c index d886206..6a40d40 100644 --- a/gst/elements/gsttee.c +++ b/gst/elements/gsttee.c @@ -123,6 +123,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) { GstTee *tee; GList *pads; + GstPadConnectReturn set_retval; tee = GST_TEE (gst_pad_get_parent (pad)); @@ -140,8 +141,8 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad)) continue; - if (!(gst_pad_try_set_caps (outpad, caps))) { - return GST_PAD_CONNECT_REFUSED; + if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) { + return set_retval; } } return GST_PAD_CONNECT_OK; diff --git a/gst/gstpad.c b/gst/gstpad.c index bc770d0..935de4d 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1337,12 +1337,14 @@ gst_pad_try_set_caps_func (GstRealPad *pad, GstCaps *caps, gboolean notify) * * Tries to set the caps on the given pad. * - * Returns: TRUE if the caps could be set, FALSE otherwise. + * Returns: A GstPadConnectReturn value indicating whether the caps + * could be set. */ -gboolean +GstPadConnectReturn gst_pad_try_set_caps (GstPad *pad, GstCaps *caps) { GstRealPad *peer, *realpad; + GstPadConnectReturn set_retval; realpad = GST_PAD_REALIZE (pad); peer = GST_RPAD_PEER (realpad); @@ -1360,30 +1362,30 @@ gst_pad_try_set_caps (GstPad *pad, GstCaps *caps) g_warning ("trying to set non fixed caps on pad %s:%s, not allowed", GST_DEBUG_PAD_NAME (realpad)); gst_caps_debug (caps, "unfixed caps"); - return FALSE; + return GST_PAD_CONNECT_DELAYED; } /* if we have a peer try to set the caps, notifying the peerpad * if it has a connect function */ - if (peer && (gst_pad_try_set_caps_func (peer, caps, TRUE) != GST_PAD_CONNECT_OK)) + if (peer && ((set_retval = gst_pad_try_set_caps_func (peer, caps, TRUE)) <= 0)) { - GST_INFO (GST_CAT_CAPS, "tried to set caps on peerpad %s:%s but couldn't", - GST_DEBUG_PAD_NAME (peer)); - return FALSE; + GST_INFO (GST_CAT_CAPS, "tried to set caps on peerpad %s:%s but couldn't, return value %d", + GST_DEBUG_PAD_NAME (peer), set_retval); + return set_retval; } /* then try to set our own caps, we don't need to be notified */ - if (gst_pad_try_set_caps_func (realpad, caps, FALSE) != GST_PAD_CONNECT_OK) + if ((set_retval = gst_pad_try_set_caps_func (realpad, caps, FALSE)) <= 0) { - GST_INFO (GST_CAT_CAPS, "tried to set own caps on pad %s:%s but couldn't", - GST_DEBUG_PAD_NAME (realpad)); - return FALSE; + GST_INFO (GST_CAT_CAPS, "tried to set own caps on pad %s:%s but couldn't, return value %d", + GST_DEBUG_PAD_NAME (realpad), set_retval); + return set_retval; } - GST_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s", - caps, GST_DEBUG_PAD_NAME (realpad)); + GST_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s, return value %d", + caps, GST_DEBUG_PAD_NAME (realpad), set_retval); g_assert (GST_PAD_CAPS (pad)); - return TRUE; + return set_retval; } /* this is a caps negotiation convenience routine, it: diff --git a/gst/gstpad.h b/gst/gstpad.h index c549298..db8bbd5 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -430,7 +430,7 @@ GstPad* gst_pad_get_peer (GstPad *pad); /* capsnego functions */ GstCaps* gst_pad_get_caps (GstPad *pad); GstCaps* gst_pad_get_pad_template_caps (GstPad *pad); -gboolean gst_pad_try_set_caps (GstPad *pad, GstCaps *caps); +GstPadConnectReturn gst_pad_try_set_caps (GstPad *pad, GstCaps *caps); gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad); void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 032e723..a113cdf 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -188,7 +188,7 @@ gst_type_find_chain (GstPad *pad, GstBuffer *buf) gst_caps_get_name (caps)); typefind->caps = caps; - if (!gst_pad_try_set_caps (pad, caps)) { + if (gst_pad_try_set_caps (pad, caps) <= 0) { g_warning ("typefind: found type but peer didn't accept it"); } diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c index be94816..61ba4eb 100644 --- a/plugins/elements/gstidentity.c +++ b/plugins/elements/gstidentity.c @@ -163,10 +163,7 @@ gst_identity_connect (GstPad *pad, GstCaps *caps) otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad); if (GST_CAPS_IS_FIXED (caps)) - if (gst_pad_try_set_caps (otherpad, caps)) - return GST_PAD_CONNECT_OK; - else - return GST_PAD_CONNECT_REFUSED; + return gst_pad_try_set_caps (otherpad, caps); else return GST_PAD_CONNECT_DELAYED; } diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index d886206..6a40d40 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -123,6 +123,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) { GstTee *tee; GList *pads; + GstPadConnectReturn set_retval; tee = GST_TEE (gst_pad_get_parent (pad)); @@ -140,8 +141,8 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad)) continue; - if (!(gst_pad_try_set_caps (outpad, caps))) { - return GST_PAD_CONNECT_REFUSED; + if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) { + return set_retval; } } return GST_PAD_CONNECT_OK; diff --git a/tests/old/testsuite/elements/tee.c b/tests/old/testsuite/elements/tee.c index d9f2b33..eb08dc8 100644 --- a/tests/old/testsuite/elements/tee.c +++ b/tests/old/testsuite/elements/tee.c @@ -109,7 +109,7 @@ main (int argc, char *argv[]) g_assert (src_caps != NULL); g_print ("Setting caps on fakesrc's src pad\n"); pad = gst_element_get_pad (src, "src"); - if (! (gst_pad_try_set_caps (pad, src_caps))) + if ((gst_pad_try_set_caps (pad, src_caps)) <= 0) { g_print ("Could not set caps !\n"); } diff --git a/testsuite/elements/tee.c b/testsuite/elements/tee.c index d9f2b33..eb08dc8 100644 --- a/testsuite/elements/tee.c +++ b/testsuite/elements/tee.c @@ -109,7 +109,7 @@ main (int argc, char *argv[]) g_assert (src_caps != NULL); g_print ("Setting caps on fakesrc's src pad\n"); pad = gst_element_get_pad (src, "src"); - if (! (gst_pad_try_set_caps (pad, src_caps))) + if ((gst_pad_try_set_caps (pad, src_caps)) <= 0) { g_print ("Could not set caps !\n"); } -- 2.7.4