blob: 6892debc3ffee9ce1e612052dff0f6e610d5a622 [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
Pau Espin Pedrole547bdd2018-07-28 02:46:12 +020024#if HAVE_GSM_H
Holger Hans Peter Freytherdd1f8152014-07-22 13:05:31 +020025#include <gsm.h>
Pau Espin Pedrole547bdd2018-07-28 02:46:12 +020026#elif HAVE_GSM_GSM_H
27#include <gsm/gsm.h>
28#endif
Holger Hans Peter Freytherdd1f8152014-07-22 13:05:31 +020029#ifdef HAVE_BCG729
30#include <bcg729/decoder.h>
31#include <bcg729/encoder.h>
32#endif
33
34enum audio_format {
35 AF_INVALID,
36 AF_S16,
37 AF_L16,
38 AF_GSM,
39 AF_G729,
Holger Hans Peter Freytherceef9362015-08-19 14:43:35 +020040 AF_PCMA,
41 AF_PCMU
Holger Hans Peter Freytherdd1f8152014-07-22 13:05:31 +020042};
43
44
45struct 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 Erlbeck239a8532014-03-13 14:25:51 +010080int mgcp_transcoding_setup(struct mgcp_endpoint *endp,
81 struct mgcp_rtp_end *dst_end,
82 struct mgcp_rtp_end *src_end);
83
84void mgcp_transcoding_net_downlink_format(struct mgcp_endpoint *endp,
85 int *payload_type,
86 const char**audio_name,
87 const char**fmtp_extra);
88
89int mgcp_transcoding_process_rtp(struct mgcp_endpoint *endp,
90 struct mgcp_rtp_end *dst_end,
91 char *data, int *len, int buf_size);
Jacob Erlbeck136a3192014-03-13 14:33:37 +010092
93int mgcp_transcoding_get_frame_size(void *state_, int nsamples, int dst);
Jacob Erlbeck239a8532014-03-13 14:25:51 +010094#endif /* OPENBSC_MGCP_TRANSCODE_H */