2 * Copyright (C) 2007-2008 Wouter Cloetens <wouter@mind.be>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more
16 * SECTION:element-souphttpsrc
18 * This plugin reads data from a remote location specified by a URI.
19 * Supported protocols are 'http', 'https'.
21 * An HTTP proxy must be specified by its URL.
22 * If the "http_proxy" environment variable is set, its value is used.
23 * If built with libsoup's GNOME integration features, the GNOME proxy
24 * configuration will be used, or failing that, proxy autodetection.
25 * The #GstSoupHTTPSrc:proxy property can be used to override the default.
27 * In case the #GstSoupHTTPSrc:iradio-mode property is set and the location is
28 * an HTTP resource, souphttpsrc will send special Icecast HTTP headers to the
29 * server to request additional Icecast meta-information.
30 * If the server is not an Icecast server, it will behave as if the
31 * #GstSoupHTTPSrc:iradio-mode property were not set. If it is, souphttpsrc will
32 * output data with a media type of application/x-icy, in which case you will
33 * need to use the #ICYDemux element as follow-up element to extract the Icecast
34 * metadata and to determine the underlying media type.
37 * <title>Example launch line</title>
39 * gst-launch-1.0 -v souphttpsrc location=https://some.server.org/index.html
40 * ! filesink location=/home/joe/server.html
41 * ]| The above pipeline reads a web page from a server using the HTTPS protocol
42 * and writes it to a local file.
44 * gst-launch-1.0 -v souphttpsrc user-agent="FooPlayer 0.99 beta"
45 * automatic-redirect=false proxy=http://proxy.intranet.local:8080
46 * location=http://music.foobar.com/demo.mp3 ! mad ! audioconvert
47 * ! audioresample ! alsasink
48 * ]| The above pipeline will read and decode and play an mp3 file from a
49 * web server using the HTTP protocol. If the server sends redirects,
50 * the request fails instead of following the redirect. The specified
51 * HTTP proxy server is used. The User-Agent HTTP request header
52 * is set to a custom string instead of "GStreamer souphttpsrc."
54 * gst-launch-1.0 -v souphttpsrc location=http://10.11.12.13/mjpeg
55 * do-timestamp=true ! multipartdemux
56 * ! image/jpeg,width=640,height=480 ! matroskamux
57 * ! filesink location=mjpeg.mkv
58 * ]| The above pipeline reads a motion JPEG stream from an IP camera
59 * using the HTTP protocol, encoded as mime/multipart image/jpeg
60 * parts, and writes a Matroska motion JPEG file. The width and
61 * height properties are set in the caps to provide the Matroska
62 * multiplexer with the information to set this in the header.
63 * Timestamps are set on the buffers as they arrive from the camera.
64 * These are used by the mime/multipart demultiplexer to emit timestamps
65 * on the JPEG-encoded video frame buffers. This allows the Matroska
66 * multiplexer to timestamp the frames in the resulting file.
76 #include <stdlib.h> /* atoi() */
78 #include <gst/gstelement.h>
79 #include <gst/gst-i18n-plugin.h>
80 #include <libsoup/soup.h>
81 #include "gstsouphttpsrc.h"
83 #include <gst/tag/tag.h>
85 GST_DEBUG_CATEGORY_STATIC (souphttpsrc_debug);
86 #define GST_CAT_DEFAULT souphttpsrc_debug
88 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
99 PROP_AUTOMATIC_REDIRECT,
110 #define DEFAULT_USER_AGENT "GStreamer souphttpsrc "
112 static void gst_soup_http_src_uri_handler_init (gpointer g_iface,
113 gpointer iface_data);
114 static void gst_soup_http_src_finalize (GObject * gobject);
116 static void gst_soup_http_src_set_property (GObject * object, guint prop_id,
117 const GValue * value, GParamSpec * pspec);
118 static void gst_soup_http_src_get_property (GObject * object, guint prop_id,
119 GValue * value, GParamSpec * pspec);
121 static GstFlowReturn gst_soup_http_src_create (GstPushSrc * psrc,
122 GstBuffer ** outbuf);
123 static gboolean gst_soup_http_src_start (GstBaseSrc * bsrc);
124 static gboolean gst_soup_http_src_stop (GstBaseSrc * bsrc);
125 static gboolean gst_soup_http_src_get_size (GstBaseSrc * bsrc, guint64 * size);
126 static gboolean gst_soup_http_src_is_seekable (GstBaseSrc * bsrc);
127 static gboolean gst_soup_http_src_do_seek (GstBaseSrc * bsrc,
128 GstSegment * segment);
129 static gboolean gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query);
130 static gboolean gst_soup_http_src_unlock (GstBaseSrc * bsrc);
131 static gboolean gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc);
132 static gboolean gst_soup_http_src_set_location (GstSoupHTTPSrc * src,
133 const gchar * uri, GError ** error);
134 static gboolean gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src,
136 static char *gst_soup_http_src_unicodify (const char *str);
137 static gboolean gst_soup_http_src_build_message (GstSoupHTTPSrc * src);
138 static void gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src);
139 static void gst_soup_http_src_queue_message (GstSoupHTTPSrc * src);
140 static gboolean gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src,
142 static void gst_soup_http_src_session_unpause_message (GstSoupHTTPSrc * src);
143 static void gst_soup_http_src_session_pause_message (GstSoupHTTPSrc * src);
144 static void gst_soup_http_src_session_close (GstSoupHTTPSrc * src);
145 static void gst_soup_http_src_parse_status (SoupMessage * msg,
146 GstSoupHTTPSrc * src);
147 static void gst_soup_http_src_chunk_free (gpointer gstbuf);
148 static SoupBuffer *gst_soup_http_src_chunk_allocator (SoupMessage * msg,
149 gsize max_len, gpointer user_data);
150 static void gst_soup_http_src_got_chunk_cb (SoupMessage * msg,
151 SoupBuffer * chunk, GstSoupHTTPSrc * src);
152 static void gst_soup_http_src_response_cb (SoupSession * session,
153 SoupMessage * msg, GstSoupHTTPSrc * src);
154 static void gst_soup_http_src_got_headers_cb (SoupMessage * msg,
155 GstSoupHTTPSrc * src);
156 static void gst_soup_http_src_got_body_cb (SoupMessage * msg,
157 GstSoupHTTPSrc * src);
158 static void gst_soup_http_src_finished_cb (SoupMessage * msg,
159 GstSoupHTTPSrc * src);
160 static void gst_soup_http_src_authenticate_cb (SoupSession * session,
161 SoupMessage * msg, SoupAuth * auth, gboolean retrying,
162 GstSoupHTTPSrc * src);
164 #define gst_soup_http_src_parent_class parent_class
165 G_DEFINE_TYPE_WITH_CODE (GstSoupHTTPSrc, gst_soup_http_src, GST_TYPE_PUSH_SRC,
166 G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
167 gst_soup_http_src_uri_handler_init));
170 gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
172 GObjectClass *gobject_class;
173 GstElementClass *gstelement_class;
174 GstBaseSrcClass *gstbasesrc_class;
175 GstPushSrcClass *gstpushsrc_class;
177 gobject_class = (GObjectClass *) klass;
178 gstelement_class = (GstElementClass *) klass;
179 gstbasesrc_class = (GstBaseSrcClass *) klass;
180 gstpushsrc_class = (GstPushSrcClass *) klass;
182 gobject_class->set_property = gst_soup_http_src_set_property;
183 gobject_class->get_property = gst_soup_http_src_get_property;
184 gobject_class->finalize = gst_soup_http_src_finalize;
186 g_object_class_install_property (gobject_class,
188 g_param_spec_string ("location", "Location",
189 "Location to read from", "",
190 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
191 g_object_class_install_property (gobject_class,
193 g_param_spec_string ("user-agent", "User-Agent",
194 "Value of the User-Agent HTTP request header field",
195 DEFAULT_USER_AGENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
196 g_object_class_install_property (gobject_class,
197 PROP_AUTOMATIC_REDIRECT,
198 g_param_spec_boolean ("automatic-redirect", "automatic-redirect",
199 "Automatically follow HTTP redirects (HTTP Status Code 3xx)",
200 TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
201 g_object_class_install_property (gobject_class,
203 g_param_spec_string ("proxy", "Proxy",
204 "HTTP proxy server URI", "",
205 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
206 g_object_class_install_property (gobject_class,
208 g_param_spec_string ("user-id", "user-id",
209 "HTTP location URI user id for authentication", "",
210 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
211 g_object_class_install_property (gobject_class, PROP_USER_PW,
212 g_param_spec_string ("user-pw", "user-pw",
213 "HTTP location URI user password for authentication", "",
214 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
215 g_object_class_install_property (gobject_class, PROP_PROXY_ID,
216 g_param_spec_string ("proxy-id", "proxy-id",
217 "HTTP proxy URI user id for authentication", "",
218 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
219 g_object_class_install_property (gobject_class, PROP_PROXY_PW,
220 g_param_spec_string ("proxy-pw", "proxy-pw",
221 "HTTP proxy URI user password for authentication", "",
222 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
223 g_object_class_install_property (gobject_class, PROP_COOKIES,
224 g_param_spec_boxed ("cookies", "Cookies", "HTTP request cookies",
225 G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
226 g_object_class_install_property (gobject_class, PROP_IS_LIVE,
227 g_param_spec_boolean ("is-live", "is-live", "Act like a live source",
228 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
229 g_object_class_install_property (gobject_class, PROP_TIMEOUT,
230 g_param_spec_uint ("timeout", "timeout",
231 "Value in seconds to timeout a blocking I/O (0 = No timeout).", 0,
232 3600, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
233 g_object_class_install_property (gobject_class, PROP_EXTRA_HEADERS,
234 g_param_spec_boxed ("extra-headers", "Extra Headers",
235 "Extra headers to append to the HTTP request",
236 GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
238 gst_element_class_add_pad_template (gstelement_class,
239 gst_static_pad_template_get (&srctemplate));
241 gst_element_class_set_static_metadata (gstelement_class, "HTTP client source",
243 "Receive data as a client over the network via HTTP using SOUP",
244 "Wouter Cloetens <wouter@mind.be>");
246 gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_soup_http_src_start);
247 gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_soup_http_src_stop);
248 gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_soup_http_src_unlock);
249 gstbasesrc_class->unlock_stop =
250 GST_DEBUG_FUNCPTR (gst_soup_http_src_unlock_stop);
251 gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_soup_http_src_get_size);
252 gstbasesrc_class->is_seekable =
253 GST_DEBUG_FUNCPTR (gst_soup_http_src_is_seekable);
254 gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_soup_http_src_do_seek);
255 gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_soup_http_src_query);
257 gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_soup_http_src_create);
259 GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0,
264 gst_soup_http_src_reset (GstSoupHTTPSrc * src)
266 src->interrupted = FALSE;
268 src->have_size = FALSE;
269 src->seekable = FALSE;
270 src->read_position = 0;
271 src->request_position = 0;
272 src->content_size = 0;
274 gst_caps_replace (&src->src_caps, NULL);
275 g_free (src->iradio_name);
276 src->iradio_name = NULL;
277 g_free (src->iradio_genre);
278 src->iradio_genre = NULL;
279 g_free (src->iradio_url);
280 src->iradio_url = NULL;
284 gst_soup_http_src_init (GstSoupHTTPSrc * src)
288 src->location = NULL;
289 src->automatic_redirect = TRUE;
290 src->user_agent = g_strdup (DEFAULT_USER_AGENT);
293 src->proxy_id = NULL;
294 src->proxy_pw = NULL;
300 proxy = g_getenv ("http_proxy");
301 if (proxy && !gst_soup_http_src_set_proxy (src, proxy)) {
302 GST_WARNING_OBJECT (src,
303 "The proxy in the http_proxy env var (\"%s\") cannot be parsed.",
307 gst_soup_http_src_reset (src);
311 gst_soup_http_src_finalize (GObject * gobject)
313 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (gobject);
315 GST_DEBUG_OBJECT (src, "finalize");
317 g_free (src->location);
318 g_free (src->user_agent);
319 if (src->proxy != NULL) {
320 soup_uri_free (src->proxy);
322 g_free (src->user_id);
323 g_free (src->user_pw);
324 g_free (src->proxy_id);
325 g_free (src->proxy_pw);
326 g_strfreev (src->cookies);
328 G_OBJECT_CLASS (parent_class)->finalize (gobject);
332 gst_soup_http_src_set_property (GObject * object, guint prop_id,
333 const GValue * value, GParamSpec * pspec)
335 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object);
340 const gchar *location;
342 location = g_value_get_string (value);
344 if (location == NULL) {
345 GST_WARNING ("location property cannot be NULL");
348 if (!gst_soup_http_src_set_location (src, location, NULL)) {
349 GST_WARNING ("badly formatted location");
354 case PROP_USER_AGENT:
356 g_free (src->user_agent);
357 src->user_agent = g_value_dup_string (value);
359 case PROP_AUTOMATIC_REDIRECT:
360 src->automatic_redirect = g_value_get_boolean (value);
366 proxy = g_value_get_string (value);
369 GST_WARNING ("proxy property cannot be NULL");
372 if (!gst_soup_http_src_set_proxy (src, proxy)) {
373 GST_WARNING ("badly formatted proxy URI");
379 g_strfreev (src->cookies);
380 src->cookies = g_strdupv (g_value_get_boxed (value));
383 gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
387 g_free (src->user_id);
388 src->user_id = g_value_dup_string (value);
392 g_free (src->user_pw);
393 src->user_pw = g_value_dup_string (value);
397 g_free (src->proxy_id);
398 src->proxy_id = g_value_dup_string (value);
402 g_free (src->proxy_pw);
403 src->proxy_pw = g_value_dup_string (value);
406 src->timeout = g_value_get_uint (value);
408 case PROP_EXTRA_HEADERS:{
409 const GstStructure *s = gst_value_get_structure (value);
411 if (src->extra_headers)
412 gst_structure_free (src->extra_headers);
414 src->extra_headers = s ? gst_structure_copy (s) : NULL;
418 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
426 gst_soup_http_src_get_property (GObject * object, guint prop_id,
427 GValue * value, GParamSpec * pspec)
429 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object);
433 g_value_set_string (value, src->location);
435 case PROP_USER_AGENT:
436 g_value_set_string (value, src->user_agent);
438 case PROP_AUTOMATIC_REDIRECT:
439 g_value_set_boolean (value, src->automatic_redirect);
442 if (src->proxy == NULL)
443 g_value_set_static_string (value, "");
445 char *proxy = soup_uri_to_string (src->proxy, FALSE);
447 g_value_set_string (value, proxy);
452 g_value_set_boxed (value, g_strdupv (src->cookies));
455 g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
458 g_value_set_string (value, src->user_id);
461 g_value_set_string (value, src->user_pw);
464 g_value_set_string (value, src->proxy_id);
467 g_value_set_string (value, src->proxy_pw);
470 g_value_set_uint (value, src->timeout);
472 case PROP_EXTRA_HEADERS:
473 gst_value_set_structure (value, src->extra_headers);
476 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
482 gst_soup_http_src_unicodify (const gchar * str)
484 const gchar *env_vars[] = { "GST_ICY_TAG_ENCODING",
485 "GST_TAG_ENCODING", NULL
488 return gst_tag_freeform_string_to_utf8 (str, -1, env_vars);
492 gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src)
494 if (src->msg != NULL) {
495 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED;
496 soup_session_cancel_message (src->session, src->msg, SOUP_STATUS_CANCELLED);
498 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
503 gst_soup_http_src_queue_message (GstSoupHTTPSrc * src)
505 soup_session_queue_message (src->session, src->msg,
506 (SoupSessionCallback) gst_soup_http_src_response_cb, src);
507 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED;
511 gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src, guint64 offset)
517 soup_message_headers_remove (src->msg->request_headers, "Range");
519 rc = g_snprintf (buf, sizeof (buf), "bytes=%" G_GUINT64_FORMAT "-", offset);
520 if (rc > sizeof (buf) || rc < 0)
522 soup_message_headers_append (src->msg->request_headers, "Range", buf);
524 src->read_position = offset;
529 _append_extra_header (GQuark field_id, const GValue * value, gpointer user_data)
531 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (user_data);
532 const gchar *field_name = g_quark_to_string (field_id);
533 gchar *field_content = NULL;
535 if (G_VALUE_TYPE (value) == G_TYPE_STRING) {
536 field_content = g_value_dup_string (value);
538 GValue dest = { 0, };
540 g_value_init (&dest, G_TYPE_STRING);
541 if (g_value_transform (value, &dest)) {
542 field_content = g_value_dup_string (&dest);
546 if (field_content == NULL) {
547 GST_ERROR_OBJECT (src, "extra-headers field '%s' contains no value "
548 "or can't be converted to a string", field_name);
552 GST_DEBUG_OBJECT (src, "Appending extra header: \"%s: %s\"", field_name,
554 soup_message_headers_append (src->msg->request_headers, field_name,
557 g_free (field_content);
563 _append_extra_headers (GQuark field_id, const GValue * value,
566 if (G_VALUE_TYPE (value) == GST_TYPE_ARRAY) {
567 guint n = gst_value_array_get_size (value);
570 for (i = 0; i < n; i++) {
571 const GValue *v = gst_value_array_get_value (value, i);
573 if (!_append_extra_header (field_id, v, user_data))
576 } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
577 guint n = gst_value_list_get_size (value);
580 for (i = 0; i < n; i++) {
581 const GValue *v = gst_value_list_get_value (value, i);
583 if (!_append_extra_header (field_id, v, user_data))
587 return _append_extra_header (field_id, value, user_data);
595 gst_soup_http_src_add_extra_headers (GstSoupHTTPSrc * src)
597 if (!src->extra_headers)
600 return gst_structure_foreach (src->extra_headers, _append_extra_headers, src);
605 gst_soup_http_src_session_unpause_message (GstSoupHTTPSrc * src)
607 soup_session_unpause_message (src->session, src->msg);
611 gst_soup_http_src_session_pause_message (GstSoupHTTPSrc * src)
613 soup_session_pause_message (src->session, src->msg);
617 gst_soup_http_src_session_close (GstSoupHTTPSrc * src)
620 soup_session_abort (src->session); /* This unrefs the message. */
621 g_object_unref (src->session);
628 gst_soup_http_src_authenticate_cb (SoupSession * session, SoupMessage * msg,
629 SoupAuth * auth, gboolean retrying, GstSoupHTTPSrc * src)
632 /* First time authentication only, if we fail and are called again with retry true fall through */
633 if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) {
634 if (src->user_id && src->user_pw)
635 soup_auth_authenticate (auth, src->user_id, src->user_pw);
636 } else if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
637 if (src->proxy_id && src->proxy_pw)
638 soup_auth_authenticate (auth, src->proxy_id, src->proxy_pw);
644 gst_soup_http_src_headers_foreach (const gchar * name, const gchar * val,
647 GST_DEBUG_OBJECT (src, " %s: %s", name, val);
651 gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
654 GstTagList *tag_list;
657 GHashTable *params = NULL;
659 GST_DEBUG_OBJECT (src, "got headers:");
660 soup_message_headers_foreach (msg->response_headers,
661 gst_soup_http_src_headers_foreach, src);
663 if (msg->status_code == 407 && src->proxy_id && src->proxy_pw)
666 if (src->automatic_redirect && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
667 GST_DEBUG_OBJECT (src, "%u redirect to \"%s\"", msg->status_code,
668 soup_message_headers_get_one (msg->response_headers, "Location"));
672 if (msg->status_code == SOUP_STATUS_UNAUTHORIZED)
675 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING;
677 /* Parse Content-Length. */
678 if (soup_message_headers_get_encoding (msg->response_headers) ==
679 SOUP_ENCODING_CONTENT_LENGTH) {
680 newsize = src->request_position +
681 soup_message_headers_get_content_length (msg->response_headers);
682 if (!src->have_size || (src->content_size != newsize)) {
683 src->content_size = newsize;
684 src->have_size = TRUE;
685 src->seekable = TRUE;
686 GST_DEBUG_OBJECT (src, "size = %" G_GUINT64_FORMAT, src->content_size);
688 basesrc = GST_BASE_SRC_CAST (src);
689 basesrc->segment.duration = src->content_size;
690 gst_element_post_message (GST_ELEMENT (src),
691 gst_message_new_duration_changed (GST_OBJECT (src)));
696 tag_list = gst_tag_list_new_empty ();
699 soup_message_headers_get_one (msg->response_headers,
700 "icy-metaint")) != NULL) {
701 gint icy_metaint = atoi (value);
703 GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, icy_metaint);
704 if (icy_metaint > 0) {
706 gst_caps_unref (src->src_caps);
708 src->src_caps = gst_caps_new_simple ("application/x-icy",
709 "metadata-interval", G_TYPE_INT, icy_metaint, NULL);
711 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
715 soup_message_headers_get_content_type (msg->response_headers,
717 GST_DEBUG_OBJECT (src, "Content-Type: %s", value);
718 if (g_ascii_strcasecmp (value, "audio/L16") == 0) {
724 gst_caps_unref (src->src_caps);
726 param = g_hash_table_lookup (params, "channels");
728 channels = atol (param);
730 param = g_hash_table_lookup (params, "rate");
734 src->src_caps = gst_caps_new_simple ("audio/x-raw",
735 "format", G_TYPE_STRING, "S16BE",
736 "layout", G_TYPE_STRING, "interleaved",
737 "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
739 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
741 /* Set the Content-Type field on the caps */
743 src->src_caps = gst_caps_make_writable (src->src_caps);
744 gst_caps_set_simple (src->src_caps, "content-type", G_TYPE_STRING,
746 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
752 g_hash_table_destroy (params);
755 soup_message_headers_get_one (msg->response_headers,
756 "icy-name")) != NULL) {
757 g_free (src->iradio_name);
758 src->iradio_name = gst_soup_http_src_unicodify (value);
759 if (src->iradio_name) {
760 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION,
761 src->iradio_name, NULL);
765 soup_message_headers_get_one (msg->response_headers,
766 "icy-genre")) != NULL) {
767 g_free (src->iradio_genre);
768 src->iradio_genre = gst_soup_http_src_unicodify (value);
769 if (src->iradio_genre) {
770 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
771 src->iradio_genre, NULL);
774 if ((value = soup_message_headers_get_one (msg->response_headers, "icy-url"))
776 g_free (src->iradio_url);
777 src->iradio_url = gst_soup_http_src_unicodify (value);
778 if (src->iradio_url) {
779 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION,
780 src->iradio_url, NULL);
783 if (!gst_tag_list_is_empty (tag_list)) {
784 GST_DEBUG_OBJECT (src,
785 "calling gst_element_found_tags with %" GST_PTR_FORMAT, tag_list);
786 gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tag_list));
788 gst_tag_list_unref (tag_list);
791 /* Handle HTTP errors. */
792 gst_soup_http_src_parse_status (msg, src);
794 /* Check if Range header was respected. */
795 if (src->ret == GST_FLOW_CUSTOM_ERROR &&
796 src->read_position && msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) {
797 src->seekable = FALSE;
798 GST_ELEMENT_ERROR (src, RESOURCE, SEEK,
799 (_("Server does not support seeking.")),
800 ("Server does not accept Range HTTP header, URL: %s", src->location));
801 src->ret = GST_FLOW_ERROR;
804 /* If we are going to error out, stop all processing right here, so we
805 * don't output any data (such as an error html page), and return
806 * GST_FLOW_ERROR from the create function instead of having
807 * got_chunk_cb overwrite src->ret with FLOW_OK again. */
808 if (src->ret == GST_FLOW_ERROR) {
809 gst_soup_http_src_session_pause_message (src);
812 g_main_loop_quit (src->loop);
816 /* Have body. Signal EOS. */
818 gst_soup_http_src_got_body_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
820 if (G_UNLIKELY (msg != src->msg)) {
821 GST_DEBUG_OBJECT (src, "got body, but not for current message");
824 if (G_UNLIKELY (src->session_io_status !=
825 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
826 /* Probably a redirect. */
829 GST_DEBUG_OBJECT (src, "got body");
830 src->ret = GST_FLOW_EOS;
832 g_main_loop_quit (src->loop);
833 gst_soup_http_src_session_pause_message (src);
836 /* Finished. Signal EOS. */
838 gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
840 if (G_UNLIKELY (msg != src->msg)) {
841 GST_DEBUG_OBJECT (src, "finished, but not for current message");
844 GST_DEBUG_OBJECT (src, "finished");
845 src->ret = GST_FLOW_EOS;
846 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED) {
847 /* gst_soup_http_src_cancel_message() triggered this; probably a seek
848 * that occurred in the QUEUEING state; i.e. before the connection setup
849 * was complete. Do nothing */
850 } else if (src->session_io_status ==
851 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING && src->read_position > 0) {
852 /* The server disconnected while streaming. Reconnect and seeking to the
855 src->ret = GST_FLOW_CUSTOM_ERROR;
856 } else if (G_UNLIKELY (src->session_io_status !=
857 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
858 /* FIXME: reason_phrase is not translated, add proper error message */
859 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
860 ("%s", msg->reason_phrase),
861 ("libsoup status code %d", msg->status_code));
864 g_main_loop_quit (src->loop);
867 /* Buffer lifecycle management.
869 * gst_soup_http_src_create() runs the GMainLoop for this element, to let
871 * A GstBuffer is allocated in gst_soup_http_src_chunk_allocator() and
872 * associated with a SoupBuffer.
873 * Soup reads HTTP data in the GstBuffer's data buffer.
874 * The gst_soup_http_src_got_chunk_cb() is then called with the SoupBuffer.
875 * That sets gst_soup_http_src_create()'s return argument to the GstBuffer,
876 * increments its refcount (to 2), pauses the flow of data from the HTTP
877 * source to prevent gst_soup_http_src_got_chunk_cb() from being called
878 * again and breaks out of the GMainLoop.
879 * Because the SOUP_MESSAGE_OVERWRITE_CHUNKS flag is set, Soup frees the
880 * SoupBuffer and calls gst_soup_http_src_chunk_free(), which decrements the
882 * gst_soup_http_src_create() returns the GstBuffer. It will be freed by a
883 * downstream element.
884 * If Soup fails to read HTTP data, it does not call
885 * gst_soup_http_src_got_chunk_cb(), but still frees the SoupBuffer and
886 * calls gst_soup_http_src_chunk_free(), which decrements the GstBuffer's
887 * refcount to 0, freeing it.
897 gst_soup_http_src_chunk_free (gpointer user_data)
899 SoupGstChunk *chunk = (SoupGstChunk *) user_data;
901 gst_buffer_unmap (chunk->buffer, &chunk->map);
902 gst_buffer_unref (chunk->buffer);
903 g_slice_free (SoupGstChunk, chunk);
907 gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
910 GstSoupHTTPSrc *src = (GstSoupHTTPSrc *) user_data;
911 GstBaseSrc *basesrc = GST_BASE_SRC_CAST (src);
919 length = MIN (basesrc->blocksize, max_len);
921 length = basesrc->blocksize;
922 GST_DEBUG_OBJECT (src, "alloc %" G_GSIZE_FORMAT " bytes <= %" G_GSIZE_FORMAT,
925 rc = GST_BASE_SRC_CLASS (parent_class)->alloc (basesrc, -1, length, &gstbuf);
926 if (G_UNLIKELY (rc != GST_FLOW_OK)) {
927 /* Failed to allocate buffer. Stall SoupSession and return error code
930 g_main_loop_quit (src->loop);
934 chunk = g_slice_new0 (SoupGstChunk);
935 chunk->buffer = gstbuf;
936 gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
938 soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
939 chunk, gst_soup_http_src_chunk_free);
945 gst_soup_http_src_got_chunk_cb (SoupMessage * msg, SoupBuffer * chunk,
946 GstSoupHTTPSrc * src)
949 guint64 new_position;
950 SoupGstChunk *gchunk;
952 if (G_UNLIKELY (msg != src->msg)) {
953 GST_DEBUG_OBJECT (src, "got chunk, but not for current message");
956 if (G_UNLIKELY (src->session_io_status !=
957 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
958 /* Probably a redirect. */
961 basesrc = GST_BASE_SRC_CAST (src);
962 GST_DEBUG_OBJECT (src, "got chunk of %" G_GSIZE_FORMAT " bytes",
965 /* Extract the GstBuffer from the SoupBuffer and set its fields. */
966 gchunk = (SoupGstChunk *) soup_buffer_get_owner (chunk);
967 *src->outbuf = gchunk->buffer;
969 gst_buffer_resize (*src->outbuf, 0, chunk->length);
970 GST_BUFFER_OFFSET (*src->outbuf) = basesrc->segment.position;
972 gst_buffer_ref (*src->outbuf);
974 new_position = src->read_position + chunk->length;
975 if (G_LIKELY (src->request_position == src->read_position))
976 src->request_position = new_position;
977 src->read_position = new_position;
979 src->ret = GST_FLOW_OK;
980 g_main_loop_quit (src->loop);
981 gst_soup_http_src_session_pause_message (src);
985 gst_soup_http_src_response_cb (SoupSession * session, SoupMessage * msg,
986 GstSoupHTTPSrc * src)
988 if (G_UNLIKELY (msg != src->msg)) {
989 GST_DEBUG_OBJECT (src, "got response %d: %s, but not for current message",
990 msg->status_code, msg->reason_phrase);
993 if (G_UNLIKELY (src->session_io_status !=
994 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)
995 && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
996 /* Ignore redirections. */
999 GST_DEBUG_OBJECT (src, "got response %d: %s", msg->status_code,
1000 msg->reason_phrase);
1001 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING &&
1002 src->read_position > 0) {
1003 /* The server disconnected while streaming. Reconnect and seeking to the
1007 gst_soup_http_src_parse_status (msg, src);
1008 /* The session's SoupMessage object expires after this callback returns. */
1010 g_main_loop_quit (src->loop);
1013 #define SOUP_HTTP_SRC_ERROR(src,soup_msg,cat,code,error_message) \
1014 GST_ELEMENT_ERROR ((src), cat, code, ("%s", error_message), \
1015 ("%s (%d), URL: %s", (soup_msg)->reason_phrase, \
1016 (soup_msg)->status_code, (src)->location));
1019 gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src)
1021 if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) {
1022 switch (msg->status_code) {
1023 case SOUP_STATUS_CANT_RESOLVE:
1024 case SOUP_STATUS_CANT_RESOLVE_PROXY:
1025 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND,
1026 _("Could not resolve server name."));
1027 src->ret = GST_FLOW_ERROR;
1029 case SOUP_STATUS_CANT_CONNECT:
1030 case SOUP_STATUS_CANT_CONNECT_PROXY:
1031 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1032 _("Could not establish connection to server."));
1033 src->ret = GST_FLOW_ERROR;
1035 case SOUP_STATUS_SSL_FAILED:
1036 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1037 _("Secure connection setup failed."));
1038 src->ret = GST_FLOW_ERROR;
1040 case SOUP_STATUS_IO_ERROR:
1041 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1042 _("A network error occured, or the server closed the connection "
1044 src->ret = GST_FLOW_ERROR;
1046 case SOUP_STATUS_MALFORMED:
1047 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1048 _("Server sent bad data."));
1049 src->ret = GST_FLOW_ERROR;
1051 case SOUP_STATUS_CANCELLED:
1052 /* No error message when interrupted by program. */
1055 } else if (SOUP_STATUS_IS_CLIENT_ERROR (msg->status_code) ||
1056 SOUP_STATUS_IS_REDIRECTION (msg->status_code) ||
1057 SOUP_STATUS_IS_SERVER_ERROR (msg->status_code)) {
1058 /* Report HTTP error. */
1059 /* FIXME: reason_phrase is not translated and not suitable for user
1060 * error dialog according to libsoup documentation.
1061 * FIXME: error code (OPEN_READ vs. READ) should depend on http status? */
1062 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1063 ("%s", msg->reason_phrase),
1064 ("%s (%d), URL: %s", msg->reason_phrase, msg->status_code,
1066 src->ret = GST_FLOW_ERROR;
1071 gst_soup_http_src_build_message (GstSoupHTTPSrc * src)
1073 src->msg = soup_message_new (SOUP_METHOD_GET, src->location);
1075 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1076 ("Error parsing URL."), ("URL: %s", src->location));
1079 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
1080 soup_message_headers_append (src->msg->request_headers, "Connection",
1082 soup_message_headers_append (src->msg->request_headers, "icy-metadata", "1");
1087 for (cookie = src->cookies; *cookie != NULL; cookie++) {
1088 soup_message_headers_append (src->msg->request_headers, "Cookie",
1094 g_signal_connect (src->msg, "got_headers",
1095 G_CALLBACK (gst_soup_http_src_got_headers_cb), src);
1096 g_signal_connect (src->msg, "got_body",
1097 G_CALLBACK (gst_soup_http_src_got_body_cb), src);
1098 g_signal_connect (src->msg, "finished",
1099 G_CALLBACK (gst_soup_http_src_finished_cb), src);
1100 g_signal_connect (src->msg, "got_chunk",
1101 G_CALLBACK (gst_soup_http_src_got_chunk_cb), src);
1102 soup_message_set_flags (src->msg, SOUP_MESSAGE_OVERWRITE_CHUNKS |
1103 (src->automatic_redirect ? 0 : SOUP_MESSAGE_NO_REDIRECT));
1104 soup_message_set_chunk_allocator (src->msg,
1105 gst_soup_http_src_chunk_allocator, src, NULL);
1106 gst_soup_http_src_add_range_header (src, src->request_position);
1108 gst_soup_http_src_add_extra_headers (src);
1110 GST_DEBUG_OBJECT (src, "request headers:");
1111 soup_message_headers_foreach (src->msg->request_headers,
1112 gst_soup_http_src_headers_foreach, src);
1117 static GstFlowReturn
1118 gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
1120 GstSoupHTTPSrc *src;
1122 src = GST_SOUP_HTTP_SRC (psrc);
1124 if (src->msg && (src->request_position != src->read_position)) {
1125 if (src->content_size != 0 && src->request_position >= src->content_size) {
1126 GST_WARNING_OBJECT (src, "Seeking behind the end of file -- EOS");
1127 return GST_FLOW_EOS;
1128 } else if (src->session_io_status ==
1129 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) {
1130 gst_soup_http_src_add_range_header (src, src->request_position);
1132 GST_DEBUG_OBJECT (src, "Seek from position %" G_GUINT64_FORMAT
1133 " to %" G_GUINT64_FORMAT ": requeueing connection request",
1134 src->read_position, src->request_position);
1135 gst_soup_http_src_cancel_message (src);
1139 if (!gst_soup_http_src_build_message (src))
1140 return GST_FLOW_ERROR;
1142 src->ret = GST_FLOW_CUSTOM_ERROR;
1143 src->outbuf = outbuf;
1145 if (src->interrupted) {
1146 GST_DEBUG_OBJECT (src, "interrupted");
1150 GST_DEBUG_OBJECT (src, "Reconnecting");
1151 if (!gst_soup_http_src_build_message (src))
1152 return GST_FLOW_ERROR;
1157 GST_DEBUG_OBJECT (src, "EOS reached");
1161 switch (src->session_io_status) {
1162 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE:
1163 GST_DEBUG_OBJECT (src, "Queueing connection request");
1164 gst_soup_http_src_queue_message (src);
1166 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED:
1168 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING:
1169 gst_soup_http_src_session_unpause_message (src);
1171 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED:
1176 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1177 g_main_loop_run (src->loop);
1178 } while (src->ret == GST_FLOW_CUSTOM_ERROR);
1180 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1181 src->ret = GST_FLOW_EOS;
1186 gst_soup_http_src_start (GstBaseSrc * bsrc)
1188 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1190 GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location);
1192 if (!src->location) {
1193 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (_("No URL set.")),
1194 ("Missing location property"));
1198 src->context = g_main_context_new ();
1200 src->loop = g_main_loop_new (src->context, TRUE);
1202 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1203 (NULL), ("Failed to start GMainLoop"));
1204 g_main_context_unref (src->context);
1208 if (src->proxy == NULL) {
1210 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1211 src->context, SOUP_SESSION_USER_AGENT, src->user_agent,
1212 SOUP_SESSION_TIMEOUT, src->timeout,
1213 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_DEFAULT,
1217 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1218 src->context, SOUP_SESSION_PROXY_URI, src->proxy,
1219 SOUP_SESSION_TIMEOUT, src->timeout,
1220 SOUP_SESSION_USER_AGENT, src->user_agent, NULL);
1223 if (!src->session) {
1224 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1225 (NULL), ("Failed to create async session"));
1229 g_signal_connect (src->session, "authenticate",
1230 G_CALLBACK (gst_soup_http_src_authenticate_cb), src);
1235 gst_soup_http_src_stop (GstBaseSrc * bsrc)
1237 GstSoupHTTPSrc *src;
1239 src = GST_SOUP_HTTP_SRC (bsrc);
1240 GST_DEBUG_OBJECT (src, "stop()");
1241 gst_soup_http_src_session_close (src);
1243 g_main_loop_unref (src->loop);
1244 g_main_context_unref (src->context);
1246 src->context = NULL;
1248 if (src->extra_headers) {
1249 gst_structure_free (src->extra_headers);
1250 src->extra_headers = NULL;
1253 gst_soup_http_src_reset (src);
1257 /* Interrupt a blocking request. */
1259 gst_soup_http_src_unlock (GstBaseSrc * bsrc)
1261 GstSoupHTTPSrc *src;
1263 src = GST_SOUP_HTTP_SRC (bsrc);
1264 GST_DEBUG_OBJECT (src, "unlock()");
1266 src->interrupted = TRUE;
1268 g_main_loop_quit (src->loop);
1272 /* Interrupt interrupt. */
1274 gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc)
1276 GstSoupHTTPSrc *src;
1278 src = GST_SOUP_HTTP_SRC (bsrc);
1279 GST_DEBUG_OBJECT (src, "unlock_stop()");
1281 src->interrupted = FALSE;
1286 gst_soup_http_src_get_size (GstBaseSrc * bsrc, guint64 * size)
1288 GstSoupHTTPSrc *src;
1290 src = GST_SOUP_HTTP_SRC (bsrc);
1292 if (src->have_size) {
1293 GST_DEBUG_OBJECT (src, "get_size() = %" G_GUINT64_FORMAT,
1295 *size = src->content_size;
1298 GST_DEBUG_OBJECT (src, "get_size() = FALSE");
1303 gst_soup_http_src_is_seekable (GstBaseSrc * bsrc)
1305 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1307 return src->seekable;
1311 gst_soup_http_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
1313 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1315 GST_DEBUG_OBJECT (src, "do_seek(%" G_GUINT64_FORMAT ")", segment->start);
1317 if (src->read_position == segment->start &&
1318 src->request_position == src->read_position) {
1319 GST_DEBUG_OBJECT (src, "Seek to current read position and no seek pending");
1323 if (!src->seekable) {
1324 GST_WARNING_OBJECT (src, "Not seekable");
1328 if (segment->rate < 0.0 || segment->format != GST_FORMAT_BYTES) {
1329 GST_WARNING_OBJECT (src, "Invalid seek segment");
1333 if (src->content_size != 0 && segment->start >= src->content_size) {
1334 GST_WARNING_OBJECT (src, "Seeking behind end of file, will go to EOS soon");
1337 /* Wait for create() to handle the jump in offset. */
1338 src->request_position = segment->start;
1343 gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
1345 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1348 switch (GST_QUERY_TYPE (query)) {
1350 gst_query_set_uri (query, src->location);
1359 ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
1365 gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri,
1368 const char *alt_schemes[] = { "icy://", "icyx://" };
1371 if (src->location) {
1372 g_free (src->location);
1373 src->location = NULL;
1379 for (i = 0; i < G_N_ELEMENTS (alt_schemes); i++) {
1380 if (g_str_has_prefix (uri, alt_schemes[i])) {
1382 g_strdup_printf ("http://%s", uri + strlen (alt_schemes[i]));
1387 src->location = g_strdup (uri);
1393 gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
1396 soup_uri_free (src->proxy);
1399 if (g_str_has_prefix (uri, "http://")) {
1400 src->proxy = soup_uri_new (uri);
1402 gchar *new_uri = g_strconcat ("http://", uri, NULL);
1404 src->proxy = soup_uri_new (new_uri);
1412 gst_soup_http_src_uri_get_type (GType type)
1417 static const gchar *const *
1418 gst_soup_http_src_uri_get_protocols (GType type)
1420 static const gchar *protocols[] = { "http", "https", "icy", "icyx", NULL };
1426 gst_soup_http_src_uri_get_uri (GstURIHandler * handler)
1428 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1430 /* FIXME: make thread-safe */
1431 return g_strdup (src->location);
1435 gst_soup_http_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
1438 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1440 return gst_soup_http_src_set_location (src, uri, error);
1444 gst_soup_http_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1446 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1448 iface->get_type = gst_soup_http_src_uri_get_type;
1449 iface->get_protocols = gst_soup_http_src_uri_get_protocols;
1450 iface->get_uri = gst_soup_http_src_uri_get_uri;
1451 iface->set_uri = gst_soup_http_src_uri_set_uri;