shithub: rtmp

Download patch

ref: 51261f3745a0dc575946599e03fcb22b122fb2f6
parent: 12219b1cfd13dff31498cd1acbfbf9c0bdf3d6d9
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jul 29 07:24:28 EDT 2021

separate in/out chunk size

--- a/main.c
+++ b/main.c
@@ -58,6 +58,8 @@
 	if((r = rtmpdial(argv[0])) == nil)
 		sysfatal("%r");
 
+	while(1)
+		sleep(100);
 	threadexitsall(nil);
 
 	bufsz = 65536;
--- a/rtmp.c
+++ b/rtmp.c
@@ -96,7 +96,8 @@
 	char *tcurl;
 	Message msg;
 	u8int *b, *p, *e;
-	int chunk;
+	int chunkin;
+	int chunkout;
 	int mode;
 	int bsz;
 	int i;
@@ -256,7 +257,7 @@
 	r->msg.data = h;
 	r->msg.sz = len;
 	for(;;){
-		n = min(len, r->chunk);
+		n = min(len, r->chunkin);
 		if(readn(r->i, h, n) != n)
 			goto err;
 		len -= n;
@@ -310,7 +311,7 @@
 		goto err;
 
 	for(p = r->msg.data, len = r->msg.sz; len > 0;){
-		n = min(len, r->chunk);
+		n = min(len, r->chunkout);
 		if(Bwrite(r, p, n) < 0)
 			goto err;
 		p += n;
@@ -460,14 +461,14 @@
 			break;
 
 		case SetChunkSize:
-			if(amf0i32get(s, e, &r->chunk) == nil)
+			if(amf0i32get(s, e, &r->chunkin) == nil)
 				goto err;
-			if(r->chunk < 2){
-				werrstr("invalid chunk size: %d", r->chunk);
+			if(r->chunkin < 2){
+				werrstr("invalid chunk size: %d", r->chunkin);
 				goto err;
 			}
 			if(debug)
-				fprint(2, ": %d", r->chunk);
+				fprint(2, ": %d", r->chunkin);
 			break;
 
 		case UserControl:
@@ -684,7 +685,8 @@
 
 	r = ecalloc(1, sizeof(*r));
 	r->i = f;
-	r->chunk = Chunk;
+	r->chunkin = Chunk;
+	r->chunkout = Chunk;
 	r->tcurl = url;
 	url = nil;
 	r->c = chancreate(sizeof(void*), 0);