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 -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 -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 -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 (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 (GST_OBJECT (src), GST_FORMAT_BYTES,
701 tag_list = gst_tag_list_new_empty ();
704 soup_message_headers_get (msg->response_headers,
705 "icy-metaint")) != NULL) {
706 gint icy_metaint = atoi (value);
708 GST_DEBUG_OBJECT (src, "icy-metaint: %s (parsed: %d)", value, icy_metaint);
709 if (icy_metaint > 0) {
711 gst_caps_unref (src->src_caps);
713 src->src_caps = gst_caps_new_simple ("application/x-icy",
714 "metadata-interval", G_TYPE_INT, icy_metaint, NULL);
716 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
720 soup_message_headers_get_content_type (msg->response_headers,
722 GST_DEBUG_OBJECT (src, "Content-Type: %s", value);
723 if (g_ascii_strcasecmp (value, "audio/L16") == 0) {
729 gst_caps_unref (src->src_caps);
731 param = g_hash_table_lookup (params, "channels");
733 channels = atol (param);
735 param = g_hash_table_lookup (params, "rate");
739 src->src_caps = gst_caps_new_simple ("audio/x-raw",
740 "format", G_TYPE_STRING, "S16BE",
741 "layout", G_TYPE_STRING, "interleaved",
742 "channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
744 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
746 /* Set the Content-Type field on the caps */
748 src->src_caps = gst_caps_make_writable (src->src_caps);
749 gst_caps_set_simple (src->src_caps, "content-type", G_TYPE_STRING,
751 gst_base_src_set_caps (GST_BASE_SRC (src), src->src_caps);
757 g_hash_table_destroy (params);
760 soup_message_headers_get (msg->response_headers,
761 "icy-name")) != NULL) {
762 g_free (src->iradio_name);
763 src->iradio_name = gst_soup_http_src_unicodify (value);
764 if (src->iradio_name) {
765 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_ORGANIZATION,
766 src->iradio_name, NULL);
770 soup_message_headers_get (msg->response_headers,
771 "icy-genre")) != NULL) {
772 g_free (src->iradio_genre);
773 src->iradio_genre = gst_soup_http_src_unicodify (value);
774 if (src->iradio_genre) {
775 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_GENRE,
776 src->iradio_genre, NULL);
779 if ((value = soup_message_headers_get (msg->response_headers, "icy-url"))
781 g_free (src->iradio_url);
782 src->iradio_url = gst_soup_http_src_unicodify (value);
783 if (src->iradio_url) {
784 gst_tag_list_add (tag_list, GST_TAG_MERGE_REPLACE, GST_TAG_LOCATION,
785 src->iradio_url, NULL);
788 if (!gst_tag_list_is_empty (tag_list)) {
789 GST_DEBUG_OBJECT (src,
790 "calling gst_element_found_tags with %" GST_PTR_FORMAT, tag_list);
791 gst_pad_push_event (GST_BASE_SRC_PAD (src), gst_event_new_tag (tag_list));
793 gst_tag_list_free (tag_list);
796 /* Handle HTTP errors. */
797 gst_soup_http_src_parse_status (msg, src);
799 /* Check if Range header was respected. */
800 if (src->ret == GST_FLOW_CUSTOM_ERROR &&
801 src->read_position && msg->status_code != SOUP_STATUS_PARTIAL_CONTENT) {
802 src->seekable = FALSE;
803 GST_ELEMENT_ERROR (src, RESOURCE, SEEK,
804 (_("Server does not support seeking.")),
805 ("Server does not accept Range HTTP header, URL: %s", src->location));
806 src->ret = GST_FLOW_ERROR;
810 /* Have body. Signal EOS. */
812 gst_soup_http_src_got_body_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
814 if (G_UNLIKELY (msg != src->msg)) {
815 GST_DEBUG_OBJECT (src, "got body, but not for current message");
818 if (G_UNLIKELY (src->session_io_status !=
819 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
820 /* Probably a redirect. */
823 GST_DEBUG_OBJECT (src, "got body");
824 src->ret = GST_FLOW_EOS;
826 g_main_loop_quit (src->loop);
827 gst_soup_http_src_session_pause_message (src);
830 /* Finished. Signal EOS. */
832 gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
834 if (G_UNLIKELY (msg != src->msg)) {
835 GST_DEBUG_OBJECT (src, "finished, but not for current message");
838 GST_DEBUG_OBJECT (src, "finished");
839 src->ret = GST_FLOW_EOS;
840 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED) {
841 /* gst_soup_http_src_cancel_message() triggered this; probably a seek
842 * that occurred in the QUEUEING state; i.e. before the connection setup
843 * was complete. Do nothing */
844 } else if (src->session_io_status ==
845 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING && src->read_position > 0) {
846 /* The server disconnected while streaming. Reconnect and seeking to the
849 src->ret = GST_FLOW_CUSTOM_ERROR;
850 } else if (G_UNLIKELY (src->session_io_status !=
851 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
852 /* FIXME: reason_phrase is not translated, add proper error message */
853 GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
854 ("%s", msg->reason_phrase),
855 ("libsoup status code %d", msg->status_code));
858 g_main_loop_quit (src->loop);
861 /* Buffer lifecycle management.
863 * gst_soup_http_src_create() runs the GMainLoop for this element, to let
865 * A GstBuffer is allocated in gst_soup_http_src_chunk_allocator() and
866 * associated with a SoupBuffer.
867 * Soup reads HTTP data in the GstBuffer's data buffer.
868 * The gst_soup_http_src_got_chunk_cb() is then called with the SoupBuffer.
869 * That sets gst_soup_http_src_create()'s return argument to the GstBuffer,
870 * increments its refcount (to 2), pauses the flow of data from the HTTP
871 * source to prevent gst_soup_http_src_got_chunk_cb() from being called
872 * again and breaks out of the GMainLoop.
873 * Because the SOUP_MESSAGE_OVERWRITE_CHUNKS flag is set, Soup frees the
874 * SoupBuffer and calls gst_soup_http_src_chunk_free(), which decrements the
876 * gst_soup_http_src_create() returns the GstBuffer. It will be freed by a
877 * downstream element.
878 * If Soup fails to read HTTP data, it does not call
879 * gst_soup_http_src_got_chunk_cb(), but still frees the SoupBuffer and
880 * calls gst_soup_http_src_chunk_free(), which decrements the GstBuffer's
881 * refcount to 0, freeing it.
891 gst_soup_http_src_chunk_free (gpointer user_data)
893 SoupGstChunk *chunk = (SoupGstChunk *) user_data;
895 gst_buffer_unmap (chunk->buffer, &chunk->map);
896 gst_buffer_unref (chunk->buffer);
897 g_slice_free (SoupGstChunk, chunk);
901 gst_soup_http_src_chunk_allocator (SoupMessage * msg, gsize max_len,
904 GstSoupHTTPSrc *src = (GstSoupHTTPSrc *) user_data;
905 GstBaseSrc *basesrc = GST_BASE_SRC_CAST (src);
913 length = MIN (basesrc->blocksize, max_len);
915 length = basesrc->blocksize;
916 GST_DEBUG_OBJECT (src, "alloc %" G_GSIZE_FORMAT " bytes <= %" G_GSIZE_FORMAT,
919 rc = GST_BASE_SRC_CLASS (parent_class)->alloc (basesrc, -1, length, &gstbuf);
920 if (G_UNLIKELY (rc != GST_FLOW_OK)) {
921 /* Failed to allocate buffer. Stall SoupSession and return error code
924 g_main_loop_quit (src->loop);
928 chunk = g_slice_new0 (SoupGstChunk);
929 chunk->buffer = gstbuf;
930 gst_buffer_map (gstbuf, &chunk->map, GST_MAP_READWRITE);
932 soupbuf = soup_buffer_new_with_owner (chunk->map.data, chunk->map.size,
933 chunk, gst_soup_http_src_chunk_free);
939 gst_soup_http_src_got_chunk_cb (SoupMessage * msg, SoupBuffer * chunk,
940 GstSoupHTTPSrc * src)
943 guint64 new_position;
944 SoupGstChunk *gchunk;
946 if (G_UNLIKELY (msg != src->msg)) {
947 GST_DEBUG_OBJECT (src, "got chunk, but not for current message");
950 if (G_UNLIKELY (src->session_io_status !=
951 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
952 /* Probably a redirect. */
955 basesrc = GST_BASE_SRC_CAST (src);
956 GST_DEBUG_OBJECT (src, "got chunk of %" G_GSIZE_FORMAT " bytes",
959 /* Extract the GstBuffer from the SoupBuffer and set its fields. */
960 gchunk = (SoupGstChunk *) soup_buffer_get_owner (chunk);
961 *src->outbuf = gchunk->buffer;
963 gst_buffer_resize (*src->outbuf, 0, chunk->length);
964 GST_BUFFER_OFFSET (*src->outbuf) = basesrc->segment.position;
966 gst_buffer_ref (*src->outbuf);
968 new_position = src->read_position + chunk->length;
969 if (G_LIKELY (src->request_position == src->read_position))
970 src->request_position = new_position;
971 src->read_position = new_position;
973 src->ret = GST_FLOW_OK;
974 g_main_loop_quit (src->loop);
975 gst_soup_http_src_session_pause_message (src);
979 gst_soup_http_src_response_cb (SoupSession * session, SoupMessage * msg,
980 GstSoupHTTPSrc * src)
982 if (G_UNLIKELY (msg != src->msg)) {
983 GST_DEBUG_OBJECT (src, "got response %d: %s, but not for current message",
984 msg->status_code, msg->reason_phrase);
987 if (G_UNLIKELY (src->session_io_status !=
988 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)
989 && SOUP_STATUS_IS_REDIRECTION (msg->status_code)) {
990 /* Ignore redirections. */
993 GST_DEBUG_OBJECT (src, "got response %d: %s", msg->status_code,
995 if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING &&
996 src->read_position > 0) {
997 /* The server disconnected while streaming. Reconnect and seeking to the
1001 gst_soup_http_src_parse_status (msg, src);
1002 /* The session's SoupMessage object expires after this callback returns. */
1004 g_main_loop_quit (src->loop);
1007 #define SOUP_HTTP_SRC_ERROR(src,soup_msg,cat,code,error_message) \
1008 GST_ELEMENT_ERROR ((src), cat, code, ("%s", error_message), \
1009 ("%s (%d), URL: %s", (soup_msg)->reason_phrase, \
1010 (soup_msg)->status_code, (src)->location));
1013 gst_soup_http_src_parse_status (SoupMessage * msg, GstSoupHTTPSrc * src)
1015 if (SOUP_STATUS_IS_TRANSPORT_ERROR (msg->status_code)) {
1016 switch (msg->status_code) {
1017 case SOUP_STATUS_CANT_RESOLVE:
1018 case SOUP_STATUS_CANT_RESOLVE_PROXY:
1019 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, NOT_FOUND,
1020 _("Could not resolve server name."));
1021 src->ret = GST_FLOW_ERROR;
1023 case SOUP_STATUS_CANT_CONNECT:
1024 case SOUP_STATUS_CANT_CONNECT_PROXY:
1025 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1026 _("Could not establish connection to server."));
1027 src->ret = GST_FLOW_ERROR;
1029 case SOUP_STATUS_SSL_FAILED:
1030 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, OPEN_READ,
1031 _("Secure connection setup failed."));
1032 src->ret = GST_FLOW_ERROR;
1034 case SOUP_STATUS_IO_ERROR:
1035 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1036 _("A network error occured, or the server closed the connection "
1038 src->ret = GST_FLOW_ERROR;
1040 case SOUP_STATUS_MALFORMED:
1041 SOUP_HTTP_SRC_ERROR (src, msg, RESOURCE, READ,
1042 _("Server sent bad data."));
1043 src->ret = GST_FLOW_ERROR;
1045 case SOUP_STATUS_CANCELLED:
1046 /* No error message when interrupted by program. */
1049 } else if (SOUP_STATUS_IS_CLIENT_ERROR (msg->status_code) ||
1050 SOUP_STATUS_IS_REDIRECTION (msg->status_code) ||
1051 SOUP_STATUS_IS_SERVER_ERROR (msg->status_code)) {
1052 /* Report HTTP error. */
1053 /* FIXME: reason_phrase is not translated and not suitable for user
1054 * error dialog according to libsoup documentation.
1055 * FIXME: error code (OPEN_READ vs. READ) should depend on http status? */
1056 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1057 ("%s", msg->reason_phrase),
1058 ("%s (%d), URL: %s", msg->reason_phrase, msg->status_code,
1060 src->ret = GST_FLOW_ERROR;
1065 gst_soup_http_src_build_message (GstSoupHTTPSrc * src)
1067 src->msg = soup_message_new (SOUP_METHOD_GET, src->location);
1069 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
1070 ("Error parsing URL."), ("URL: %s", src->location));
1073 src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
1074 soup_message_headers_append (src->msg->request_headers, "Connection",
1076 soup_message_headers_append (src->msg->request_headers, "icy-metadata", "1");
1081 for (cookie = src->cookies; *cookie != NULL; cookie++) {
1082 soup_message_headers_append (src->msg->request_headers, "Cookie",
1086 soup_message_headers_append (src->msg->request_headers,
1087 "transferMode.dlna.org", "Streaming");
1090 g_signal_connect (src->msg, "got_headers",
1091 G_CALLBACK (gst_soup_http_src_got_headers_cb), src);
1092 g_signal_connect (src->msg, "got_body",
1093 G_CALLBACK (gst_soup_http_src_got_body_cb), src);
1094 g_signal_connect (src->msg, "finished",
1095 G_CALLBACK (gst_soup_http_src_finished_cb), src);
1096 g_signal_connect (src->msg, "got_chunk",
1097 G_CALLBACK (gst_soup_http_src_got_chunk_cb), src);
1098 soup_message_set_flags (src->msg, SOUP_MESSAGE_OVERWRITE_CHUNKS |
1099 (src->automatic_redirect ? 0 : SOUP_MESSAGE_NO_REDIRECT));
1100 soup_message_set_chunk_allocator (src->msg,
1101 gst_soup_http_src_chunk_allocator, src, NULL);
1102 gst_soup_http_src_add_range_header (src, src->request_position);
1104 gst_soup_http_src_add_extra_headers (src);
1106 GST_DEBUG_OBJECT (src, "request headers:");
1107 soup_message_headers_foreach (src->msg->request_headers,
1108 gst_soup_http_src_headers_foreach, src);
1113 static GstFlowReturn
1114 gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
1116 GstSoupHTTPSrc *src;
1118 src = GST_SOUP_HTTP_SRC (psrc);
1120 if (src->msg && (src->request_position != src->read_position)) {
1121 if (src->content_size != 0 && src->request_position >= src->content_size) {
1122 GST_WARNING_OBJECT (src, "Seeking behind the end of file -- EOS");
1123 return GST_FLOW_EOS;
1124 } else if (src->session_io_status ==
1125 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE) {
1126 gst_soup_http_src_add_range_header (src, src->request_position);
1128 GST_DEBUG_OBJECT (src, "Seek from position %" G_GUINT64_FORMAT
1129 " to %" G_GUINT64_FORMAT ": requeueing connection request",
1130 src->read_position, src->request_position);
1131 gst_soup_http_src_cancel_message (src);
1135 if (!gst_soup_http_src_build_message (src))
1136 return GST_FLOW_ERROR;
1138 src->ret = GST_FLOW_CUSTOM_ERROR;
1139 src->outbuf = outbuf;
1141 if (src->interrupted) {
1142 GST_DEBUG_OBJECT (src, "interrupted");
1146 GST_DEBUG_OBJECT (src, "Reconnecting");
1147 if (!gst_soup_http_src_build_message (src))
1148 return GST_FLOW_ERROR;
1153 GST_DEBUG_OBJECT (src, "EOS reached");
1157 switch (src->session_io_status) {
1158 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE:
1159 GST_DEBUG_OBJECT (src, "Queueing connection request");
1160 gst_soup_http_src_queue_message (src);
1162 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED:
1164 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING:
1165 gst_soup_http_src_session_unpause_message (src);
1167 case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED:
1172 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1173 g_main_loop_run (src->loop);
1174 } while (src->ret == GST_FLOW_CUSTOM_ERROR);
1176 if (src->ret == GST_FLOW_CUSTOM_ERROR)
1177 src->ret = GST_FLOW_EOS;
1182 gst_soup_http_src_start (GstBaseSrc * bsrc)
1184 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1186 GST_DEBUG_OBJECT (src, "start(\"%s\")", src->location);
1188 if (!src->location) {
1189 GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (_("No URL set.")),
1190 ("Missing location property"));
1194 src->context = g_main_context_new ();
1196 src->loop = g_main_loop_new (src->context, TRUE);
1198 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1199 (NULL), ("Failed to start GMainLoop"));
1200 g_main_context_unref (src->context);
1204 if (src->proxy == NULL) {
1206 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1207 src->context, SOUP_SESSION_USER_AGENT, src->user_agent,
1208 SOUP_SESSION_TIMEOUT, src->timeout,
1209 #ifdef HAVE_LIBSOUP_GNOME
1210 SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_PROXY_RESOLVER_GNOME,
1215 soup_session_async_new_with_options (SOUP_SESSION_ASYNC_CONTEXT,
1216 src->context, SOUP_SESSION_PROXY_URI, src->proxy,
1217 SOUP_SESSION_TIMEOUT, src->timeout,
1218 SOUP_SESSION_USER_AGENT, src->user_agent, NULL);
1221 if (!src->session) {
1222 GST_ELEMENT_ERROR (src, LIBRARY, INIT,
1223 (NULL), ("Failed to create async session"));
1227 g_signal_connect (src->session, "authenticate",
1228 G_CALLBACK (gst_soup_http_src_authenticate_cb), src);
1233 gst_soup_http_src_stop (GstBaseSrc * bsrc)
1235 GstSoupHTTPSrc *src;
1237 src = GST_SOUP_HTTP_SRC (bsrc);
1238 GST_DEBUG_OBJECT (src, "stop()");
1239 gst_soup_http_src_session_close (src);
1241 g_main_loop_unref (src->loop);
1242 g_main_context_unref (src->context);
1244 src->context = NULL;
1246 if (src->extra_headers) {
1247 gst_structure_free (src->extra_headers);
1248 src->extra_headers = NULL;
1251 gst_soup_http_src_reset (src);
1255 /* Interrupt a blocking request. */
1257 gst_soup_http_src_unlock (GstBaseSrc * bsrc)
1259 GstSoupHTTPSrc *src;
1261 src = GST_SOUP_HTTP_SRC (bsrc);
1262 GST_DEBUG_OBJECT (src, "unlock()");
1264 src->interrupted = TRUE;
1266 g_main_loop_quit (src->loop);
1270 /* Interrupt interrupt. */
1272 gst_soup_http_src_unlock_stop (GstBaseSrc * bsrc)
1274 GstSoupHTTPSrc *src;
1276 src = GST_SOUP_HTTP_SRC (bsrc);
1277 GST_DEBUG_OBJECT (src, "unlock_stop()");
1279 src->interrupted = FALSE;
1284 gst_soup_http_src_get_size (GstBaseSrc * bsrc, guint64 * size)
1286 GstSoupHTTPSrc *src;
1288 src = GST_SOUP_HTTP_SRC (bsrc);
1290 if (src->have_size) {
1291 GST_DEBUG_OBJECT (src, "get_size() = %" G_GUINT64_FORMAT,
1293 *size = src->content_size;
1296 GST_DEBUG_OBJECT (src, "get_size() = FALSE");
1301 gst_soup_http_src_is_seekable (GstBaseSrc * bsrc)
1303 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1305 return src->seekable;
1309 gst_soup_http_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
1311 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1313 GST_DEBUG_OBJECT (src, "do_seek(%" G_GUINT64_FORMAT ")", segment->start);
1315 if (src->read_position == segment->start) {
1316 GST_DEBUG_OBJECT (src, "Seeking to current read position");
1320 if (!src->seekable) {
1321 GST_WARNING_OBJECT (src, "Not seekable");
1325 if (segment->rate < 0.0 || segment->format != GST_FORMAT_BYTES) {
1326 GST_WARNING_OBJECT (src, "Invalid seek segment");
1330 if (src->content_size != 0 && segment->start >= src->content_size) {
1331 GST_WARNING_OBJECT (src, "Seeking behind end of file, will go to EOS soon");
1334 /* Wait for create() to handle the jump in offset. */
1335 src->request_position = segment->start;
1340 gst_soup_http_src_query (GstBaseSrc * bsrc, GstQuery * query)
1342 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (bsrc);
1345 switch (GST_QUERY_TYPE (query)) {
1347 gst_query_set_uri (query, src->location);
1356 ret = GST_BASE_SRC_CLASS (parent_class)->query (bsrc, query);
1362 gst_soup_http_src_set_location (GstSoupHTTPSrc * src, const gchar * uri,
1365 const char *alt_schemes[] = { "icy://", "icyx://" };
1368 if (src->location) {
1369 g_free (src->location);
1370 src->location = NULL;
1376 for (i = 0; i < G_N_ELEMENTS (alt_schemes); i++) {
1377 if (g_str_has_prefix (uri, alt_schemes[i])) {
1379 g_strdup_printf ("http://%s", uri + strlen (alt_schemes[i]));
1384 src->location = g_strdup (uri);
1390 gst_soup_http_src_set_proxy (GstSoupHTTPSrc * src, const gchar * uri)
1393 soup_uri_free (src->proxy);
1396 if (g_str_has_prefix (uri, "http://")) {
1397 src->proxy = soup_uri_new (uri);
1399 gchar *new_uri = g_strconcat ("http://", uri, NULL);
1401 src->proxy = soup_uri_new (new_uri);
1409 gst_soup_http_src_uri_get_type (GType type)
1414 static const gchar *const *
1415 gst_soup_http_src_uri_get_protocols (GType type)
1417 static const gchar *protocols[] = { "http", "https", "icy", "icyx", NULL };
1423 gst_soup_http_src_uri_get_uri (GstURIHandler * handler)
1425 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1427 /* FIXME: make thread-safe */
1428 return g_strdup (src->location);
1432 gst_soup_http_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
1435 GstSoupHTTPSrc *src = GST_SOUP_HTTP_SRC (handler);
1437 return gst_soup_http_src_set_location (src, uri, error);
1441 gst_soup_http_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
1443 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
1445 iface->get_type = gst_soup_http_src_uri_get_type;
1446 iface->get_protocols = gst_soup_http_src_uri_get_protocols;
1447 iface->get_uri = gst_soup_http_src_uri_get_uri;
1448 iface->set_uri = gst_soup_http_src_uri_set_uri;