Home | History | Annotate | Download | only in acm2
      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_MAIN_ACM2_ACM_COMMON_DEFS_H_
     12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_
     13 
     14 #include <string.h>
     15 
     16 #include "webrtc/common_types.h"
     17 #include "webrtc/engine_configurations.h"
     18 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h"
     19 #include "webrtc/typedefs.h"
     20 
     21 // Checks for enabled codecs, we prevent enabling codecs which are not
     22 // compatible.
     23 #if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX))
     24 #error iSAC and iSACFX codecs cannot be enabled at the same time
     25 #endif
     26 
     27 
     28 namespace webrtc {
     29 
     30 // 60 ms is the maximum block size we support. An extra 20 ms is considered
     31 // for safety if process() method is not called when it should be, i.e. we
     32 // accept 20 ms of jitter. 80 ms @ 48 kHz (full-band) stereo is 7680 samples.
     33 #define AUDIO_BUFFER_SIZE_W16 7680
     34 
     35 // There is one timestamp per each 10 ms of audio
     36 // the audio buffer, at max, may contain 32 blocks of 10ms
     37 // audio if the sampling frequency is 8000 Hz (80 samples per block).
     38 // Therefore, The size of the buffer where we keep timestamps
     39 // is defined as follows
     40 #define TIMESTAMP_BUFFER_SIZE_W32  (AUDIO_BUFFER_SIZE_W16/80)
     41 
     42 // The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo
     43 #define MAX_PAYLOAD_SIZE_BYTE   7680
     44 
     45 // General codec specific defines
     46 const int kIsacWbDefaultRate = 32000;
     47 const int kIsacSwbDefaultRate = 56000;
     48 const int kIsacPacSize480 = 480;
     49 const int kIsacPacSize960 = 960;
     50 const int kIsacPacSize1440 = 1440;
     51 
     52 // An encoded bit-stream is labeled by one of the following enumerators.
     53 //
     54 //   kNoEncoding              : There has been no encoding.
     55 //   kActiveNormalEncoded     : Active audio frame coded by the codec.
     56 //   kPassiveNormalEncoded    : Passive audio frame coded by the codec.
     57 //   kPassiveDTXNB            : Passive audio frame coded by narrow-band CN.
     58 //   kPassiveDTXWB            : Passive audio frame coded by wide-band CN.
     59 //   kPassiveDTXSWB           : Passive audio frame coded by super-wide-band CN.
     60 //   kPassiveDTXFB            : Passive audio frame coded by full-band CN.
     61 enum WebRtcACMEncodingType {
     62   kNoEncoding,
     63   kActiveNormalEncoded,
     64   kPassiveNormalEncoded,
     65   kPassiveDTXNB,
     66   kPassiveDTXWB,
     67   kPassiveDTXSWB,
     68   kPassiveDTXFB
     69 };
     70 
     71 // A structure which contains codec parameters. For instance, used when
     72 // initializing encoder and decoder.
     73 //
     74 //   codec_inst: c.f. common_types.h
     75 //   enable_dtx: set true to enable DTX. If codec does not have
     76 //               internal DTX, this will enable VAD.
     77 //   enable_vad: set true to enable VAD.
     78 //   vad_mode: VAD mode, c.f. audio_coding_module_typedefs.h
     79 //             for possible values.
     80 struct WebRtcACMCodecParams {
     81   CodecInst codec_inst;
     82   bool enable_dtx;
     83   bool enable_vad;
     84   ACMVADMode vad_mode;
     85 };
     86 
     87 // TODO(turajs): Remove when ACM1 is removed.
     88 struct WebRtcACMAudioBuff {
     89   int16_t in_audio[AUDIO_BUFFER_SIZE_W16];
     90   int16_t in_audio_ix_read;
     91   int16_t in_audio_ix_write;
     92   uint32_t in_timestamp[TIMESTAMP_BUFFER_SIZE_W32];
     93   int16_t in_timestamp_ix_write;
     94   uint32_t last_timestamp;
     95   uint32_t last_in_timestamp;
     96 };
     97 
     98 }  // namespace webrtc
     99 
    100 #endif  // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_COMMON_DEFS_H_
    101