changeset 33:e70e7b266f89

hook in RTCP output
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 08 Jul 2024 07:25:19 +0000
parents aa97e77e7de6
children fc77c3482084
files include/endp.h src/rtp_tx.c
diffstat 2 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/include/endp.h	Mon Jul 08 07:17:38 2024 +0000
+++ b/include/endp.h	Mon Jul 08 07:25:19 2024 +0000
@@ -37,7 +37,6 @@
 struct twrtp_endp_rtcp_tx {
 	uint32_t last_received;
 	uint32_t last_expected;
-	uint16_t auto_rtcp_count;
 };
 
 struct twrtp_endp_stats {
@@ -68,6 +67,7 @@
 	uint8_t *sdes_buf;
 	uint16_t sdes_len;
 	uint16_t auto_rtcp_interval;
+	uint16_t auto_rtcp_count;
 	/* always have to have stats */
 	struct twrtp_endp_stats stats;
 	/* bool flags at the end for structure packing optimization */
--- a/src/rtp_tx.c	Mon Jul 08 07:17:38 2024 +0000
+++ b/src/rtp_tx.c	Mon Jul 08 07:25:19 2024 +0000
@@ -15,6 +15,7 @@
 #include <themwi/rtp/endp.h>
 #include <themwi/rtp/rtp_basic_hdr.h>
 #include <themwi/rtp/twjit.h>
+#include "endp_internal.h"
 
 static uint32_t gen_timestamp(struct timespec *now,
 			      struct twrtp_jibuf_inst *twjit)
@@ -94,7 +95,17 @@
 	endp->stats.tx_rtp_pkt++;
 	endp->stats.tx_rtp_bytes += payload_len;
 
-	/* TODO: send RTCP if requested */
+	if (endp->auto_rtcp_interval) {
+		endp->auto_rtcp_count++;
+		if (endp->auto_rtcp_count >= endp->auto_rtcp_interval) {
+			endp->auto_rtcp_count = 0;
+			send_rtcp = true;
+		}
+	}
+	if (send_rtcp) {
+		_twrtp_endp_send_rtcp(endp, true, &now,
+				      endp->tx.ts - ts_quantum);
+	}
 
 	return 0;
 }