2003-01-16 21:22:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2003-01-16 22:03:39 +00:00
|
|
|
* gsturi.c: register URI handlers
|
2003-01-16 21:22:06 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2004-05-07 02:36:28 +00:00
|
|
|
#include "gst_private.h"
|
2003-01-16 21:22:06 +00:00
|
|
|
#include "gsturi.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2003-11-24 03:21:54 +00:00
|
|
|
#include "gstregistrypool.h"
|
|
|
|
#include "gstmarshal.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_uri_handler_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_uri_handler_debug
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_uri_handler_base_init (gpointer g_class);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_uri_handler_get_type (void)
|
|
|
|
{
|
2003-01-16 22:03:39 +00:00
|
|
|
static GType urihandler_type = 0;
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-01-16 22:03:39 +00:00
|
|
|
if (!urihandler_type) {
|
|
|
|
static const GTypeInfo urihandler_info = {
|
2003-11-24 03:21:54 +00:00
|
|
|
sizeof (GstURIHandlerInterface),
|
|
|
|
gst_uri_handler_base_init,
|
2003-01-16 21:22:06 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
2003-11-24 03:21:54 +00:00
|
|
|
0,
|
|
|
|
NULL,
|
2003-01-16 21:22:06 +00:00
|
|
|
NULL
|
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
urihandler_type = g_type_register_static (G_TYPE_INTERFACE,
|
2004-03-15 19:27:17 +00:00
|
|
|
"GstURIHandler", &urihandler_info, 0);
|
2003-11-24 03:21:54 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_uri_handler_debug, "GST_URI", GST_DEBUG_BOLD,
|
2004-03-15 19:27:17 +00:00
|
|
|
"handling of URIs");
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2003-01-16 22:03:39 +00:00
|
|
|
return urihandler_type;
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
|
|
|
static void
|
2003-11-24 03:21:54 +00:00
|
|
|
gst_uri_handler_base_init (gpointer g_class)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
static gboolean initialized = FALSE;
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
if (!initialized) {
|
2004-03-04 20:06:02 +00:00
|
|
|
g_signal_new ("new-uri", GST_TYPE_URI_HANDLER, G_SIGNAL_RUN_LAST,
|
2004-03-15 19:27:17 +00:00
|
|
|
G_STRUCT_OFFSET (GstURIHandlerInterface, new_uri), NULL, NULL,
|
|
|
|
gst_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
|
2003-11-24 03:21:54 +00:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_protocol_check_internal (const gchar * uri, gchar ** endptr)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar *check = (gchar *) uri;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_assert (uri != NULL);
|
|
|
|
g_assert (endptr != NULL);
|
|
|
|
|
2004-02-02 21:08:52 +00:00
|
|
|
if (g_ascii_isalpha (*check)) {
|
2003-11-24 03:21:54 +00:00
|
|
|
check++;
|
2004-03-13 15:27:01 +00:00
|
|
|
while (g_ascii_isalnum (*check))
|
|
|
|
check++;
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*endptr = check;
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_uri_protocol_is_valid:
|
|
|
|
* @protocol: string to check
|
|
|
|
*
|
|
|
|
* Tests if the given string is a valid protocol identifier. Protocols
|
|
|
|
* must consist of alphanumeric characters and not start with a number.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the string is a valid protocol identifier
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_protocol_is_valid (const gchar * protocol)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
gchar *endptr;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (protocol != NULL, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
gst_uri_protocol_check_internal (protocol, &endptr);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return *endptr == '\0' && endptr != protocol;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 21:22:06 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_uri_is_valid:
|
2004-03-30 07:36:19 +00:00
|
|
|
* @uri: string to check
|
2003-01-16 21:22:06 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Tests if the given string is a valid URI identifier. URIs start with a valid
|
|
|
|
* protocol followed by "://" and a string identifying the location.
|
2003-01-16 21:22:06 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Returns: TRUE if the string is a valid URI
|
2003-01-16 21:22:06 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_is_valid (const gchar * uri)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar *endptr;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (uri != NULL, FALSE);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
gst_uri_protocol_check_internal (uri, &endptr);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return (*endptr == ':' && *(endptr + 1) == '/' && *(endptr + 2) == '/');
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_uri_get_protocol:
|
|
|
|
* @uri: URI to get protocol from
|
|
|
|
*
|
|
|
|
* Extracts the protocol out of a given valid URI. The returned string must be
|
|
|
|
* freed using g_free().
|
|
|
|
*
|
|
|
|
* Returns: The protocol for this URI.
|
|
|
|
*/
|
|
|
|
gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_get_protocol (const gchar * uri)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
gchar *colon;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 21:22:06 +00:00
|
|
|
g_return_val_if_fail (uri != NULL, NULL);
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
colon = strstr (uri, "://");
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return g_strndup (uri, colon - uri);
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 21:22:06 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_uri_get_location:
|
|
|
|
* @uri: URI to get the location from
|
2003-01-16 21:22:06 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Extracts the location out of a given valid URI. So the protocol and "://"
|
|
|
|
* are stripped from the URI. The returned string must be freed using
|
|
|
|
* g_free().
|
2003-01-16 21:22:06 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Returns: The location for this URI.
|
2003-01-16 21:22:06 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_get_location (const gchar * uri)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar *colon;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (uri != NULL, NULL);
|
|
|
|
g_return_val_if_fail (gst_uri_is_valid (uri), NULL);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
colon = strstr (uri, "://");
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return g_strdup (colon + 3);
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_uri_construct:
|
|
|
|
* @protocol: protocol for URI
|
|
|
|
* @location: location for URI
|
|
|
|
*
|
|
|
|
* Constructs a URI for a given valid protocol and location.
|
|
|
|
*
|
|
|
|
* Returns: a new string for this URI
|
2003-01-17 16:06:23 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_construct (const gchar * protocol, const gchar * location)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (gst_uri_protocol_is_valid (protocol), NULL);
|
|
|
|
g_return_val_if_fail (location != NULL, NULL);
|
|
|
|
|
|
|
|
return g_strdup_printf ("%s://%s", protocol, location);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GstURIType type;
|
|
|
|
gchar *protocol;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
SearchEntry;
|
2003-01-17 16:06:23 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
search_by_entry (GstPluginFeature * feature, gpointer search_entry)
|
2003-01-17 16:06:23 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar **protocols;
|
|
|
|
GstElementFactory *factory;
|
|
|
|
SearchEntry *entry = (SearchEntry *) search_entry;
|
|
|
|
|
|
|
|
if (!GST_IS_ELEMENT_FACTORY (feature))
|
2003-01-17 16:06:23 +00:00
|
|
|
return FALSE;
|
2003-11-24 03:21:54 +00:00
|
|
|
factory = GST_ELEMENT_FACTORY (feature);
|
|
|
|
|
|
|
|
if (gst_element_factory_get_uri_type (factory) != entry->type)
|
|
|
|
return FALSE;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
protocols = gst_element_factory_get_uri_protocols (factory);
|
|
|
|
/* must be set when uri type is valid */
|
|
|
|
g_assert (protocols);
|
|
|
|
while (*protocols != NULL) {
|
|
|
|
if (strcmp (*protocols, entry->protocol) == 0)
|
|
|
|
return TRUE;
|
|
|
|
protocols++;
|
2003-01-17 16:06:23 +00:00
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
static gint
|
|
|
|
sort_by_rank (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
GstPluginFeature *first = GST_PLUGIN_FEATURE (a);
|
|
|
|
GstPluginFeature *second = GST_PLUGIN_FEATURE (b);
|
2003-01-17 16:06:23 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
return gst_plugin_feature_get_rank (second) -
|
|
|
|
gst_plugin_feature_get_rank (first);
|
2003-11-24 03:21:54 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_element_make_from_uri:
|
|
|
|
* @type: wether to create a source or a sink
|
|
|
|
* @uri: URI to create element for
|
|
|
|
* @elementname: optional name of created element
|
2003-05-06 22:10:29 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Creates an element for handling the given URI.
|
|
|
|
*
|
|
|
|
* Returns: a new element or NULL if none could be created
|
2003-05-06 22:10:29 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
GstElement *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_element_make_from_uri (const GstURIType type, const gchar * uri,
|
|
|
|
const gchar * elementname)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
GList *possibilities, *walk;
|
|
|
|
SearchEntry entry;
|
|
|
|
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);
|
2004-03-13 15:27:01 +00:00
|
|
|
possibilities =
|
|
|
|
gst_registry_pool_feature_filter (search_by_entry, FALSE, &entry);
|
2003-11-24 03:21:54 +00:00
|
|
|
g_free (entry.protocol);
|
|
|
|
|
|
|
|
if (!possibilities) {
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_DEBUG ("No %s for URI '%s'", type == GST_URI_SINK ? "sink" : "source",
|
2004-03-15 19:27:17 +00:00
|
|
|
uri);
|
2003-11-24 03:21:54 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
possibilities = g_list_sort (possibilities, sort_by_rank);
|
|
|
|
walk = possibilities;
|
|
|
|
while (walk) {
|
2004-03-13 15:27:01 +00:00
|
|
|
if ((ret = gst_element_factory_create (GST_ELEMENT_FACTORY (walk->data),
|
2004-03-15 19:27:17 +00:00
|
|
|
elementname)) != NULL) {
|
2003-11-24 03:21:54 +00:00
|
|
|
GstURIHandler *handler = GST_URI_HANDLER (ret);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
if (gst_uri_handler_set_uri (handler, uri))
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2004-04-06 19:45:27 +00:00
|
|
|
gst_object_unref (GST_OBJECT (ret));
|
2003-11-24 03:21:54 +00:00
|
|
|
ret = NULL;
|
2003-04-14 18:53:03 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-24 03:21:54 +00:00
|
|
|
g_list_free (possibilities);
|
2003-05-06 22:10:29 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
GST_LOG_OBJECT (ret, "created %s for URL '%s'",
|
|
|
|
type == GST_URI_SINK ? "sink" : "source", uri);
|
2003-11-24 03:21:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 22:03:39 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_uri_handler_get_uri_type:
|
|
|
|
* @handler: Handler to query type of
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Gets the type of a URI handler
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Returns: the type of the URI handler
|
2003-01-16 22:03:39 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
guint
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_handler_get_uri_type (GstURIHandler * handler)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
GstURIHandlerInterface *iface;
|
|
|
|
guint ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), GST_URI_UNKNOWN);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
|
|
|
|
g_return_val_if_fail (iface != NULL, GST_URI_UNKNOWN);
|
|
|
|
g_return_val_if_fail (iface->get_type != NULL, GST_URI_UNKNOWN);
|
|
|
|
ret = iface->get_type ();
|
|
|
|
g_return_val_if_fail (GST_URI_TYPE_IS_VALID (ret), GST_URI_UNKNOWN);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return ret;
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 22:03:39 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_uri_handler_get_protocols:
|
|
|
|
* @handler: Handler to get protocols for
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Gets the list of supported protocols for this handler. This list may not be
|
|
|
|
* modified.
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Returns: the supported protocols
|
2003-01-16 22:03:39 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
gchar **
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_handler_get_protocols (GstURIHandler * handler)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
GstURIHandlerInterface *iface;
|
|
|
|
gchar **ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
|
|
|
|
g_return_val_if_fail (iface != NULL, NULL);
|
|
|
|
g_return_val_if_fail (iface->get_protocols != NULL, NULL);
|
|
|
|
ret = iface->get_protocols ();
|
|
|
|
g_return_val_if_fail (ret != NULL, NULL);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return ret;
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-01-16 22:03:39 +00:00
|
|
|
/**
|
2003-11-24 03:21:54 +00:00
|
|
|
* gst_uri_handler_get_uri:
|
|
|
|
* @handler: handler to query URI of
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Gets the currently handled URI of the handler or NULL, if none is set.
|
2003-01-16 22:03:39 +00:00
|
|
|
*
|
2003-11-24 03:21:54 +00:00
|
|
|
* Returns: the URI
|
2003-01-16 22:03:39 +00:00
|
|
|
*/
|
2003-11-24 03:21:54 +00:00
|
|
|
G_CONST_RETURN gchar *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_handler_get_uri (GstURIHandler * handler)
|
2003-01-16 21:22:06 +00:00
|
|
|
{
|
2003-11-24 03:21:54 +00:00
|
|
|
GstURIHandlerInterface *iface;
|
|
|
|
const gchar *ret;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), NULL);
|
|
|
|
|
|
|
|
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
|
|
|
|
g_return_val_if_fail (iface != NULL, NULL);
|
|
|
|
g_return_val_if_fail (iface->get_uri != NULL, NULL);
|
|
|
|
ret = iface->get_uri (handler);
|
|
|
|
if (ret != NULL)
|
|
|
|
g_return_val_if_fail (gst_uri_is_valid (ret), NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
return ret;
|
2003-01-16 21:22:06 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_uri_handler_set_uri:
|
|
|
|
* @handler: handler to set URI of
|
|
|
|
* @uri: URI to set
|
|
|
|
*
|
|
|
|
* Tries to set the URI of the given handler and returns TRUE if it succeeded.
|
|
|
|
*
|
|
|
|
* Returns: TRUE, if the URI was set successfully
|
|
|
|
*/
|
|
|
|
gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
GstURIHandlerInterface *iface;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE);
|
|
|
|
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
|
|
|
|
g_return_val_if_fail (iface != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (iface->set_uri != NULL, FALSE);
|
|
|
|
return iface->set_uri (handler, uri);
|
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
/**
|
|
|
|
* gst_uri_handler_new_uri:
|
|
|
|
* @handler: handler with a new URI
|
|
|
|
* @uri: new URI or NULL if it was unset
|
|
|
|
*
|
|
|
|
* Emits the new-uri event for a given handler, when that handler has a new URI.
|
|
|
|
* This function should only be called by URI handlers themselves.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_uri_handler_new_uri (GstURIHandler * handler, const gchar * uri)
|
2003-11-24 03:21:54 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_URI_HANDLER (handler));
|
2003-01-16 21:22:06 +00:00
|
|
|
|
2003-11-24 03:21:54 +00:00
|
|
|
g_signal_emit_by_name (handler, "new-uri", uri);
|
|
|
|
}
|