FreeCalypso > hg > sipout-test-utils
diff test-fsk/rtp_rx.c @ 6:ba66d297fe57
test-fsk: first attempt at modem Rx
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 04 Mar 2024 23:21:07 -0800 |
parents | cc997f9ae186 |
children | eaf0e8f81a22 |
line wrap: on
line diff
--- a/test-fsk/rtp_rx.c Mon Mar 04 22:25:53 2024 -0800 +++ b/test-fsk/rtp_rx.c Mon Mar 04 23:21:07 2024 -0800 @@ -14,8 +14,12 @@ #include <strings.h> #include "../include/tmgw_const.h" #include "../include/rtp_defs.h" +#include "../include/pstn_defs.h" #include "../librtpalloc/rtp_alloc_simple.h" +extern const uint16_t pcmu_decode_table[256]; +extern const uint16_t pcma_decode_table[256]; + struct sockaddr_in rtp_local_addr; int rtp_udp_fd, rtcp_udp_fd; @@ -49,6 +53,9 @@ socklen_t addrlen; int16_t seq_delta; int32_t ts_delta; + const uint16_t *pcm_dec_table; + int16_t pcm_samples[FRAME_20MS]; + unsigned n; int rc; addrlen = sizeof(struct sockaddr_in); @@ -67,7 +74,10 @@ goto bad_rtp_pkt; switch (pkt.m_pt & 0x7F) { case PSTN_CODEC_PCMU: + pcm_dec_table = pcmu_decode_table; + break; case PSTN_CODEC_PCMA: + pcm_dec_table = pcma_decode_table; break; default: goto bad_rtp_pkt; @@ -114,6 +124,9 @@ rtp_last_seq, rtp_last_ts); rtp_start_flag = 1; } + for (n = 0; n < FRAME_20MS; n++) + pcm_samples[n] = pcm_dec_table[pkt.payload[n]]; + process_rx_frame(pcm_samples); } void