FreeCalypso > hg > gsm-codec-lib
comparison libgsmfr2/full_dec_wrap.c @ 528:f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 19 Sep 2024 07:52:17 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 527:f3246d109e2d | 528:f681fb758041 |
|---|---|
| 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 "tw_gsmfr.h" | |
| 8 | |
| 9 int gsmfr_fulldec_rtp_in(struct gsmfr_fulldec_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 gsmfr_fulldec_bfi(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 gsmfr_fulldec_bfi(st, rtp_pl[0] & 1, pcm); | |
| 22 return 0; | |
| 23 case GSMFR_RTP_FRAME_LEN: | |
| 24 if ((rtp_pl[0] & 0xF0) != 0xD0) | |
| 25 goto bad_rtp_input; | |
| 26 /* basic RTP format */ | |
| 27 gsmfr_fulldec_good_frame(st, rtp_pl, pcm); | |
| 28 return 0; | |
| 29 case GSMFR_RTP_FRAME_LEN+1: | |
| 30 if ((rtp_pl[0] & 0xF4) != 0xE0) | |
| 31 goto bad_rtp_input; | |
| 32 if ((rtp_pl[1] & 0xF0) != 0xD0) | |
| 33 goto bad_rtp_input; | |
| 34 /* extended RTP format (TW-TS-001) */ | |
| 35 if (rtp_pl[0] & 0x02) | |
| 36 gsmfr_fulldec_bfi_bits(st, rtp_pl + 1, rtp_pl[0] & 1, | |
| 37 pcm); | |
| 38 else | |
| 39 gsmfr_fulldec_good_frame(st, rtp_pl + 1, pcm); | |
| 40 return 0; | |
| 41 default: | |
| 42 bad_rtp_input: | |
| 43 /* | |
| 44 * Treat it like BFI-no-data, and tell the caller | |
| 45 * that we received an invalid RTP payload. | |
| 46 */ | |
| 47 gsmfr_fulldec_bfi(st, 0, pcm); | |
| 48 return -1; | |
| 49 } | |
| 50 } |
