diff options
author | Yann Jouanin <yjo@witbe.net> | 2016-03-27 03:11:45 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-03-27 11:54:36 +0300 |
commit | 9554e1c666e8a986ad80f1b37cc4d7018de48a4e (patch) | |
tree | bebb0c0e1f6e6be24ca80844d6e87b484ce0b87b /ext/rtmp | |
parent | cc1feff99f19c62cba46e32b1110b1414cadb6df (diff) | |
download | gstreamer-plugins-bad-9554e1c666e8a986ad80f1b37cc4d7018de48a4e.tar.gz |
rtmpsrc plugin : add timeout option
https://bugzilla.gnome.org/show_bug.cgi?id=764251
Diffstat (limited to 'ext/rtmp')
-rw-r--r-- | ext/rtmp/gstrtmpsrc.c | 20 | ||||
-rw-r--r-- | ext/rtmp/gstrtmpsrc.h | 2 |
2 files changed, 19 insertions, 3 deletions
diff --git a/ext/rtmp/gstrtmpsrc.c b/ext/rtmp/gstrtmpsrc.c index cea765ca6..eba8360e8 100644 --- a/ext/rtmp/gstrtmpsrc.c +++ b/ext/rtmp/gstrtmpsrc.c @@ -68,7 +68,8 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", enum { PROP_0, - PROP_LOCATION + PROP_LOCATION, + PROP_TIMEOUT #if 0 PROP_SWF_URL, PROP_PAGE_URL @@ -76,6 +77,7 @@ enum }; #define DEFAULT_LOCATION NULL +#define DEFAULT_TIMEOUT 120 static void gst_rtmp_src_uri_handler_init (gpointer g_iface, gpointer iface_data); @@ -125,6 +127,12 @@ gst_rtmp_src_class_init (GstRTMPSrcClass * klass) "Location of the RTMP url to read", DEFAULT_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_TIMEOUT, + g_param_spec_int ("timeout", "RTMP Timeout", + "Time without receiving any data from the server to wait before to timeout the session", + 0, G_MAXINT, + DEFAULT_TIMEOUT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + gst_element_class_add_static_pad_template (gstelement_class, &srctemplate); gst_element_class_set_static_metadata (gstelement_class, @@ -160,6 +168,7 @@ gst_rtmp_src_init (GstRTMPSrc * rtmpsrc) rtmpsrc->cur_offset = 0; rtmpsrc->last_timestamp = 0; + rtmpsrc->timeout = DEFAULT_TIMEOUT; gst_base_src_set_format (GST_BASE_SRC (rtmpsrc), GST_FORMAT_TIME); } @@ -271,6 +280,10 @@ gst_rtmp_src_set_property (GObject * object, guint prop_id, g_value_get_string (value), NULL); break; } + case PROP_TIMEOUT:{ + src->timeout = g_value_get_int (value); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -289,6 +302,9 @@ gst_rtmp_src_get_property (GObject * object, guint prop_id, GValue * value, case PROP_LOCATION: g_value_set_string (value, src->uri); break; + case PROP_TIMEOUT: + g_value_set_int (value, src->timeout); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -574,13 +590,13 @@ gst_rtmp_src_start (GstBaseSrc * basesrc) src->discont = TRUE; src->rtmp = RTMP_Alloc (); - if (!src->rtmp) { GST_ERROR_OBJECT (src, "Could not allocate librtmp's RTMP context"); goto error; } RTMP_Init (src->rtmp); + src->rtmp->Link.timeout = src->timeout; if (!RTMP_SetupURL (src->rtmp, src->uri)) { GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ, (NULL), ("Failed to setup URL '%s'", src->uri)); diff --git a/ext/rtmp/gstrtmpsrc.h b/ext/rtmp/gstrtmpsrc.h index fa6da17e1..60ebcb226 100644 --- a/ext/rtmp/gstrtmpsrc.h +++ b/ext/rtmp/gstrtmpsrc.h @@ -63,7 +63,7 @@ struct _GstRTMPSrc gchar *page_url; RTMP *rtmp; - + int timeout; gint64 cur_offset; GstClockTime last_timestamp; gboolean seekable; |