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_G722_INTERFACE_H_ 12 #define MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ 13 14 #include <stdint.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 * 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 */ 45 int16_t WebRtcG722_CreateEncoder(G722EncInst** G722enc_inst); 46 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 60 int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst); 61 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 */ 73 int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst); 74 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 * 89 * Return value : Length (in bytes) of coded data 90 */ 91 92 size_t WebRtcG722_Encode(G722EncInst* G722enc_inst, 93 const int16_t* speechIn, 94 size_t len, 95 uint8_t* encoded); 96 97 /**************************************************************************** 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 */ 108 int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst); 109 110 /**************************************************************************** 111 * WebRtcG722_DecoderInit(...) 112 * 113 * This function initializes a G722 instance 114 * 115 * Input: 116 * - inst : G722 instance 117 */ 118 119 void WebRtcG722_DecoderInit(G722DecInst* inst); 120 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 133 int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst); 134 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 * 152 * Return value : Samples in decoded vector 153 */ 154 155 size_t WebRtcG722_Decode(G722DecInst* G722dec_inst, 156 const uint8_t* encoded, 157 size_t len, 158 int16_t* decoded, 159 int16_t* speechType); 160 161 /**************************************************************************** 162 * WebRtcG722_Version(...) 163 * 164 * Get a string with the current version of the codec 165 */ 166 167 int16_t WebRtcG722_Version(char* versionStr, short len); 168 169 #ifdef __cplusplus 170 } 171 #endif 172 173 #endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */ 174