diff --git a/plugins/obs-outputs/librtmp/rtmp.c b/plugins/obs-outputs/librtmp/rtmp.c index a80320280..9f15e48fb 100644 --- a/plugins/obs-outputs/librtmp/rtmp.c +++ b/plugins/obs-outputs/librtmp/rtmp.c @@ -463,6 +463,17 @@ RTMP_Init(RTMP *r) { memset(r, 0, sizeof(RTMP)); r->m_sb.sb_socket = -1; + RTMP_Reset(r); + +#ifdef CRYPTO + RTMP_TLS_Init(r); +#endif + +} + +void +RTMP_Reset(RTMP *r) +{ r->m_inChunkSize = RTMP_DEFAULT_CHUNKSIZE; r->m_outChunkSize = RTMP_DEFAULT_CHUNKSIZE; r->m_bSendChunkSizeInfo = 1; @@ -476,11 +487,6 @@ RTMP_Init(RTMP *r) r->Link.nStreams = 0; r->Link.timeout = 30; r->Link.swfAge = 30; - -#ifdef CRYPTO - RTMP_TLS_Init(r); -#endif - } void diff --git a/plugins/obs-outputs/librtmp/rtmp.h b/plugins/obs-outputs/librtmp/rtmp.h index a4b5355c2..6c1f2567e 100644 --- a/plugins/obs-outputs/librtmp/rtmp.h +++ b/plugins/obs-outputs/librtmp/rtmp.h @@ -506,6 +506,7 @@ extern "C" int RTMP_ClientPacket(RTMP *r, RTMPPacket *packet); void RTMP_Init(RTMP *r); + void RTMP_Reset(RTMP *r); void RTMP_Close(RTMP *r); RTMP *RTMP_Alloc(void); void RTMP_TLS_Free(RTMP *r); diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 50579150a..18cb18cd0 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -969,8 +969,9 @@ static int try_connect(struct rtmp_stream *stream) info("Connecting to RTMP URL %s...", stream->path.array); - // this should have been called already by rtmp_stream_create - //RTMP_Init(&stream->rtmp); + // on reconnect we need to reset the internal variables of librtmp + // otherwise the data sent/received will not parse correctly on the other end + RTMP_Reset(&stream->rtmp); // since we don't call RTMP_Init above, there's no other good place // to reset this as doing it in RTMP_Close breaks the ugly RTMP