shithub: rtmp

Download patch

ref: 1471e462a43ff169164215653f13bdf75ccf8ea4
parent: daf4e542e31036ad232613f82ca1c5d100a270a2
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Fri Aug 13 07:42:38 EDT 2021

don't flush on every audio/video packet

--- a/rtmp.c
+++ b/rtmp.c
@@ -324,7 +324,7 @@
 }
 
 static int
-rtmpsend(RTMP *r)
+rtmpsend(RTMP *r, int flush)
 {
 	u8int *p, *h, *e, hdata[24];
 	int len, n, hsz;
@@ -368,7 +368,7 @@
 		}
 	}
 
-	if(Bflush(r) < 0)
+	if(flush && Bflush(r) < 0)
 		goto err;
 
 	if(debug){
@@ -412,7 +412,7 @@
 	puti16(CtlPingResponse);
 	puti32(n);
 
-	return rtmpsend(r);
+	return rtmpsend(r, 1);
 }
 
 static int
@@ -422,7 +422,7 @@
 
 	newmsg(r, SetChunkSize, Type0, CSUserCtl);
 	puti32(sz);
-	n = rtmpsend(r);
+	n = rtmpsend(r, 1);
 	r->chunkout = sz;
 
 	return n;
@@ -676,7 +676,7 @@
 
 	r->o.msg.cmd.cb = streamcreated;
 	r->o.msg.cmd.aux = c;
-	n = rtmpsend(r);
+	n = rtmpsend(r, 1);
 
 	qunlock(r);
 
@@ -732,7 +732,7 @@
 	r->o.msg.cmd.aux = c;
 	r->o.msg.cmd.code = "NetStream.Publish.Start";
 	r->o.msg.sid = sid;
-	n = rtmpsend(r);
+	n = rtmpsend(r, 1);
 
 	qunlock(r);
 
@@ -777,7 +777,7 @@
 	putend();
 	r->o.msg.sid = sid;
 
-	res = rtmpsend(r);
+	res = rtmpsend(r, 1);
 
 	qunlock(r);
 
@@ -872,7 +872,7 @@
 
 		putdata(ps, p-ps);
 
-		if(rtmpsend(r) < 0)
+		if(rtmpsend(r, 0) < 0)
 			return -1;
 
 		r->sps = 1;
@@ -898,7 +898,7 @@
 		putdata(p, nsz);
 	}
 
-	return rtmpsend(r);
+	return rtmpsend(r, 0);
 }
 
 static int
@@ -944,7 +944,7 @@
 		putbyte(0xe5);
 		putbyte(0x00);
 
-		if(rtmpsend(r) < 0)
+		if(rtmpsend(r, 0) < 0)
 			return -1;
 
 		r->aacpd = 1;
@@ -961,7 +961,7 @@
 
 	putdata(p+7, sz-7);
 
-	return rtmpsend(r);
+	return rtmpsend(r, 0);
 }
 
 int
@@ -1011,7 +1011,7 @@
 		putkvnum("objectEncoding", 0); /* AMF0 */
 	putend();
 
-	return rtmpsend(r);
+	return rtmpsend(r, 1);
 }
 
 static int