blob: f206f30306a48c97e4433c89dbaf2aa3658f6ea9 [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_G711_G711_INTERFACE_H_
12#define MODULES_AUDIO_CODING_CODECS_G711_G711_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// Comfort noise constants
pbos@webrtc.orgae4e2b32013-03-21 13:38:29 +000017#define G711_WEBRTC_SPEECH 1
18#define G711_WEBRTC_CNG 2
niklase@google.com470e71d2011-07-07 08:21:25 +000019
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24/****************************************************************************
25 * WebRtcG711_EncodeA(...)
26 *
27 * This function encodes a G711 A-law frame and inserts it into a packet.
28 * Input speech length has be of any length.
29 *
30 * Input:
niklase@google.com470e71d2011-07-07 08:21:25 +000031 * - speechIn : Input speech vector
32 * - len : Samples in speechIn
33 *
34 * Output:
35 * - encoded : The encoded data vector
36 *
jmarusic@webrtc.org2acec4c2015-02-23 15:27:52 +000037 * Return value : Length (in bytes) of coded data.
38 * Always equal to len input parameter.
niklase@google.com470e71d2011-07-07 08:21:25 +000039 */
40
Peter Kastingdce40cf2015-08-24 14:52:23 -070041size_t WebRtcG711_EncodeA(const int16_t* speechIn,
42 size_t len,
43 uint8_t* encoded);
niklase@google.com470e71d2011-07-07 08:21:25 +000044
45/****************************************************************************
46 * WebRtcG711_EncodeU(...)
47 *
48 * This function encodes a G711 U-law frame and inserts it into a packet.
49 * Input speech length has be of any length.
50 *
51 * Input:
niklase@google.com470e71d2011-07-07 08:21:25 +000052 * - speechIn : Input speech vector
53 * - len : Samples in speechIn
54 *
55 * Output:
56 * - encoded : The encoded data vector
57 *
jmarusic@webrtc.org2acec4c2015-02-23 15:27:52 +000058 * Return value : Length (in bytes) of coded data.
59 * Always equal to len input parameter.
niklase@google.com470e71d2011-07-07 08:21:25 +000060 */
61
Peter Kastingdce40cf2015-08-24 14:52:23 -070062size_t WebRtcG711_EncodeU(const int16_t* speechIn,
63 size_t len,
64 uint8_t* encoded);
niklase@google.com470e71d2011-07-07 08:21:25 +000065
66/****************************************************************************
67 * WebRtcG711_DecodeA(...)
68 *
69 * This function decodes a packet G711 A-law frame.
70 *
71 * Input:
niklase@google.com470e71d2011-07-07 08:21:25 +000072 * - encoded : Encoded data
73 * - len : Bytes in encoded vector
74 *
75 * Output:
76 * - decoded : The decoded vector
77 * - speechType : 1 normal, 2 CNG (for G711 it should
78 * always return 1 since G711 does not have a
79 * built-in DTX/CNG scheme)
80 *
81 * Return value : >0 - Samples in decoded vector
82 * -1 - Error
83 */
84
Peter Kastingdce40cf2015-08-24 14:52:23 -070085size_t WebRtcG711_DecodeA(const uint8_t* encoded,
86 size_t len,
87 int16_t* decoded,
88 int16_t* speechType);
niklase@google.com470e71d2011-07-07 08:21:25 +000089
90/****************************************************************************
91 * WebRtcG711_DecodeU(...)
92 *
93 * This function decodes a packet G711 U-law frame.
94 *
95 * Input:
niklase@google.com470e71d2011-07-07 08:21:25 +000096 * - encoded : Encoded data
97 * - len : Bytes in encoded vector
98 *
99 * Output:
100 * - decoded : The decoded vector
101 * - speechType : 1 normal, 2 CNG (for G711 it should
102 * always return 1 since G711 does not have a
103 * built-in DTX/CNG scheme)
104 *
105 * Return value : >0 - Samples in decoded vector
106 * -1 - Error
107 */
108
Peter Kastingdce40cf2015-08-24 14:52:23 -0700109size_t WebRtcG711_DecodeU(const uint8_t* encoded,
110 size_t len,
111 int16_t* decoded,
112 int16_t* speechType);
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55 +0000113
niklase@google.com470e71d2011-07-07 08:21:25 +0000114/**********************************************************************
Yves Gerey665174f2018-06-19 15:03:05 +0200115 * WebRtcG711_Version(...)
116 *
117 * This function gives the version string of the G.711 codec.
118 *
119 * Input:
120 * - lenBytes: the size of Allocated space (in Bytes) where
121 * the version number is written to (in string format).
122 *
123 * Output:
124 * - version: Pointer to a buffer where the version number is
125 * written to.
126 *
127 */
niklase@google.com470e71d2011-07-07 08:21:25 +0000128
pbos@webrtc.orgae4e2b32013-03-21 13:38:29 +0000129int16_t WebRtcG711_Version(char* version, int16_t lenBytes);
niklase@google.com470e71d2011-07-07 08:21:25 +0000130
131#ifdef __cplusplus
132}
133#endif
134
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200135#endif // MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_