FreeCalypso > hg > gsm-codec-lib
annotate libgsmfr2/tfo_main.c @ 543:53d3f48af107
libgsmefr is now at version 1.2.0
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 29 Sep 2024 02:41:28 +0000 |
parents | c7b1e796e91b |
children |
rev | line source |
---|---|
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements a wrapper around the main processing functions |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
3 * of our Rx DTX or TFO preprocessor, handling RTP input per TW-TS-001. |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdint.h> |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
7 #include <string.h> |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include "tw_gsmfr.h" |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
10 int gsmfr_tfo_xfrm_main(struct gsmfr_preproc_state *st, const uint8_t *rtp_pl, |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
11 unsigned rtp_pl_len, uint8_t *out) |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 { |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 switch (rtp_pl_len) { |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 case 0: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 /* BFI-no-data, but not an invalid RTP input per se */ |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
16 gsmfr_preproc_bfi(st, 0, out); |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 case 1: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 if ((rtp_pl[0] & 0xF6) != 0xE6) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 /* TW-TS-001 No_Data frame */ |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
22 gsmfr_preproc_bfi(st, rtp_pl[0] & 1, out); |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 case GSMFR_RTP_FRAME_LEN: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if ((rtp_pl[0] & 0xF0) != 0xD0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 /* basic RTP format */ |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
28 memcpy(out, rtp_pl, GSMFR_RTP_FRAME_LEN); |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
29 gsmfr_preproc_good_frame_hm(st, out); |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 case GSMFR_RTP_FRAME_LEN+1: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if ((rtp_pl[0] & 0xF4) != 0xE0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 if ((rtp_pl[1] & 0xF0) != 0xD0) |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 goto bad_rtp_input; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 /* extended RTP format (TW-TS-001) */ |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (rtp_pl[0] & 0x02) |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
38 gsmfr_preproc_bfi_bits(st, rtp_pl + 1, rtp_pl[0] & 1, |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
39 out); |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
40 else { |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
41 memcpy(out, rtp_pl + 1, GSMFR_RTP_FRAME_LEN); |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
42 gsmfr_preproc_good_frame_hm(st, out); |
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
43 } |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 return 0; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 default: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 bad_rtp_input: |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 /* |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * Treat it like BFI-no-data, and tell the caller |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * that we received an invalid RTP payload. |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 */ |
531
c7b1e796e91b
libgsmfr2 TFO: implement main entry point function
Mychaela Falconia <falcon@freecalypso.org>
parents:
528
diff
changeset
|
51 gsmfr_preproc_bfi(st, 0, out); |
528
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 return -1; |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
f681fb758041
libgsmfr2: add gsmfr_fulldec_rtp_in()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 } |