comparison sip-manual-out/rtp_tx.c @ 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 a3d71489672f
children f3164f732b84
comparison
equal deleted inserted replaced
200:834656633fa0 201:d3c99b41fb04
22 22
23 static uint32_t rtp_ssrc; 23 static uint32_t rtp_ssrc;
24 static uint32_t rtp_out_ts; 24 static uint32_t rtp_out_ts;
25 static uint16_t rtp_out_seq; 25 static uint16_t rtp_out_seq;
26 26
27 static uint16_t is_out_buf[7], *is_out_ptr; 27 static uint16_t tfo_fill_buf[9], tfo_req_buf[7];
28 static uint16_t *is_out_ptr;
28 static unsigned is_out_count; 29 static unsigned is_out_count;
29 30
30 void 31 void
31 assign_rtpout_ssrc() 32 assign_rtpout_ssrc()
32 { 33 {
33 rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid(); 34 rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid();
35 }
36
37 void
38 prepare_tfo_fill()
39 {
40 tfo_fill_buf[0] = 0x15A;
41 tfo_fill_buf[1] = 0x1A9;
42 tfo_fill_buf[2] = 0x129;
43 tfo_fill_buf[3] = 0x15A;
44 tfo_fill_buf[4] = 0x1A9;
45 tfo_fill_buf[5] = 0x129;
46 tfo_fill_buf[6] = 0x15A;
47 tfo_fill_buf[7] = 0x1A9;
48 tfo_fill_buf[8] = 0x129;
34 } 49 }
35 50
36 static void 51 static void
37 insert_is_msg(payload, word) 52 insert_is_msg(payload, word)
38 uint8_t *payload; 53 uint8_t *payload;
64 pkt.ssrc = rtp_ssrc; 79 pkt.ssrc = rtp_ssrc;
65 memset(pkt.payload, pcma_selected ? 0xD5 : 0xFF, RTP_MAX_PAYLOAD); 80 memset(pkt.payload, pcma_selected ? 0xD5 : 0xFF, RTP_MAX_PAYLOAD);
66 if (is_out_count) { 81 if (is_out_count) {
67 insert_is_msg(pkt.payload, *is_out_ptr++); 82 insert_is_msg(pkt.payload, *is_out_ptr++);
68 is_out_count--; 83 is_out_count--;
84 if (!is_out_count) {
85 is_out_ptr = tfo_req_buf;
86 is_out_count = 7;
87 }
69 } 88 }
70 addrlen = sizeof(struct sockaddr_in); 89 addrlen = sizeof(struct sockaddr_in);
71 sendto(rtp_udp_fd, &pkt, RTP_PACKET_SIZE_PSTN, 0, 90 sendto(rtp_udp_fd, &pkt, RTP_PACKET_SIZE_PSTN, 0,
72 (struct sockaddr *) &rtp_remote_addr, addrlen); 91 (struct sockaddr *) &rtp_remote_addr, addrlen);
73 } 92 }
74 93
75 void 94 void
76 send_tfo_req(sig, codec) 95 send_tfo_req(sig, codec)
77 unsigned sig, codec; 96 unsigned sig, codec;
78 { 97 {
79 is_out_buf[0] = 0x15A; 98 tfo_req_buf[0] = 0x15A;
80 is_out_buf[1] = 0x1A9; 99 tfo_req_buf[1] = 0x1A9;
81 is_out_buf[2] = 0x05D; 100 tfo_req_buf[2] = 0x05D;
82 is_out_buf[3] = 0x14E; 101 tfo_req_buf[3] = 0x14E;
83 is_out_buf[4] = 0x14B; 102 tfo_req_buf[4] = 0x14B;
84 encode_tfo_ext_words(sig, codec, 0, is_out_buf + 5); 103 encode_tfo_ext_words(sig, codec, 0, tfo_req_buf + 5);
85 is_out_ptr = is_out_buf; 104 is_out_ptr = tfo_fill_buf;
86 is_out_count = 7; 105 is_out_count = 9;
87 } 106 }