rtspconnection: Add read source on write socket.
authorGöran Jönsson <goranjn@axis.com>
Mon, 19 May 2014 11:28:52 +0000 (13:28 +0200)
committerWim Taymans <wtaymans@redhat.com>
Tue, 20 May 2014 10:02:13 +0000 (12:02 +0200)
Add a read source on write socket when lost tunnel.
To be able to detect when clint closes get channel.

This is already done in gst_rtsp_source_dispatch_write but
only when the queue is empty.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=730368

gst-libs/gst/rtsp/gstrtspconnection.c

index b4f5b4f..87be31a 100644 (file)
@@ -3131,6 +3131,16 @@ gst_rtsp_source_dispatch_read (GPollableInputStream * stream,
       /* and signal that we lost our tunnel */
       if (watch->funcs.tunnel_lost)
         res = watch->funcs.tunnel_lost (watch, watch->user_data);
+      /* we add read source on the write socket able to detect when client closes get channel in tunneled mode */
+      if (watch->conn->control_stream && !watch->controlsrc) {
+        watch->controlsrc =
+            g_pollable_input_stream_create_source (G_POLLABLE_INPUT_STREAM
+            (watch->conn->control_stream), NULL);
+        g_source_set_callback (watch->controlsrc,
+            (GSourceFunc) gst_rtsp_source_dispatch_read_get_channel, watch,
+            NULL);
+        g_source_add_child_source ((GSource *) watch, watch->controlsrc);
+      }        
       goto read_done;
     } else
       goto eof;