1 /* GStreamer 2 * Copyright (C) 2007-2008 Wouter Cloetens <wouter@mind.be> 3 * Copyright (C) 2021 Igalia S.L. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more 14 */ 15 16 #ifndef __GST_SOUP_HTTP_SRC_H__ 17 #define __GST_SOUP_HTTP_SRC_H__ 18 19 #include "gstsouputils.h" 20 #include "gstsouploader.h" 21 #include <gio/gio.h> 22 #include <gst/base/gstpushsrc.h> 23 24 G_BEGIN_DECLS 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 /* opaque from here, implementation detail */ 59 typedef struct _GstSoupSession GstSoupSession; 60 61 struct _GstSoupHTTPSrc { 62 GstPushSrc element; 63 64 gchar *location; /* Full URI. */ 65 gchar *redirection_uri; /* Full URI after redirections. */ 66 gboolean redirection_permanent; /* Permanent or temporary redirect? */ 67 gchar *user_agent; /* User-Agent HTTP header. */ 68 gboolean automatic_redirect; /* Follow redirects. */ 69 GstSoupUri *proxy; /* HTTP proxy URI. */ 70 gchar *user_id; /* Authentication user id for location URI. */ 71 gchar *user_pw; /* Authentication user password for location URI. */ 72 gchar *proxy_id; /* Authentication user id for proxy URI. */ 73 gchar *proxy_pw; /* Authentication user password for proxy URI. */ 74 gchar **cookies; /* HTTP request cookies. */ 75 GstSoupSession *session; /* Libsoup session wrapper. */ 76 gboolean session_is_shared; 77 GstSoupSession *external_session; /* Shared via GstContext */ 78 SoupMessage *msg; /* Request message. */ 79 gint retry_count; /* Number of retries since we received data */ 80 gint max_retries; /* Maximum number of retries */ 81 gchar *method; /* HTTP method */ 82 83 GstFlowReturn headers_ret; 84 gboolean got_headers; /* Already received headers from the server */ 85 gboolean have_size; /* Received and parsed Content-Length 86 header. */ 87 guint64 content_size; /* Value of Content-Length header. */ 88 guint64 read_position; /* Current position. */ 89 gboolean seekable; /* FALSE if the server does not support 90 Range. */ 91 guint64 request_position; /* Seek to this position. */ 92 guint64 stop_position; /* Stop at this position. */ 93 gboolean have_body; /* Indicates if it has just been signaled the 94 * end of the message body. This is used to 95 * decide if an out of range request should be 96 * handled as an error or EOS when the content 97 * size is unknown */ 98 gboolean keep_alive; /* Use keep-alive sessions */ 99 gboolean ssl_strict; 100 gchar *ssl_ca_file; 101 gboolean ssl_use_system_ca_file; 102 GTlsDatabase *tls_database; 103 GTlsInteraction *tls_interaction; 104 105 GCancellable *cancellable; 106 GInputStream *input_stream; 107 108 gint reduce_blocksize_count; 109 gint increase_blocksize_count; 110 guint minimum_blocksize; 111 112 /* Shoutcast/icecast metadata extraction handling. */ 113 gboolean iradio_mode; 114 GstCaps *src_caps; 115 gchar *iradio_name; 116 gchar *iradio_genre; 117 gchar *iradio_url; 118 119 GstStructure *extra_headers; 120 121 SoupLoggerLogLevel log_level;/* Soup HTTP session logger level */ 122 123 gboolean compress; 124 125 guint timeout; 126 127 /* This mutex-cond pair is used to talk to the soup session thread; it is 128 * per src to allow concurrent access to shared sessions (if it was inside 129 * the shared session structure, it would be effectively global) 130 */ 131 GMutex session_mutex; 132 GCond session_cond; 133 134 GstEvent *http_headers_event; 135 136 gint64 last_socket_read_time; 137 138 #ifdef OHOS_EXT_FUNC 139 // ohos.ext.func.0012 140 guint last_status_code; 141 gint64 buffering_time; 142 gint64 last_try_time; 143 gint64 wait_time; 144 gint64 wait_already; 145 GMutex wait_lock; 146 GCond wait_cond; 147 gboolean exit_block; 148 guint32 error_code; 149 gint trickmode_key_units; 150 gboolean has_sent_first_request; 151 gboolean has_received_first_response; 152 gint64 playerState; 153 #endif 154 }; 155 156 struct _GstSoupHTTPSrcClass { 157 GstPushSrcClass parent_class; 158 }; 159 160 GType gst_soup_http_src_get_type (void); 161 162 G_END_DECLS 163 164 #endif /* __GST_SOUP_HTTP_SRC_H__ */ 165 166