Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 1 | #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 Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 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 Affero General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 25 | /*! \defgroup trau_frame TRAU frame handling |
| 26 | * @{ |
| 27 | * |
| 28 | * \file trau_frame.h |
| 29 | */ |
| 30 | |
| 31 | /*! \brief Maximum number of C-bits in a TRAU frame: |
| 32 | * 21 for FR/EFR, 25 for AMR, 15 for OM, 15 for data, 13 for E-data, 21 idle */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 33 | #define MAX_C_BITS 25 |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 34 | /*! \brief Maximum number of D-bits in a TRAU frame: |
| 35 | * 260 for FR/EFR, 256 for AMR, 264 for OM, 288 for E-data */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 36 | #define MAX_D_BITS 288 |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 37 | /*! \brief Maximum number of T-bits in a TRAU frame for all speech frames */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 38 | #define MAX_T_BITS 4 |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 39 | /*! \brief Maximum number of S-bits in a TRAU frame for OM */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 40 | #define MAX_S_BITS 6 |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 41 | /*! \brief Maximum number of M-bits in a TRAU frame for E-data */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 42 | #define MAX_M_BITS 2 |
| 43 | |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 44 | /*! \brief a decoded TRAU frame, extracted C/D/T/S/M bits */ |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 45 | struct decoded_trau_frame { |
| 46 | uint8_t c_bits[MAX_C_BITS]; |
| 47 | uint8_t d_bits[MAX_D_BITS]; |
| 48 | uint8_t t_bits[MAX_T_BITS]; |
| 49 | uint8_t s_bits[MAX_S_BITS]; |
| 50 | uint8_t m_bits[MAX_M_BITS]; |
| 51 | }; |
| 52 | |
| 53 | #define TRAU_FT_FR_UP 0x02 /* 0 0 0 1 0 - 3.5.1.1.1 */ |
| 54 | #define TRAU_FT_FR_DOWN 0x1c /* 1 1 1 0 0 - 3.5.1.1.1 */ |
| 55 | #define TRAU_FT_EFR 0x1a /* 1 1 0 1 0 - 3.5.1.1.1 */ |
| 56 | #define TRAU_FT_AMR 0x06 /* 0 0 1 1 0 - 3.5.1.2 */ |
| 57 | #define TRAU_FT_OM_UP 0x07 /* 0 0 1 0 1 - 3.5.2 */ |
| 58 | #define TRAU_FT_OM_DOWN 0x1b /* 1 1 0 1 1 - 3.5.2 */ |
| 59 | #define TRAU_FT_DATA_UP 0x08 /* 0 1 0 0 0 - 3.5.3 */ |
| 60 | #define TRAU_FT_DATA_DOWN 0x16 /* 1 0 1 1 0 - 3.5.3 */ |
| 61 | #define TRAU_FT_D145_SYNC 0x14 /* 1 0 1 0 0 - 3.5.3 */ |
| 62 | #define TRAU_FT_EDATA 0x1f /* 1 1 1 1 1 - 3.5.4 */ |
| 63 | #define TRAU_FT_IDLE_UP 0x10 /* 1 0 0 0 0 - 3.5.5 */ |
| 64 | #define TRAU_FT_IDLE_DOWN 0x0e /* 0 1 1 1 0 - 3.5.5 */ |
| 65 | |
| 66 | |
| 67 | int decode_trau_frame(struct decoded_trau_frame *fr, const uint8_t *trau_bits); |
| 68 | int encode_trau_frame(uint8_t *trau_bits, const struct decoded_trau_frame *fr); |
| 69 | int trau_frame_up2down(struct decoded_trau_frame *fr); |
| 70 | |
Pablo Neira Ayuso | 392d1dc | 2011-06-07 17:56:19 +0200 | [diff] [blame] | 71 | uint8_t *trau_idle_frame(void); |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 72 | |
Harald Welte | 2f69b89 | 2011-08-21 11:13:50 +0200 | [diff] [blame] | 73 | /* }@ */ |
| 74 | |
Pablo Neira Ayuso | 0ba77d5 | 2011-06-05 18:32:44 +0200 | [diff] [blame] | 75 | #endif /* _TRAU_FRAME_H */ |