• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #ifndef MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_
12 #define MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_
13 
14 #include "webrtc/typedefs.h"
15 
16 /*
17  * Solution to support multiple instances
18  */
19 
20 typedef struct WebRtcG722EncInst    G722EncInst;
21 typedef 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
31 extern "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  */
46 int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst);
47 
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 
62 int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst);
63 
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  */
76 int16_t WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst);
77 
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  *
94  * Return value               : >0 - Length (in bytes) of coded data
95  *                              -1 - Error
96  */
97 
98 int16_t WebRtcG722_Encode(G722EncInst *G722enc_inst,
99                           int16_t *speechIn,
100                           int16_t len,
101                           int16_t *encoded);
102 
103 
104 /****************************************************************************
105  * WebRtcG722_CreateDecoder(...)
106  *
107  * Create memory used for G722 encoder
108  *
109  * Input:
110  *     - G722dec_inst         : G722 instance for decoder
111  *
112  * Return value               :  0 - Ok
113  *                              -1 - Error
114  */
115 int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst);
116 
117 
118 /****************************************************************************
119  * WebRtcG722_DecoderInit(...)
120  *
121  * This function initializes a G729 instance
122  *
123  * Input:
124  *     - G729_decinst_t    : G729 instance, i.e. the user that should receive
125  *                           be initialized
126  *
127  * Return value            :  0 - Ok
128  *                           -1 - Error
129  */
130 
131 int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst);
132 
133 
134 /****************************************************************************
135  * WebRtcG722_FreeDecoder(...)
136  *
137  * Free the memory used for G722 decoder
138  *
139  * Input:
140  *     - G722dec_inst         : G722 instance for decoder
141  *
142  * Return value               :  0 - Ok
143  *                              -1 - Error
144  */
145 
146 int16_t WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst);
147 
148 
149 /****************************************************************************
150  * WebRtcG722_Decode(...)
151  *
152  * This function decodes a packet with G729 frame(s). Output speech length
153  * will be a multiple of 80 samples (80*frames/packet).
154  *
155  * Input:
156  *     - G722dec_inst       : G722 instance, i.e. the user that should decode
157  *                            a packet
158  *     - encoded            : Encoded G722 frame(s)
159  *     - len                : Bytes in encoded vector
160  *
161  * Output:
162  *        - decoded         : The decoded vector
163  *      - speechType        : 1 normal, 2 CNG (Since G722 does not have its own
164  *                            DTX/CNG scheme it should always return 1)
165  *
166  * Return value             : >0 - Samples in decoded vector
167  *                            -1 - Error
168  */
169 
170 int16_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
171                           int16_t *encoded,
172                           int16_t len,
173                           int16_t *decoded,
174                           int16_t *speechType);
175 
176 /****************************************************************************
177  * WebRtcG722_Version(...)
178  *
179  * Get a string with the current version of the codec
180  */
181 
182 int16_t WebRtcG722_Version(char *versionStr, short len);
183 
184 
185 #ifdef __cplusplus
186 }
187 #endif
188 
189 
190 #endif /* MODULES_AUDIO_CODING_CODECS_G722_MAIN_INTERFACE_G722_INTERFACE_H_ */
191