niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_ |
| 12 | #define MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 14 | #include "typedefs.h" // NOLINT(build/include) |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 15 | |
| 16 | // Comfort noise constants |
pbos@webrtc.org | ae4e2b3 | 2013-03-21 13:38:29 +0000 | [diff] [blame] | 17 | #define G711_WEBRTC_SPEECH 1 |
| 18 | #define G711_WEBRTC_CNG 2 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 31 | * - speechIn : Input speech vector |
| 32 | * - len : Samples in speechIn |
| 33 | * |
| 34 | * Output: |
| 35 | * - encoded : The encoded data vector |
| 36 | * |
jmarusic@webrtc.org | 2acec4c | 2015-02-23 15:27:52 +0000 | [diff] [blame] | 37 | * Return value : Length (in bytes) of coded data. |
| 38 | * Always equal to len input parameter. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | */ |
| 40 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 41 | size_t WebRtcG711_EncodeA(const int16_t* speechIn, |
| 42 | size_t len, |
| 43 | uint8_t* encoded); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | |
| 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 52 | * - speechIn : Input speech vector |
| 53 | * - len : Samples in speechIn |
| 54 | * |
| 55 | * Output: |
| 56 | * - encoded : The encoded data vector |
| 57 | * |
jmarusic@webrtc.org | 2acec4c | 2015-02-23 15:27:52 +0000 | [diff] [blame] | 58 | * Return value : Length (in bytes) of coded data. |
| 59 | * Always equal to len input parameter. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 60 | */ |
| 61 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 62 | size_t WebRtcG711_EncodeU(const int16_t* speechIn, |
| 63 | size_t len, |
| 64 | uint8_t* encoded); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 65 | |
| 66 | /**************************************************************************** |
| 67 | * WebRtcG711_DecodeA(...) |
| 68 | * |
| 69 | * This function decodes a packet G711 A-law frame. |
| 70 | * |
| 71 | * Input: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 72 | * - 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 Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 85 | size_t WebRtcG711_DecodeA(const uint8_t* encoded, |
| 86 | size_t len, |
| 87 | int16_t* decoded, |
| 88 | int16_t* speechType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 89 | |
| 90 | /**************************************************************************** |
| 91 | * WebRtcG711_DecodeU(...) |
| 92 | * |
| 93 | * This function decodes a packet G711 U-law frame. |
| 94 | * |
| 95 | * Input: |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 96 | * - 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 Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 109 | size_t WebRtcG711_DecodeU(const uint8_t* encoded, |
| 110 | size_t len, |
| 111 | int16_t* decoded, |
| 112 | int16_t* speechType); |
tina.legrand@webrtc.org | 5ac387c | 2012-11-19 08:02:55 +0000 | [diff] [blame] | 113 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 114 | /********************************************************************** |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 115 | * 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.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 128 | |
pbos@webrtc.org | ae4e2b3 | 2013-03-21 13:38:29 +0000 | [diff] [blame] | 129 | int16_t WebRtcG711_Version(char* version, int16_t lenBytes); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 130 | |
| 131 | #ifdef __cplusplus |
| 132 | } |
| 133 | #endif |
| 134 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 135 | #endif // MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_ |