annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement our RTP handling: obtaining a PSTN-side
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * RTP endpoint from themwi-rtp-mgr, then handling read select on RTP
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * and RTCP UDP sockets.
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/types.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/socket.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <netinet/in.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdio.h>
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
11 #include <stdint.h>
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdlib.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <string.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <strings.h>
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "../include/tmgw_const.h"
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
16 #include "../include/rtp_defs.h"
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "../librtpalloc/rtp_alloc_simple.h"
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 struct sockaddr_in rtp_local_addr;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int rtp_udp_fd, rtcp_udp_fd;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
22 static int rtp_start_flag, rtp_bad_flag, rtp_ssrc_chg_flag;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
23 static int rtp_seq_brk_flag, rtp_seq_zero_flag, rtp_seq_neg_flag;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
24 static int rtp_ts_brk_flag;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
25 static uint32_t rtp_ssrc;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
26 static uint32_t rtp_last_ts;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
27 static uint16_t rtp_last_seq;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
28 static int got_some_rtcp;
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
30 static const uint8_t hdr_pattern[20] = {0, 1, 0, 1, 0, 1, 1, 0, 1, 0,
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
31 0, 1, 1, 0, 1, 0, 1, 0, 0, 1};
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
32
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
33 static uint8_t is_hunt_buf[320];
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
34
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
35 static void
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
36 reset_is_hunt()
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
37 {
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
38 memset(is_hunt_buf, 0xFF, 320);
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
39 }
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
40
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
41 static void
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
42 is_hunt_proc(input, input_pos)
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
43 uint8_t *input;
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
44 unsigned input_pos;
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
45 {
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
46 unsigned offset, n;
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
47
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
48 memmove(is_hunt_buf, is_hunt_buf + 16, 304);
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
49 memcpy(is_hunt_buf + 304, input, 16);
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
50 for (offset = 0; offset < 16; offset++) {
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
51 for (n = 0; n < 20; n++)
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
52 if ((is_hunt_buf[offset + n*16] & 1) != hdr_pattern[n])
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
53 break;
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
54 if (n == 20)
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
55 break;
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
56 }
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
57 if (n == 20)
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
58 printf("Found IS_Header, last bit offset %u\n",
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
59 input_pos * 16 + offset);
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
60 }
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
61
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 void
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 obtain_rtp_endp()
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 int rc;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 struct rtp_alloc_simple res;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 rc = rtp_alloc_simple(TMGW_EP_TYPE_PSTN_ONLY, &res);
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 if (rc < 0)
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 exit(1); /* error msg already printed */
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 bcopy(&res.pstn_addr, &rtp_local_addr, sizeof(struct sockaddr_in));
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 rtp_udp_fd = res.pstn_rtp_fd;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 rtcp_udp_fd = res.pstn_rtcp_fd;
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
74 reset_is_hunt();
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 void
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 rtp_rx_select()
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 {
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
80 struct rtp_packet pkt;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
81 struct sockaddr_in sin_from;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
82 socklen_t addrlen;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
83 int16_t seq_delta;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
84 int32_t ts_delta;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
85 int rc;
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
86 unsigned is_chunk;
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
88 addrlen = sizeof(struct sockaddr_in);
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
89 rc = recvfrom(rtp_udp_fd, &pkt, sizeof pkt, 0,
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
90 (struct sockaddr *) &sin_from, &addrlen);
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
91 if (rc < 0)
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
92 return;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
93 if (rc != RTP_PACKET_SIZE_PSTN) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
94 bad_rtp_pkt: if (!rtp_bad_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
95 printf("Got a bad RTP packet\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
96 rtp_bad_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
97 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
98 return;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
99 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
100 if (pkt.v_p_x_cc != 0x80)
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
101 goto bad_rtp_pkt;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
102 switch (pkt.m_pt & 0x7F) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
103 case PSTN_CODEC_PCMU:
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
104 case PSTN_CODEC_PCMA:
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
105 break;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
106 default:
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
107 goto bad_rtp_pkt;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
108 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
109 if (rtp_start_flag && pkt.ssrc != rtp_ssrc) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
110 if (!rtp_ssrc_chg_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
111 printf("Rx RTP stream changed SSRC\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
112 rtp_ssrc_chg_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
113 }
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
114 reset_is_hunt();
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
115 } else if (rtp_start_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
116 seq_delta = ntohs(pkt.seq) - rtp_last_seq;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
117 ts_delta = ntohl(pkt.tstamp) - rtp_last_ts;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
118 if (seq_delta == 0) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
119 if (!rtp_seq_zero_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
120 printf("Rx RTP seq zero increment\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
121 rtp_seq_zero_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
122 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
123 return;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
124 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
125 if (seq_delta < 0) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
126 if (!rtp_seq_neg_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
127 printf("Rx RTP seq negative increment\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
128 rtp_seq_neg_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
129 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
130 return;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
131 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
132 if (seq_delta != 1) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
133 if (!rtp_seq_brk_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
134 printf("Rx RTP stream seq break\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
135 rtp_seq_brk_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
136 }
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
137 reset_is_hunt();
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
138 } else if (ts_delta != 160) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
139 if (!rtp_ts_brk_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
140 printf("Rx RTP stream tstamp break\n");
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
141 rtp_ts_brk_flag = 1;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
142 }
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
143 reset_is_hunt();
188
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
144 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
145 }
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
146 rtp_ssrc = pkt.ssrc;
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
147 rtp_last_ts = ntohl(pkt.tstamp);
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
148 rtp_last_seq = ntohs(pkt.seq);
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
149 if (!rtp_start_flag) {
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
150 printf("Rx RTP stream begins with seq=%u ts=%u\n",
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
151 rtp_last_seq, rtp_last_ts);
6aecee01cf0a sip-manual-out: add RTP stream continuity analysis
Mychaela Falconia <falcon@freecalypso.org>
parents: 187
diff changeset
152 rtp_start_flag = 1;
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 }
189
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
154 for (is_chunk = 0; is_chunk < 10; is_chunk++)
1266e024de6c sip-manual-out: implement hunt for IS_Header in Rx RTP
Mychaela Falconia <falcon@freecalypso.org>
parents: 188
diff changeset
155 is_hunt_proc(pkt.payload + is_chunk * 16, is_chunk);
187
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 }
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 void
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 rtcp_rx_select()
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 {
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 u_char buf[512];
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 recv(rtcp_udp_fd, buf, sizeof buf, 0);
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 if (!got_some_rtcp) {
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 printf("Got some RTCP\n");
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 got_some_rtcp = 1;
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 }
258932879f8b sip-manual-out: rework for internal RTP handling, using themwi-rtp-mgr
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 }