From b45fd85b9529cc9458de6559ab8a18cec7b47885 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Tue, 14 Jul 2020 21:47:11 +0200
Subject: [PATCH] Workaround bug in OBS v25

---
 src/output/output_rtmp.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp
index 8cd5302d..4fd86c65 100644
--- a/src/output/output_rtmp.cpp
+++ b/src/output/output_rtmp.cpp
@@ -396,7 +396,14 @@ namespace Mist {
       }
       app_name = amfData.getContentP(2)->getContentP("tcUrl")->StrValue();
       app_name = app_name.substr(app_name.find('/', 7) + 1);
-      //send a _result reply
+
+      //If this user agent matches, we can safely guess it's librtmp, and this is not dangerous
+      if (UA == "FMLE/3.0 (compatible; FMSc/1.0)"){
+        //set max chunk size early, to work around OBS v25 bug
+        RTMPStream::chunk_snd_max = 65536;                                 // 64KiB
+        myConn.SendNow(RTMPStream::SendCTL(1, RTMPStream::chunk_snd_max)); // send chunk size max (msg 1)
+      }
+      // send a _result reply
       AMF::Object amfReply("container", AMF::AMF0_DDV_CONTAINER);
       amfReply.addContent(AMF::Object("", "_result")); //result success
       amfReply.addContent(amfData.getContent(1)); //same transaction ID