From dada82fec1e6fabdf83fb402d068f80112e88439 Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Sun, 19 Jun 2022 22:58:26 +0200 Subject: [PATCH] obs-outputs: Don't shutdown RTMP session when silently reconnecting The silent reconnect (GOAWAY) is supposed to be used for switching the connection to a different server. As such, cleanly shutting down the RTMP connection can destroy state that needs to be preserved in order for the GOAWAY-enabled server to properly resume the same stream on reconnect. This commit closes the TLS/TCP connection before calling RTMP_Close, causing librtmp to skip the FCUnpublish and deleteStream messages. --- plugins/obs-outputs/rtmp-stream.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 4df12a33d..34f3c3489 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -708,6 +708,15 @@ static void *send_thread(void *data) } set_output_error(stream); + + if (silently_reconnecting(stream)) { + /* manually close the socket to prevent librtmp from sending + * unpublish / deletestream messages when we call RTMP_Close, + * since we want to re-use this stream when we reconnect */ + RTMPSockBuf_Close(&stream->rtmp.m_sb); + stream->rtmp.m_sb.sb_socket = -1; + } + RTMP_Close(&stream->rtmp); /* reset bitrate on stop */