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 ;)
This commit is contained in:
Ronald S. Bultje 2002-09-10 08:52:58 +00:00
parent 1cbfc22ca4
commit 5b5274daf2
9 changed files with 28 additions and 30 deletions

View file

@ -163,10 +163,7 @@ gst_identity_connect (GstPad *pad, GstCaps *caps)
otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad); otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
if (GST_CAPS_IS_FIXED (caps)) if (GST_CAPS_IS_FIXED (caps))
if (gst_pad_try_set_caps (otherpad, caps)) return gst_pad_try_set_caps (otherpad, caps);
return GST_PAD_CONNECT_OK;
else
return GST_PAD_CONNECT_REFUSED;
else else
return GST_PAD_CONNECT_DELAYED; return GST_PAD_CONNECT_DELAYED;
} }

View file

@ -123,6 +123,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GList *pads; GList *pads;
GstPadConnectReturn set_retval;
tee = GST_TEE (gst_pad_get_parent (pad)); 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)) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
continue; continue;
if (!(gst_pad_try_set_caps (outpad, caps))) { if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) {
return GST_PAD_CONNECT_REFUSED; return set_retval;
} }
} }
return GST_PAD_CONNECT_OK; return GST_PAD_CONNECT_OK;

View file

@ -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. * 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) gst_pad_try_set_caps (GstPad *pad, GstCaps *caps)
{ {
GstRealPad *peer, *realpad; GstRealPad *peer, *realpad;
GstPadConnectReturn set_retval;
realpad = GST_PAD_REALIZE (pad); realpad = GST_PAD_REALIZE (pad);
peer = GST_RPAD_PEER (realpad); 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", g_warning ("trying to set non fixed caps on pad %s:%s, not allowed",
GST_DEBUG_PAD_NAME (realpad)); GST_DEBUG_PAD_NAME (realpad));
gst_caps_debug (caps, "unfixed caps"); 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 we have a peer try to set the caps, notifying the peerpad
* if it has a connect function */ * 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_INFO (GST_CAT_CAPS, "tried to set caps on peerpad %s:%s but couldn't, return value %d",
GST_DEBUG_PAD_NAME (peer)); GST_DEBUG_PAD_NAME (peer), set_retval);
return FALSE; return set_retval;
} }
/* then try to set our own caps, we don't need to be notified */ /* 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_INFO (GST_CAT_CAPS, "tried to set own caps on pad %s:%s but couldn't, return value %d",
GST_DEBUG_PAD_NAME (realpad)); GST_DEBUG_PAD_NAME (realpad), set_retval);
return FALSE; return set_retval;
} }
GST_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s", GST_INFO (GST_CAT_CAPS, "succeeded setting caps %p on pad %s:%s, return value %d",
caps, GST_DEBUG_PAD_NAME (realpad)); caps, GST_DEBUG_PAD_NAME (realpad), set_retval);
g_assert (GST_PAD_CAPS (pad)); g_assert (GST_PAD_CAPS (pad));
return TRUE; return set_retval;
} }
/* this is a caps negotiation convenience routine, it: /* this is a caps negotiation convenience routine, it:

View file

@ -430,7 +430,7 @@ GstPad* gst_pad_get_peer (GstPad *pad);
/* capsnego functions */ /* capsnego functions */
GstCaps* gst_pad_get_caps (GstPad *pad); GstCaps* gst_pad_get_caps (GstPad *pad);
GstCaps* gst_pad_get_pad_template_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); gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps); void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);

View file

@ -188,7 +188,7 @@ gst_type_find_chain (GstPad *pad, GstBuffer *buf)
gst_caps_get_name (caps)); gst_caps_get_name (caps));
typefind->caps = 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"); g_warning ("typefind: found type but peer didn't accept it");
} }

View file

@ -163,10 +163,7 @@ gst_identity_connect (GstPad *pad, GstCaps *caps)
otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad); otherpad = (pad == identity->srcpad ? identity->sinkpad : identity->srcpad);
if (GST_CAPS_IS_FIXED (caps)) if (GST_CAPS_IS_FIXED (caps))
if (gst_pad_try_set_caps (otherpad, caps)) return gst_pad_try_set_caps (otherpad, caps);
return GST_PAD_CONNECT_OK;
else
return GST_PAD_CONNECT_REFUSED;
else else
return GST_PAD_CONNECT_DELAYED; return GST_PAD_CONNECT_DELAYED;
} }

View file

@ -123,6 +123,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
{ {
GstTee *tee; GstTee *tee;
GList *pads; GList *pads;
GstPadConnectReturn set_retval;
tee = GST_TEE (gst_pad_get_parent (pad)); 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)) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
continue; continue;
if (!(gst_pad_try_set_caps (outpad, caps))) { if ((set_retval = gst_pad_try_set_caps (outpad, caps)) <= 0) {
return GST_PAD_CONNECT_REFUSED; return set_retval;
} }
} }
return GST_PAD_CONNECT_OK; return GST_PAD_CONNECT_OK;

View file

@ -109,7 +109,7 @@ main (int argc, char *argv[])
g_assert (src_caps != NULL); g_assert (src_caps != NULL);
g_print ("Setting caps on fakesrc's src pad\n"); g_print ("Setting caps on fakesrc's src pad\n");
pad = gst_element_get_pad (src, "src"); 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"); g_print ("Could not set caps !\n");
} }

View file

@ -109,7 +109,7 @@ main (int argc, char *argv[])
g_assert (src_caps != NULL); g_assert (src_caps != NULL);
g_print ("Setting caps on fakesrc's src pad\n"); g_print ("Setting caps on fakesrc's src pad\n");
pad = gst_element_get_pad (src, "src"); 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"); g_print ("Could not set caps !\n");
} }