title: gst-rtsp-server: detect client disconnect
body: <p>I am implementing a video streaming pipeline using gst-rtsp-server. I need to know when an RTSP client both connects and disconnects.</p>
  <p>From the examples provided with gst-rtsp-server, I can detect a client connecting using the <code>&quot;client-connected&quot;</code> signal of the <code>GstRTSPServer</code>. I'm looking for something similar for when the client disconnects.</p>
  <p>I have tried the <code>&quot;closed&quot;</code> and <code>&quot;teardown-request&quot;</code> signals of <code>GstRTSPClient</code>, but those don't do anything when I disconnect the client.</p>
  <p>I have also tried calling the following function on a timer, like it is done in several examples. I would expect that to print &quot;Removed 1 sessions&quot; at some point after I've terminated the client, but it never does.</p>
  <pre><code>static gboolean
  remove_sessions (GstRTSPServer * server)
  {
    GstRTSPSessionPool *pool;
  
    pool = gst_rtsp_server_get_session_pool (server);
    guint removed = gst_rtsp_session_pool_cleanup (pool);
    g_object_unref (pool);
    g_print(&quot;Removed %d sessions\n&quot;, removed);
  
    return TRUE;
  }
  </code></pre>
  <p>My client is the following gstreamer pipeline:</p>
  <pre><code>gst-launch-1.0 -v rtspsrc location=rtsp://$STREAM_IP:8554/test latency=50 ! queue ! rtph264depay ! queue ! avdec_h264 ! autovideosink sync=false
  </code></pre>
  <p>How can I detect client disconnections?</p>