mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
neonhttpsrc: add connect-timeout and read-timeout properties
https://bugzilla.gnome.org/show_bug.cgi?id=625076
This commit is contained in:
parent
640a1ff0e8
commit
f724428e07
2 changed files with 54 additions and 0 deletions
|
@ -59,6 +59,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
#define DEFAULT_AUTOMATIC_REDIRECT TRUE
|
||||
#define DEFAULT_ACCEPT_SELF_SIGNED FALSE
|
||||
#define DEFAULT_NEON_HTTP_DEBUG FALSE
|
||||
#define DEFAULT_CONNECT_TIMEOUT 0
|
||||
#define DEFAULT_READ_TIMEOUT 0
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -73,6 +75,8 @@ enum
|
|||
PROP_IRADIO_URL,
|
||||
PROP_AUTOMATIC_REDIRECT,
|
||||
PROP_ACCEPT_SELF_SIGNED,
|
||||
PROP_CONNECT_TIMEOUT,
|
||||
PROP_READ_TIMEOUT,
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
PROP_NEON_HTTP_DEBUG
|
||||
#endif
|
||||
|
@ -219,6 +223,30 @@ gst_neonhttp_src_class_init (GstNeonhttpSrcClass * klass)
|
|||
"Accept self-signed SSL/TLS certificates",
|
||||
DEFAULT_ACCEPT_SELF_SIGNED, G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GstNeonhttpSrc:connect-timeout
|
||||
*
|
||||
* After how many seconds to timeout a connect attempt (0 = default)
|
||||
*
|
||||
* Since: 0.10.20
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_CONNECT_TIMEOUT,
|
||||
g_param_spec_uint ("connect-timeout", "connect-timeout",
|
||||
"Value in seconds to timeout a blocking connection (0 = default).", 0,
|
||||
3600, DEFAULT_CONNECT_TIMEOUT, G_PARAM_READWRITE));
|
||||
|
||||
/**
|
||||
* GstNeonhttpSrc:read-timeout
|
||||
*
|
||||
* After how many seconds to timeout a blocking read (0 = default)
|
||||
*
|
||||
* Since: 0.10.20
|
||||
*/
|
||||
g_object_class_install_property (gobject_class, PROP_READ_TIMEOUT,
|
||||
g_param_spec_uint ("read-timeout", "read-timeout",
|
||||
"Value in seconds to timeout a blocking read (0 = default).", 0,
|
||||
3600, DEFAULT_READ_TIMEOUT, G_PARAM_READWRITE));
|
||||
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
g_object_class_install_property
|
||||
(gobject_class, PROP_NEON_HTTP_DEBUG,
|
||||
|
@ -253,6 +281,8 @@ gst_neonhttp_src_init (GstNeonhttpSrc * src, GstNeonhttpSrcClass * g_class)
|
|||
src->user_agent = g_strdup (DEFAULT_USER_AGENT);
|
||||
src->automatic_redirect = DEFAULT_AUTOMATIC_REDIRECT;
|
||||
src->accept_self_signed = DEFAULT_ACCEPT_SELF_SIGNED;
|
||||
src->connect_timeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
src->read_timeout = DEFAULT_READ_TIMEOUT;
|
||||
|
||||
src->cookies = NULL;
|
||||
src->session = NULL;
|
||||
|
@ -376,6 +406,12 @@ gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
|||
case PROP_ACCEPT_SELF_SIGNED:
|
||||
src->accept_self_signed = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_CONNECT_TIMEOUT:
|
||||
src->connect_timeout = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_READ_TIMEOUT:
|
||||
src->read_timeout = g_value_get_uint (value);
|
||||
break;
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
case PROP_NEON_HTTP_DEBUG:
|
||||
src->neon_http_debug = g_value_get_boolean (value);
|
||||
|
@ -450,6 +486,12 @@ gst_neonhttp_src_get_property (GObject * object, guint prop_id,
|
|||
case PROP_ACCEPT_SELF_SIGNED:
|
||||
g_value_set_boolean (value, neonhttpsrc->accept_self_signed);
|
||||
break;
|
||||
case PROP_CONNECT_TIMEOUT:
|
||||
g_value_set_uint (value, neonhttpsrc->connect_timeout);
|
||||
break;
|
||||
case PROP_READ_TIMEOUT:
|
||||
g_value_set_uint (value, neonhttpsrc->read_timeout);
|
||||
break;
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
case PROP_NEON_HTTP_DEBUG:
|
||||
g_value_set_boolean (value, neonhttpsrc->neon_http_debug);
|
||||
|
@ -867,6 +909,14 @@ gst_neonhttp_src_send_request_and_redirect (GstNeonhttpSrc * src,
|
|||
ne_session_create (src->uri.scheme, src->uri.host, src->uri.port);
|
||||
}
|
||||
|
||||
if (src->connect_timeout > 0) {
|
||||
ne_set_connect_timeout (session, src->connect_timeout);
|
||||
}
|
||||
|
||||
if (src->read_timeout > 0) {
|
||||
ne_set_read_timeout (session, src->read_timeout);
|
||||
}
|
||||
|
||||
ne_set_session_flag (session, NE_SESSFLAG_ICYPROTO, 1);
|
||||
ne_ssl_set_verify (session, ssl_verify_callback, src);
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@ struct _GstNeonhttpSrc {
|
|||
|
||||
gint64 read_position;
|
||||
gboolean seekable;
|
||||
|
||||
/* seconds before timing out when connecting or reading to/from a socket */
|
||||
guint connect_timeout;
|
||||
guint read_timeout;
|
||||
};
|
||||
|
||||
struct _GstNeonhttpSrcClass {
|
||||
|
|
Loading…
Reference in a new issue