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
15 #ifndef __GST_SOUP_HTTP_SRC_H__
16 #define __GST_SOUP_HTTP_SRC_H__
19 #include <gst/base/gstpushsrc.h>
24 #include <libsoup/soup.h>
26 #define GST_TYPE_SOUP_HTTP_SRC \
27 (gst_soup_http_src_get_type())
28 #define GST_SOUP_HTTP_SRC(obj) \
29 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SOUP_HTTP_SRC,GstSoupHTTPSrc))
30 #define GST_SOUP_HTTP_SRC_CLASS(klass) \
31 (G_TYPE_CHECK_CLASS_CAST((klass), \
32 GST_TYPE_SOUP_HTTP_SRC,GstSoupHTTPSrcClass))
33 #define GST_IS_SOUP_HTTP_SRC(obj) \
34 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SOUP_HTTP_SRC))
35 #define GST_IS_SOUP_HTTP_SRC_CLASS(klass) \
36 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SOUP_HTTP_SRC))
38 typedef struct _GstSoupHTTPSrc GstSoupHTTPSrc;
39 typedef struct _GstSoupHTTPSrcClass GstSoupHTTPSrcClass;
42 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE,
43 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED,
44 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING,
45 GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED,
46 } GstSoupHTTPSrcSessionIOStatus;
48 struct _GstSoupHTTPSrc {
51 gchar *location; /* Full URI. */
52 gchar *redirection_uri; /* Full URI after redirections. */
53 gchar *user_agent; /* User-Agent HTTP header. */
54 gboolean automatic_redirect; /* Follow redirects. */
55 SoupURI *proxy; /* HTTP proxy URI. */
56 gchar *user_id; /* Authentication user id for location URI. */
57 gchar *user_pw; /* Authentication user password for location URI. */
58 gchar *proxy_id; /* Authentication user id for proxy URI. */
59 gchar *proxy_pw; /* Authentication user password for proxy URI. */
60 gchar **cookies; /* HTTP request cookies. */
61 GMainContext *context; /* I/O context. */
62 GMainLoop *loop; /* Event loop. */
63 SoupSession *session; /* Async context. */
64 GstSoupHTTPSrcSessionIOStatus session_io_status;
65 /* Async I/O status. */
66 SoupMessage *msg; /* Request message. */
67 GstFlowReturn ret; /* Return code from callback. */
68 GstBuffer **outbuf; /* Return buffer allocated by callback. */
69 gboolean interrupted; /* Signal unlock(). */
70 gboolean retry; /* Should attempt to reconnect. */
71 gint retry_count; /* Number of retries since we received data */
72 gint max_retries; /* Maximum number of retries */
74 gboolean got_headers; /* Already received headers from the server */
75 gboolean have_size; /* Received and parsed Content-Length
77 guint64 content_size; /* Value of Content-Length header. */
78 guint64 read_position; /* Current position. */
79 gboolean seekable; /* FALSE if the server does not support
81 guint64 request_position; /* Seek to this position. */
82 guint64 stop_position; /* Stop at this position. */
83 gboolean have_body; /* Indicates if it has just been signaled the
84 * end of the message body. This is used to
85 * decide if an out of range request should be
86 * handled as an error or EOS when the content
88 gboolean keep_alive; /* Use keep-alive sessions */
91 gboolean ssl_use_system_ca_file;
93 /* Shoutcast/icecast metadata extraction handling. */
100 GstStructure *extra_headers;
102 SoupLoggerLogLevel log_level;/* Soup HTTP session logger level */
109 GCond request_finished_cond;
112 struct _GstSoupHTTPSrcClass {
113 GstPushSrcClass parent_class;
116 GType gst_soup_http_src_get_type (void);
120 #endif /* __GST_SOUP_HTTP_SRC_H__ */