blob: 85c1cd02a08925bc3d6b21ede84ad54260cf2f20 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
12#define MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
Niels Möllera12c42a2018-07-25 16:05:48 +020014#include <stdint.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16/*
17 * Solution to support multiple instances
18 */
19
Yves Gerey665174f2018-06-19 15:03:05 +020020typedef struct WebRtcG722EncInst G722EncInst;
21typedef struct WebRtcG722DecInst G722DecInst;
niklase@google.com470e71d2011-07-07 08:21:25 +000022
23/*
24 * Comfort noise constants
25 */
26
Yves Gerey665174f2018-06-19 15:03:05 +020027#define G722_WEBRTC_SPEECH 1
28#define G722_WEBRTC_CNG 2
niklase@google.com470e71d2011-07-07 08:21:25 +000029
30#ifdef __cplusplus
31extern "C" {
32#endif
33
niklase@google.com470e71d2011-07-07 08:21:25 +000034/****************************************************************************
35 * WebRtcG722_CreateEncoder(...)
36 *
37 * Create memory used for G722 encoder
38 *
39 * Input:
40 * - G722enc_inst : G722 instance for encoder
41 *
42 * Return value : 0 - Ok
43 * -1 - Error
44 */
Yves Gerey665174f2018-06-19 15:03:05 +020045int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000046
47/****************************************************************************
48 * WebRtcG722_EncoderInit(...)
49 *
50 * This function initializes a G722 instance
51 *
52 * Input:
53 * - G722enc_inst : G722 instance, i.e. the user that should receive
54 * be initialized
55 *
56 * Return value : 0 - Ok
57 * -1 - Error
58 */
59
Yves Gerey665174f2018-06-19 15:03:05 +020060int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000061
62/****************************************************************************
63 * WebRtcG722_FreeEncoder(...)
64 *
65 * Free the memory used for G722 encoder
66 *
67 * Input:
68 * - G722enc_inst : G722 instance for encoder
69 *
70 * Return value : 0 - Ok
71 * -1 - Error
72 */
Yves Gerey665174f2018-06-19 15:03:05 +020073int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000074
75/****************************************************************************
76 * WebRtcG722_Encode(...)
77 *
78 * This function encodes G722 encoded data.
79 *
80 * Input:
81 * - G722enc_inst : G722 instance, i.e. the user that should encode
82 * a packet
83 * - speechIn : Input speech vector
84 * - len : Samples in speechIn
85 *
86 * Output:
87 * - encoded : The encoded data vector
88 *
Peter Kasting728d9032015-06-11 14:31:38 -070089 * Return value : Length (in bytes) of coded data
niklase@google.com470e71d2011-07-07 08:21:25 +000090 */
91
Peter Kastingdce40cf2015-08-24 14:52:23 -070092size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
93 const int16_t* speechIn,
94 size_t len,
95 uint8_t* encoded);
niklase@google.com470e71d2011-07-07 08:21:25 +000096
niklase@google.com470e71d2011-07-07 08:21:25 +000097/****************************************************************************
98 * WebRtcG722_CreateDecoder(...)
99 *
100 * Create memory used for G722 encoder
101 *
102 * Input:
103 * - G722dec_inst : G722 instance for decoder
104 *
105 * Return value : 0 - Ok
106 * -1 - Error
107 */
Yves Gerey665174f2018-06-19 15:03:05 +0200108int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000109
niklase@google.com470e71d2011-07-07 08:21:25 +0000110/****************************************************************************
111 * WebRtcG722_DecoderInit(...)
112 *
Karl Wiberg43766482015-08-27 15:22:11 +0200113 * This function initializes a G722 instance
niklase@google.com470e71d2011-07-07 08:21:25 +0000114 *
115 * Input:
Karl Wiberg43766482015-08-27 15:22:11 +0200116 * - inst : G722 instance
niklase@google.com470e71d2011-07-07 08:21:25 +0000117 */
118
Karl Wiberg43766482015-08-27 15:22:11 +0200119void WebRtcG722_DecoderInit(G722DecInst* inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000120
121/****************************************************************************
122 * WebRtcG722_FreeDecoder(...)
123 *
124 * Free the memory used for G722 decoder
125 *
126 * Input:
127 * - G722dec_inst : G722 instance for decoder
128 *
129 * Return value : 0 - Ok
130 * -1 - Error
131 */
132
Yves Gerey665174f2018-06-19 15:03:05 +0200133int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000134
135/****************************************************************************
136 * WebRtcG722_Decode(...)
137 *
138 * This function decodes a packet with G729 frame(s). Output speech length
139 * will be a multiple of 80 samples (80*frames/packet).
140 *
141 * Input:
142 * - G722dec_inst : G722 instance, i.e. the user that should decode
143 * a packet
144 * - encoded : Encoded G722 frame(s)
145 * - len : Bytes in encoded vector
146 *
147 * Output:
148 * - decoded : The decoded vector
149 * - speechType : 1 normal, 2 CNG (Since G722 does not have its own
150 * DTX/CNG scheme it should always return 1)
151 *
Peter Kastingdce40cf2015-08-24 14:52:23 -0700152 * Return value : Samples in decoded vector
niklase@google.com470e71d2011-07-07 08:21:25 +0000153 */
154
Yves Gerey665174f2018-06-19 15:03:05 +0200155size_t WebRtcG722_Decode(G722DecInst* G722dec_inst,
Peter Kastingdce40cf2015-08-24 14:52:23 -0700156 const uint8_t* encoded,
157 size_t len,
Yves Gerey665174f2018-06-19 15:03:05 +0200158 int16_t* decoded,
159 int16_t* speechType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000160
161/****************************************************************************
162 * WebRtcG722_Version(...)
163 *
164 * Get a string with the current version of the codec
165 */
166
Yves Gerey665174f2018-06-19 15:03:05 +0200167int16_t WebRtcG722_Version(char* versionStr, short len);
niklase@google.com470e71d2011-07-07 08:21:25 +0000168
169#ifdef __cplusplus
170}
171#endif
172
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200173#endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */