From 60cb9cddd4dbd6ee0bcae45f9ea27f8c40ae19b2 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sat, 30 Jul 2011 14:04:43 +0200 Subject: [PATCH] bufferpool: add method to check for an option Add a method to check if an option is supported on the bufferpool. --- gst/gstbufferpool.c | 41 ++++++++++++++++++++++++++++++++--- gst/gstbufferpool.h | 1 + win32/common/libgstreamer.def | 1 + 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/gst/gstbufferpool.c b/gst/gstbufferpool.c index d5d2d8b3dd..de6c6beaa6 100644 --- a/gst/gstbufferpool.c +++ b/gst/gstbufferpool.c @@ -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; } /** diff --git a/gst/gstbufferpool.h b/gst/gstbufferpool.h index a8cb7ede3c..115b052742 100644 --- a/gst/gstbufferpool.h +++ b/gst/gstbufferpool.h @@ -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, diff --git a/win32/common/libgstreamer.def b/win32/common/libgstreamer.def index ea9a6b104f..35ad278938 100644 --- a/win32/common/libgstreamer.def +++ b/win32/common/libgstreamer.def @@ -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