summaryrefslogtreecommitdiff
path: root/ext/neon
diff options
context:
space:
mode:
authorDavid Hoyt <dhoyt@llnl.gov>2010-08-06 11:04:57 +0100
committerTim-Philipp Müller <tim.muller@collabora.co.uk>2010-08-06 11:07:13 +0100
commitf724428e073df3c3fc7c50407efe365233cdc030 (patch)
tree2c6d54c33f31a2e615baa8a97610e520c31ee85d /ext/neon
parent640a1ff0e81143fe8bb502ef2f46492d2d5e4f37 (diff)
downloadgstreamer-plugins-bad-f724428e073df3c3fc7c50407efe365233cdc030.tar.gz
neonhttpsrc: add connect-timeout and read-timeout properties
https://bugzilla.gnome.org/show_bug.cgi?id=625076
Diffstat (limited to 'ext/neon')
-rw-r--r--ext/neon/gstneonhttpsrc.c50
-rw-r--r--ext/neon/gstneonhttpsrc.h4
2 files changed, 54 insertions, 0 deletions
diff --git a/ext/neon/gstneonhttpsrc.c b/ext/neon/gstneonhttpsrc.c
index 0e4f472d6..a20a7e749 100644
--- a/ext/neon/gstneonhttpsrc.c
+++ b/ext/neon/gstneonhttpsrc.c
@@ -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);
diff --git a/ext/neon/gstneonhttpsrc.h b/ext/neon/gstneonhttpsrc.h
index ae10fd3d8..e3207691a 100644
--- a/ext/neon/gstneonhttpsrc.h
+++ b/ext/neon/gstneonhttpsrc.h
@@ -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 {