blob: 5923d4ac18ecff50d1487104148802dcafb4934f [file] [log] [blame]
Harald Welte2a8ee522009-01-05 19:01:01 +00001#ifndef _TRAU_FRAME_H
2#define _TRAU_FRAME_H
3/* TRAU frame handling according to GSM TS 08.60 */
4
5/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
6 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#include <sys/types.h>
25
26/* 21 for FR/EFR, 25 for AMR, 15 for OM, 15 for data, 13 for E-data, 21 idle */
27#define MAX_C_BITS 25
28/* 260 for FR/EFR, 256 for AMR, 264 for OM, 288 for E-data */
29#define MAX_D_BITS 288
30/* for all speech frames */
31#define MAX_T_BITS 4
32/* for OM */
33#define MAX_S_BITS 6
34/* for E-data */
35#define MAX_M_BITS 2
36
37struct decoded_trau_frame {
38 u_int8_t c_bits[MAX_C_BITS];
39 u_int8_t d_bits[MAX_D_BITS];
40 u_int8_t t_bits[MAX_T_BITS];
41 u_int8_t s_bits[MAX_S_BITS];
42 u_int8_t m_bits[MAX_M_BITS];
43};
44
45#define TRAU_FT_FR_UP 0x02 /* 0 0 0 1 0 - 3.5.1.1.1 */
46#define TRAU_FT_FR_DOWN 0x1c /* 1 1 1 0 0 - 3.5.1.1.1 */
47#define TRAU_FT_EFR 0x1a /* 1 1 0 1 0 - 3.5.1.1.1 */
48#define TRAU_FT_AMR 0x06 /* 0 0 1 1 0 - 3.5.1.2 */
49#define TRAU_FT_OM_UP 0x07 /* 0 0 1 0 1 - 3.5.2 */
50#define TRAU_FT_OM_DOWN 0x1b /* 1 1 0 1 1 - 3.5.2 */
51#define TRAU_FT_DATA_UP 0x08 /* 0 1 0 0 0 - 3.5.3 */
52#define TRAU_FT_DATA_DOWN 0x16 /* 1 0 1 1 0 - 3.5.3 */
53#define TRAU_FT_D145_SYNC 0x14 /* 1 0 1 0 0 - 3.5.3 */
54#define TRAU_FT_EDATA 0x1f /* 1 1 1 1 1 - 3.5.4 */
Harald Welte38e04372009-01-05 19:42:46 +000055#define TRAU_FT_IDLE_UP 0x10 /* 1 0 0 0 0 - 3.5.5 */
56#define TRAU_FT_IDLE_DOWN 0x0e /* 0 1 1 1 0 - 3.5.5 */
Harald Welte2a8ee522009-01-05 19:01:01 +000057
58
Harald Welte418f5a42009-01-05 20:12:47 +000059int decode_trau_frame(struct decoded_trau_frame *fr, const u_int8_t *trau_bits);
60int encode_trau_frame(u_int8_t *trau_bits, const struct decoded_trau_frame *fr);
61int trau_frame_up2down(struct decoded_trau_frame *fr);
Harald Welte1fa60c82009-02-09 18:13:26 +000062u_int8_t *trau_idle_frame(void);
Harald Welte418f5a42009-01-05 20:12:47 +000063
Harald Welte2a8ee522009-01-05 19:01:01 +000064
65#endif /* _TRAU_FRAME_H */