From 1682d77df34a5c98ab24f41a273b29dd52e4f59e Mon Sep 17 00:00:00 2001 From: Jess Mayo Date: Sat, 11 Jul 2015 13:53:07 +0900 Subject: [PATCH] obs-outputs: Fix rtmp authentication Reinstate flag checks in RTMP_Close that were erroneously removed. Clear out the Link state before we establish a new connection. There is too much state carried around during authentication that has no good place to clear it in librtmp, which assumes a clean structure when the connection is initially established. --- plugins/obs-outputs/librtmp/rtmp.c | 15 +++++++++------ plugins/obs-outputs/rtmp-stream.c | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugins/obs-outputs/librtmp/rtmp.c b/plugins/obs-outputs/librtmp/rtmp.c index 08bf0eb23..16d729ce4 100644 --- a/plugins/obs-outputs/librtmp/rtmp.c +++ b/plugins/obs-outputs/librtmp/rtmp.c @@ -4221,14 +4221,17 @@ RTMP_Close(RTMP *r) } #if defined(CRYPTO) || defined(USE_ONLY_MD5) - for (int idx = 0; idx < r->Link.nStreams; idx++) + if (!(r->Link.protocol & RTMP_FEATURE_WRITE) || (r->Link.pFlags & RTMP_PUB_CLEAN)) { - free(r->Link.streams[idx].playpath.av_val); - r->Link.streams[idx].playpath.av_val = NULL; - } + for (int idx = 0; idx < r->Link.nStreams; idx++) + { + free(r->Link.streams[idx].playpath.av_val); + r->Link.streams[idx].playpath.av_val = NULL; + } - r->Link.curStreamIdx = 0; - r->Link.nStreams = 0; + r->Link.curStreamIdx = 0; + r->Link.nStreams = 0; + } if ((r->Link.protocol & RTMP_FEATURE_WRITE) && (r->Link.pFlags & RTMP_PUB_CLEAN) && diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 4f7650764..b6a7d7fa4 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -394,6 +394,7 @@ static int try_connect(struct rtmp_stream *stream) info("Connecting to RTMP URL %s...", stream->path.array); + memset(&stream->rtmp.Link, 0, sizeof(stream->rtmp.Link)); if (!RTMP_SetupURL(&stream->rtmp, stream->path.array)) return OBS_OUTPUT_BAD_PATH;