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 #ifdef HAVE_LIBSOUP_GNOME
81 #include <libsoup/soup-gnome.h>
83 #include <libsoup/soup.h>
85 #include "gstsouphttpsrc.h"
87 #include <gst/tag/tag.h>
89 GST_DEBUG_CATEGORY_STATIC (souphttpsrc_debug);
90 #define GST_CAT_DEFAULT souphttpsrc_debug
92 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
103 PROP_AUTOMATIC_REDIRECT,
114 #define DEFAULT_USER_AGENT "GStreamer souphttpsrc "
116 static void gst_soup_http_src_uri_handler_init (gpointer g_iface,
117 gpointer iface_data);
118 static void gst_soup_http_src_finalize (GObject * gobject);
120 static void gst_soup_http_src_set_property (GObject * object, guint prop_id,
121 const GValue * value, GParamSpec * pspec);
122 static void gst_soup_http_src_get_property (GObject * object, guint prop_id,
123 GValue * value, GParamSpec * pspec);
125 static GstFlowReturn gst_soup_http_src_create (GstPushSrc * psrc,
126 GstBuffer ** outbuf);
127 static gboolean gst_soup_http_src_start (GstBaseSrc * bsrc);
128 static gboolean gst_soup_http_src_stop (GstBaseSrc * bsrc);
129 static gboolean gst_soup_http_src_get_size (GstBaseSrc * bsrc, guint64 * size);
130 static gboolean gst_soup_http_src_is_seekable (GstBaseSrc * bsrc);
131 static gboolean gst_soup_http_src_do_seek (GstBaseSrc * bsrc,
132 GstSegment * segment);
133 static gboolean gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query);
134 static gboolean gst_soup_http_src_unlock (GstBaseSrc * bsrc);
135 static gboolean gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc);
136 static gboolean gst_soup_http_src_set_location (GstSoupHTTPSrc * src,
137 const gchar * uri, GError ** error);
138 static gboolean gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src,
140 static char *gst_soup_http_src_unicodify (const char *str);
141 static gboolean gst_soup_http_src_build_message (GstSoupHTTPSrc * src);
142 static void gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src);
143 static void gst_soup_http_src_queue_message (GstSoupHTTPSrc * src);
144 static gboolean gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src,
146 static void gst_soup_http_src_session_unpause_message (GstSoupHTTPSrc * src);
147 static void gst_soup_http_src_session_pause_message (GstSoupHTTPSrc * src);
148 static void gst_soup_http_src_session_close (GstSoupHTTPSrc * src);
149 static void gst_soup_http_src_parse_status (SoupMessage * msg,
150 GstSoupHTTPSrc * src);
151 static void gst_soup_http_src_chunk_free (gpointer gstbuf);
152 static SoupBuffer *gst_soup_http_src_chunk_allocator (SoupMessage * msg,
153 gsize max_len, gpointer user_data);
154 static void gst_soup_http_src_got_chunk_cb (SoupMessage * msg,
155 SoupBuffer * chunk, GstSoupHTTPSrc * src);
156 static void gst_soup_http_src_response_cb (SoupSession * session,
157 SoupMessage * msg, GstSoupHTTPSrc * src);
158 static void gst_soup_http_src_got_headers_cb (SoupMessage * msg,
159 GstSoupHTTPSrc * src);
160 static void gst_soup_http_src_got_body_cb (SoupMessage * msg,
161 GstSoupHTTPSrc * src);
162 static void gst_soup_http_src_finished_cb (SoupMessage * msg,
163 GstSoupHTTPSrc * src);
164 static void gst_soup_http_src_authenticate_cb (SoupSession * session,
165 SoupMessage * msg, SoupAuth * auth, gboolean retrying,
166 GstSoupHTTPSrc * src);
168 #define gst_soup_http_src_parent_class parent_class
169 G_DEFINE_TYPE_WITH_CODE (GstSoupHTTPSrc, gst_soup_http_src, GST_TYPE_PUSH_SRC,
170 G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER,
171 gst_soup_http_src_uri_handler_init));
174 gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
176 GObjectClass *gobject_class;
177 GstElementClass *gstelement_class;
178 GstBaseSrcClass *gstbasesrc_class;
179 GstPushSrcClass *gstpushsrc_class;
181 gobject_class = (GObjectClass *) klass;
182 gstelement_class = (GstElementClass *) klass;
183 gstbasesrc_class = (GstBaseSrcClass *) klass;
184 gstpushsrc_class = (GstPushSrcClass *) klass;
186 gobject_class->set_property = gst_soup_http_src_set_property;
187 gobject_class->get_property = gst_soup_http_src_get_property;
188 gobject_class->finalize = gst_soup_http_src_finalize;
190 g_object_class_install_property (gobject_class,
192 g_param_spec_string ("location", "Location",
193 "Location to read from", "",
194 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
195 g_object_class_install_property (gobject_class,
197 g_param_spec_string ("user-agent", "User-Agent",
198 "Value of the User-Agent HTTP request header field",
199 DEFAULT_USER_AGENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
200 g_object_class_install_property (gobject_class,
201 PROP_AUTOMATIC_REDIRECT,
202 g_param_spec_boolean ("automatic-redirect", "automatic-redirect",
203 "Automatically follow HTTP redirects (HTTP Status Code 3xx)",
204 TRUE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
205 g_object_class_install_property (gobject_class,
207 g_param_spec_string ("proxy", "Proxy",
208 "HTTP proxy server URI", "",
209 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
210 g_object_class_install_property (gobject_class,
212 g_param_spec_string ("user-id", "user-id",
213 "HTTP location URI user id for authentication", "",
214 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
215 g_object_class_install_property (gobject_class, PROP_USER_PW,
216 g_param_spec_string ("user-pw", "user-pw",
217 "HTTP location URI user password for authentication", "",
218 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
219 g_object_class_install_property (gobject_class, PROP_PROXY_ID,
220 g_param_spec_string ("proxy-id", "proxy-id",
221 "HTTP proxy URI user id for authentication", "",
222 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
223 g_object_class_install_property (gobject_class, PROP_PROXY_PW,
224 g_param_spec_string ("proxy-pw", "proxy-pw",
225 "HTTP proxy URI user password for authentication", "",
226 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
227 g_object_class_install_property (gobject_class, PROP_COOKIES,
228 g_param_spec_boxed ("cookies", "Cookies", "HTTP request cookies",
229 G_TYPE_STRV, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
230 g_object_class_install_property (gobject_class, PROP_IS_LIVE,
231 g_param_spec_boolean ("is-live", "is-live", "Act like a live source",
232 FALSE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
233 g_object_class_install_property (gobject_class, PROP_TIMEOUT,
234 g_param_spec_uint ("timeout", "timeout",
235 "Value in seconds to timeout a blocking I/O (0 = No timeout).", 0,
236 3600, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
237 g_object_class_install_property (gobject_class, PROP_EXTRA_HEADERS,
238 g_param_spec_boxed ("extra-headers", "Extra Headers",
239 "Extra headers to append to the HTTP request",
240 GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
242 gst_element_class_add_pad_template (gstelement_class,
243 gst_static_pad_template_get (&srctemplate));
245 gst_element_class_set_static_metadata (gstelement_class, "HTTP client source",
247 "Receive data as a client over the network via HTTP using SOUP",
248 "Wouter Cloetens <wouter@mind.be>");
250 gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_soup_http_src_start);
251 gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_soup_http_src_stop);
252 gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_soup_http_src_unlock);
253 gstbasesrc_class->unlock_stop =
254 GST_DEBUG_FUNCPTR (gst_soup_http_src_unlock_stop);
255 gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_soup_http_src_get_size);
256 gstbasesrc_class->is_seekable =
257 GST_DEBUG_FUNCPTR (gst_soup_http_src_is_seekable);
258 gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_soup_http_src_do_seek);
259 gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_soup_http_src_query);
261 gstpushsrc_class->create = GST_DEBUG_FUNCPTR (gst_soup_http_src_create);
263 GST_DEBUG_CATEGORY_INIT (souphttpsrc_debug, "souphttpsrc", 0,
268 gst_soup_http_src_reset (GstSoupHTTPSrc * src)
270 src->interrupted = FALSE;
272 src->have_size = FALSE;
273 src->seekable = FALSE;
274 src->read_position = 0;
275 src->request_position = 0;
276 src->content_size = 0;
278 gst_caps_replace (&src->src_caps, NULL);
279 g_free (src->iradio_name);
280 src->iradio_name = NULL;
281 g_free (src->iradio_genre);
282 src->iradio_genre = NULL;
283 g_free (src->iradio_url);
284 src->iradio_url = NULL;
288 gst_soup_http_src_init (GstSoupHTTPSrc * src)
292 src->location = NULL;
293 src->automatic_redirect = TRUE;
294 src->user_agent = g_strdup (DEFAULT_USER_AGENT);
297 src->proxy_id = NULL;
298 src->proxy_pw = NULL;
304 proxy = g_getenv ("http_proxy");
305 if (proxy && !gst_soup_http_src_set_proxy (src, proxy)) {
306 GST_WARNING_OBJECT (src,
307 "The proxy in the http_proxy env var (\"%s\") cannot be parsed.",
311 gst_soup_http_src_reset (src);
315 gst_soup_http_src_finalize (GObject * gobject)
317 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (gobject);
319 GST_DEBUG_OBJECT (src, "finalize");
321 g_free (src->location);
322 g_free (src->user_agent);
323 if (src->proxy != NULL) {
324 soup_uri_free (src->proxy);
326 g_free (src->user_id);
327 g_free (src->user_pw);
328 g_free (src->proxy_id);
329 g_free (src->proxy_pw);
330 g_strfreev (src->cookies);
332 G_OBJECT_CLASS (parent_class)->finalize (gobject);
336 gst_soup_http_src_set_property (GObject * object, guint prop_id,
337 const GValue * value, GParamSpec * pspec)
339 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object);
344 const gchar *location;
346 location = g_value_get_string (value);
348 if (location == NULL) {
349 GST_WARNING ("location property cannot be NULL");
352 if (!gst_soup_http_src_set_location (src, location, NULL)) {
353 GST_WARNING ("badly formatted location");
358 case PROP_USER_AGENT:
360 g_free (src->user_agent);
361 src->user_agent = g_value_dup_string (value);
363 case PROP_AUTOMATIC_REDIRECT:
364 src->automatic_redirect = g_value_get_boolean (value);
370 proxy = g_value_get_string (value);
373 GST_WARNING ("proxy property cannot be NULL");
376 if (!gst_soup_http_src_set_proxy (src, proxy)) {
377 GST_WARNING ("badly formatted proxy URI");
383 g_strfreev (src->cookies);
384 src->cookies = g_strdupv (g_value_get_boxed (value));
387 gst_base_src_set_live (GST_BASE_SRC (src), g_value_get_boolean (value));
391 g_free (src->user_id);
392 src->user_id = g_value_dup_string (value);
396 g_free (src->user_pw);
397 src->user_pw = g_value_dup_string (value);
401 g_free (src->proxy_id);
402 src->proxy_id = g_value_dup_string (value);
406 g_free (src->proxy_pw);
407 src->proxy_pw = g_value_dup_string (value);
410 src->timeout = g_value_get_uint (value);
412 case PROP_EXTRA_HEADERS:{
413 const GstStructure *s = gst_value_get_structure (value);
415 if (src->extra_headers)
416 gst_structure_free (src->extra_headers);
418 src->extra_headers = s ? gst_structure_copy (s) : NULL;
422 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
430 gst_soup_http_src_get_property (GObject * object, guint prop_id,
431 GValue * value, GParamSpec * pspec)
433 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (object);
437 g_value_set_string (value, src->location);
439 case PROP_USER_AGENT:
440 g_value_set_string (value, src->user_agent);
442 case PROP_AUTOMATIC_REDIRECT:
443 g_value_set_boolean (value, src->automatic_redirect);
446 if (src->proxy == NULL)
447 g_value_set_static_string (value, "");
449 char *proxy = soup_uri_to_string (src->proxy, FALSE);
451 g_value_set_string (value, proxy);
456 g_value_set_boxed (value, g_strdupv (src->cookies));
459 g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (src)));
462 g_value_set_string (value, src->user_id);
465 g_value_set_string (value, src->user_pw);
468 g_value_set_string (value, src->proxy_id);
471 g_value_set_string (value, src->proxy_pw);
474 g_value_set_uint (value, src->timeout);
476 case PROP_EXTRA_HEADERS:
477 gst_value_set_structure (value, src->extra_headers);
480 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
486 gst_soup_http_src_unicodify (const gchar * str)
488 const gchar *env_vars[] = { "GST_ICY_TAG_ENCODING",
489 "GST_TAG_ENCODING", NULL
492 return gst_tag_freeform_string_to_utf8 (str, -1, env_vars);
496 gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src)
498 if (src->msg != NULL) {
499 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED;
500 soup_session_cancel_message (src->session, src->msg, SOUP_STATUS_CANCELLED);
502 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
507 gst_soup_http_src_queue_message (GstSoupHTTPSrc * src)
509 soup_session_queue_message (src->session, src->msg,
510 (SoupSessionCallback) gst_soup_http_src_response_cb, src);
511 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED;
515 gst_soup_http_src_add_range_header (GstSoupHTTPSrc * src, guint64 offset)
521 soup_message_headers_remove (src->msg->request_headers, "Range");
523 rc = g_snprintf (buf, sizeof (buf), "bytes=%" G_GUINT64_FORMAT "-", offset);
524 if (rc > sizeof (buf) || rc < 0)
526 soup_message_headers_append (src->msg->request_headers, "Range", buf);
528 src->read_position = offset;
533 _append_extra_header (GQuark field_id, const GValue * value, gpointer user_data)
535 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (user_data);
536 const gchar *field_name = g_quark_to_string (field_id);
537 gchar *field_content = NULL;
539 if (G_VALUE_TYPE (value) == G_TYPE_STRING) {
540 field_content = g_value_dup_string (value);
542 GValue dest = { 0, };
544 g_value_init (&dest, G_TYPE_STRING);
545 if (g_value_transform (value, &dest)) {
546 field_content = g_value_dup_string (&dest);
550 if (field_content == NULL) {
551 GST_ERROR_OBJECT (src, "extra-headers field '%s' contains no value "
552 "or can't be converted to a string", field_name);
556 GST_DEBUG_OBJECT (src, "Appending extra header: \"%s: %s\"", field_name,
558 soup_message_headers_append (src->msg->request_headers, field_name,
561 g_free (field_content);
567 _append_extra_headers (GQuark field_id, const GValue * value,
570 if (G_VALUE_TYPE (value) == GST_TYPE_ARRAY) {
571 guint n = gst_value_array_get_size (value);
574 for (i = 0; i < n; i++) {
575 const GValue *v = gst_value_array_get_value (value, i);
577 if (!_append_extra_header (field_id, v, user_data))
580 } else if (G_VALUE_TYPE (value) == GST_TYPE_LIST) {
581 guint n = gst_value_list_get_size (value);
584 for (i = 0; i < n; i++) {
585 const GValue *v = gst_value_list_get_value (value, i);
587 if (!_append_extra_header (field_id, v, user_data))
591 return _append_extra_header (field_id, value, user_data);
599 gst_soup_http_src_add_extra_headers (GstSoupHTTPSrc * src)
601 if (!src->extra_headers)
604 return gst_structure_foreach (src->extra_headers, _append_extra_headers, src);
609 gst_soup_http_src_session_unpause_message (GstSoupHTTPSrc * src)
611 soup_session_unpause_message (src->session, src->msg);
615 gst_soup_http_src_session_pause_message (GstSoupHTTPSrc * src)
617 soup_session_pause_message (src->session, src->msg);
621 gst_soup_http_src_session_close (GstSoupHTTPSrc * src)
624 soup_session_abort (src->session); /* This unrefs the message. */
625 g_object_unref (src->session);
632 gst_soup_http_src_authenticate_cb (SoupSession * session, SoupMessage * msg,
633 SoupAuth * auth, gboolean retrying, GstSoupHTTPSrc * src)
636 /* First time authentication only, if we fail and are called again with retry true fall through */
637 if (msg->status_code == SOUP_STATUS_UNAUTHORIZED) {
638 if (src->user_id && src->user_pw)
639 soup_auth_authenticate (auth, src->user_id, src->user_pw);
640 } else if (msg->status_code == SOUP_STATUS_PROXY_AUTHENTICATION_REQUIRED) {
641 if (src->proxy_id && src->proxy_pw)
642 soup_auth_authenticate (auth, src->proxy_id, src->proxy_pw);
648 gst_soup_http_src_headers_foreach (const gchar * name, const gchar * val,
651 GST_DEBUG_OBJECT (src, " %s: %s", name, val);
655 gst_soup_http_src_got_headers_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
658 GstTagList *tag_list;
661 GHashTable *params = NULL;
663 GST_DEBUG_OBJECT (src, "got headers:");
664 soup_message_headers_foreach (msg->response_headers,
665 gst_soup_http_src_headers_foreach, src);
667 if (msg->status_code == 407 && src->proxy_id && src->proxy_pw)
670 if (src->automatic_redirect && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
671 GST_DEBUG_OBJECT (src, "%u redirect to \"%s\"", msg->status_code,
672 soup_message_headers_get_one (msg->response_headers, "Location"));
676 if (msg->status_code == SOUP_STATUS_UNAUTHORIZED)
679 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING;
681 /* Parse Content-Length. */
682 if (soup_message_headers_get_encoding (msg->response_headers) ==
683 SOUP_ENCODING_CONTENT_LENGTH) {
684 newsize = src->request_position +
685 soup_message_headers_get_content_length (msg->response_headers);
686 if (!src->have_size || (src->content_size != newsize)) {
687 src->content_size = newsize;
688 src->have_size = TRUE;
689 src->seekable = TRUE;
690 GST_DEBUG_OBJECT (src, "size = %" G_GUINT64_FORMAT, src->content_size);
692 basesrc = GST_BASE_SRC_CAST (src);
693 basesrc->segment.duration = src->content_size;
694 gst_element_post_message (GST_ELEMENT (src),
695 gst_message_new_duration_changed (GST_OBJECT (src)));
700 tag_list = gst_tag_list_new_empty ();
703 soup_message_headers_get_one (msg->response_headers,
704 "icy-metaint")) != NULL) {
705 gint icy_metaint = atoi (value);
707 GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, icy_metaint);
708 if (icy_metaint > 0) {
710 gst_caps_unref (src->src_caps);
712 src->src_caps = gst_caps_new_simple ("application/x-icy",
713 "metadata-interval", G_TYPE_INT, icy_metaint, NULL);
715 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
719 soup_message_headers_get_content_type (msg->response_headers,
721 GST_DEBUG_OBJECT (src, "Content-Type: %s", value);
722 if (g_ascii_strcasecmp (value, "audio/L16") == 0) {
728 gst_caps_unref (src->src_caps);
730 param = g_hash_table_lookup (params, "channels");
732 channels = atol (param);
734 param = g_hash_table_lookup (params, "rate");
738 src->src_caps = gst_caps_new_simple ("audio/x-raw",
739 "format", G_TYPE_STRING, "S16BE",
740 "layout", G_TYPE_STRING, "interleaved",
741 "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
743 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
745 /* Set the Content-Type field on the caps */
747 src->src_caps = gst_caps_make_writable (src->src_caps);
748 gst_caps_set_simple (src->src_caps, "content-type", G_TYPE_STRING,
750 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
756 g_hash_table_destroy (params);
759 soup_message_headers_get_one (msg->response_headers,
760 "icy-name")) != NULL) {
761 g_free (src->iradio_name);
762 src->iradio_name = gst_soup_http_src_unicodify (value);
763 if (src->iradio_name) {
764 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION,
765 src->iradio_name, NULL);
769 soup_message_headers_get_one (msg->response_headers,
770 "icy-genre")) != NULL) {
771 g_free (src->iradio_genre);
772 src->iradio_genre = gst_soup_http_src_unicodify (value);
773 if (src->iradio_genre) {
774 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
775 src->iradio_genre, NULL);
778 if ((value = soup_message_headers_get_one (msg->response_headers, "icy-url"))
780 g_free (src->iradio_url);
781 src->iradio_url = gst_soup_http_src_unicodify (value);
782 if (src->iradio_url) {
783 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION,
784 src->iradio_url, NULL);
787 if (!gst_tag_list_is_empty (tag_list)) {
788 GST_DEBUG_OBJECT (src,
789 "calling gst_element_found_tags with %" GST_PTR_FORMAT, tag_list);
790 gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tag_list));
792 gst_tag_list_unref (tag_list);
795 /* Handle HTTP errors. */
796 gst_soup_http_src_parse_status (msg, src);
798 /* Check if Range header was respected. */
799 if (src->ret == GST_FLOW_CUSTOM_ERROR &&
800 src->read_position && msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) {
801 src->seekable = FALSE;
802 GST_ELEMENT_ERROR (src, RESOURCE, SEEK,
803 (_("Server does not support seeking.")),
804 ("Server does not accept Range HTTP header, URL: %s", src->location));
805 src->ret = GST_FLOW_ERROR;
809 /* Have body. Signal EOS. */
811 gst_soup_http_src_got_body_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
813 if (G_UNLIKELY (msg != src->msg)) {
814 GST_DEBUG_OBJECT (src, "got body, but not for current message");
817 if (G_UNLIKELY (src->session_io_status !=
818 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
819 /* Probably a redirect. */
822 GST_DEBUG_OBJECT (src, "got body");
823 src->ret = GST_FLOW_EOS;
825 g_main_loop_quit (src->loop);
826 gst_soup_http_src_session_pause_message (src);
829 /* Finished. Signal EOS. */
831 gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
833 if (G_UNLIKELY (msg != src->msg)) {
834 GST_DEBUG_OBJECT (src, "finished, but not for current message");
837 GST_DEBUG_OBJECT (src, "finished");
838 src->ret = GST_FLOW_EOS;
839 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED) {
840 /* gst_soup_http_src_cancel_message() triggered this; probably a seek
841 * that occurred in the QUEUEING state; i.e. before the connection setup
842 * was complete. Do nothing */
843 } else if (src->session_io_status ==
844 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING && src->read_position > 0) {
845 /* The server disconnected while streaming. Reconnect and seeking to the
848 src->ret = GST_FLOW_CUSTOM_ERROR;
849 } else if (G_UNLIKELY (src->session_io_status !=
850 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
851 /* FIXME: reason_phrase is not translated, add proper error message */
852 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
853 ("%s", msg->reason_phrase),
854 ("libsoup status code %d", msg->status_code));
857 g_main_loop_quit (src->loop);
860 /* Buffer lifecycle management.
862 * gst_soup_http_src_create() runs the GMainLoop for this element, to let
864 * A GstBuffer is allocated in gst_soup_http_src_chunk_allocator() and
865 * associated with a SoupBuffer.
866 * Soup reads HTTP data in the GstBuffer's data buffer.
867 * The gst_soup_http_src_got_chunk_cb() is then called with the SoupBuffer.
868 * That sets gst_soup_http_src_create()'s return argument to the GstBuffer,
869 * increments its refcount (to 2), pauses the flow of data from the HTTP
870 * source to prevent gst_soup_http_src_got_chunk_cb() from being called
871 * again and breaks out of the GMainLoop.
872 * Because the SOUP_MESSAGE_OVERWRITE_CHUNKS flag is set, Soup frees the
873 * SoupBuffer and calls gst_soup_http_src_chunk_free(), which decrements the
875 * gst_soup_http_src_create() returns the GstBuffer. It will be freed by a
876 * downstream element.
877 * If Soup fails to read HTTP data, it does not call
878 * gst_soup_http_src_got_chunk_cb(), but still frees the SoupBuffer and
879 * calls gst_soup_http_src_chunk_free(), which decrements the GstBuffer's
880 * refcount to 0, freeing it.
890 gst_soup_http_src_chunk_free (gpointer user_data)
892 SoupGstChunk *chunk = (SoupGstChunk *) user_data;
894 gst_buffer_unmap (chunk->buffer, &chunk->map);
895 gst_buffer_unref (chunk->buffer);
896 g_slice_free (SoupGstChunk, chunk);
900 gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
903 GstSoupHTTPSrc *src = (GstSoupHTTPSrc *) user_data;
904 GstBaseSrc *basesrc = GST_BASE_SRC_CAST (src);
912 length = MIN (basesrc->blocksize, max_len);
914 length = basesrc->blocksize;
915 GST_DEBUG_OBJECT (src, "alloc %" G_GSIZE_FORMAT " bytes <= %" G_GSIZE_FORMAT,
918 rc = GST_BASE_SRC_CLASS (parent_class)->alloc (basesrc, -1, length, &gstbuf);
919 if (G_UNLIKELY (rc != GST_FLOW_OK)) {
920 /* Failed to allocate buffer. Stall SoupSession and return error code
923 g_main_loop_quit (src->loop);
927 chunk = g_slice_new0 (SoupGstChunk);
928 chunk->buffer = gstbuf;
929 gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
931 soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
932 chunk, gst_soup_http_src_chunk_free);
938 gst_soup_http_src_got_chunk_cb (SoupMessage * msg, SoupBuffer * chunk,
939 GstSoupHTTPSrc * src)
942 guint64 new_position;
943 SoupGstChunk *gchunk;
945 if (G_UNLIKELY (msg != src->msg)) {
946 GST_DEBUG_OBJECT (src, "got chunk, but not for current message");
949 if (G_UNLIKELY (src->session_io_status !=
950 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
951 /* Probably a redirect. */
954 basesrc = GST_BASE_SRC_CAST (src);
955 GST_DEBUG_OBJECT (src, "got chunk of %" G_GSIZE_FORMAT " bytes",
958 /* Extract the GstBuffer from the SoupBuffer and set its fields. */
959 gchunk = (SoupGstChunk *) soup_buffer_get_owner (chunk);
960 *src->outbuf = gchunk->buffer;
962 gst_buffer_resize (*src->outbuf, 0, chunk->length);
963 GST_BUFFER_OFFSET (*src->outbuf) = basesrc->segment.position;
965 gst_buffer_ref (*src->outbuf);
967 new_position = src->read_position + chunk->length;
968 if (G_LIKELY (src->request_position == src->read_position))
969 src->request_position = new_position;
970 src->read_position = new_position;
972 src->ret = GST_FLOW_OK;
973 g_main_loop_quit (src->loop);
974 gst_soup_http_src_session_pause_message (src);
978 gst_soup_http_src_response_cb (SoupSession * session, SoupMessage * msg,
979 GstSoupHTTPSrc * src)
981 if (G_UNLIKELY (msg != src->msg)) {
982 GST_DEBUG_OBJECT (src, "got response %d: %s, but not for current message",
983 msg->status_code, msg->reason_phrase);
986 if (G_UNLIKELY (src->session_io_status !=
987 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)
988 && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
989 /* Ignore redirections. */
992 GST_DEBUG_OBJECT (src, "got response %d: %s", msg->status_code,
994 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING &&
995 src->read_position > 0) {
996 /* The server disconnected while streaming. Reconnect and seeking to the
1000 gst_soup_http_src_parse_status (msg, src);
1001 /* The session's SoupMessage object expires after this callback returns. */
1003 g_main_loop_quit (src->loop);
1006 #define SOUP_HTTP_SRC_ERROR(src,soup_msg,cat,code,error_message) \
1007 GST_ELEMENT_ERROR ((src), cat, code, ("%s", error_message), \
1008 ("%s (%d), URL: %s", (soup_msg)->reason_phrase, \
1009 (soup_msg)->status_code, (src)->location));
1012 gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src)
1014 if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) {
1015 switch (msg->status_code) {
1016 case SOUP_STATUS_CANT_RESOLVE:
1017 case SOUP_STATUS_CANT_RESOLVE_PROXY:
1018 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND,
1019 _("Could not resolve server name."));
1020 src->ret = GST_FLOW_ERROR;
1022 case SOUP_STATUS_CANT_CONNECT:
1023 case SOUP_STATUS_CANT_CONNECT_PROXY:
1024 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1025 _("Could not establish connection to server."));
1026 src->ret = GST_FLOW_ERROR;
1028 case SOUP_STATUS_SSL_FAILED:
1029 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1030 _("Secure connection setup failed."));
1031 src->ret = GST_FLOW_ERROR;
1033 case SOUP_STATUS_IO_ERROR:
1034 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1035 _("A network error occured, or the server closed the connection "
1037 src->ret = GST_FLOW_ERROR;
1039 case SOUP_STATUS_MALFORMED:
1040 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1041 _("Server sent bad data."));
1042 src->ret = GST_FLOW_ERROR;
1044 case SOUP_STATUS_CANCELLED:
1045 /* No error message when interrupted by program. */
1048 } else if (SOUP_STATUS_IS_CLIENT_ERROR (msg->status_code) ||
1049 SOUP_STATUS_IS_REDIRECTION (msg->status_code) ||
1050 SOUP_STATUS_IS_SERVER_ERROR (msg->status_code)) {
1051 /* Report HTTP error. */
1052 /* FIXME: reason_phrase is not translated and not suitable for user
1053 * error dialog according to libsoup documentation.
1054 * FIXME: error code (OPEN_READ vs. READ) should depend on http status? */
1055 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1056 ("%s", msg->reason_phrase),
1057 ("%s (%d), URL: %s", msg->reason_phrase, msg->status_code,
1059 src->ret = GST_FLOW_ERROR;
1064 gst_soup_http_src_build_message (GstSoupHTTPSrc * src)
1066 src->msg = soup_message_new (SOUP_METHOD_GET, src->location);
1068 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1069 ("Error parsing URL."), ("URL: %s", src->location));
1072 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
1073 soup_message_headers_append (src->msg->request_headers, "Connection",
1075 soup_message_headers_append (src->msg->request_headers, "icy-metadata", "1");
1080 for (cookie = src->cookies; *cookie != NULL; cookie++) {
1081 soup_message_headers_append (src->msg->request_headers, "Cookie",
1087 g_signal_connect (src->msg, "got_headers",
1088 G_CALLBACK (gst_soup_http_src_got_headers_cb), src);
1089 g_signal_connect (src->msg, "got_body",
1090 G_CALLBACK (gst_soup_http_src_got_body_cb), src);
1091 g_signal_connect (src->msg, "finished",
1092 G_CALLBACK (gst_soup_http_src_finished_cb), src);
1093 g_signal_connect (src->msg, "got_chunk",
1094 G_CALLBACK (gst_soup_http_src_got_chunk_cb), src);
1095 soup_message_set_flags (src->msg, SOUP_MESSAGE_OVERWRITE_CHUNKS |
1096 (src->automatic_redirect ? 0 : SOUP_MESSAGE_NO_REDIRECT));
1097 soup_message_set_chunk_allocator (src->msg,
1098 gst_soup_http_src_chunk_allocator, src, NULL);
1099 gst_soup_http_src_add_range_header (src, src->request_position);
1101 gst_soup_http_src_add_extra_headers (src);
1103 GST_DEBUG_OBJECT (src, "request headers:");
1104 soup_message_headers_foreach (src->msg->request_headers,
1105 gst_soup_http_src_headers_foreach, src);
1110 static GstFlowReturn
1111 gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
1113 GstSoupHTTPSrc *src;
1115 src = GST_SOUP_HTTP_SRC (psrc);
1117 if (src->msg && (src->request_position != src->read_position)) {
1118 if (src->content_size != 0 && src->request_position >= src->content_size) {
1119 GST_WARNING_OBJECT (src, "Seeking behind the end of file -- EOS");
1120 return GST_FLOW_EOS;
1121 } else if (src->session_io_status ==
1122 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) {
1123 gst_soup_http_src_add_range_header (src, src->request_position);
1125 GST_DEBUG_OBJECT (src, "Seek from position %" G_GUINT64_FORMAT
1126 " to %" G_GUINT64_FORMAT ": requeueing connection request",
1127 src->read_position, src->request_position);
1128 gst_soup_http_src_cancel_message (src);
1132 if (!gst_soup_http_src_build_message (src))
1133 return GST_FLOW_ERROR;
1135 src->ret = GST_FLOW_CUSTOM_ERROR;
1136 src->outbuf = outbuf;
1138 if (src->interrupted) {
1139 GST_DEBUG_OBJECT (src, "interrupted");
1143 GST_DEBUG_OBJECT (src, "Reconnecting");
1144 if (!gst_soup_http_src_build_message (src))
1145 return GST_FLOW_ERROR;
1150 GST_DEBUG_OBJECT (src, "EOS reached");
1154 switch (src->session_io_status) {
1155 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE:
1156 GST_DEBUG_OBJECT (src, "Queueing connection request");
1157 gst_soup_http_src_queue_message (src);
1159 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED:
1161 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING:
1162 gst_soup_http_src_session_unpause_message (src);
1164 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED:
1169 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1170 g_main_loop_run (src->loop);
1171 } while (src->ret == GST_FLOW_CUSTOM_ERROR);
1173 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1174 src->ret = GST_FLOW_EOS;
1179 gst_soup_http_src_start (GstBaseSrc * bsrc)
1181 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1183 GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location);
1185 if (!src->location) {
1186 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (_("No URL set.")),
1187 ("Missing location property"));
1191 src->context = g_main_context_new ();
1193 src->loop = g_main_loop_new (src->context, TRUE);
1195 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1196 (NULL), ("Failed to start GMainLoop"));
1197 g_main_context_unref (src->context);
1201 if (src->proxy == NULL) {
1203 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1204 src->context, SOUP_SESSION_USER_AGENT, src->user_agent,
1205 SOUP_SESSION_TIMEOUT, src->timeout,
1206 #ifdef HAVE_LIBSOUP_GNOME
1207 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_GNOME,
1212 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1213 src->context, SOUP_SESSION_PROXY_URI, src->proxy,
1214 SOUP_SESSION_TIMEOUT, src->timeout,
1215 SOUP_SESSION_USER_AGENT, src->user_agent, NULL);
1218 if (!src->session) {
1219 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1220 (NULL), ("Failed to create async session"));
1224 g_signal_connect (src->session, "authenticate",
1225 G_CALLBACK (gst_soup_http_src_authenticate_cb), src);
1230 gst_soup_http_src_stop (GstBaseSrc * bsrc)
1232 GstSoupHTTPSrc *src;
1234 src = GST_SOUP_HTTP_SRC (bsrc);
1235 GST_DEBUG_OBJECT (src, "stop()");
1236 gst_soup_http_src_session_close (src);
1238 g_main_loop_unref (src->loop);
1239 g_main_context_unref (src->context);
1241 src->context = NULL;
1243 if (src->extra_headers) {
1244 gst_structure_free (src->extra_headers);
1245 src->extra_headers = NULL;
1248 gst_soup_http_src_reset (src);
1252 /* Interrupt a blocking request. */
1254 gst_soup_http_src_unlock (GstBaseSrc * bsrc)
1256 GstSoupHTTPSrc *src;
1258 src = GST_SOUP_HTTP_SRC (bsrc);
1259 GST_DEBUG_OBJECT (src, "unlock()");
1261 src->interrupted = TRUE;
1263 g_main_loop_quit (src->loop);
1267 /* Interrupt interrupt. */
1269 gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc)
1271 GstSoupHTTPSrc *src;
1273 src = GST_SOUP_HTTP_SRC (bsrc);
1274 GST_DEBUG_OBJECT (src, "unlock_stop()");
1276 src->interrupted = FALSE;
1281 gst_soup_http_src_get_size (GstBaseSrc * bsrc, guint64 * size)
1283 GstSoupHTTPSrc *src;
1285 src = GST_SOUP_HTTP_SRC (bsrc);
1287 if (src->have_size) {
1288 GST_DEBUG_OBJECT (src, "get_size() = %" G_GUINT64_FORMAT,
1290 *size = src->content_size;
1293 GST_DEBUG_OBJECT (src, "get_size() = FALSE");
1298 gst_soup_http_src_is_seekable (GstBaseSrc * bsrc)
1300 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1302 return src->seekable;
1306 gst_soup_http_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
1308 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1310 GST_DEBUG_OBJECT (src, "do_seek(%" G_GUINT64_FORMAT ")", segment->start);
1312 if (src->read_position == segment->start &&
1313 src->request_position == src->read_position) {
1314 GST_DEBUG_OBJECT (src, "Seek to current read position and no seek pending");
1318 if (!src->seekable) {
1319 GST_WARNING_OBJECT (src, "Not seekable");
1323 if (segment->rate < 0.0 || segment->format != GST_FORMAT_BYTES) {
1324 GST_WARNING_OBJECT (src, "Invalid seek segment");
1328 if (src->content_size != 0 && segment->start >= src->content_size) {
1329 GST_WARNING_OBJECT (src, "Seeking behind end of file, will go to EOS soon");
1332 /* Wait for create() to handle the jump in offset. */
1333 src->request_position = segment->start;
1338 gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
1340 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1343 switch (GST_QUERY_TYPE (query)) {
1345 gst_query_set_uri (query, src->location);
1354 ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
1360 gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri,
1363 const char *alt_schemes[] = { "icy://", "icyx://" };
1366 if (src->location) {
1367 g_free (src->location);
1368 src->location = NULL;
1374 for (i = 0; i < G_N_ELEMENTS (alt_schemes); i++) {
1375 if (g_str_has_prefix (uri, alt_schemes[i])) {
1377 g_strdup_printf ("http://%s", uri + strlen (alt_schemes[i]));
1382 src->location = g_strdup (uri);
1388 gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
1391 soup_uri_free (src->proxy);
1394 if (g_str_has_prefix (uri, "http://")) {
1395 src->proxy = soup_uri_new (uri);
1397 gchar *new_uri = g_strconcat ("http://", uri, NULL);
1399 src->proxy = soup_uri_new (new_uri);
1407 gst_soup_http_src_uri_get_type (GType type)
1412 static const gchar *const *
1413 gst_soup_http_src_uri_get_protocols (GType type)
1415 static const gchar *protocols[] = { "http", "https", "icy", "icyx", NULL };
1421 gst_soup_http_src_uri_get_uri (GstURIHandler * handler)
1423 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1425 /* FIXME: make thread-safe */
1426 return g_strdup (src->location);
1430 gst_soup_http_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
1433 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1435 return gst_soup_http_src_set_location (src, uri, error);
1439 gst_soup_http_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1441 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1443 iface->get_type = gst_soup_http_src_uri_get_type;
1444 iface->get_protocols = gst_soup_http_src_uri_get_protocols;
1445 iface->get_uri = gst_soup_http_src_uri_get_uri;
1446 iface->set_uri = gst_soup_http_src_uri_set_uri;