FreeCalypso > hg > themwi-system-sw
diff sip-manual-out/rtp.c @ 189:1266e024de6c
sip-manual-out: implement hunt for IS_Header in Rx RTP
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Mar 2023 09:54:22 -0800 |
parents | 6aecee01cf0a |
children | 62ecc0aa081f |
line wrap: on
line diff
--- a/sip-manual-out/rtp.c Fri Mar 17 01:14:57 2023 -0800 +++ b/sip-manual-out/rtp.c Fri Mar 17 09:54:22 2023 -0800 @@ -27,6 +27,38 @@ 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 void +reset_is_hunt() +{ + memset(is_hunt_buf, 0xFF, 320); +} + +static void +is_hunt_proc(input, input_pos) + uint8_t *input; + unsigned input_pos; +{ + unsigned offset, n; + + memmove(is_hunt_buf, is_hunt_buf + 16, 304); + memcpy(is_hunt_buf + 304, input, 16); + 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) + printf("Found IS_Header, last bit offset %u\n", + input_pos * 16 + offset); +} + void obtain_rtp_endp() { @@ -39,6 +71,7 @@ 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 @@ -50,6 +83,7 @@ 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, @@ -77,6 +111,7 @@ 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; @@ -99,11 +134,13 @@ 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; @@ -114,6 +151,8 @@ rtp_last_seq, rtp_last_ts); rtp_start_flag = 1; } + for (is_chunk = 0; is_chunk < 10; is_chunk++) + is_hunt_proc(pkt.payload + is_chunk * 16, is_chunk); } void