From bc13ad8a9ee8a098f37b70e283dd5e6d5b57aaab Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Wed, 25 Feb 2004 14:16:24 +0000 Subject: [PATCH] gst/gstpad.c (gst_pad_link_prepare): Re-add gst_pad_link_prepare. Please email the list with specific reasons for rev... Original commit message from CVS: 2004-02-25 Andy Wingo * gst/gstpad.c (gst_pad_link_prepare): Re-add gst_pad_link_prepare. Please email the list with specific reasons for reverting. ---------------------------------------------------------------------- --- ChangeLog | 6 ++++++ gst/gstpad.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 60 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89295fc..814e1b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-02-25 Andy Wingo + + * gst/gstpad.c (gst_pad_link_prepare): Re-add + gst_pad_link_prepare. Please email the list with specific reasons + for reverting. + 2004-02-24 Andy Wingo * gst/gstelement.c (gst_element_dispose): Protect against multiple diff --git a/gst/gstpad.c b/gst/gstpad.c index a624951..636ef42 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -1552,11 +1552,6 @@ gst_pad_can_link_filtered (GstPad *srcpad, GstPad *sinkpad, realsrc = GST_PAD_REALIZE (srcpad); realsink = GST_PAD_REALIZE (sinkpad); - g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL); - g_return_val_if_fail (GST_RPAD_PEER (realsink) == NULL, NULL); - g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, NULL); - g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, NULL); - if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { GST_CAT_INFO (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); @@ -2089,6 +2084,60 @@ gst_pad_unnegotiate (GstPad *pad) gst_pad_link_unnegotiate (link); } +/* returning NULL indicates that the arguments are invalid */ +static GstPadLink* +gst_pad_link_prepare (GstPad *srcpad, GstPad *sinkpad, + const GstCaps *filtercaps) +{ + GstRealPad *realsrc, *realsink; + GstPadLink *link; + + g_return_val_if_fail (GST_IS_PAD (srcpad), NULL); + g_return_val_if_fail (GST_IS_PAD (sinkpad), NULL); + + realsrc = GST_PAD_REALIZE (srcpad); + realsink = GST_PAD_REALIZE (sinkpad); + + if ((GST_PAD (realsrc) != srcpad) || (GST_PAD (realsink) != sinkpad)) { + GST_CAT_DEBUG (GST_CAT_PADS, "*actually* linking %s:%s and %s:%s", + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink)); + } + + g_return_val_if_fail (GST_RPAD_PEER (realsrc) == NULL, NULL); + g_return_val_if_fail (GST_RPAD_PEER (realsink) == NULL, NULL); + g_return_val_if_fail (GST_PAD_PARENT (realsrc) != NULL, NULL); + g_return_val_if_fail (GST_PAD_PARENT (realsink) != NULL, NULL); + + if (!gst_pad_check_schedulers (realsrc, realsink)) { + g_warning ("linking pads with different scheds requires " + "exactly one decoupled element (such as queue)"); + return NULL; + } + + if (GST_RPAD_DIRECTION (realsrc) == GST_RPAD_DIRECTION (realsink)) { + g_warning ("%s:%s and %s:%s are both %s pads, failed", + GST_DEBUG_PAD_NAME (realsrc), GST_DEBUG_PAD_NAME (realsink), + GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC ? "src" : "sink"); + return NULL; + } + + link = gst_pad_link_new (); + + if (GST_RPAD_DIRECTION (realsrc) == GST_PAD_SRC) { + link->srcpad = GST_PAD (realsrc); + link->sinkpad = GST_PAD (realsink); + } else { + link->srcpad = GST_PAD (realsink); + link->sinkpad = GST_PAD (realsrc); + } + + link->srccaps = gst_pad_get_caps (link->srcpad); + link->sinkcaps = gst_pad_get_caps (link->sinkpad); + if (filtercaps) link->filtercaps = gst_caps_copy (filtercaps); + + return link; +} + /** * gst_pad_try_relink_filtered: * @srcpad: the source #GstPad to relink. -- 2.7.4