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 #ifdef OHOS_EXT_FUNC 49 // ohos.ext.func.0012 50 typedef enum { 51 GST_PLAYER_STATUS_IDLE, 52 GST_PLAYER_STATUS_BUFFERING, 53 GST_PLAYER_STATUS_PAUSED, 54 GST_PLAYER_STATUS_PLAYING, 55 } GstPlayerStatus; 56 #endif 57 58 struct _GstSoupHTTPSrc { 59 GstPushSrc element; 60 61 gchar *location; /* Full URI. */ 62 gchar *redirection_uri; /* Full URI after redirections. */ 63 gboolean redirection_permanent; /* Permanent or temporary redirect? */ 64 gchar *user_agent; /* User-Agent HTTP header. */ 65 gboolean automatic_redirect; /* Follow redirects. */ 66 SoupURI *proxy; /* HTTP proxy URI. */ 67 gchar *user_id; /* Authentication user id for location URI. */ 68 gchar *user_pw; /* Authentication user password for location URI. */ 69 gchar *proxy_id; /* Authentication user id for proxy URI. */ 70 gchar *proxy_pw; /* Authentication user password for proxy URI. */ 71 gchar **cookies; /* HTTP request cookies. */ 72 SoupSession *session; /* Async context. */ 73 gboolean session_is_shared; 74 SoupSession *external_session; /* Shared via GstContext */ 75 gboolean forced_external_session; /* If session was explicitly set from application */ 76 SoupMessage *msg; /* Request message. */ 77 gint retry_count; /* Number of retries since we received data */ 78 gint max_retries; /* Maximum number of retries */ 79 gchar *method; /* HTTP method */ 80 81 gboolean got_headers; /* Already received headers from the server */ 82 gboolean have_size; /* Received and parsed Content-Length 83 header. */ 84 guint64 content_size; /* Value of Content-Length header. */ 85 guint64 read_position; /* Current position. */ 86 gboolean seekable; /* FALSE if the server does not support 87 Range. */ 88 guint64 request_position; /* Seek to this position. */ 89 guint64 stop_position; /* Stop at this position. */ 90 gboolean have_body; /* Indicates if it has just been signaled the 91 * end of the message body. This is used to 92 * decide if an out of range request should be 93 * handled as an error or EOS when the content 94 * size is unknown */ 95 gboolean keep_alive; /* Use keep-alive sessions */ 96 gboolean ssl_strict; 97 gchar *ssl_ca_file; 98 gboolean ssl_use_system_ca_file; 99 GTlsDatabase *tls_database; 100 GTlsInteraction *tls_interaction; 101 102 GCancellable *cancellable; 103 GInputStream *input_stream; 104 105 gint reduce_blocksize_count; 106 gint increase_blocksize_count; 107 guint minimum_blocksize; 108 109 /* Shoutcast/icecast metadata extraction handling. */ 110 gboolean iradio_mode; 111 GstCaps *src_caps; 112 gchar *iradio_name; 113 gchar *iradio_genre; 114 gchar *iradio_url; 115 116 GstStructure *extra_headers; 117 118 SoupLoggerLogLevel log_level;/* Soup HTTP session logger level */ 119 120 gboolean compress; 121 122 guint timeout; 123 124 GMutex mutex; 125 GCond have_headers_cond; 126 127 GstEvent *http_headers_event; 128 129 gint64 last_socket_read_time; 130 #ifdef OHOS_EXT_FUNC 131 // ohos.ext.func.0012 132 GstFlowReturn ret; /* Return code from callback. */ 133 guint last_status_code; 134 gint64 buffering_time; 135 gint64 last_try_time; 136 gint64 wait_time; 137 gint64 wait_already; 138 GMutex wait_lock; 139 GCond wait_cond; 140 gboolean exit_block; 141 guint32 error_code; 142 gint trickmode_key_units; 143 gboolean has_sent_first_request; 144 gboolean has_received_first_response; 145 gint64 playerState; 146 #endif 147 }; 148 149 struct _GstSoupHTTPSrcClass { 150 GstPushSrcClass parent_class; 151 }; 152 153 GType gst_soup_http_src_get_type (void); 154 155 G_END_DECLS 156 157 #endif /* __GST_SOUP_HTTP_SRC_H__ */ 158 159