client: also watch newly created session

When we newly created a session, start watching it immediately instead of
on the next request.
This commit is contained in:
Wim Taymans 2013-06-20 12:20:21 +02:00
parent a8a051f780
commit fa1d3354c0

View file

@ -247,6 +247,27 @@ client_unlink_session (GstRTSPClient * client, GstRTSPSession * session)
gst_rtsp_session_filter (session, filter_session, client);
}
static void
client_watch_session (GstRTSPClient * client, GstRTSPSession * session)
{
GstRTSPClientPrivate *priv = client->priv;
GList *walk;
for (walk = priv->sessions; walk; walk = g_list_next (walk)) {
GstRTSPSession *msession = (GstRTSPSession *) walk->data;
/* we already know about this session */
if (msession == session)
return;
}
GST_INFO ("watching session %p", session);
g_object_weak_ref (G_OBJECT (session), (GWeakNotify) client_session_finalized,
client);
priv->sessions = g_list_prepend (priv->sessions, session);
}
static void
client_cleanup_sessions (GstRTSPClient * client)
{
@ -1307,6 +1328,9 @@ handle_setup_request (GstRTSPClient * client, GstRTSPClientState * state)
if (!(session = gst_rtsp_session_pool_create (priv->session_pool)))
goto service_unavailable;
/* make sure this client is closed when the session is closed */
client_watch_session (client, session);
/* signal new session */
g_signal_emit (client, gst_rtsp_client_signals[SIGNAL_NEW_SESSION], 0,
session);
@ -1679,27 +1703,6 @@ client_session_finalized (GstRTSPClient * client, GstRTSPSession * session)
}
}
static void
client_watch_session (GstRTSPClient * client, GstRTSPSession * session)
{
GstRTSPClientPrivate *priv = client->priv;
GList *walk;
for (walk = priv->sessions; walk; walk = g_list_next (walk)) {
GstRTSPSession *msession = (GstRTSPSession *) walk->data;
/* we already know about this session */
if (msession == session)
return;
}
GST_INFO ("watching session %p", session);
g_object_weak_ref (G_OBJECT (session), (GWeakNotify) client_session_finalized,
client);
priv->sessions = g_list_prepend (priv->sessions, session);
}
static void
handle_request (GstRTSPClient * client, GstRTSPMessage * request)
{