mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 03:35:21 +00:00
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
This commit is contained in:
parent
c3e53322d9
commit
0f87202a71
2 changed files with 31 additions and 0 deletions
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue