From 003aaeaef3640b224be807edcc37d2904b03fb4d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 27 Apr 2007 08:30:59 +0000 Subject: [PATCH] API: Add gst_uri_protocol_is_supported(), which checks if an sink or src that supports a given URI protocol exists. Original commit message from CVS: * docs/gst/gstreamer-sections.txt: * gst/gsturi.c: (get_element_factories_from_uri_protocol), (gst_uri_protocol_is_supported), (gst_element_make_from_uri): * gst/gsturi.h: API: Add gst_uri_protocol_is_supported(), which checks if an sink or src that supports a given URI protocol exists. --- ChangeLog | 9 +++++++ docs/gst/gstreamer-sections.txt | 1 + gst/gsturi.c | 56 +++++++++++++++++++++++++++++++++++------ gst/gsturi.h | 2 ++ 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9aad6ed..4a8b8f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2007-04-27 Sebastian Dröge + * docs/gst/gstreamer-sections.txt: + * gst/gsturi.c: (get_element_factories_from_uri_protocol), + (gst_uri_protocol_is_supported), (gst_element_make_from_uri): + * gst/gsturi.h: + API: Add gst_uri_protocol_is_supported(), which checks if an sink + or src that supports a given URI protocol exists. + +2007-04-27 Sebastian Dröge + * plugins/elements/gstfilesink.c: (gst_file_sink_uri_set_uri): * plugins/elements/gstfilesrc.c: (gst_file_src_uri_set_uri): Set the location to NULL if "file://" is set as URI. Otherwise diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 096bb9a..5ce8dff 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2070,6 +2070,7 @@ GstURIHandlerInterface GstURIType GST_URI_TYPE_IS_VALID gst_uri_protocol_is_valid +gst_uri_protocol_is_supported gst_uri_is_valid gst_uri_has_protocol gst_uri_get_protocol diff --git a/gst/gsturi.c b/gst/gsturi.c index 0f3dd58..85e7cac 100644 --- a/gst/gsturi.c +++ b/gst/gsturi.c @@ -458,7 +458,7 @@ gst_uri_construct (const gchar * protocol, const gchar * location) typedef struct { GstURIType type; - gchar *protocol; + const gchar *protocol; } SearchEntry; @@ -502,6 +502,50 @@ sort_by_rank (gconstpointer a, gconstpointer b) gst_plugin_feature_get_rank (first); } +static GList * +get_element_factories_from_uri_protocol (const GstURIType type, + const gchar * protocol) +{ + GList *possibilities; + SearchEntry entry; + + g_return_val_if_fail (protocol, NULL); + + entry.type = type; + entry.protocol = protocol; + possibilities = gst_registry_feature_filter (gst_registry_get_default (), + search_by_entry, FALSE, &entry); + + return possibilities; +} + +/** + * gst_uri_protocol_is_supported: + * @type: Wether to check for a source or a sink + * @protocol: Protocol that should be checkd for. + * + * Checks if an element exists that supports the given URI protocol. + * + * Returns: TRUE + * + * Since: 0.10.13 +*/ +gboolean +gst_uri_protocol_is_supported (const GstURIType type, const gchar * protocol) +{ + GList *possibilities; + + g_return_val_if_fail (protocol, FALSE); + + possibilities = get_element_factories_from_uri_protocol (type, protocol); + + if (possibilities) { + g_list_free (possibilities); + return TRUE; + } else + return FALSE; +} + /** * gst_element_make_from_uri: * @type: Wether to create a source or a sink @@ -517,17 +561,15 @@ gst_element_make_from_uri (const GstURIType type, const gchar * uri, const gchar * elementname) { GList *possibilities, *walk; - SearchEntry entry; + gchar *protocol; GstElement *ret = NULL; g_return_val_if_fail (GST_URI_TYPE_IS_VALID (type), NULL); g_return_val_if_fail (gst_uri_is_valid (uri), NULL); - entry.type = type; - entry.protocol = gst_uri_get_protocol (uri); - possibilities = gst_registry_feature_filter (gst_registry_get_default (), - search_by_entry, FALSE, &entry); - g_free (entry.protocol); + protocol = gst_uri_get_protocol (uri); + possibilities = get_element_factories_from_uri_protocol (type, protocol); + g_free (protocol); if (!possibilities) { GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source", diff --git a/gst/gsturi.h b/gst/gsturi.h index 82bae5d..a3256a5 100644 --- a/gst/gsturi.h +++ b/gst/gsturi.h @@ -113,6 +113,8 @@ struct _GstURIHandlerInterface { /* general URI functions */ gboolean gst_uri_protocol_is_valid (const gchar * protocol); +gboolean gst_uri_protocol_is_supported (const GstURIType type, + const gchar *protocol); gboolean gst_uri_is_valid (const gchar * uri); gchar * gst_uri_get_protocol (const gchar * uri); gboolean gst_uri_has_protocol (const gchar * uri, -- 2.7.4