souphttpsrc: dynamically adjust blocksize
[platform/upstream/gst-plugins-good.git] / ext / soup / gstsouphttpsrc.h
1 /* GStreamer
2  * Copyright (C) 2007-2008 Wouter Cloetens <wouter@mind.be>
3  *
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.
8  *
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 
13  */
14
15 #ifndef __GST_SOUP_HTTP_SRC_H__
16 #define __GST_SOUP_HTTP_SRC_H__
17
18 #include <gst/gst.h>
19 #include <gst/base/gstpushsrc.h>
20 #include <glib.h>
21
22 G_BEGIN_DECLS
23
24 #include <libsoup/soup.h>
25
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))
37
38 typedef struct _GstSoupHTTPSrc GstSoupHTTPSrc;
39 typedef struct _GstSoupHTTPSrcClass GstSoupHTTPSrcClass;
40
41 typedef enum {
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;
47
48 struct _GstSoupHTTPSrc {
49   GstPushSrc element;
50
51   gchar *location;             /* Full URI. */
52   gchar *redirection_uri;      /* Full URI after redirections. */
53   gboolean redirection_permanent; /* Permanent or temporary redirect? */
54   gchar *user_agent;           /* User-Agent HTTP header. */
55   gboolean automatic_redirect; /* Follow redirects. */
56   SoupURI *proxy;              /* HTTP proxy URI. */
57   gchar *user_id;              /* Authentication user id for location URI. */
58   gchar *user_pw;              /* Authentication user password for location URI. */
59   gchar *proxy_id;             /* Authentication user id for proxy URI. */
60   gchar *proxy_pw;             /* Authentication user password for proxy URI. */
61   gchar **cookies;             /* HTTP request cookies. */
62   SoupSession *session;        /* Async context. */
63   SoupMessage *msg;            /* Request message. */
64   GstFlowReturn ret;           /* Return code from callback. */
65   gint retry_count;            /* Number of retries since we received data */
66   gint max_retries;            /* Maximum number of retries */
67   gchar *method;               /* HTTP method */
68
69   gboolean got_headers;        /* Already received headers from the server */
70   gboolean have_size;          /* Received and parsed Content-Length
71                                   header. */
72   guint64 content_size;        /* Value of Content-Length header. */
73   guint64 read_position;       /* Current position. */
74   gboolean seekable;           /* FALSE if the server does not support
75                                   Range. */
76   guint64 request_position;    /* Seek to this position. */
77   guint64 stop_position;       /* Stop at this position. */
78   gboolean have_body;          /* Indicates if it has just been signaled the
79                                 * end of the message body. This is used to
80                                 * decide if an out of range request should be
81                                 * handled as an error or EOS when the content
82                                 * size is unknown */
83   gboolean keep_alive;         /* Use keep-alive sessions */
84   gboolean ssl_strict;
85   gchar *ssl_ca_file;
86   gboolean ssl_use_system_ca_file;
87   GTlsDatabase *tls_database;
88   GTlsInteraction *tls_interaction;
89
90   GCancellable *cancellable;
91   GInputStream *input_stream;
92   gboolean has_pollable_interface;
93   gboolean have_data;
94   GMainContext *poll_context;
95   GSource *poll_source;
96
97   gint reduce_blocksize_count;
98   gint increase_blocksize_count;
99   guint minimum_blocksize;
100
101   /* Shoutcast/icecast metadata extraction handling. */
102   gboolean iradio_mode;
103   GstCaps *src_caps;
104   gchar *iradio_name;
105   gchar *iradio_genre;
106   gchar *iradio_url;
107
108   GstStructure *extra_headers;
109
110   SoupLoggerLogLevel log_level;/* Soup HTTP session logger level */
111
112   gboolean compress;
113
114   guint timeout;
115
116   GMutex mutex;
117   GCond have_headers_cond;
118
119   GstEvent *http_headers_event;
120 };
121
122 struct _GstSoupHTTPSrcClass {
123   GstPushSrcClass parent_class;
124 };
125
126 GType gst_soup_http_src_get_type (void);
127
128 G_END_DECLS
129
130 #endif /* __GST_SOUP_HTTP_SRC_H__ */
131