Jacob Erlbeck | 239a853 | 2014-03-13 14:25:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) 2014 by On-Waves |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | #ifndef OPENBSC_MGCP_TRANSCODE_H |
| 20 | #define OPENBSC_MGCP_TRANSCODE_H |
| 21 | |
Holger Hans Peter Freyther | dd1f815 | 2014-07-22 13:05:31 +0200 | [diff] [blame] | 22 | #include "bscconfig.h" |
| 23 | |
Pau Espin Pedrol | e547bdd | 2018-07-28 02:46:12 +0200 | [diff] [blame] | 24 | #if HAVE_GSM_H |
Holger Hans Peter Freyther | dd1f815 | 2014-07-22 13:05:31 +0200 | [diff] [blame] | 25 | #include <gsm.h> |
Pau Espin Pedrol | e547bdd | 2018-07-28 02:46:12 +0200 | [diff] [blame] | 26 | #elif HAVE_GSM_GSM_H |
| 27 | #include <gsm/gsm.h> |
| 28 | #endif |
Holger Hans Peter Freyther | dd1f815 | 2014-07-22 13:05:31 +0200 | [diff] [blame] | 29 | #ifdef HAVE_BCG729 |
| 30 | #include <bcg729/decoder.h> |
| 31 | #include <bcg729/encoder.h> |
| 32 | #endif |
| 33 | |
| 34 | enum audio_format { |
| 35 | AF_INVALID, |
| 36 | AF_S16, |
| 37 | AF_L16, |
| 38 | AF_GSM, |
| 39 | AF_G729, |
Holger Hans Peter Freyther | ceef936 | 2015-08-19 14:43:35 +0200 | [diff] [blame] | 40 | AF_PCMA, |
| 41 | AF_PCMU |
Holger Hans Peter Freyther | dd1f815 | 2014-07-22 13:05:31 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
| 44 | |
| 45 | struct mgcp_process_rtp_state { |
| 46 | /* decoding */ |
| 47 | enum audio_format src_fmt; |
| 48 | union { |
| 49 | gsm gsm_handle; |
| 50 | #ifdef HAVE_BCG729 |
| 51 | bcg729DecoderChannelContextStruct *g729_dec; |
| 52 | #endif |
| 53 | } src; |
| 54 | size_t src_frame_size; |
| 55 | size_t src_samples_per_frame; |
| 56 | |
| 57 | /* processing */ |
| 58 | |
| 59 | /* encoding */ |
| 60 | enum audio_format dst_fmt; |
| 61 | union { |
| 62 | gsm gsm_handle; |
| 63 | #ifdef HAVE_BCG729 |
| 64 | bcg729EncoderChannelContextStruct *g729_enc; |
| 65 | #endif |
| 66 | } dst; |
| 67 | size_t dst_frame_size; |
| 68 | size_t dst_samples_per_frame; |
| 69 | int dst_packet_duration; |
| 70 | |
| 71 | int is_running; |
| 72 | uint16_t next_seq; |
| 73 | uint32_t next_time; |
| 74 | int16_t samples[10*160]; |
| 75 | size_t sample_cnt; |
| 76 | size_t sample_offs; |
| 77 | }; |
| 78 | |
| 79 | |
Jacob Erlbeck | 239a853 | 2014-03-13 14:25:51 +0100 | [diff] [blame] | 80 | int mgcp_transcoding_setup(struct mgcp_endpoint *endp, |
| 81 | struct mgcp_rtp_end *dst_end, |
| 82 | struct mgcp_rtp_end *src_end); |
| 83 | |
| 84 | void mgcp_transcoding_net_downlink_format(struct mgcp_endpoint *endp, |
| 85 | int *payload_type, |
| 86 | const char**audio_name, |
| 87 | const char**fmtp_extra); |
| 88 | |
| 89 | int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp, |
| 90 | struct mgcp_rtp_end *dst_end, |
| 91 | char *data, int *len, int buf_size); |
Jacob Erlbeck | 136a319 | 2014-03-13 14:33:37 +0100 | [diff] [blame] | 92 | |
| 93 | int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst); |
Jacob Erlbeck | 239a853 | 2014-03-13 14:25:51 +0100 | [diff] [blame] | 94 | #endif /* OPENBSC_MGCP_TRANSCODE_H */ |