annotate libgsmhr1/twts002_in.c @ 529:79cd992de3ad

libgsmfr2: API definitions for TFO transform
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Sep 2024 08:07:26 +0000
parents 45bf34451dd7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
491
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The function implemented in this module parses a received TW-TS-002
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * RTP payload and turns it into the internal input form for the HRv1
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * decoder.
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <string.h>
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include "tw_gsmhr.h"
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 int gsmhr_decoder_twts002_in(const uint8_t *payload, int16_t *params)
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int ft;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 if (payload[0] & 0x80)
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 return -1;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 ft = payload[0] >> 4;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 switch (ft) {
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 case 0:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 gsmhr_unpack_ts101318(payload + 1, params);
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 params[18] = 0; /* BFI */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 params[20] = 0; /* SID */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 break;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 case 1:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 memset(params, 0, sizeof(int16_t) * GSMHR_NUM_PARAMS);
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 params[18] = 0; /* BFI */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 params[20] = 1; /* SID */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 break;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 case 2:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 gsmhr_unpack_ts101318(payload + 1, params);
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 params[18] = 0; /* BFI */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 params[20] = 2; /* SID */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 break;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 case 6:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 gsmhr_unpack_ts101318(payload + 1, params);
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 params[18] = 1; /* BFI */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 params[20] = 0; /* SID */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 break;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 case 7:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 memset(params, 0, sizeof(int16_t) * GSMHR_NUM_PARAMS);
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 params[18] = 2; /* BFI with no data */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 params[20] = 0; /* SID */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 break;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 default:
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 return -2;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 /* UFI and TAF always get their own bits */
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 params[19] = (payload[0] & 0x02) >> 1;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 params[21] = payload[0] & 0x01;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 return 0;
45bf34451dd7 libgsmhr1: implement TW-TS-002 input
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }