Home | History | Annotate | Download | only in interface
      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 WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_
     12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_
     13 
     14 /*
     15  * Define the fixed-point numeric formats
     16  */
     17 #include "typedefs.h"
     18 
     19 typedef struct WebRtcISACStruct    ISACStruct;
     20 
     21 enum IsacSamplingRate {kIsacWideband = 16,  kIsacSuperWideband = 32};
     22 
     23 
     24 #if defined(__cplusplus)
     25 extern "C" {
     26 #endif
     27 
     28   /******************************************************************************
     29    * WebRtcIsac_AssignSize(...)
     30    *
     31    * This function returns the size of the ISAC instance, so that the instance
     32    * can be created outside iSAC.
     33    *
     34    * Input:
     35    *        - samplingRate      : sampling rate of the input/output audio.
     36    *
     37    * Output:
     38    *        - sizeinbytes       : number of bytes needed to allocate for the
     39    *                              instance.
     40    *
     41    * Return value               : 0 - Ok
     42    *                             -1 - Error
     43    */
     44 
     45   WebRtc_Word16 WebRtcIsac_AssignSize(
     46       int* sizeinbytes);
     47 
     48 
     49   /******************************************************************************
     50    * WebRtcIsac_Assign(...)
     51    *
     52    * This function assignes the memory already created to the ISAC instance.
     53    *
     54    * Input:
     55    *        - *ISAC_main_inst   : a pointer to the coder instance.
     56    *        - samplingRate      : sampling rate of the input/output audio.
     57    *        - ISAC_inst_Addr    : the already allocated memory, where we put the
     58    *                              iSAC structure.
     59    *
     60    * Return value               : 0 - Ok
     61    *                             -1 - Error
     62    */
     63 
     64   WebRtc_Word16 WebRtcIsac_Assign(
     65       ISACStruct** ISAC_main_inst,
     66       void*        ISAC_inst_Addr);
     67 
     68 
     69   /******************************************************************************
     70    * WebRtcIsac_Create(...)
     71    *
     72    * This function creates an ISAC instance, which will contain the state
     73    * information for one coding/decoding channel.
     74    *
     75    * Input:
     76    *        - *ISAC_main_inst   : a pointer to the coder instance.
     77    *
     78    * Return value               : 0 - Ok
     79    *                             -1 - Error
     80    */
     81 
     82   WebRtc_Word16 WebRtcIsac_Create(
     83       ISACStruct** ISAC_main_inst);
     84 
     85 
     86   /******************************************************************************
     87    * WebRtcIsac_Free(...)
     88    *
     89    * This function frees the ISAC instance created at the beginning.
     90    *
     91    * Input:
     92    *        - ISAC_main_inst    : an ISAC instance.
     93    *
     94    * Return value               : 0 - Ok
     95    *                             -1 - Error
     96    */
     97 
     98   WebRtc_Word16 WebRtcIsac_Free(
     99       ISACStruct* ISAC_main_inst);
    100 
    101 
    102   /******************************************************************************
    103    * WebRtcIsac_EncoderInit(...)
    104    *
    105    * This function initializes an ISAC instance prior to the encoder calls.
    106    *
    107    * Input:
    108    *        - ISAC_main_inst    : ISAC instance.
    109    *        - CodingMode        : 0 -> Bit rate and frame length are
    110    *                                automatically adjusted to available bandwidth
    111    *                                on transmission channel, just valid if codec
    112    *                                is created to work in wideband mode.
    113    *                              1 -> User sets a frame length and a target bit
    114    *                                rate which is taken as the maximum
    115    *                                short-term average bit rate.
    116    *
    117    * Return value               : 0 - Ok
    118    *                             -1 - Error
    119    */
    120 
    121   WebRtc_Word16 WebRtcIsac_EncoderInit(
    122       ISACStruct* ISAC_main_inst,
    123       WebRtc_Word16 CodingMode);
    124 
    125 
    126   /******************************************************************************
    127    * WebRtcIsac_Encode(...)
    128    *
    129    * This function encodes 10ms audio blocks and inserts it into a package.
    130    * Input speech length has 160 samples if operating at 16 kHz sampling
    131    * rate, or 320 if operating at 32 kHz sampling rate. The encoder buffers the
    132    * input audio until the whole frame is buffered then proceeds with encoding.
    133    *
    134    *
    135    * Input:
    136    *        - ISAC_main_inst    : ISAC instance.
    137    *        - speechIn          : input speech vector.
    138    *
    139    * Output:
    140    *        - encoded           : the encoded data vector
    141    *
    142    * Return value:
    143    *                            : >0 - Length (in bytes) of coded data
    144    *                            :  0 - The buffer didn't reach the chosen
    145    *                               frame-size so it keeps buffering speech
    146    *                               samples.
    147    *                            : -1 - Error
    148    */
    149 
    150   WebRtc_Word16 WebRtcIsac_Encode(
    151       ISACStruct*        ISAC_main_inst,
    152       const WebRtc_Word16* speechIn,
    153       WebRtc_Word16*       encoded);
    154 
    155 
    156   /******************************************************************************
    157    * WebRtcIsac_DecoderInit(...)
    158    *
    159    * This function initializes an ISAC instance prior to the decoder calls.
    160    *
    161    * Input:
    162    *        - ISAC_main_inst    : ISAC instance.
    163    *
    164    * Return value
    165    *                            : 0 - Ok
    166    *                             -1 - Error
    167    */
    168 
    169   WebRtc_Word16 WebRtcIsac_DecoderInit(
    170       ISACStruct* ISAC_main_inst);
    171 
    172 
    173   /******************************************************************************
    174    * WebRtcIsac_UpdateBwEstimate(...)
    175    *
    176    * This function updates the estimate of the bandwidth.
    177    *
    178    * Input:
    179    *        - ISAC_main_inst    : ISAC instance.
    180    *        - encoded           : encoded ISAC frame(s).
    181    *        - packet_size       : size of the packet.
    182    *        - rtp_seq_number    : the RTP number of the packet.
    183    *        - send_ts           : the RTP send timestamp, given in samples
    184    *        - arr_ts            : the arrival time of the packet (from NetEq)
    185    *                              in samples.
    186    *
    187    * Return value               : 0 - Ok
    188    *                             -1 - Error
    189    */
    190 
    191   WebRtc_Word16 WebRtcIsac_UpdateBwEstimate(
    192       ISACStruct*         ISAC_main_inst,
    193       const WebRtc_UWord16* encoded,
    194       WebRtc_Word32         packet_size,
    195       WebRtc_UWord16        rtp_seq_number,
    196       WebRtc_UWord32        send_ts,
    197       WebRtc_UWord32        arr_ts);
    198 
    199 
    200   /******************************************************************************
    201    * WebRtcIsac_Decode(...)
    202    *
    203    * This function decodes an ISAC frame. At 16 kHz sampling rate, the length
    204    * of the output audio could be either 480 or 960 samples, equivalent to
    205    * 30 or 60 ms respectively. At 32 kHz sampling rate, the length of the
    206    * output audio is 960 samples, which is 30 ms.
    207    *
    208    * Input:
    209    *        - ISAC_main_inst    : ISAC instance.
    210    *        - encoded           : encoded ISAC frame(s).
    211    *        - len               : bytes in encoded vector.
    212    *
    213    * Output:
    214    *        - decoded           : The decoded vector.
    215    *
    216    * Return value               : >0 - number of samples in decoded vector.
    217    *                              -1 - Error.
    218    */
    219 
    220   WebRtc_Word16 WebRtcIsac_Decode(
    221       ISACStruct*           ISAC_main_inst,
    222       const WebRtc_UWord16* encoded,
    223       WebRtc_Word16         len,
    224       WebRtc_Word16*        decoded,
    225       WebRtc_Word16*        speechType);
    226 
    227 
    228   /******************************************************************************
    229    * WebRtcIsac_DecodePlc(...)
    230    *
    231    * This function conducts PLC for ISAC frame(s). Output speech length
    232    * will be a multiple of frames, i.e. multiples of 30 ms audio. Therefore,
    233    * the output is multiple of 480 samples if operating at 16 kHz and multiple
    234    * of 960 if operating at 32 kHz.
    235    *
    236    * Input:
    237    *        - ISAC_main_inst    : ISAC instance.
    238    *        - noOfLostFrames    : Number of PLC frames to produce.
    239    *
    240    * Output:
    241    *        - decoded           : The decoded vector.
    242    *
    243    * Return value               : >0 - number of samples in decoded PLC vector
    244    *                              -1 - Error
    245    */
    246 
    247   WebRtc_Word16 WebRtcIsac_DecodePlc(
    248       ISACStruct*  ISAC_main_inst,
    249       WebRtc_Word16* decoded,
    250       WebRtc_Word16  noOfLostFrames);
    251 
    252 
    253   /******************************************************************************
    254    * WebRtcIsac_Control(...)
    255    *
    256    * This function sets the limit on the short-term average bit-rate and the
    257    * frame length. Should be used only in Instantaneous mode. At 16 kHz sampling
    258    * rate, an average bit-rate between 10000 to 32000 bps is valid and a
    259    * frame-size of 30 or 60 ms is acceptable. At 32 kHz, an average bit-rate
    260    * between 10000 to 56000 is acceptable, and the valid frame-size is 30 ms.
    261    *
    262    * Input:
    263    *        - ISAC_main_inst    : ISAC instance.
    264    *        - rate              : limit on the short-term average bit rate,
    265    *                              in bits/second.
    266    *        - framesize         : frame-size in millisecond.
    267    *
    268    * Return value               : 0  - ok
    269    *                             -1 - Error
    270    */
    271 
    272   WebRtc_Word16 WebRtcIsac_Control(
    273       ISACStruct*   ISAC_main_inst,
    274       WebRtc_Word32 rate,
    275       WebRtc_Word16 framesize);
    276 
    277 
    278   /******************************************************************************
    279    * WebRtcIsac_ControlBwe(...)
    280    *
    281    * This function sets the initial values of bottleneck and frame-size if
    282    * iSAC is used in channel-adaptive mode. Therefore, this API is not
    283    * applicable if the codec is created to operate in super-wideband mode.
    284    *
    285    * Through this API, users can enforce a frame-size for all values of
    286    * bottleneck. Then iSAC will not automatically change the frame-size.
    287    *
    288    *
    289    * Input:
    290    *        - ISAC_main_inst    : ISAC instance.
    291    *        - rateBPS           : initial value of bottleneck in bits/second
    292    *                              10000 <= rateBPS <= 56000 is accepted
    293    *                              For default bottleneck set rateBPS = 0
    294    *        - frameSizeMs       : number of milliseconds per frame (30 or 60)
    295    *        - enforceFrameSize  : 1 to enforce the given frame-size through
    296    *                              out the adaptation process, 0 to let iSAC
    297    *                              change the frame-size if required.
    298    *
    299    * Return value               : 0  - ok
    300    *                             -1 - Error
    301    */
    302 
    303   WebRtc_Word16 WebRtcIsac_ControlBwe(
    304       ISACStruct* ISAC_main_inst,
    305       WebRtc_Word32 rateBPS,
    306       WebRtc_Word16 frameSizeMs,
    307       WebRtc_Word16 enforceFrameSize);
    308 
    309 
    310   /******************************************************************************
    311    * WebRtcIsac_ReadFrameLen(...)
    312    *
    313    * This function returns the length of the frame represented in the packet.
    314    *
    315    * Input:
    316    *        - encoded           : Encoded bit-stream
    317    *
    318    * Output:
    319    *        - frameLength       : Length of frame in packet (in samples)
    320    *
    321    */
    322 
    323   WebRtc_Word16 WebRtcIsac_ReadFrameLen(
    324       ISACStruct*          ISAC_main_inst,
    325       const WebRtc_Word16* encoded,
    326       WebRtc_Word16*       frameLength);
    327 
    328 
    329   /******************************************************************************
    330    * WebRtcIsac_version(...)
    331    *
    332    * This function returns the version number.
    333    *
    334    * Output:
    335    *        - version      : Pointer to character string
    336    *
    337    */
    338 
    339   void WebRtcIsac_version(
    340       char *version);
    341 
    342 
    343   /******************************************************************************
    344    * WebRtcIsac_GetErrorCode(...)
    345    *
    346    * This function can be used to check the error code of an iSAC instance. When
    347    * a function returns -1 a error code will be set for that instance. The
    348    * function below extract the code of the last error that occurred in the
    349    * specified instance.
    350    *
    351    * Input:
    352    *        - ISAC_main_inst    : ISAC instance
    353    *
    354    * Return value               : Error code
    355    */
    356 
    357   WebRtc_Word16 WebRtcIsac_GetErrorCode(
    358       ISACStruct* ISAC_main_inst);
    359 
    360 
    361   /****************************************************************************
    362    * WebRtcIsac_GetUplinkBw(...)
    363    *
    364    * This function outputs the target bottleneck of the codec. In
    365    * channel-adaptive mode, the target bottleneck is specified through in-band
    366    * signalling retreived by bandwidth estimator.
    367    * In channel-independent, also called instantaneous mode, the target
    368    * bottleneck is provided to the encoder by calling xxx_control(...). If
    369    * xxx_control is never called the default values is returned. The default
    370    * value for bottleneck at 16 kHz encoder sampling rate is 32000 bits/sec,
    371    * and it is 56000 bits/sec for 32 kHz sampling rate.
    372    * Note that the output is the iSAC internal operating bottleneck which might
    373    * differ slightly from the one provided through xxx_control().
    374    *
    375    * Input:
    376    *        - ISAC_main_inst    : iSAC instance
    377    *
    378    * Output:
    379    *        - *bottleneck       : bottleneck in bits/sec
    380    *
    381    * Return value               : -1 if error happens
    382    *                               0 bit-rates computed correctly.
    383    */
    384 
    385   WebRtc_Word16 WebRtcIsac_GetUplinkBw(
    386       ISACStruct*    ISAC_main_inst,
    387       WebRtc_Word32* bottleneck);
    388 
    389 
    390   /******************************************************************************
    391    * WebRtcIsac_SetMaxPayloadSize(...)
    392    *
    393    * This function sets a limit for the maximum payload size of iSAC. The same
    394    * value is used both for 30 and 60 ms packets. If the encoder sampling rate
    395    * is 16 kHz the maximum payload size is between 120 and 400 bytes. If the
    396    * encoder sampling rate is 32 kHz the maximum payload size is between 120
    397    * and 600 bytes.
    398    *
    399    * If an out of range limit is used, the function returns -1, but the closest
    400    * valid value will be applied.
    401    *
    402    * ---------------
    403    * IMPORTANT NOTES
    404    * ---------------
    405    * The size of a packet is limited to the minimum of 'max-payload-size' and
    406    * 'max-rate.' For instance, let's assume the max-payload-size is set to
    407    * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
    408    * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
    409    * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
    410    * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
    411    * 170 bytes, i.e. min(170, 300).
    412    *
    413    * Input:
    414    *        - ISAC_main_inst    : iSAC instance
    415    *        - maxPayloadBytes   : maximum size of the payload in bytes
    416    *                              valid values are between 120 and 400 bytes
    417    *                              if encoder sampling rate is 16 kHz. For
    418    *                              32 kHz encoder sampling rate valid values
    419    *                              are between 120 and 600 bytes.
    420    *
    421    * Return value               : 0 if successful
    422    *                             -1 if error happens
    423    */
    424 
    425   WebRtc_Word16 WebRtcIsac_SetMaxPayloadSize(
    426       ISACStruct* ISAC_main_inst,
    427       WebRtc_Word16 maxPayloadBytes);
    428 
    429 
    430   /******************************************************************************
    431    * WebRtcIsac_SetMaxRate(...)
    432    *
    433    * This function sets the maximum rate which the codec may not exceed for
    434    * any signal packet. The maximum rate is defined and payload-size per
    435    * frame-size in bits per second.
    436    *
    437    * The codec has a maximum rate of 53400 bits per second (200 bytes per 30
    438    * ms) if the encoder sampling rate is 16kHz, and 160 kbps (600 bytes/30 ms)
    439    * if the encoder sampling rate is 32 kHz.
    440    *
    441    * It is possible to set a maximum rate between 32000 and 53400 bits/sec
    442    * in wideband mode, and 32000 to 160000 bits/sec in super-wideband mode.
    443    *
    444    * If an out of range limit is used, the function returns -1, but the closest
    445    * valid value will be applied.
    446    *
    447    * ---------------
    448    * IMPORTANT NOTES
    449    * ---------------
    450    * The size of a packet is limited to the minimum of 'max-payload-size' and
    451    * 'max-rate.' For instance, let's assume the max-payload-size is set to
    452    * 170 bytes, and max-rate is set to 40 kbps. Note that a limit of 40 kbps
    453    * translates to 150 bytes for 30ms frame-size & 300 bytes for 60ms
    454    * frame-size. Then a packet with a frame-size of 30 ms is limited to 150,
    455    * i.e. min(170, 150), and a packet with 60 ms frame-size is limited to
    456    * 170 bytes, min(170, 300).
    457    *
    458    * Input:
    459    *        - ISAC_main_inst    : iSAC instance
    460    *        - maxRate           : maximum rate in bits per second,
    461    *                              valid values are 32000 to 53400 bits/sec in
    462    *                              wideband mode, and 32000 to 160000 bits/sec in
    463    *                              super-wideband mode.
    464    *
    465    * Return value               : 0 if successful
    466    *                             -1 if error happens
    467    */
    468 
    469   WebRtc_Word16 WebRtcIsac_SetMaxRate(
    470       ISACStruct* ISAC_main_inst,
    471       WebRtc_Word32 maxRate);
    472 
    473 
    474   /******************************************************************************
    475    * WebRtcIsac_DecSampRate()
    476    * Return the sampling rate of the decoded audio.
    477    *
    478    * Input:
    479    *        - ISAC_main_inst    : iSAC instance
    480    *
    481    * Return value               : enumerator representing sampling frequency
    482    *                              associated with the decoder, i.e. the
    483    *                              sampling rate of the decoded audio.
    484    *
    485    */
    486 
    487   enum IsacSamplingRate WebRtcIsac_DecSampRate(
    488       ISACStruct*                ISAC_main_inst);
    489 
    490 
    491   /******************************************************************************
    492    * WebRtcIsac_EncSampRate()
    493    *
    494    * Input:
    495    *        - ISAC_main_inst    : iSAC instance
    496    *
    497    * Return value               : enumerator representing sampling frequency
    498    *                              associated with the encoder, the input audio
    499    *                              is expected to be sampled at this rate.
    500    *
    501    */
    502 
    503   enum IsacSamplingRate WebRtcIsac_EncSampRate(
    504       ISACStruct*                ISAC_main_inst);
    505 
    506 
    507   /******************************************************************************
    508    * WebRtcIsac_SetDecSampRate()
    509    * Set the sampling rate of the decoder.  Initialization of the decoder WILL
    510    * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
    511    * which is set when the instance is created.
    512    *
    513    * Input:
    514    *        - ISAC_main_inst    : iSAC instance
    515    *        - sampRate          : enumerator specifying the sampling rate.
    516    *
    517    * Return value               : 0 if successful
    518    *                             -1 if failed.
    519    */
    520 
    521   WebRtc_Word16 WebRtcIsac_SetDecSampRate(
    522       ISACStruct*           ISAC_main_inst,
    523       enum IsacSamplingRate sampRate);
    524 
    525 
    526   /******************************************************************************
    527    * WebRtcIsac_SetEncSampRate()
    528    * Set the sampling rate of the encoder. Initialization of the encoder WILL
    529    * NOT overwrite the sampling rate of the encoder. The default value is 16 kHz
    530    * which is set when the instance is created. The encoding-mode and the
    531    * bottleneck remain unchanged by this call, however, the maximum rate and
    532    * maximum payload-size will reset to their default value.
    533    *
    534    * Input:
    535    *        - ISAC_main_inst    : iSAC instance
    536    *        - sampRate          : enumerator specifying the sampling rate.
    537    *
    538    * Return value               : 0 if successful
    539    *                             -1 if failed.
    540    */
    541 
    542   WebRtc_Word16 WebRtcIsac_SetEncSampRate(
    543       ISACStruct*           ISAC_main_inst,
    544       enum IsacSamplingRate sampRate);
    545 
    546 
    547 
    548   /******************************************************************************
    549    * WebRtcIsac_GetNewBitStream(...)
    550    *
    551    * This function returns encoded data, with the recieved bwe-index in the
    552    * stream. If the rate is set to a value less than bottleneck of codec
    553    * the new bistream will be re-encoded with the given target rate.
    554    * It should always return a complete packet, i.e. only called once
    555    * even for 60 msec frames.
    556    *
    557    * NOTE 1! This function does not write in the ISACStruct, it is not allowed.
    558    * NOTE 2! Currently not implemented for SWB mode.
    559    * NOTE 3! Rates larger than the bottleneck of the codec will be limited
    560    *         to the current bottleneck.
    561    *
    562    * Input:
    563    *        - ISAC_main_inst    : ISAC instance.
    564    *        - bweIndex          : Index of bandwidth estimate to put in new
    565    *                              bitstream
    566    *        - rate              : target rate of the transcoder is bits/sec.
    567    *                              Valid values are the accepted rate in iSAC,
    568    *                              i.e. 10000 to 56000.
    569    *        - isRCU                       : if the new bit-stream is an RCU stream.
    570    *                              Note that the rate parameter always indicates
    571    *                              the target rate of the main paylaod, regardless
    572    *                              of 'isRCU' value.
    573    *
    574    * Output:
    575    *        - encoded           : The encoded data vector
    576    *
    577    * Return value               : >0 - Length (in bytes) of coded data
    578    *                              -1 - Error  or called in SWB mode
    579    *                                 NOTE! No error code is written to
    580    *                                 the struct since it is only allowed to read
    581    *                                 the struct.
    582    */
    583   WebRtc_Word16 WebRtcIsac_GetNewBitStream(
    584       ISACStruct*    ISAC_main_inst,
    585       WebRtc_Word16  bweIndex,
    586       WebRtc_Word16  jitterInfo,
    587       WebRtc_Word32  rate,
    588       WebRtc_Word16* encoded,
    589       WebRtc_Word16  isRCU);
    590 
    591 
    592 
    593   /****************************************************************************
    594    * WebRtcIsac_GetDownLinkBwIndex(...)
    595    *
    596    * This function returns index representing the Bandwidth estimate from
    597    * other side to this side.
    598    *
    599    * Input:
    600    *        - ISAC_main_inst    : iSAC struct
    601    *
    602    * Output:
    603    *        - bweIndex          : Bandwidth estimate to transmit to other side.
    604    *
    605    */
    606 
    607   WebRtc_Word16 WebRtcIsac_GetDownLinkBwIndex(
    608       ISACStruct*  ISAC_main_inst,
    609       WebRtc_Word16* bweIndex,
    610       WebRtc_Word16* jitterInfo);
    611 
    612 
    613   /****************************************************************************
    614    * WebRtcIsac_UpdateUplinkBw(...)
    615    *
    616    * This function takes an index representing the Bandwidth estimate from
    617    * this side to other side and updates BWE.
    618    *
    619    * Input:
    620    *        - ISAC_main_inst    : iSAC struct
    621    *        - bweIndex          : Bandwidth estimate from other side.
    622    *
    623    */
    624 
    625   WebRtc_Word16 WebRtcIsac_UpdateUplinkBw(
    626       ISACStruct* ISAC_main_inst,
    627       WebRtc_Word16 bweIndex);
    628 
    629 
    630   /****************************************************************************
    631    * WebRtcIsac_ReadBwIndex(...)
    632    *
    633    * This function returns the index of the Bandwidth estimate from the bitstream.
    634    *
    635    * Input:
    636    *        - encoded           : Encoded bitstream
    637    *
    638    * Output:
    639    *        - frameLength       : Length of frame in packet (in samples)
    640    *        - bweIndex         : Bandwidth estimate in bitstream
    641    *
    642    */
    643 
    644   WebRtc_Word16 WebRtcIsac_ReadBwIndex(
    645       const WebRtc_Word16* encoded,
    646       WebRtc_Word16*       bweIndex);
    647 
    648 
    649 
    650   /*******************************************************************************
    651    * WebRtcIsac_GetNewFrameLen(...)
    652    *
    653    * returns the frame lenght (in samples) of the next packet. In the case of channel-adaptive
    654    * mode, iSAC decides on its frame lenght based on the estimated bottleneck
    655    * this allows a user to prepare for the next packet (at the encoder)
    656    *
    657    * The primary usage is in CE to make the iSAC works in channel-adaptive mode
    658    *
    659    * Input:
    660    *        - ISAC_main_inst     : iSAC struct
    661    *
    662    * Return Value                : frame lenght in samples
    663    *
    664    */
    665 
    666   WebRtc_Word16 WebRtcIsac_GetNewFrameLen(
    667       ISACStruct* ISAC_main_inst);
    668 
    669 
    670   /****************************************************************************
    671    *  WebRtcIsac_GetRedPayload(...)
    672    *
    673    *  Populates "encoded" with the redundant payload of the recently encoded
    674    *  frame. This function has to be called once that WebRtcIsac_Encode(...)
    675    *  returns a positive value. Regardless of the frame-size this function will
    676    *  be called only once after encoding is completed.
    677    *
    678    * Input:
    679    *      - ISAC_main_inst    : iSAC struct
    680    *
    681    * Output:
    682    *        - encoded            : the encoded data vector
    683    *
    684    *
    685    * Return value:
    686    *                              : >0 - Length (in bytes) of coded data
    687    *                              : -1 - Error
    688    *
    689    *
    690    */
    691   WebRtc_Word16 WebRtcIsac_GetRedPayload(
    692       ISACStruct*    ISAC_main_inst,
    693       WebRtc_Word16* encoded);
    694 
    695 
    696   /****************************************************************************
    697    * WebRtcIsac_DecodeRcu(...)
    698    *
    699    * This function decodes a redundant (RCU) iSAC frame. Function is called in
    700    * NetEq with a stored RCU payload i case of packet loss. Output speech length
    701    * will be a multiple of 480 samples: 480 or 960 samples,
    702    * depending on the framesize (30 or 60 ms).
    703    *
    704    * Input:
    705    *      - ISAC_main_inst     : ISAC instance.
    706    *      - encoded            : encoded ISAC RCU frame(s)
    707    *      - len                : bytes in encoded vector
    708    *
    709    * Output:
    710    *      - decoded            : The decoded vector
    711    *
    712    * Return value              : >0 - number of samples in decoded vector
    713    *                             -1 - Error
    714    */
    715   WebRtc_Word16 WebRtcIsac_DecodeRcu(
    716       ISACStruct*           ISAC_main_inst,
    717       const WebRtc_UWord16* encoded,
    718       WebRtc_Word16         len,
    719       WebRtc_Word16*        decoded,
    720       WebRtc_Word16*        speechType);
    721 
    722 
    723 #if defined(__cplusplus)
    724 }
    725 #endif
    726 
    727 
    728 
    729 #endif /* WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_MAIN_INTERFACE_ISAC_H_ */
    730