tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

g711_interface.h (4327B)


      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_G711_G711_INTERFACE_H_
     12 #define MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_
     13 
     14 #include <stddef.h>
     15 #include <stdint.h>
     16 
     17 // Comfort noise constants
     18 #define G711_WEBRTC_SPEECH 1
     19 #define G711_WEBRTC_CNG 2
     20 
     21 #ifdef __cplusplus
     22 extern "C" {
     23 #endif
     24 
     25 /****************************************************************************
     26 * WebRtcG711_EncodeA(...)
     27 *
     28 * This function encodes a G711 A-law frame and inserts it into a packet.
     29 * Input speech length has be of any length.
     30 *
     31 * Input:
     32 *      - speechIn           : Input speech vector
     33 *      - len                : Samples in speechIn
     34 *
     35 * Output:
     36 *      - encoded            : The encoded data vector
     37 *
     38 * Return value              : Length (in bytes) of coded data.
     39 *                             Always equal to len input parameter.
     40 */
     41 
     42 size_t WebRtcG711_EncodeA(const int16_t* speechIn,
     43                          size_t len,
     44                          uint8_t* encoded);
     45 
     46 /****************************************************************************
     47 * WebRtcG711_EncodeU(...)
     48 *
     49 * This function encodes a G711 U-law frame and inserts it into a packet.
     50 * Input speech length has be of any length.
     51 *
     52 * Input:
     53 *      - speechIn           : Input speech vector
     54 *      - len                : Samples in speechIn
     55 *
     56 * Output:
     57 *      - encoded            : The encoded data vector
     58 *
     59 * Return value              : Length (in bytes) of coded data.
     60 *                             Always equal to len input parameter.
     61 */
     62 
     63 size_t WebRtcG711_EncodeU(const int16_t* speechIn,
     64                          size_t len,
     65                          uint8_t* encoded);
     66 
     67 /****************************************************************************
     68 * WebRtcG711_DecodeA(...)
     69 *
     70 * This function decodes a packet G711 A-law frame.
     71 *
     72 * Input:
     73 *      - encoded            : Encoded data
     74 *      - len                : Bytes in encoded vector
     75 *
     76 * Output:
     77 *      - decoded            : The decoded vector
     78 *      - speechType         : 1 normal, 2 CNG (for G711 it should
     79 *                             always return 1 since G711 does not have a
     80 *                             built-in DTX/CNG scheme)
     81 *
     82 * Return value              : >0 - Samples in decoded vector
     83 *                             -1 - Error
     84 */
     85 
     86 size_t WebRtcG711_DecodeA(const uint8_t* encoded,
     87                          size_t len,
     88                          int16_t* decoded,
     89                          int16_t* speechType);
     90 
     91 /****************************************************************************
     92 * WebRtcG711_DecodeU(...)
     93 *
     94 * This function decodes a packet G711 U-law frame.
     95 *
     96 * Input:
     97 *      - encoded            : Encoded data
     98 *      - len                : Bytes in encoded vector
     99 *
    100 * Output:
    101 *      - decoded            : The decoded vector
    102 *      - speechType         : 1 normal, 2 CNG (for G711 it should
    103 *                             always return 1 since G711 does not have a
    104 *                             built-in DTX/CNG scheme)
    105 *
    106 * Return value              : >0 - Samples in decoded vector
    107 *                             -1 - Error
    108 */
    109 
    110 size_t WebRtcG711_DecodeU(const uint8_t* encoded,
    111                          size_t len,
    112                          int16_t* decoded,
    113                          int16_t* speechType);
    114 
    115 /**********************************************************************
    116 * WebRtcG711_Version(...)
    117 *
    118 * This function gives the version string of the G.711 codec.
    119 *
    120 * Input:
    121 *      - lenBytes:     the size of Allocated space (in Bytes) where
    122 *                      the version number is written to (in string format).
    123 *
    124 * Output:
    125 *      - version:      Pointer to a buffer where the version number is
    126 *                      written to.
    127 *
    128 */
    129 
    130 int16_t WebRtcG711_Version(char* version, int16_t lenBytes);
    131 
    132 #ifdef __cplusplus
    133 }
    134 #endif
    135 
    136 #endif  // MODULES_AUDIO_CODING_CODECS_G711_G711_INTERFACE_H_