# HG changeset patch # User Mychaela Falconia # Date 1712538572 28800 # Node ID 059b79c9f0c343419c549e8ace9fd4728bc6e2e0 # Parent 372be50488d63b694821e39acdb63ccea9583897 sipout-test-voice: add DMW output mode diff -r 372be50488d6 -r 059b79c9f0c3 test-voice/rtp_tx.c --- 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; +} diff -r 372be50488d6 -r 059b79c9f0c3 test-voice/user_cmd.c --- a/test-voice/user_cmd.c Mon Mar 11 12:45:09 2024 -0800 +++ b/test-voice/user_cmd.c Sun Apr 07 17:09:32 2024 -0800 @@ -93,6 +93,10 @@ send_cancel_req(); else if (!strncmp(cp, "pcm-fill", 8) && isspace(cp[8])) pcm_fill_cmd(cp + 9); + else if (!strcmp(cp, "dmw-on")) + cmd_dmw_on(); + else if (!strcmp(cp, "dmw-off")) + cmd_dmw_off(); else if (!strncmp(cp, "tfo-req", 7) && isspace(cp[7])) tfo_req_cmd(cp + 8); else if (!strcmp(cp, "tfo-stop"))