Browse Source

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.
Jess Mayo 10 years ago
parent
commit
1682d77df3
2 changed files with 10 additions and 6 deletions
  1. 9 6
      plugins/obs-outputs/librtmp/rtmp.c
  2. 1 0
      plugins/obs-outputs/rtmp-stream.c

+ 9 - 6
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) &&

+ 1 - 0
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;