mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Add functions useful default pad_link and fixate functions.
Original commit message from CVS: Add functions useful default pad_link and fixate functions.
This commit is contained in:
parent
1933a78c8e
commit
8f8aaf83f4
3 changed files with 95 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2003-12-31 David Schleef <ds@schleef.org>
|
||||
|
||||
* gst/gstpad.c: (gst_pad_proxy_pad_link), (gst_pad_proxy_fixate):
|
||||
* gst/gstpad.h: Add functions that are useful as default pad
|
||||
link and fixate functions for elements.
|
||||
|
||||
2003-12-30 David Schleef <ds@schleef.org>
|
||||
|
||||
* gst/gstpad.c: (gst_pad_link_try):
|
||||
|
|
85
gst/gstpad.c
85
gst/gstpad.c
|
@ -2013,6 +2013,91 @@ gst_pad_proxy_getcaps (GstPad *pad)
|
|||
return caps;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_proxy_pad_link:
|
||||
* @pad: a #GstPad to proxy.
|
||||
*
|
||||
* Calls gst_pad_try_set_caps() for every other pad belonging to the
|
||||
* same element as @pad. If gst_pad_try_set_caps() fails on any pad,
|
||||
* the proxy link fails.
|
||||
*
|
||||
* Returns: GST_PAD_LINK_OK if sucessful
|
||||
*/
|
||||
GstPadLinkReturn
|
||||
gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps)
|
||||
{
|
||||
GstElement *element;
|
||||
const GList *pads;
|
||||
GstPadLinkReturn ret;
|
||||
|
||||
GST_DEBUG ("proxying pad link for %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
element = gst_pad_get_parent (pad);
|
||||
|
||||
pads = gst_element_get_pad_list (element);
|
||||
|
||||
while (pads) {
|
||||
GstPad *otherpad = GST_PAD (pads->data);
|
||||
|
||||
if (otherpad != pad) {
|
||||
ret = gst_pad_try_set_caps (otherpad, caps);
|
||||
if (GST_PAD_LINK_FAILED (ret)) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
pads = g_list_next (pads);
|
||||
}
|
||||
|
||||
return GST_PAD_LINK_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_proxy_fixate:
|
||||
* @pad: a #GstPad to proxy.
|
||||
*
|
||||
* Implements a default fixate function based on the caps set on the other
|
||||
* pads in the element. This function should only be used if every pad
|
||||
* has the same pad template caps.
|
||||
*
|
||||
* Returns: a fixated caps, or NULL if caps cannot be fixed
|
||||
*/
|
||||
GstCaps *
|
||||
gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps, gpointer unused)
|
||||
{
|
||||
GstElement *element;
|
||||
const GList *pads;
|
||||
const GstCaps *othercaps;
|
||||
|
||||
GST_DEBUG ("proxying fixate for %s:%s\n", GST_DEBUG_PAD_NAME (pad));
|
||||
|
||||
element = gst_pad_get_parent (pad);
|
||||
|
||||
pads = gst_element_get_pad_list (element);
|
||||
|
||||
while (pads) {
|
||||
GstPad *otherpad = GST_PAD (pads->data);
|
||||
|
||||
/* FIXME check that each pad has the same pad template caps */
|
||||
|
||||
if (otherpad != pad) {
|
||||
othercaps = gst_pad_get_negotiated_caps (otherpad);
|
||||
|
||||
if (othercaps) {
|
||||
GstCaps *icaps;
|
||||
icaps = gst_caps_intersect (othercaps, caps);
|
||||
if (!gst_caps_is_empty (icaps)) {
|
||||
return icaps;
|
||||
} else {
|
||||
gst_caps_free (icaps);
|
||||
}
|
||||
}
|
||||
}
|
||||
pads = g_list_next (pads);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_pad_proxy_link:
|
||||
* @pad: a #GstPad to proxy to.
|
||||
|
|
|
@ -411,7 +411,11 @@ gboolean gst_pad_check_compatibility (GstPad *srcpad, GstPad *sinkpad);
|
|||
void gst_pad_set_getcaps_function (GstPad *pad, GstPadGetCapsFunction getcaps);
|
||||
void gst_pad_set_fixate_function (GstPad *pad, GstPadFixateFunction fixate);
|
||||
GstCaps * gst_pad_proxy_getcaps (GstPad *pad);
|
||||
GstPadLinkReturn gst_pad_proxy_pad_link (GstPad *pad, const GstCaps *caps);
|
||||
GstCaps * gst_pad_proxy_fixate (GstPad *pad, const GstCaps *caps, gpointer unused);
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
GstPadLinkReturn gst_pad_proxy_link (GstPad *pad, const GstCaps *caps);
|
||||
#endif
|
||||
gboolean gst_pad_relink_filtered (GstPad *srcpad, GstPad *sinkpad, const GstCaps *filtercaps);
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
gboolean gst_pad_perform_negotiate (GstPad *srcpad, GstPad *sinkpad);
|
||||
|
|
Loading…
Reference in a new issue