blob: 147e48bba941fcbc9410f7b28845262b8b1956d6 [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,
Holger Hans Peter Freytherceef9362015-08-19 14:43:35 +020036 AF_PCMA,
37 AF_PCMU
Holger Hans Peter Freytherdd1f8152014-07-22 13:05:31 +020038};
39
40
41struct mgcp_process_rtp_state {
42 /* decoding */
43 enum audio_format src_fmt;
44 union {
45 gsm gsm_handle;
46#ifdef HAVE_BCG729
47 bcg729DecoderChannelContextStruct *g729_dec;
48#endif
49 } src;
50 size_t src_frame_size;
51 size_t src_samples_per_frame;
52
53 /* processing */
54
55 /* encoding */
56 enum audio_format dst_fmt;
57 union {
58 gsm gsm_handle;
59#ifdef HAVE_BCG729
60 bcg729EncoderChannelContextStruct *g729_enc;
61#endif
62 } dst;
63 size_t dst_frame_size;
64 size_t dst_samples_per_frame;
65 int dst_packet_duration;
66
67 int is_running;
68 uint16_t next_seq;
69 uint32_t next_time;
70 int16_t samples[10*160];
71 size_t sample_cnt;
72 size_t sample_offs;
73};
74
75
Jacob Erlbeck239a8532014-03-13 14:25:51 +010076int mgcp_transcoding_setup(struct mgcp_endpoint *endp,
77 struct mgcp_rtp_end *dst_end,
78 struct mgcp_rtp_end *src_end);
79
80void mgcp_transcoding_net_downlink_format(struct mgcp_endpoint *endp,
81 int *payload_type,
82 const char**audio_name,
83 const char**fmtp_extra);
84
85int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
86 struct mgcp_rtp_end *dst_end,
87 char *data, int *len, int buf_size);
Jacob Erlbeck136a3192014-03-13 14:33:37 +010088
89int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst);
Jacob Erlbeck239a8532014-03-13 14:25:51 +010090#endif /* OPENBSC_MGCP_TRANSCODE_H */