comparison sip-manual-out/rtp_tx.c @ 211:fbfa72b114e8

sip-manual-out: prep for making PCM fill octet changeable
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 21 May 2023 15:33:00 -0800
parents f3164f732b84
children b3aeacc5722a
comparison
equal deleted inserted replaced
210:d96eaf2d6900 211:fbfa72b114e8
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 uint8_t pcm_fill_octet;
28
27 static uint16_t tfo_fill_buf[9], tfo_req_buf[7]; 29 static uint16_t tfo_fill_buf[9], tfo_req_buf[7];
28 static uint16_t *is_out_ptr; 30 static uint16_t *is_out_ptr;
29 static unsigned is_out_count; 31 static unsigned is_out_count;
30 static int tfo_stop_req; 32 static int tfo_stop_req;
31 33
32 void 34 void
33 assign_rtpout_ssrc() 35 assign_rtpout_ssrc()
34 { 36 {
35 rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid(); 37 rtp_ssrc = cur_event_time.tv_sec ^ cur_event_time.tv_usec ^ getpid();
38 }
39
40 void
41 init_pcm_fill_octet()
42 {
43 if (pcma_selected)
44 pcm_fill_octet = 0xD5;
45 else
46 pcm_fill_octet = 0xFF;
36 } 47 }
37 48
38 void 49 void
39 prepare_tfo_fill() 50 prepare_tfo_fill()
40 { 51 {
76 pkt.m_pt = pcma_selected ? PSTN_CODEC_PCMA : PSTN_CODEC_PCMU; 87 pkt.m_pt = pcma_selected ? PSTN_CODEC_PCMA : PSTN_CODEC_PCMU;
77 pkt.seq = htons(rtp_out_seq++); 88 pkt.seq = htons(rtp_out_seq++);
78 pkt.tstamp = htonl(rtp_out_ts); 89 pkt.tstamp = htonl(rtp_out_ts);
79 rtp_out_ts += 160; 90 rtp_out_ts += 160;
80 pkt.ssrc = rtp_ssrc; 91 pkt.ssrc = rtp_ssrc;
81 memset(pkt.payload, pcma_selected ? 0xD5 : 0xFF, RTP_MAX_PAYLOAD); 92 memset(pkt.payload, pcm_fill_octet, RTP_MAX_PAYLOAD);
82 if (is_out_count) { 93 if (is_out_count) {
83 insert_is_msg(pkt.payload, *is_out_ptr++); 94 insert_is_msg(pkt.payload, *is_out_ptr++);
84 is_out_count--; 95 is_out_count--;
85 if (!is_out_count && !tfo_stop_req) { 96 if (!is_out_count && !tfo_stop_req) {
86 is_out_ptr = tfo_req_buf; 97 is_out_ptr = tfo_req_buf;