FreeCalypso > hg > sipout-test-utils
diff test-voice/rtp_tx.c @ 13:059b79c9f0c3
sipout-test-voice: add DMW output mode
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 07 Apr 2024 17:09:32 -0800 |
parents | 35c0d9f03c0a |
children | f96153d15889 |
line wrap: on
line diff
--- a/test-voice/rtp_tx.c Mon Mar 11 12:45:09 2024 -0800 +++ b/test-voice/rtp_tx.c Sun Apr 07 17:09:32 2024 -0800 @@ -20,11 +20,17 @@ extern int rtp_udp_fd, rtcp_udp_fd, pcma_selected; extern struct timeval cur_event_time; +static const uint8_t dmw_alaw[8] = + {0x34, 0x21, 0x21, 0x34, 0xB4, 0xA1, 0xA1, 0xB4}; +static const uint8_t dmw_ulaw[8] = + {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E}; + static uint32_t rtp_ssrc; static uint32_t rtp_out_ts; static uint16_t rtp_out_seq; static uint8_t pcm_fill_octet; +static int dmw_active; static uint16_t tfo_fill_buf[9], tfo_req_buf[7]; static uint16_t *is_out_ptr; @@ -77,6 +83,23 @@ } } +static void +fill_with_dmw(buf) + uint8_t *buf; +{ + const uint8_t *src; + unsigned n; + + if (pcma_selected) + src = dmw_alaw; + else + src = dmw_ulaw; + for (n = 0; n < 20; n++) { + memcpy(buf, src, 8); + buf += 8; + } +} + void generate_rtp_packet() { @@ -89,7 +112,10 @@ pkt.tstamp = htonl(rtp_out_ts); rtp_out_ts += 160; pkt.ssrc = rtp_ssrc; - memset(pkt.payload, pcm_fill_octet, RTP_MAX_PAYLOAD); + if (dmw_active) + fill_with_dmw(pkt.payload); + else + memset(pkt.payload, pcm_fill_octet, RTP_MAX_PAYLOAD); if (is_out_count) { insert_is_msg(pkt.payload, *is_out_ptr++); is_out_count--; @@ -130,3 +156,15 @@ { tfo_stop_req = 1; } + +void +cmd_dmw_on() +{ + dmw_active = 1; +} + +void +cmd_dmw_off() +{ + dmw_active = 0; +}