diff options
author | Jonathan Karlsson <jonakn@axis.com> | 2017-08-09 11:52:38 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2017-11-15 17:20:33 +0200 |
commit | 0f87202a71e5560491be66182773e923f7b094ab (patch) | |
tree | 1c38766e035613cc548fadadbe89ced8721c2640 | |
parent | c3e53322d934af47e697c94945112f06572555e3 (diff) |
rtsp-session: Handle the case when timeout=0
According to the documentation, a timeout of value 0 means
that the session never timeouts. This adds handling of that.
If timeout=0 we just return with a -1 from
gst_rtsp_session_next_timeout_usec ().
https://bugzilla.gnome.org/show_bug.cgi?id=785058
-rw-r--r-- | gst/rtsp-server/rtsp-session.c | 9 | ||||
-rw-r--r-- | tests/check/gst/rtspserver.c | 22 |
2 files changed, 31 insertions, 0 deletions
diff --git a/gst/rtsp-server/rtsp-session.c b/gst/rtsp-server/rtsp-session.c index e6faaf5..e8fd68b 100644 --- a/gst/rtsp-server/rtsp-session.c +++ b/gst/rtsp-server/rtsp-session.c @@ -69,6 +69,7 @@ struct _GstRTSPSessionPrivate #undef DEBUG #define DEFAULT_TIMEOUT 60 +#define NO_TIMEOUT -1 #define DEFAULT_ALWAYS_VISIBLE FALSE enum @@ -634,6 +635,14 @@ gst_rtsp_session_next_timeout_usec (GstRTSPSession * session, gint64 now) priv = session->priv; + g_mutex_lock (&priv->lock); + /* If timeout is set to 0, we never timeout */ + if (priv->timeout == 0) { + g_mutex_unlock (&priv->lock); + return NO_TIMEOUT; + } + g_mutex_unlock (&priv->lock); + g_mutex_lock (&priv->last_access_lock); if (g_atomic_int_get (&priv->expire_count) != 0) { /* touch session when the expire count is not 0 */ diff --git a/tests/check/gst/rtspserver.c b/tests/check/gst/rtspserver.c index 1a92d52..7f636f5 100644 --- a/tests/check/gst/rtspserver.c +++ b/tests/check/gst/rtspserver.c @@ -1559,6 +1559,27 @@ GST_START_TEST (test_play_multithreaded_timeout_session) GST_END_TEST; +GST_START_TEST (test_no_session_timeout) +{ + GstRTSPSession *session; + gint64 now; + gboolean is_expired; + + session = gst_rtsp_session_new ("test-session"); + gst_rtsp_session_set_timeout (session, 0); + + now = g_get_monotonic_time (); + /* add more than the extra 5 seconds that are usually added in + * gst_rtsp_session_next_timeout_usec */ + now += 7000000; + + is_expired = gst_rtsp_session_is_expired_usec (session, now); + fail_unless (is_expired == FALSE); +} + +GST_END_TEST; + + GST_START_TEST (test_play_disconnect) { GstRTSPConnection *conn; @@ -2118,6 +2139,7 @@ rtspserver_suite (void) tcase_add_test (tc, test_play_multithreaded_block_in_describe); tcase_add_test (tc, test_play_multithreaded_timeout_client); tcase_add_test (tc, test_play_multithreaded_timeout_session); + tcase_add_test (tc, test_no_session_timeout); tcase_add_test (tc, test_play_disconnect); tcase_add_test (tc, test_play_specific_server_port); tcase_add_test (tc, test_play_smpte_range); |