diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-01-28 00:07:14 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-01-28 00:08:16 +0000 |
commit | 2cc409861c24a27c30fdf8f554340fb09637c3f6 (patch) | |
tree | fffcccc322b26710542ec6d4de3c7652206853e1 /gst/dataurisrc | |
parent | 766c52766e1bd11b674b691f2c08be2239e2e7e9 (diff) | |
download | gstreamer-plugins-bad-2cc409861c24a27c30fdf8f554340fb09637c3f6.tar.gz |
dataurisrc: add start function so we can error out properly if no uri is set
Also save a set URI after it has been parsed successfully, so that _get_uri()
actually works.
Diffstat (limited to 'gst/dataurisrc')
-rw-r--r-- | gst/dataurisrc/gstdataurisrc.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gst/dataurisrc/gstdataurisrc.c b/gst/dataurisrc/gstdataurisrc.c index 04deed9a7..bb4b895fe 100644 --- a/gst/dataurisrc/gstdataurisrc.c +++ b/gst/dataurisrc/gstdataurisrc.c @@ -67,6 +67,7 @@ static gboolean gst_data_uri_src_is_seekable (GstBaseSrc * src); static GstFlowReturn gst_data_uri_src_create (GstBaseSrc * src, guint64 offset, guint size, GstBuffer ** buf); static gboolean gst_data_uri_src_check_get_range (GstBaseSrc * src); +static gboolean gst_data_uri_src_start (GstBaseSrc * src); static void gst_data_uri_src_handler_init (gpointer g_iface, gpointer iface_data); @@ -128,6 +129,7 @@ gst_data_uri_src_class_init (GstDataURISrcClass * klass) basesrc_class->create = GST_DEBUG_FUNCPTR (gst_data_uri_src_create); basesrc_class->check_get_range = GST_DEBUG_FUNCPTR (gst_data_uri_src_check_get_range); + basesrc_class->start = GST_DEBUG_FUNCPTR (gst_data_uri_src_start); } static void @@ -267,6 +269,31 @@ gst_data_uri_src_check_get_range (GstBaseSrc * basesrc) return TRUE; } +static gboolean +gst_data_uri_src_start (GstBaseSrc * basesrc) +{ + GstDataURISrc *src = GST_DATA_URI_SRC (basesrc); + + GST_OBJECT_LOCK (src); + + if (src->uri == NULL || *src->uri == '\0' || src->buffer == NULL) + goto no_uri; + + GST_OBJECT_UNLOCK (src); + + return TRUE; + +/* ERRORS */ +no_uri: + { + GST_OBJECT_UNLOCK (src); + GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, + ("No valid data URI specified, or the data URI could not be parsed."), + ("%s", src->uri)); + return FALSE; + } +} + static void gst_data_uri_src_handler_init (gpointer g_iface, gpointer iface_data) { @@ -308,6 +335,7 @@ gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri) gchar *mimetype = NULL; const gchar *parameters_start; const gchar *data_start; + const gchar *orig_uri = uri; GstCaps *caps; gboolean base64 = FALSE; gchar *charset = NULL; @@ -409,6 +437,9 @@ gst_data_uri_src_set_uri (GstURIHandler * handler, const gchar * uri) gst_buffer_set_caps (src->buffer, caps); gst_caps_unref (caps); + g_free (src->uri); + src->uri = g_strdup (orig_uri); + ret = TRUE; out: |