2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_
12 #define MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_
14 #include "webrtc/typedefs.h"
16 // Comfort noise constants
17 #define G711_WEBRTC_SPEECH 1
18 #define G711_WEBRTC_CNG 2
24 /****************************************************************************
25 * WebRtcG711_EncodeA(...)
27 * This function encodes a G711 A-law frame and inserts it into a packet.
28 * Input speech length has be of any length.
31 * - state : Dummy state to make this codec look more like
33 * - speechIn : Input speech vector
34 * - len : Samples in speechIn
37 * - encoded : The encoded data vector
39 * Return value : >0 - Length (in bytes) of coded data
43 int16_t WebRtcG711_EncodeA(void* state,
48 /****************************************************************************
49 * WebRtcG711_EncodeU(...)
51 * This function encodes a G711 U-law frame and inserts it into a packet.
52 * Input speech length has be of any length.
55 * - state : Dummy state to make this codec look more like
57 * - speechIn : Input speech vector
58 * - len : Samples in speechIn
61 * - encoded : The encoded data vector
63 * Return value : >0 - Length (in bytes) of coded data
67 int16_t WebRtcG711_EncodeU(void* state,
72 /****************************************************************************
73 * WebRtcG711_DecodeA(...)
75 * This function decodes a packet G711 A-law frame.
78 * - state : Dummy state to make this codec look more like
80 * - encoded : Encoded data
81 * - len : Bytes in encoded vector
84 * - decoded : The decoded vector
85 * - speechType : 1 normal, 2 CNG (for G711 it should
86 * always return 1 since G711 does not have a
87 * built-in DTX/CNG scheme)
89 * Return value : >0 - Samples in decoded vector
93 int16_t WebRtcG711_DecodeA(void* state,
99 /****************************************************************************
100 * WebRtcG711_DecodeU(...)
102 * This function decodes a packet G711 U-law frame.
105 * - state : Dummy state to make this codec look more like
107 * - encoded : Encoded data
108 * - len : Bytes in encoded vector
111 * - decoded : The decoded vector
112 * - speechType : 1 normal, 2 CNG (for G711 it should
113 * always return 1 since G711 does not have a
114 * built-in DTX/CNG scheme)
116 * Return value : >0 - Samples in decoded vector
120 int16_t WebRtcG711_DecodeU(void* state,
124 int16_t* speechType);
126 /****************************************************************************
127 * WebRtcG711_DurationEst(...)
129 * This function estimates the duration of a G711 packet in samples.
132 * - state : Dummy state to make this codec look more like
134 * - payload : Encoded data
135 * - payloadLengthBytes : Bytes in encoded vector
137 * Return value : The duration of the packet in samples, which is
138 * just payload_length_bytes, since G.711 uses one
142 int WebRtcG711_DurationEst(void* state,
143 const uint8_t* payload,
144 int payload_length_bytes);
146 /**********************************************************************
147 * WebRtcG711_Version(...)
149 * This function gives the version string of the G.711 codec.
152 * - lenBytes: the size of Allocated space (in Bytes) where
153 * the version number is written to (in string format).
156 * - version: Pointer to a buffer where the version number is
161 int16_t WebRtcG711_Version(char* version, int16_t lenBytes);
167 #endif /* MODULES_AUDIO_CODING_CODECS_G711_MAIN_INTERFACE_G711_INTERFACE_H_ */