gstutils: replace gst_element_factory_can_{sink,src}_caps

Add new functions to clarify how the caps are compared to the template caps of
the element factory. Improve the docs to point out the difference.

Deprecate: gst_element_factory_can_{src|sink}_caps
API: add gst_element_factory_can_{src|sink}_{any|all}_capps

https://bugzilla.gnome.org/show_bug.cgi?id=402141
This commit is contained in:
Thijs Vermeir 2010-06-23 22:00:04 +02:00 committed by Stefan Kost
parent e66ae6681a
commit dbc21e0174
3 changed files with 156 additions and 49 deletions

View file

@ -1271,18 +1271,9 @@ gst_element_state_change_return_get_name (GstStateChangeReturn state_ret)
} }
/** static gboolean
* gst_element_factory_can_src_caps: gst_element_factory_can_accept_all_caps_in_direction (GstElementFactory *
* @factory: factory to query factory, const GstCaps * caps, GstPadDirection direction)
* @caps: the caps to check
*
* Checks if the factory can source the given capability.
*
* Returns: true if it can src the capabilities
*/
gboolean
gst_element_factory_can_src_caps (GstElementFactory * factory,
const GstCaps * caps)
{ {
GList *templates; GList *templates;
@ -1294,41 +1285,7 @@ gst_element_factory_can_src_caps (GstElementFactory * factory,
while (templates) { while (templates) {
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data; GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
if (template->direction == GST_PAD_SRC) { if (template->direction == direction) {
if (gst_caps_is_always_compatible (gst_static_caps_get
(&template->static_caps), caps))
return TRUE;
}
templates = g_list_next (templates);
}
return FALSE;
}
/**
* gst_element_factory_can_sink_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can sink the given capability.
*
* Returns: true if it can sink the capabilities
*/
gboolean
gst_element_factory_can_sink_caps (GstElementFactory * factory,
const GstCaps * caps)
{
GList *templates;
g_return_val_if_fail (factory != NULL, FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->staticpadtemplates;
while (templates) {
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
if (template->direction == GST_PAD_SINK) {
if (gst_caps_is_always_compatible (caps, if (gst_caps_is_always_compatible (caps,
gst_static_caps_get (&template->static_caps))) gst_static_caps_get (&template->static_caps)))
return TRUE; return TRUE;
@ -1339,6 +1296,146 @@ gst_element_factory_can_sink_caps (GstElementFactory * factory,
return FALSE; return FALSE;
} }
static gboolean
gst_element_factory_can_accept_any_caps_in_direction (GstElementFactory *
factory, const GstCaps * caps, GstPadDirection direction)
{
GList *templates;
g_return_val_if_fail (factory != NULL, FALSE);
g_return_val_if_fail (caps != NULL, FALSE);
templates = factory->staticpadtemplates;
while (templates) {
GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;
if (template->direction == direction) {
if (gst_caps_can_intersect (caps,
gst_static_caps_get (&template->static_caps)))
return TRUE;
}
templates = g_list_next (templates);
}
return FALSE;
}
#ifndef GST_DISABLE_DEPRECATED
/**
* gst_element_factory_can_src_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can source the given capability.
*
* Returns: %TRUE if it can src the capabilities
*
* Deprecated: use gst_element_factory_can_src_all_caps() instead.
*/
gboolean
gst_element_factory_can_src_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
GST_PAD_SRC);
}
/**
* gst_element_factory_can_sink_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can sink the given capability.
*
* Returns: %TRUE if it can sink the capabilities
*
* Deprecated: use gst_element_factory_can_sink_all_caps() instead.
*/
gboolean
gst_element_factory_can_sink_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
GST_PAD_SINK);
}
#endif /* GST_DISABLE_DEPRECATED */
/**
* gst_element_factory_can_sink_all_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can sink all possible capabilities.
*
* Returns: %TRUE if the caps are fully compatible.
*
* Since: 0.10.33
*/
gboolean
gst_element_factory_can_sink_all_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
GST_PAD_SINK);
}
/**
* gst_element_factory_can_src_all_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can src all possible capabilities.
*
* Returns: %TRUE if the caps are fully compatible.
*
* Since: 0.10.33
*/
gboolean
gst_element_factory_can_src_all_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_all_caps_in_direction (factory, caps,
GST_PAD_SRC);
}
/**
* gst_element_factory_can_sink_any_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can sink any possible capability.
*
* Returns: %TRUE if the caps have a common subset.
*
* Since: 0.10.33
*/
gboolean
gst_element_factory_can_sink_any_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_any_caps_in_direction (factory, caps,
GST_PAD_SINK);
}
/**
* gst_element_factory_can_src_any_caps:
* @factory: factory to query
* @caps: the caps to check
*
* Checks if the factory can src any possible capability.
*
* Returns: %TRUE if the caps have a common subset.
*
* Since: 0.10.33
*/
gboolean
gst_element_factory_can_src_any_caps (GstElementFactory * factory,
const GstCaps * caps)
{
return gst_element_factory_can_accept_any_caps_in_direction (factory, caps,
GST_PAD_SRC);
}
/* if return val is true, *direct_child is a caller-owned ref on the direct /* if return val is true, *direct_child is a caller-owned ref on the direct
* child of ancestor that is part of object's ancestry */ * child of ancestor that is part of object's ancestry */

View file

@ -1034,8 +1034,14 @@ gboolean gst_element_seek_simple (GstElement *element,
gint64 seek_pos); gint64 seek_pos);
/* util elementfactory functions */ /* util elementfactory functions */
gboolean gst_element_factory_can_src_caps(GstElementFactory *factory, const GstCaps *caps); #ifndef GST_DISABLE_DEPRECATED
gboolean gst_element_factory_can_sink_caps(GstElementFactory *factory, const GstCaps *caps); gboolean gst_element_factory_can_src_caps (GstElementFactory *factory, const GstCaps *caps);
gboolean gst_element_factory_can_sink_caps (GstElementFactory *factory, const GstCaps *caps);
#endif /* GST_DISABLE_DEPRECATED */
gboolean gst_element_factory_can_sink_all_caps (GstElementFactory *factory, const GstCaps *caps);
gboolean gst_element_factory_can_src_all_caps (GstElementFactory *factory, const GstCaps *caps);
gboolean gst_element_factory_can_sink_any_caps (GstElementFactory *factory, const GstCaps *caps);
gboolean gst_element_factory_can_src_any_caps (GstElementFactory *factory, const GstCaps *caps);
/* util query functions */ /* util query functions */
gboolean gst_element_query_position (GstElement *element, GstFormat *format, gboolean gst_element_query_position (GstElement *element, GstFormat *format,

View file

@ -303,6 +303,10 @@ EXPORTS
gst_element_create_all_pads gst_element_create_all_pads
gst_element_factory_can_sink_caps gst_element_factory_can_sink_caps
gst_element_factory_can_src_caps gst_element_factory_can_src_caps
gst_element_factory_can_sink_all_caps
gst_element_factory_can_sink_any_caps
gst_element_factory_can_src_all_caps
gst_element_factory_can_src_any_caps
gst_element_factory_create gst_element_factory_create
gst_element_factory_find gst_element_factory_find
gst_element_factory_get_author gst_element_factory_get_author