bufferpool: add method to check for an option

Add a method to check if an option is supported on the bufferpool.
This commit is contained in:
Wim Taymans 2011-07-30 14:04:43 +02:00
parent 733e94ada8
commit 60cb9cddd4
3 changed files with 40 additions and 3 deletions

View file

@ -513,12 +513,47 @@ gst_buffer_pool_get_options (GstBufferPool * pool)
pclass = GST_BUFFER_POOL_GET_CLASS (pool);
if (G_LIKELY (pclass->get_options))
result = pclass->get_options (pool);
else
if (G_LIKELY (pclass->get_options)) {
if ((result = pclass->get_options (pool)) == NULL)
goto invalid_result;
} else
result = empty_option;
return result;
/* ERROR */
invalid_result:
{
g_warning ("bufferpool subclass returned NULL options");
return empty_option;
}
}
/**
* gst_buffer_pool_has_option:
* @pool: a #GstBufferPool
* @option: an option
*
* Check if the bufferpool supports @option.
*
* Returns: a NULL terminated array of strings.
*/
gboolean
gst_buffer_pool_has_option (GstBufferPool * pool, const gchar * option)
{
guint i;
const gchar **options;
g_return_val_if_fail (GST_IS_BUFFER_POOL (pool), FALSE);
g_return_val_if_fail (option != NULL, FALSE);
options = gst_buffer_pool_get_options (pool);
for (i = 0; options[i]; i++) {
if (g_str_equal (options[i], option))
return TRUE;
}
return FALSE;
}
/**

View file

@ -184,6 +184,7 @@ gboolean gst_buffer_pool_set_config (GstBufferPool *pool, GstStruct
GstStructure * gst_buffer_pool_get_config (GstBufferPool *pool);
const gchar ** gst_buffer_pool_get_options (GstBufferPool *pool);
gboolean gst_buffer_pool_has_option (GstBufferPool *pool, const gchar *option);
/* helpers for configuring the config structure */
void gst_buffer_pool_config_set (GstStructure *config, const GstCaps *caps,

View file

@ -134,6 +134,7 @@ EXPORTS
gst_buffer_pool_get_config
gst_buffer_pool_get_options
gst_buffer_pool_get_type
gst_buffer_pool_has_option
gst_buffer_pool_new
gst_buffer_pool_release_buffer
gst_buffer_pool_set_active