From 50033d03d31da5a1f7b5e8ffb8e03a969d88a3de Mon Sep 17 00:00:00 2001 From: Mikhail Rudenko Date: Thu, 8 Feb 2024 01:36:43 +0300 Subject: [PATCH] rtsp-stream: clear sockets when leaving bin Since commit 4d86f994, when setting an RTSP media both shared and reusable, streaming cannot be restarted after the first time all the clients disconnect. That happens because the sockets (unlike addresses) of GstRTSPStream are not cleared in gst_rtsp_stream_leave_bin, and on restart sockets and addresses are not allocated in gst_rtsp_stream_allocate_udp_sockets, and then the check in create_sender_part fails. Fix this by clearing sockets in gst_rtsp_stream_leave_bin. Fixes gstreamer/gst-rtsp-server#113 Part-of: --- subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c b/subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c index 24e8e63e0b..cbdffadad0 100644 --- a/subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c +++ b/subprojects/gst-rtsp-server/gst/rtsp-server/rtsp-stream.c @@ -4225,6 +4225,13 @@ gst_rtsp_stream_leave_bin (GstRTSPStream * stream, GstBin * bin, gst_rtsp_address_free (priv->server_addr_v6); priv->server_addr_v6 = NULL; + for (i = 0; i < 2; i++) { + g_clear_object (&priv->socket_v4[i]); + g_clear_object (&priv->socket_v6[i]); + g_clear_object (&priv->mcast_socket_v4[i]); + g_clear_object (&priv->mcast_socket_v6[i]); + } + g_mutex_unlock (&priv->lock); return TRUE;