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 <stddef.h> 15 #include <stdint.h> 16 17 /* 18 * Solution to support multiple instances 19 */ 20 21 typedef struct WebRtcG722EncInst G722EncInst; 22 typedef struct WebRtcG722DecInst G722DecInst; 23 24 /* 25 * Comfort noise constants 26 */ 27 28 #define G722_WEBRTC_SPEECH 1 29 #define G722_WEBRTC_CNG 2 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 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 * WebRtcG722_EncoderInit(...) 50 * 51 * This function initializes a G722 instance 52 * 53 * Input: 54 * - G722enc_inst : G722 instance, i.e. the user that should receive 55 * be initialized 56 * 57 * Return value : 0 - Ok 58 * -1 - Error 59 */ 60 61 int16_t WebRtcG722_EncoderInit(G722EncInst* G722enc_inst); 62 63 /**************************************************************************** 64 * WebRtcG722_FreeEncoder(...) 65 * 66 * Free the memory used for G722 encoder 67 * 68 * Input: 69 * - G722enc_inst : G722 instance for encoder 70 * 71 * Return value : 0 - Ok 72 * -1 - Error 73 */ 74 int WebRtcG722_FreeEncoder(G722EncInst* G722enc_inst); 75 76 /**************************************************************************** 77 * WebRtcG722_Encode(...) 78 * 79 * This function encodes G722 encoded data. 80 * 81 * Input: 82 * - G722enc_inst : G722 instance, i.e. the user that should encode 83 * a packet 84 * - speechIn : Input speech vector 85 * - len : Samples in speechIn 86 * 87 * Output: 88 * - encoded : The encoded data vector 89 * 90 * Return value : Length (in bytes) of coded data 91 */ 92 93 size_t WebRtcG722_Encode(G722EncInst* G722enc_inst, 94 const int16_t* speechIn, 95 size_t len, 96 uint8_t* encoded); 97 98 /**************************************************************************** 99 * WebRtcG722_CreateDecoder(...) 100 * 101 * Create memory used for G722 encoder 102 * 103 * Input: 104 * - G722dec_inst : G722 instance for decoder 105 * 106 * Return value : 0 - Ok 107 * -1 - Error 108 */ 109 int16_t WebRtcG722_CreateDecoder(G722DecInst** G722dec_inst); 110 111 /**************************************************************************** 112 * WebRtcG722_DecoderInit(...) 113 * 114 * This function initializes a G722 instance 115 * 116 * Input: 117 * - inst : G722 instance 118 */ 119 120 void WebRtcG722_DecoderInit(G722DecInst* inst); 121 122 /**************************************************************************** 123 * WebRtcG722_FreeDecoder(...) 124 * 125 * Free the memory used for G722 decoder 126 * 127 * Input: 128 * - G722dec_inst : G722 instance for decoder 129 * 130 * Return value : 0 - Ok 131 * -1 - Error 132 */ 133 134 int WebRtcG722_FreeDecoder(G722DecInst* G722dec_inst); 135 136 /**************************************************************************** 137 * WebRtcG722_Decode(...) 138 * 139 * This function decodes a packet with G729 frame(s). Output speech length 140 * will be a multiple of 80 samples (80*frames/packet). 141 * 142 * Input: 143 * - G722dec_inst : G722 instance, i.e. the user that should decode 144 * a packet 145 * - encoded : Encoded G722 frame(s) 146 * - len : Bytes in encoded vector 147 * 148 * Output: 149 * - decoded : The decoded vector 150 * - speechType : 1 normal, 2 CNG (Since G722 does not have its own 151 * DTX/CNG scheme it should always return 1) 152 * 153 * Return value : Samples in decoded vector 154 */ 155 156 size_t WebRtcG722_Decode(G722DecInst* G722dec_inst, 157 const uint8_t* encoded, 158 size_t len, 159 int16_t* decoded, 160 int16_t* speechType); 161 162 /**************************************************************************** 163 * WebRtcG722_Version(...) 164 * 165 * Get a string with the current version of the codec 166 */ 167 168 int16_t WebRtcG722_Version(char* versionStr, short len); 169 170 #ifdef __cplusplus 171 } 172 #endif 173 174 #endif /* MODULES_AUDIO_CODING_CODECS_G722_G722_INTERFACE_H_ */ 175