blob: cb11cb217a9d4c553852b635460904236916b3fe [file] [log] [blame]
Jacob Erlbeck239a8532014-03-13 14:25:51 +01001/*
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 Freytherdd1f8152014-07-22 13:05:31 +020022#include "bscconfig.h"
23
24#include <gsm.h>
25#ifdef HAVE_BCG729
26#include <bcg729/decoder.h>
27#include <bcg729/encoder.h>
28#endif
29
30enum audio_format {
31 AF_INVALID,
32 AF_S16,
33 AF_L16,
34 AF_GSM,
35 AF_G729,
36 AF_PCMA
37};
38
39
40struct mgcp_process_rtp_state {
41 /* decoding */
42 enum audio_format src_fmt;
43 union {
44 gsm gsm_handle;
45#ifdef HAVE_BCG729
46 bcg729DecoderChannelContextStruct *g729_dec;
47#endif
48 } src;
49 size_t src_frame_size;
50 size_t src_samples_per_frame;
51
52 /* processing */
53
54 /* encoding */
55 enum audio_format dst_fmt;
56 union {
57 gsm gsm_handle;
58#ifdef HAVE_BCG729
59 bcg729EncoderChannelContextStruct *g729_enc;
60#endif
61 } dst;
62 size_t dst_frame_size;
63 size_t dst_samples_per_frame;
64 int dst_packet_duration;
65
66 int is_running;
67 uint16_t next_seq;
68 uint32_t next_time;
69 int16_t samples[10*160];
70 size_t sample_cnt;
71 size_t sample_offs;
72};
73
74
Jacob Erlbeck239a8532014-03-13 14:25:51 +010075int mgcp_transcoding_setup(struct mgcp_endpoint *endp,
76 struct mgcp_rtp_end *dst_end,
77 struct mgcp_rtp_end *src_end);
78
79void mgcp_transcoding_net_downlink_format(struct mgcp_endpoint *endp,
80 int *payload_type,
81 const char**audio_name,
82 const char**fmtp_extra);
83
84int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
85 struct mgcp_rtp_end *dst_end,
86 char *data, int *len, int buf_size);
Jacob Erlbeck136a3192014-03-13 14:33:37 +010087
88int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst);
Jacob Erlbeck239a8532014-03-13 14:25:51 +010089#endif /* OPENBSC_MGCP_TRANSCODE_H */