return protocols;
}
-static const gchar *
+static gchar *
gst_gio_uri_handler_get_uri (GstURIHandler * handler)
{
GstElement *element = GST_ELEMENT (handler);
- const gchar *uri;
+ gchar *uri;
g_return_val_if_fail (GST_IS_ELEMENT (element), NULL);
}
static gboolean
-gst_gio_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_gio_uri_handler_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstElement *element = GST_ELEMENT (handler);
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
if (GST_STATE (element) == GST_STATE_PLAYING ||
- GST_STATE (element) == GST_STATE_PAUSED)
+ GST_STATE (element) == GST_STATE_PAUSED) {
+ g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
+ "Changing the 'location' property while the element is running is "
+ "not supported");
return FALSE;
+ }
g_object_set (G_OBJECT (element), "location", uri, NULL);
-
return TRUE;
}
return TRUE;
case GST_QUERY_URI:
if (GST_IS_URI_HANDLER (sink)) {
- const gchar *uri;
+ gchar *uri;
uri = gst_uri_handler_get_uri (GST_URI_HANDLER (sink));
gst_query_set_uri (query, uri);
+ g_free (uri);
return TRUE;
}
return FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_URI:
if (GST_IS_URI_HANDLER (src)) {
- const gchar *uri = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
+ gchar *uri = gst_uri_handler_get_uri (GST_URI_HANDLER (src));
gst_query_set_uri (query, uri);
+ g_free (uri);
ret = TRUE;
}
break;
return protocols;
}
-static const gchar *
+static gchar *
gst_app_sink_uri_get_uri (GstURIHandler * handler)
{
- return "appsink";
+ return g_strdup ("appsink");
}
static gboolean
-gst_app_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_app_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
- gchar *protocol;
- gboolean ret;
-
- protocol = gst_uri_get_protocol (uri);
- ret = !strcmp (protocol, "appsink");
- g_free (protocol);
-
- return ret;
+ /* GstURIHandler checks the protocol for us */
+ return TRUE;
}
static void
return protocols;
}
-static const gchar *
+static gchar *
gst_app_src_uri_get_uri (GstURIHandler * handler)
{
- return "appsrc";
+ return g_strdup ("appsrc");
}
static gboolean
-gst_app_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_app_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
- gchar *protocol;
- gboolean ret;
-
- protocol = gst_uri_get_protocol (uri);
- ret = !strcmp (protocol, "appsrc");
- g_free (protocol);
-
- return ret;
+ /* GstURIHandler checks the protocol for us */
+ return TRUE;
}
static void
return protocols;
}
-static const gchar *
+static gchar *
gst_audio_cd_src_uri_get_uri (GstURIHandler * handler)
{
GstAudioCdSrc *src = GST_AUDIO_CD_SRC (handler);
GST_OBJECT_LOCK (src);
+ /* FIXME: can we get rid of all that here and just return a copy of the
+ * existing URI perhaps? */
g_free (src->uri);
if (GST_OBJECT_FLAG_IS_SET (GST_BASE_SRC (src), GST_BASE_SRC_STARTED)) {
GST_OBJECT_UNLOCK (src);
- return src->uri;
+ return g_strdup (src->uri);
}
/* Note: gst_element_make_from_uri() might call us with just 'cdda://' as
/* We accept URIs of the format cdda://(device#track)|(track) */
static gboolean
-gst_audio_cd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_audio_cd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+ GError ** error)
{
GstAudioCdSrc *src = GST_AUDIO_CD_SRC (handler);
- gchar *protocol;
const gchar *location;
gchar *track_number;
GST_OBJECT_LOCK (src);
- protocol = gst_uri_get_protocol (uri);
- if (!protocol || g_ascii_strcasecmp (protocol, "cdda") != 0) {
- g_free (protocol);
- goto failed;
- }
- g_free (protocol);
-
location = uri + 7;
track_number = g_strrstr (location, "#");
src->uri_track = 0;
{
GST_OBJECT_UNLOCK (src);
GST_DEBUG_OBJECT (src, "cannot handle URI '%s'", uri);
+ g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
+ "Could not handle CDDA URI");
return FALSE;
}
}
gint set_track = 0;
foosrc = gst_element_factory_make ("cdfoosrc", "cdfoosrc");
- fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc), uri) == TRUE,
+ fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc), uri, NULL),
"couldn't set uri %s", uri);
g_object_get (foosrc, "device", &set_device, "track", &set_track, NULL);
fail_unless (set_device != NULL);
/* wrong protocol */
foosrc = gst_element_factory_make ("cdfoosrc", "cdfoosrc");
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "x://") == FALSE);
+ "x://", NULL) == FALSE);
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "cddaq://") == FALSE);
+ "cddaq://", NULL) == FALSE);
/* cdda://track */
test_uri_parse ("cdda://", "/dev/cdrom", 1);
test_uri_parse ("cdda://2", "/dev/cdrom", 2);
test_uri_parse ("cdda://47", "/dev/cdrom", 47);
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "cdda://-1") == FALSE);
+ "cdda://-1", NULL) == FALSE);
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "cdda://what") == FALSE);
+ "cdda://what", NULL) == FALSE);
/* cdda://device#track */
test_uri_parse ("cdda:///dev/hdb#1", "/dev/hdb", 1);
test_uri_parse ("cdda://anything#8", "anything", 8);
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "cdda:///dev/hdb#nonsense") == FALSE);
+ "cdda:///dev/hdb#nonsense", NULL) == FALSE);
fail_unless (gst_uri_handler_set_uri (GST_URI_HANDLER (foosrc),
- "cdda:///dev/hdb#-2") == FALSE);
+ "cdda:///dev/hdb#-2", NULL) == FALSE);
/* cdda://track#device (device should be ignored - FIXME 0.11) */
test_uri_parse ("cdda://8#/dev/hdb", "/dev/cdrom", 8);