FreeCalypso > hg > gsm-codec-lib
comparison libgsmefr/dec_rtp_in.c @ 542:f2d0f2f15d5f
libgsmefr: add wrapper for TW-TS-001 RTP input
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 28 Sep 2024 06:38:08 +0000 |
parents | libgsmfr2/full_dec_wrap.c@f681fb758041 |
children |
comparison
equal
deleted
inserted
replaced
541:23656d874524 | 542:f2d0f2f15d5f |
---|---|
1 /* | |
2 * This module implements a wrapper around the main processing functions | |
3 * of our full decoder, handling RTP input per TW-TS-001. | |
4 */ | |
5 | |
6 #include <stdint.h> | |
7 #include "gsm_efr.h" | |
8 | |
9 int EFR_decode_rtp(struct EFR_decoder_state *st, const uint8_t *rtp_pl, | |
10 unsigned rtp_pl_len, int16_t *pcm) | |
11 { | |
12 switch (rtp_pl_len) { | |
13 case 0: | |
14 /* BFI-no-data, but not an invalid RTP input per se */ | |
15 EFR_decode_bfi_nodata(st, 0, pcm); | |
16 return 0; | |
17 case 1: | |
18 if ((rtp_pl[0] & 0xF6) != 0xE6) | |
19 goto bad_rtp_input; | |
20 /* TW-TS-001 No_Data frame */ | |
21 EFR_decode_bfi_nodata(st, rtp_pl[0] & 1, pcm); | |
22 return 0; | |
23 case EFR_RTP_FRAME_LEN: | |
24 if ((rtp_pl[0] & 0xF0) != 0xC0) | |
25 goto bad_rtp_input; | |
26 /* basic RTP format */ | |
27 EFR_decode_frame(st, rtp_pl, 0, 0, pcm); | |
28 return 0; | |
29 case EFR_RTP_FRAME_LEN+1: | |
30 if ((rtp_pl[0] & 0xF4) != 0xE0) | |
31 goto bad_rtp_input; | |
32 if ((rtp_pl[1] & 0xF0) != 0xC0) | |
33 goto bad_rtp_input; | |
34 /* extended RTP format (TW-TS-001) */ | |
35 EFR_decode_frame(st, rtp_pl + 1, (rtp_pl[0] & 2) >> 1, | |
36 rtp_pl[0] & 1, pcm); | |
37 return 0; | |
38 default: | |
39 bad_rtp_input: | |
40 /* | |
41 * Treat it like BFI-no-data, and tell the caller | |
42 * that we received an invalid RTP payload. | |
43 */ | |
44 EFR_decode_bfi_nodata(st, 0, pcm); | |
45 return -1; | |
46 } | |
47 } |