FreeCalypso > hg > gsm-codec-lib
comparison libgsmhr1/twts002_in.c @ 491:45bf34451dd7
libgsmhr1: implement TW-TS-002 input
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 15 Jun 2024 06:22:21 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
490:4d80730683d4 | 491:45bf34451dd7 |
---|---|
1 /* | |
2 * The function implemented in this module parses a received TW-TS-002 | |
3 * RTP payload and turns it into the internal input form for the HRv1 | |
4 * decoder. | |
5 */ | |
6 | |
7 #include <stdint.h> | |
8 #include <string.h> | |
9 #include "tw_gsmhr.h" | |
10 | |
11 int gsmhr_decoder_twts002_in(const uint8_t *payload, int16_t *params) | |
12 { | |
13 int ft; | |
14 | |
15 if (payload[0] & 0x80) | |
16 return -1; | |
17 ft = payload[0] >> 4; | |
18 switch (ft) { | |
19 case 0: | |
20 gsmhr_unpack_ts101318(payload + 1, params); | |
21 params[18] = 0; /* BFI */ | |
22 params[20] = 0; /* SID */ | |
23 break; | |
24 case 1: | |
25 memset(params, 0, sizeof(int16_t) * GSMHR_NUM_PARAMS); | |
26 params[18] = 0; /* BFI */ | |
27 params[20] = 1; /* SID */ | |
28 break; | |
29 case 2: | |
30 gsmhr_unpack_ts101318(payload + 1, params); | |
31 params[18] = 0; /* BFI */ | |
32 params[20] = 2; /* SID */ | |
33 break; | |
34 case 6: | |
35 gsmhr_unpack_ts101318(payload + 1, params); | |
36 params[18] = 1; /* BFI */ | |
37 params[20] = 0; /* SID */ | |
38 break; | |
39 case 7: | |
40 memset(params, 0, sizeof(int16_t) * GSMHR_NUM_PARAMS); | |
41 params[18] = 2; /* BFI with no data */ | |
42 params[20] = 0; /* SID */ | |
43 break; | |
44 default: | |
45 return -2; | |
46 } | |
47 /* UFI and TAF always get their own bits */ | |
48 params[19] = (payload[0] & 0x02) >> 1; | |
49 params[21] = payload[0] & 0x01; | |
50 return 0; | |
51 } |