changeset 201:d3c99b41fb04

sip-manual-out TFO: rework for continuous output of TFO_REQ
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 02 Apr 2023 18:01:34 -0800
parents 834656633fa0
children f3164f732b84
files sip-manual-out/rtp_tx.c sip-manual-out/sdp_in.c
diffstat 2 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/sip-manual-out/rtp_tx.c	Sun Apr 02 17:44:23 2023 -0800
+++ b/sip-manual-out/rtp_tx.c	Sun Apr 02 18:01:34 2023 -0800
@@ -24,7 +24,8 @@
 static uint32_t rtp_out_ts;
 static uint16_t rtp_out_seq;
 
-static uint16_t is_out_buf[7], *is_out_ptr;
+static uint16_t tfo_fill_buf[9], tfo_req_buf[7];
+static uint16_t *is_out_ptr;
 static unsigned is_out_count;
 
 void
@@ -33,6 +34,20 @@
 	rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid();
 }
 
+void
+prepare_tfo_fill()
+{
+	tfo_fill_buf[0] = 0x15A;
+	tfo_fill_buf[1] = 0x1A9;
+	tfo_fill_buf[2] = 0x129;
+	tfo_fill_buf[3] = 0x15A;
+	tfo_fill_buf[4] = 0x1A9;
+	tfo_fill_buf[5] = 0x129;
+	tfo_fill_buf[6] = 0x15A;
+	tfo_fill_buf[7] = 0x1A9;
+	tfo_fill_buf[8] = 0x129;
+}
+
 static void
 insert_is_msg(payload, word)
 	uint8_t *payload;
@@ -66,6 +81,10 @@
 	if (is_out_count) {
 		insert_is_msg(pkt.payload, *is_out_ptr++);
 		is_out_count--;
+		if (!is_out_count) {
+			is_out_ptr = tfo_req_buf;
+			is_out_count = 7;
+		}
 	}
 	addrlen = sizeof(struct sockaddr_in);
 	sendto(rtp_udp_fd, &pkt, RTP_PACKET_SIZE_PSTN, 0,
@@ -76,12 +95,12 @@
 send_tfo_req(sig, codec)
 	unsigned sig, codec;
 {
-	is_out_buf[0] = 0x15A;
-	is_out_buf[1] = 0x1A9;
-	is_out_buf[2] = 0x05D;
-	is_out_buf[3] = 0x14E;
-	is_out_buf[4] = 0x14B;
-	encode_tfo_ext_words(sig, codec, 0, is_out_buf + 5);
-	is_out_ptr = is_out_buf;
-	is_out_count = 7;
+	tfo_req_buf[0] = 0x15A;
+	tfo_req_buf[1] = 0x1A9;
+	tfo_req_buf[2] = 0x05D;
+	tfo_req_buf[3] = 0x14E;
+	tfo_req_buf[4] = 0x14B;
+	encode_tfo_ext_words(sig, codec, 0, tfo_req_buf + 5);
+	is_out_ptr = tfo_fill_buf;
+	is_out_count = 9;
 }
--- a/sip-manual-out/sdp_in.c	Sun Apr 02 17:44:23 2023 -0800
+++ b/sip-manual-out/sdp_in.c	Sun Apr 02 18:01:34 2023 -0800
@@ -73,4 +73,5 @@
 	rtp_remote_addr.sin_port = htons(sdp_parse.audio_port);
 	rtp_out_enable = 1;
 	assign_rtpout_ssrc();
+	prepare_tfo_fill();
 }