shithub: rtmp

Download patch

ref: 12219b1cfd13dff31498cd1acbfbf9c0bdf3d6d9
parent: a0e0f7a6367f88fc26c66cf9442cc2462cb97e6d
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Jul 29 06:39:32 EDT 2021

pong

--- a/rtmp.c
+++ b/rtmp.c
@@ -20,6 +20,7 @@
 	Type2,
 	Type3,
 
+	CSUserCtl = 2,
 	CSCtl = 3,
 
 	CbCommand = 0,
@@ -372,6 +373,16 @@
 	free(r);
 }
 
+static int
+pong(RTMP *r, s32int n)
+{
+	newmsg(r, UserControl, Type0, CSUserCtl);
+	puti16(CtlPingResponse);
+	puti32(n);
+
+	return rtmpsend(r);
+}
+
 static void
 loop(void *aux)
 {
@@ -472,8 +483,8 @@
 			case CtlStreamIsRecorded:
 				if(0){
 			case CtlPingRequest:
-					/* FIXME pong */
-					USED(n);
+					if(pong(r, n) != 0)
+						goto err;
 				}
 				if(debug)
 					fprint(2, ": %s %d", ctl2s[s16], n);