mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 05:31:15 +00:00
rtsp-*: Treat sending packets to clients as keepalive
As long as gst-rtsp-server can successfully send RTP/RTCP data to clients then the client must be reading. This change makes the server timeout the connection if the client stops reading. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=736647
This commit is contained in:
parent
733ef1162b
commit
2218510cae
3 changed files with 16 additions and 6 deletions
|
@ -691,6 +691,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
|
||||||
{
|
{
|
||||||
GstRTSPClientPrivate *priv = client->priv;
|
GstRTSPClientPrivate *priv = client->priv;
|
||||||
GstRTSPMessage message = { 0 };
|
GstRTSPMessage message = { 0 };
|
||||||
|
GstRTSPResult res = GST_RTSP_OK;
|
||||||
GstMapInfo map_info;
|
GstMapInfo map_info;
|
||||||
guint8 *data;
|
guint8 *data;
|
||||||
guint usize;
|
guint usize;
|
||||||
|
@ -705,7 +706,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
|
||||||
|
|
||||||
g_mutex_lock (&priv->send_lock);
|
g_mutex_lock (&priv->send_lock);
|
||||||
if (priv->send_func)
|
if (priv->send_func)
|
||||||
priv->send_func (client, &message, FALSE, priv->send_data);
|
res = priv->send_func (client, &message, FALSE, priv->send_data);
|
||||||
g_mutex_unlock (&priv->send_lock);
|
g_mutex_unlock (&priv->send_lock);
|
||||||
|
|
||||||
gst_rtsp_message_steal_body (&message, &data, &usize);
|
gst_rtsp_message_steal_body (&message, &data, &usize);
|
||||||
|
@ -713,7 +714,7 @@ do_send_data (GstBuffer * buffer, guint8 channel, GstRTSPClient * client)
|
||||||
|
|
||||||
gst_rtsp_message_unset (&message);
|
gst_rtsp_message_unset (&message);
|
||||||
|
|
||||||
return TRUE;
|
return res == GST_RTSP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct _GstRTSPSessionPrivate
|
||||||
guint timeout;
|
guint timeout;
|
||||||
gboolean timeout_always_visible;
|
gboolean timeout_always_visible;
|
||||||
GTimeVal create_time; /* immutable */
|
GTimeVal create_time; /* immutable */
|
||||||
|
GMutex last_access_lock;
|
||||||
GTimeVal last_access;
|
GTimeVal last_access;
|
||||||
gint expire_count;
|
gint expire_count;
|
||||||
|
|
||||||
|
@ -132,6 +133,7 @@ gst_rtsp_session_init (GstRTSPSession * session)
|
||||||
GST_INFO ("init session %p", session);
|
GST_INFO ("init session %p", session);
|
||||||
|
|
||||||
g_mutex_init (&priv->lock);
|
g_mutex_init (&priv->lock);
|
||||||
|
g_mutex_init (&priv->last_access_lock);
|
||||||
priv->timeout = DEFAULT_TIMEOUT;
|
priv->timeout = DEFAULT_TIMEOUT;
|
||||||
g_get_current_time (&priv->create_time);
|
g_get_current_time (&priv->create_time);
|
||||||
gst_rtsp_session_touch (session);
|
gst_rtsp_session_touch (session);
|
||||||
|
@ -153,6 +155,7 @@ gst_rtsp_session_finalize (GObject * obj)
|
||||||
|
|
||||||
/* free session id */
|
/* free session id */
|
||||||
g_free (priv->sessionid);
|
g_free (priv->sessionid);
|
||||||
|
g_mutex_clear (&priv->last_access_lock);
|
||||||
g_mutex_clear (&priv->lock);
|
g_mutex_clear (&priv->lock);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gst_rtsp_session_parent_class)->finalize (obj);
|
G_OBJECT_CLASS (gst_rtsp_session_parent_class)->finalize (obj);
|
||||||
|
@ -555,9 +558,9 @@ gst_rtsp_session_touch (GstRTSPSession * session)
|
||||||
|
|
||||||
priv = session->priv;
|
priv = session->priv;
|
||||||
|
|
||||||
g_mutex_lock (&priv->lock);
|
g_mutex_lock (&priv->last_access_lock);
|
||||||
g_get_current_time (&priv->last_access);
|
g_get_current_time (&priv->last_access);
|
||||||
g_mutex_unlock (&priv->lock);
|
g_mutex_unlock (&priv->last_access_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -608,7 +611,7 @@ gst_rtsp_session_next_timeout (GstRTSPSession * session, GTimeVal * now)
|
||||||
|
|
||||||
priv = session->priv;
|
priv = session->priv;
|
||||||
|
|
||||||
g_mutex_lock (&priv->lock);
|
g_mutex_lock (&priv->last_access_lock);
|
||||||
if (g_atomic_int_get (&priv->expire_count) != 0) {
|
if (g_atomic_int_get (&priv->expire_count) != 0) {
|
||||||
/* touch session when the expire count is not 0 */
|
/* touch session when the expire count is not 0 */
|
||||||
g_get_current_time (&priv->last_access);
|
g_get_current_time (&priv->last_access);
|
||||||
|
@ -617,7 +620,7 @@ gst_rtsp_session_next_timeout (GstRTSPSession * session, GTimeVal * now)
|
||||||
last_access = GST_TIMEVAL_TO_TIME (priv->last_access);
|
last_access = GST_TIMEVAL_TO_TIME (priv->last_access);
|
||||||
/* add timeout allow for 5 seconds of extra time */
|
/* add timeout allow for 5 seconds of extra time */
|
||||||
last_access += priv->timeout * GST_SECOND + (5 * GST_SECOND);
|
last_access += priv->timeout * GST_SECOND + (5 * GST_SECOND);
|
||||||
g_mutex_unlock (&priv->lock);
|
g_mutex_unlock (&priv->last_access_lock);
|
||||||
|
|
||||||
now_ns = GST_TIMEVAL_TO_TIME (*now);
|
now_ns = GST_TIMEVAL_TO_TIME (*now);
|
||||||
|
|
||||||
|
|
|
@ -456,6 +456,9 @@ gst_rtsp_stream_transport_send_rtp (GstRTSPStreamTransport * trans,
|
||||||
priv->send_rtp (buffer, priv->transport->interleaved.min,
|
priv->send_rtp (buffer, priv->transport->interleaved.min,
|
||||||
priv->user_data);
|
priv->user_data);
|
||||||
|
|
||||||
|
if (res)
|
||||||
|
gst_rtsp_stream_transport_keep_alive (trans);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -482,6 +485,9 @@ gst_rtsp_stream_transport_send_rtcp (GstRTSPStreamTransport * trans,
|
||||||
priv->send_rtcp (buffer, priv->transport->interleaved.max,
|
priv->send_rtcp (buffer, priv->transport->interleaved.max,
|
||||||
priv->user_data);
|
priv->user_data);
|
||||||
|
|
||||||
|
if (res)
|
||||||
|
gst_rtsp_stream_transport_keep_alive (trans);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue