allows bindings to properly use GstIterator and prevents complex
return value ownership issues.
+* GstURIHandler
+ gst_uri_handler_get_uri() and the get_uri vfunc now return a copy of
+ the URI string
+
+ gst_uri_handler_set_uri() and the set_uri vfunc now take an additional
+ GError argument so the handler can notify the caller why it didn't
+ accept a particular URI.
+
+ gst_uri_handler_set_uri() now checks if the protocol of the URI passed
+ is one of the protocols advertised by the uri handler, so set_uri vfunc
+ implementations no longer need to check that as well.
+
* GstTagList
is now an opaque object instead of being typedefed to a GstStructure. Cast
to GstStructure or use gst_structure_* API on it at your own peril (it may
g_type_class_ref (gst_task_state_get_type ());
g_type_class_ref (gst_alloc_trace_flags_get_type ());
g_type_class_ref (gst_type_find_probability_get_type ());
+ g_type_class_ref (gst_uri_error_get_type ());
g_type_class_ref (gst_uri_type_get_type ());
g_type_class_ref (gst_parse_error_get_type ());
g_type_class_ref (gst_parse_flags_get_type ());
g_type_class_unref (g_type_class_peek (gst_type_find_probability_get_type
()));
g_type_class_unref (g_type_class_peek (gst_uri_type_get_type ()));
+ g_type_class_unref (g_type_class_peek (gst_uri_error_get_type ()));
g_type_class_unref (g_type_class_peek (gst_parse_error_get_type ()));
g_type_class_unref (g_type_class_peek (gst_param_spec_fraction_get_type ()));
g_type_class_unref (g_type_class_peek (gst_progress_type_get_type ()));
#include "gstmarshal.h"
#include "gstregistry.h"
+#include "gst-i18n-lib.h"
+
#include <string.h>
GST_DEBUG_CATEGORY_STATIC (gst_uri_handler_debug);
return urihandler_type;
}
+GQuark
+gst_uri_error_quark (void)
+{
+ return g_quark_from_static_string ("gst-uri-error-quark");
+}
+
static const guchar acceptable[96] = { /* X0 X1 X2 X3 X4 X5 X6 X7 X8 X9 XA XB XC XD XE XF */
0x00, 0x3F, 0x20, 0x20, 0x20, 0x00, 0x2C, 0x3F, 0x3F, 0x3F, 0x3F, 0x22, 0x20, 0x3F, 0x3F, 0x1C, /* 2X !"#$%&'()*+,-./ */
0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x38, 0x20, 0x20, 0x2C, 0x20, 0x2C, /* 3X 0123456789:;<=>? */
elementname)) != NULL) {
GstURIHandler *handler = GST_URI_HANDLER (ret);
- if (gst_uri_handler_set_uri (handler, uri))
+ if (gst_uri_handler_set_uri (handler, uri, NULL))
break;
gst_object_unref (ret);
ret = NULL;
* gst_uri_handler_set_uri:
* @handler: A #GstURIHandler
* @uri: URI to set
+ * @error: (allow-none): address where to store a #GError in case of
+ * an error, or NULL
*
* Tries to set the URI of the given handler.
*
* Returns: TRUE if the URI was set successfully, else FALSE.
*/
gboolean
-gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstURIHandlerInterface *iface;
gboolean ret;
g_return_val_if_fail (GST_IS_URI_HANDLER (handler), FALSE);
g_return_val_if_fail (gst_uri_is_valid (uri), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
iface = GST_URI_HANDLER_GET_INTERFACE (handler);
g_return_val_if_fail (iface != NULL, FALSE);
protocol = gst_uri_get_protocol (uri);
+ if (iface->get_protocols) {
+ gchar **p, **protocols;
+ gboolean found_protocol = FALSE;
+
+ protocols = iface->get_protocols (G_OBJECT_TYPE (handler));
+ if (protocols != NULL) {
+ for (p = protocols; *p != NULL; ++p) {
+ if (g_ascii_strcasecmp (protocol, *p) == 0) {
+ found_protocol = TRUE;
+ break;
+ }
+ }
+
+ if (!found_protocol) {
+ g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_PROTOCOL,
+ _("URI scheme '%s' not supported"), protocol);
+ g_free (protocol);
+ return FALSE;
+ }
+ }
+ }
+
colon = strstr (uri, ":");
location = g_strdup (colon);
new_uri = g_strdup_printf ("%s%s", protocol, location);
- ret = iface->set_uri (handler, uri);
+ ret = iface->set_uri (handler, uri, error);
g_free (new_uri);
g_free (location);
G_BEGIN_DECLS
+GQuark gst_uri_error_quark (void);
+
+/**
+ * GST_URI_ERROR:
+ *
+ * Get access to the error quark of the uri subsystem.
+ */
+#define GST_URI_ERROR gst_uri_error_quark ()
+
+/**
+ * GstURIError:
+ * @GST_URI_ERROR_BAD_PROTOCOL: The protocol is not supported
+ * @GST_URI_ERROR_BAD_URI: There was a problem with the URI
+ * @GST_URI_ERROR_BAD_STATE: Could not set or change the URI because the
+ * URI handler was in a state where that is not possible or not permitted
+ * @GST_URI_ERROR_BAD_REFERENCE: There was a problem with the entity that
+ * the URI references
+ *
+ * Different URI-related errors that can occur.
+ */
+typedef enum
+{
+ GST_URI_ERROR_BAD_PROTOCOL,
+ GST_URI_ERROR_BAD_URI,
+ GST_URI_ERROR_BAD_STATE,
+ GST_URI_ERROR_BAD_REFERENCE
+} GstURIError;
+
/**
* GstURIType:
* @GST_URI_UNKNOWN : The URI direction is unknown
/* using the interface */
gchar * (* get_uri) (GstURIHandler * handler);
gboolean (* set_uri) (GstURIHandler * handler,
- const gchar * uri);
+ const gchar * uri,
+ GError ** error);
};
/* general URI functions */
gchar ** gst_uri_handler_get_protocols (GstURIHandler * handler);
gchar * gst_uri_handler_get_uri (GstURIHandler * handler);
gboolean gst_uri_handler_set_uri (GstURIHandler * handler,
- const gchar * uri);
+ const gchar * uri,
+ GError ** error);
G_END_DECLS