blob: d95722314f8718a2e88c28849c4b4c9142747252 [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
Mirko Bonadei71207422017-09-15 13:58:09 +020014#include "typedefs.h" // NOLINT(build/include)
niklase@google.com470e71d2011-07-07 08:21:25 +000015
16/*
17 * Solution to support multiple instances
18 */
19
20typedef struct WebRtcG722EncInst G722EncInst;
21typedef struct WebRtcG722DecInst G722DecInst;
22
23/*
24 * Comfort noise constants
25 */
26
27#define G722_WEBRTC_SPEECH 1
28#define G722_WEBRTC_CNG 2
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34
35/****************************************************************************
36 * WebRtcG722_CreateEncoder(...)
37 *
38 * Create memory used for G722 encoder
39 *
40 * Input:
41 * - G722enc_inst : G722 instance for encoder
42 *
43 * Return value : 0 - Ok
44 * -1 - Error
45 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +000046int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000047
48
49/****************************************************************************
50 * WebRtcG722_EncoderInit(...)
51 *
52 * This function initializes a G722 instance
53 *
54 * Input:
55 * - G722enc_inst : G722 instance, i.e. the user that should receive
56 * be initialized
57 *
58 * Return value : 0 - Ok
59 * -1 - Error
60 */
61
pbos@webrtc.org0946a562013-04-09 00:28:06 +000062int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000063
64
65/****************************************************************************
66 * WebRtcG722_FreeEncoder(...)
67 *
68 * Free the memory used for G722 encoder
69 *
70 * Input:
71 * - G722enc_inst : G722 instance for encoder
72 *
73 * Return value : 0 - Ok
74 * -1 - Error
75 */
Peter Kastingbba78072015-06-11 19:02:46 -070076int WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +000077
78
79
80/****************************************************************************
81 * WebRtcG722_Encode(...)
82 *
83 * This function encodes G722 encoded data.
84 *
85 * Input:
86 * - G722enc_inst : G722 instance, i.e. the user that should encode
87 * a packet
88 * - speechIn : Input speech vector
89 * - len : Samples in speechIn
90 *
91 * Output:
92 * - encoded : The encoded data vector
93 *
Peter Kasting728d9032015-06-11 14:31:38 -070094 * Return value : Length (in bytes) of coded data
niklase@google.com470e71d2011-07-07 08:21:25 +000095 */
96
Peter Kastingdce40cf2015-08-24 14:52:23 -070097size_t WebRtcG722_Encode(G722EncInst* G722enc_inst,
98 const int16_t* speechIn,
99 size_t len,
100 uint8_t* encoded);
niklase@google.com470e71d2011-07-07 08:21:25 +0000101
102
103/****************************************************************************
104 * WebRtcG722_CreateDecoder(...)
105 *
106 * Create memory used for G722 encoder
107 *
108 * Input:
109 * - G722dec_inst : G722 instance for decoder
110 *
111 * Return value : 0 - Ok
112 * -1 - Error
113 */
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000114int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000115
niklase@google.com470e71d2011-07-07 08:21:25 +0000116/****************************************************************************
117 * WebRtcG722_DecoderInit(...)
118 *
Karl Wiberg43766482015-08-27 15:22:11 +0200119 * This function initializes a G722 instance
niklase@google.com470e71d2011-07-07 08:21:25 +0000120 *
121 * Input:
Karl Wiberg43766482015-08-27 15:22:11 +0200122 * - inst : G722 instance
niklase@google.com470e71d2011-07-07 08:21:25 +0000123 */
124
Karl Wiberg43766482015-08-27 15:22:11 +0200125void WebRtcG722_DecoderInit(G722DecInst* inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000126
127/****************************************************************************
128 * WebRtcG722_FreeDecoder(...)
129 *
130 * Free the memory used for G722 decoder
131 *
132 * Input:
133 * - G722dec_inst : G722 instance for decoder
134 *
135 * Return value : 0 - Ok
136 * -1 - Error
137 */
138
Peter Kastingbba78072015-06-11 19:02:46 -0700139int WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
niklase@google.com470e71d2011-07-07 08:21:25 +0000140
141
142/****************************************************************************
143 * WebRtcG722_Decode(...)
144 *
145 * This function decodes a packet with G729 frame(s). Output speech length
146 * will be a multiple of 80 samples (80*frames/packet).
147 *
148 * Input:
149 * - G722dec_inst : G722 instance, i.e. the user that should decode
150 * a packet
151 * - encoded : Encoded G722 frame(s)
152 * - len : Bytes in encoded vector
153 *
154 * Output:
155 * - decoded : The decoded vector
156 * - speechType : 1 normal, 2 CNG (Since G722 does not have its own
157 * DTX/CNG scheme it should always return 1)
158 *
Peter Kastingdce40cf2015-08-24 14:52:23 -0700159 * Return value : Samples in decoded vector
niklase@google.com470e71d2011-07-07 08:21:25 +0000160 */
161
Peter Kastingdce40cf2015-08-24 14:52:23 -0700162size_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
163 const uint8_t* encoded,
164 size_t len,
165 int16_t *decoded,
166 int16_t *speechType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000167
168/****************************************************************************
169 * WebRtcG722_Version(...)
170 *
171 * Get a string with the current version of the codec
172 */
173
pbos@webrtc.org0946a562013-04-09 00:28:06 +0000174int16_t WebRtcG722_Version(char *versionStr, short len);
niklase@google.com470e71d2011-07-07 08:21:25 +0000175
176
177#ifdef __cplusplus
178}
179#endif
180
181
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200182#endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */