changeset 3:cc997f9ae186

test-fsk: rm TFO code
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 04 Mar 2024 21:22:27 -0800
parents 26383ed8b79f
children 030d52b96a23
files test-fsk/rtp_rx.c test-fsk/rtp_tx.c test-fsk/sdp_in.c test-fsk/user_cmd.c
diffstat 4 files changed, 1 insertions(+), 250 deletions(-) [+]
line wrap: on
line diff
--- a/test-fsk/rtp_rx.c	Mon Mar 04 21:03:19 2024 -0800
+++ b/test-fsk/rtp_rx.c	Mon Mar 04 21:22:27 2024 -0800
@@ -27,140 +27,6 @@
 static uint16_t rtp_last_seq;
 static int got_some_rtcp;
 
-static const uint8_t hdr_pattern[20] =	{0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
-					 0, 1, 1, 0, 1, 0, 1, 0, 0, 1};
-
-static uint8_t is_hunt_buf[320];
-static int is_state;
-static unsigned is_offset, is_bit_count, is_hunt_fill;
-static uint32_t is_rx_word;
-
-static void
-reset_is_hunt()
-{
-	is_state = 0;
-	is_hunt_fill = 0;
-}
-
-static void
-is_rx_hunt(input_pos)
-	unsigned input_pos;
-{
-	unsigned offset, n;
-
-	for (offset = 0; offset < 16; offset++) {
-		for (n = 0; n < 20; n++)
-			if ((is_hunt_buf[offset + n*16] & 1) != hdr_pattern[n])
-				break;
-		if (n == 20)
-			break;
-	}
-	if (n != 20)
-		return;
-	printf("Found IS_Header, last bit offset %u\n",
-		input_pos * 16 + offset);
-	is_offset = offset;
-	is_state = 1;
-	is_bit_count = 0;
-	is_rx_word = 0;
-	is_hunt_fill = 0;
-}
-
-static void
-is_process_cmd()
-{
-	int cont;
-
-	printf("IS_Command: 0x%03X", is_rx_word);
-	switch (is_rx_word) {
-	case 0x05D:
-		printf(" (REQ)\n");
-		cont = 1;
-		break;
-	case 0x0BA:
-		printf(" (ACK)\n");
-		cont = 1;
-		break;
-	case 0x0E7:
-		printf(" (IPE)\n");
-		cont = 1;
-		break;
-	case 0x129:
-		printf(" (FILL)\n");
-		cont = 0;
-		break;
-	case 0x174:
-		printf(" (DUP)\n");
-		cont = 0;
-		break;
-	case 0x193:
-		printf(" (SYL)\n");
-		cont = 0;
-		break;
-	default:
-		printf(" (bad)\n");
-		cont = 0;
-	}
-	if (cont) {
-		is_state = 2;
-		is_bit_count = 0;
-		is_rx_word = 0;
-	} else
-		is_state = 0;
-}
-
-static void
-is_process_ext()
-{
-	printf("IS_Extension: 0x%05X", is_rx_word);
-	if (is_rx_word & 0x80200) {
-		printf(" (bad sync)\n");
-		is_state = 0;
-		return;
-	}
-	switch (is_rx_word & 3) {
-	case 0:
-		printf(" (final)\n");
-		is_state = 0;
-		return;
-	case 3:
-		printf(" (continue)\n");
-		is_state = 2;
-		is_bit_count = 0;
-		is_rx_word = 0;
-		return;
-	default:
-		printf(" (bad EX)\n");
-		is_state = 0;
-	}
-}
-
-static void
-is_rx_process(input, input_pos)
-	uint8_t *input;
-	unsigned input_pos;
-{
-	unsigned new_bit;
-
-	memmove(is_hunt_buf, is_hunt_buf + 16, 304);
-	memcpy(is_hunt_buf + 304, input, 16);
-	if (!is_state) {
-		if (is_hunt_fill < 20)
-			is_hunt_fill++;
-		if (is_hunt_fill == 20)
-			is_rx_hunt(input_pos);
-		return;
-	}
-	new_bit = input[is_offset] & 1;
-	is_rx_word <<= 1;
-	is_rx_word |= new_bit;
-	is_bit_count++;
-	if (is_state == 1 && is_bit_count == 10)
-		is_process_cmd();
-	else if (is_state == 2 && is_bit_count == 20)
-		is_process_ext();
-}
-
 void
 obtain_rtp_endp()
 {
@@ -173,7 +39,6 @@
 	bcopy(&res.pstn_addr, &rtp_local_addr, sizeof(struct sockaddr_in));
 	rtp_udp_fd = res.pstn_rtp_fd;
 	rtcp_udp_fd = res.pstn_rtcp_fd;
-	reset_is_hunt();
 }
 
 void
@@ -185,7 +50,6 @@
 	int16_t seq_delta;
 	int32_t ts_delta;
 	int rc;
-	unsigned is_chunk;
 
 	addrlen = sizeof(struct sockaddr_in);
 	rc = recvfrom(rtp_udp_fd, &pkt, sizeof pkt, 0,
@@ -213,7 +77,6 @@
 			printf("Rx RTP stream changed SSRC\n");
 			rtp_ssrc_chg_flag = 1;
 		}
-		reset_is_hunt();
 	} else if (rtp_start_flag) {
 		seq_delta = ntohs(pkt.seq) - rtp_last_seq;
 		ts_delta = ntohl(pkt.tstamp) - rtp_last_ts;
@@ -236,13 +99,11 @@
 				printf("Rx RTP stream seq break\n");
 				rtp_seq_brk_flag = 1;
 			}
-			reset_is_hunt();
 		} else if (ts_delta != 160) {
 			if (!rtp_ts_brk_flag) {
 				printf("Rx RTP stream tstamp break\n");
 				rtp_ts_brk_flag = 1;
 			}
-			reset_is_hunt();
 		}
 	}
 	rtp_ssrc = pkt.ssrc;
@@ -253,8 +114,6 @@
 			rtp_last_seq, rtp_last_ts);
 		rtp_start_flag = 1;
 	}
-	for (is_chunk = 0; is_chunk < 10; is_chunk++)
-		is_rx_process(pkt.payload + is_chunk * 16, is_chunk);
 }
 
 void
--- a/test-fsk/rtp_tx.c	Mon Mar 04 21:03:19 2024 -0800
+++ b/test-fsk/rtp_tx.c	Mon Mar 04 21:22:27 2024 -0800
@@ -26,11 +26,6 @@
 
 static uint8_t pcm_fill_octet;
 
-static uint16_t tfo_fill_buf[9], tfo_req_buf[7];
-static uint16_t *is_out_ptr;
-static unsigned is_out_count;
-static int tfo_stop_req;
-
 void
 assign_rtpout_ssrc()
 {
@@ -47,37 +42,6 @@
 }
 
 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;
-	uint16_t word;
-{
-	ubit_t is_bits[10];
-	uint8_t *bytep;
-	unsigned n;
-
-	uint16_to_bits(word, is_bits, 10);
-	for (n = 0; n < 10; n++) {
-		bytep = payload + n * 16;
-		*bytep &= 0xFE;
-		*bytep |= is_bits[n];
-	}
-}
-
-void
 generate_rtp_packet()
 {
 	struct rtp_packet pkt;
@@ -90,14 +54,6 @@
 	rtp_out_ts += 160;
 	pkt.ssrc = rtp_ssrc;
 	memset(pkt.payload, pcm_fill_octet, RTP_MAX_PAYLOAD);
-	if (is_out_count) {
-		insert_is_msg(pkt.payload, *is_out_ptr++);
-		is_out_count--;
-		if (!is_out_count && !tfo_stop_req) {
-			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,
 		(struct sockaddr *) &rtp_remote_addr, addrlen);
@@ -109,24 +65,3 @@
 {
 	pcm_fill_octet = oct;
 }
-
-void
-send_tfo_req(sig, codec)
-	unsigned sig, codec;
-{
-	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;
-	tfo_stop_req = 0;
-}
-
-void
-stop_tfo_out()
-{
-	tfo_stop_req = 1;
-}
--- a/test-fsk/sdp_in.c	Mon Mar 04 21:03:19 2024 -0800
+++ b/test-fsk/sdp_in.c	Mon Mar 04 21:22:27 2024 -0800
@@ -82,5 +82,4 @@
 	rtp_out_enable = 1;
 	assign_rtpout_ssrc();
 	init_pcm_fill_octet();
-	prepare_tfo_fill();
 }
--- a/test-fsk/user_cmd.c	Mon Mar 04 21:03:19 2024 -0800
+++ b/test-fsk/user_cmd.c	Mon Mar 04 21:22:27 2024 -0800
@@ -1,6 +1,6 @@
 /*
  * In this module we implement stdin command handling, supporting
- * user-initiated CANCEL and BYE as well as TFO testing commands.
+ * user-initiated CANCEL and BYE.
  */
 
 #include <ctype.h>
@@ -33,44 +33,6 @@
 	set_pcm_fill_octet(octet);
 }
 
-static void
-tfo_req_cmd(args)
-	char *args;
-{
-	char *cp;
-	unsigned sig, codec;
-
-	for (cp = args; isspace(*cp); cp++)
-		;
-	if (!isdigit(*cp)) {
-inv_syntax:	fprintf(stderr, "error: tfo-req command invalid syntax\n");
-		return;
-	}
-	sig = strtoul(cp, &cp, 0);
-	if (!isspace(*cp))
-		goto inv_syntax;
-	if (sig > 0xFF) {
-		fprintf(stderr, "error: Sig argument out of range\n");
-		return;
-	}
-	while (isspace(*cp))
-		cp++;
-	if (!isdigit(*cp))
-		goto inv_syntax;
-	codec = strtoul(cp, &cp, 0);
-	if (*cp && !isspace(*cp))
-		goto inv_syntax;
-	if (codec > 14) {
-		fprintf(stderr, "error: Codec_Type argument out of range\n");
-		return;
-	}
-	while (isspace(*cp))
-		cp++;
-	if (*cp)
-		goto inv_syntax;
-	send_tfo_req(sig, codec);
-}
-
 void
 select_stdin()
 {
@@ -93,10 +55,6 @@
 		send_cancel_req();
 	else if (!strncmp(cp, "pcm-fill", 8) && isspace(cp[8]))
 		pcm_fill_cmd(cp + 9);
-	else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7]))
-		tfo_req_cmd(cp + 8);
-	else if (!strcmp(cp, "tfo-stop"))
-		stop_tfo_out();
 	else
 		fprintf(stderr, "error: non-understood stdin command\n");
 }