diff --git a/webrtc/engine_configurations.h b/webrtc/engine_configurations.h index 5b093e5c2..ba18147bf 100644 --- a/webrtc/engine_configurations.h +++ b/webrtc/engine_configurations.h @@ -139,7 +139,6 @@ // Deprecated // ---------------------------------------------------------------------------- -// #define WEBRTC_CODEC_G729 // #define WEBRTC_DTMF_DETECTION #endif // WEBRTC_ENGINE_CONFIGURATIONS_H_ diff --git a/webrtc/modules/audio_coding/BUILD.gn b/webrtc/modules/audio_coding/BUILD.gn index 2577f3477..4ce448b41 100644 --- a/webrtc/modules/audio_coding/BUILD.gn +++ b/webrtc/modules/audio_coding/BUILD.gn @@ -18,48 +18,11 @@ config("audio_coding_config") { source_set("audio_coding") { sources = [ - "main/acm2/acm_amr.cc", - "main/acm2/acm_amr.h", - "main/acm2/acm_amrwb.cc", - "main/acm2/acm_amrwb.h", - "main/acm2/acm_cng.cc", - "main/acm2/acm_cng.h", "main/acm2/acm_codec_database.cc", "main/acm2/acm_codec_database.h", "main/acm2/acm_common_defs.h", - "main/acm2/acm_dtmf_playout.cc", - "main/acm2/acm_dtmf_playout.h", - "main/acm2/acm_g722.cc", - "main/acm2/acm_g722.h", - "main/acm2/acm_g7221.cc", - "main/acm2/acm_g7221.h", - "main/acm2/acm_g7221c.cc", - "main/acm2/acm_g7221c.h", - "main/acm2/acm_g729.cc", - "main/acm2/acm_g729.h", - "main/acm2/acm_g7291.cc", - "main/acm2/acm_g7291.h", "main/acm2/acm_generic_codec.cc", "main/acm2/acm_generic_codec.h", - "main/acm2/acm_gsmfr.cc", - "main/acm2/acm_gsmfr.h", - "main/acm2/acm_ilbc.cc", - "main/acm2/acm_ilbc.h", - "main/acm2/acm_isac.cc", - "main/acm2/acm_isac.h", - "main/acm2/acm_isac_macros.h", - "main/acm2/acm_opus.cc", - "main/acm2/acm_opus.h", - "main/acm2/acm_speex.cc", - "main/acm2/acm_speex.h", - "main/acm2/acm_pcm16b.cc", - "main/acm2/acm_pcm16b.h", - "main/acm2/acm_pcma.cc", - "main/acm2/acm_pcma.h", - "main/acm2/acm_pcmu.cc", - "main/acm2/acm_pcmu.h", - "main/acm2/acm_red.cc", - "main/acm2/acm_red.h", "main/acm2/acm_receiver.cc", "main/acm2/acm_receiver.h", "main/acm2/acm_resampler.cc", diff --git a/webrtc/modules/audio_coding/main/acm2/acm_amr.cc b/webrtc/modules/audio_coding/main/acm2/acm_amr.cc deleted file mode 100644 index b2d733ad5..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_amr.cc +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_amr.h" - -#ifdef WEBRTC_CODEC_AMR -// NOTE! GSM AMR is not included in the open-source package. The following -// interface file is needed: -#include "webrtc/modules/audio_coding/main/codecs/amr/interface/amr_interface.h" -#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// The API in the header file should match the one below. -// -// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** enc_inst); -// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** dec_inst); -// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* enc_inst); -// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* dec_inst); -// int16_t WebRtcAmr_Encode(AMR_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t*output, -// int16_t mode); -// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* enc_inst, -// int16_t dtx_mode); -// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* enc_inst, -// int format); -// int16_t WebRtcAmr_Decode(AMR_decinst_t_* dec_inst); -// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* dec_inst); -// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* dec_inst); -// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* dec_inst, -// int format); -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_AMR -ACMAMR::ACMAMR(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoding_mode_(-1), // Invalid value. - encoding_rate_(0), // Invalid value. - encoder_packing_format_(AMRBandwidthEfficient) { - return; -} - -ACMAMR::~ACMAMR() { return; } - -int16_t ACMAMR::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMAMR::EnableDTX() { return -1; } - -int16_t ACMAMR::DisableDTX() { return -1; } - -int16_t ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMAMR::CreateInstance(void) { return NULL; } - -int16_t ACMAMR::InternalCreateEncoder() { return -1; } - -void ACMAMR::DestructEncoderSafe() { return; } - -int16_t ACMAMR::SetBitRateSafe(const int32_t /* rate */) { return -1; } - -int16_t ACMAMR::SetAMREncoderPackingFormat( - ACMAMRPackingFormat /* packing_format */) { - return -1; -} - -ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const { - return AMRUndefined; -} - -int16_t ACMAMR::SetAMRDecoderPackingFormat( - ACMAMRPackingFormat /* packing_format */) { - return -1; -} - -ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const { - return AMRUndefined; -} - -#else //===================== Actual Implementation ======================= - -#define WEBRTC_AMR_MR475 0 -#define WEBRTC_AMR_MR515 1 -#define WEBRTC_AMR_MR59 2 -#define WEBRTC_AMR_MR67 3 -#define WEBRTC_AMR_MR74 4 -#define WEBRTC_AMR_MR795 5 -#define WEBRTC_AMR_MR102 6 -#define WEBRTC_AMR_MR122 7 - -ACMAMR::ACMAMR(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoding_mode_(-1), // invalid value - encoding_rate_(0) { // invalid value - codec_id_ = codec_id; - has_internal_dtx_ = true; - encoder_packing_format_ = AMRBandwidthEfficient; - return; -} - -ACMAMR::~ACMAMR() { - if (encoder_inst_ptr_ != NULL) { - WebRtcAmr_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMAMR::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - int16_t vad_decision = 1; - // sanity check, if the rate is set correctly. we might skip this - // sanity check. if rate is not set correctly, initialization flag - // should be false and should not be here. - if ((encoding_mode_ < WEBRTC_AMR_MR475) || - (encoding_mode_ > WEBRTC_AMR_MR122)) { - *bitstream_len_byte = 0; - return -1; - } - *bitstream_len_byte = WebRtcAmr_Encode(encoder_inst_ptr_, - &in_audio_[in_audio_ix_read_], - frame_len_smpl_, - reinterpret_cast(bitstream), - encoding_mode_); - - // Update VAD, if internal DTX is used - if (has_internal_dtx_ && dtx_enabled_) { - if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) { - vad_decision = 0; - } - for (int16_t n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { - vad_label_[n] = vad_decision; - } - } - // increment the read index - in_audio_ix_read_ += frame_len_smpl_; - return *bitstream_len_byte; -} - -int16_t ACMAMR::EnableDTX() { - if (dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // enable DTX - if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 1) < 0) { - return -1; - } - dtx_enabled_ = true; - return 0; - } else { - return -1; - } -} - -int16_t ACMAMR::DisableDTX() { - if (!dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // disable DTX - if (WebRtcAmr_EncoderInit(encoder_inst_ptr_, 0) < 0) { - return -1; - } - dtx_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -int16_t ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - int16_t status = SetBitRateSafe((codec_params->codec_inst).rate); - status += (WebRtcAmr_EncoderInit(encoder_inst_ptr_, - ((codec_params->enable_dtx) ? 1 : 0)) < 0) - ? -1 - : 0; - status += - (WebRtcAmr_EncodeBitmode(encoder_inst_ptr_, encoder_packing_format_) < 0) - ? -1 - : 0; - return (status < 0) ? -1 : 0; -} - -ACMGenericCodec* ACMAMR::CreateInstance(void) { return NULL; } - -int16_t ACMAMR::InternalCreateEncoder() { - return WebRtcAmr_CreateEnc(&encoder_inst_ptr_); -} - -void ACMAMR::DestructEncoderSafe() { - if (encoder_inst_ptr_ != NULL) { - WebRtcAmr_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - // there is no encoder set the following - encoder_exist_ = false; - encoder_initialized_ = false; - encoding_mode_ = -1; // invalid value - encoding_rate_ = 0; // invalid value -} - -int16_t ACMAMR::SetBitRateSafe(const int32_t rate) { - switch (rate) { - case 4750: { - encoding_mode_ = WEBRTC_AMR_MR475; - encoding_rate_ = 4750; - break; - } - case 5150: { - encoding_mode_ = WEBRTC_AMR_MR515; - encoding_rate_ = 5150; - break; - } - case 5900: { - encoding_mode_ = WEBRTC_AMR_MR59; - encoding_rate_ = 5900; - break; - } - case 6700: { - encoding_mode_ = WEBRTC_AMR_MR67; - encoding_rate_ = 6700; - break; - } - case 7400: { - encoding_mode_ = WEBRTC_AMR_MR74; - encoding_rate_ = 7400; - break; - } - case 7950: { - encoding_mode_ = WEBRTC_AMR_MR795; - encoding_rate_ = 7950; - break; - } - case 10200: { - encoding_mode_ = WEBRTC_AMR_MR102; - encoding_rate_ = 10200; - break; - } - case 12200: { - encoding_mode_ = WEBRTC_AMR_MR122; - encoding_rate_ = 12200; - break; - } - default: { - return -1; - } - } - return 0; -} - -int16_t ACMAMR::SetAMREncoderPackingFormat(ACMAMRPackingFormat packing_format) { - if ((packing_format != AMRBandwidthEfficient) && - (packing_format != AMROctetAlligned) && - (packing_format != AMRFileStorage)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Invalid AMR Encoder packing-format."); - return -1; - } else { - if (WebRtcAmr_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) { - return -1; - } else { - encoder_packing_format_ = packing_format; - return 0; - } - } -} - -ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const { - return encoder_packing_format_; -} - -int16_t ACMAMR::SetAMRDecoderPackingFormat( - ACMAMRPackingFormat /* packing_format */) { - // Not implemented. - return -1; -} - -ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const { - // Not implemented. - return AMRUndefined; -} - -#endif -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_amr.h b/webrtc/modules/audio_coding/main/acm2/acm_amr.h deleted file mode 100644 index 09d9e4326..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_amr.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMR_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct AMR_encinst_t_; -struct AMR_decinst_t_; - -namespace webrtc { - -enum ACMAMRPackingFormat; - -namespace acm2 { - -class ACMAMR : public ACMGenericCodec { - public: - ACMAMR(int16_t codec_id, bool enable_red); - ~ACMAMR(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - int16_t SetAMREncoderPackingFormat(const ACMAMRPackingFormat packing_format); - - ACMAMRPackingFormat AMREncoderPackingFormat() const; - - int16_t SetAMRDecoderPackingFormat(const ACMAMRPackingFormat packing_format); - - ACMAMRPackingFormat AMRDecoderPackingFormat() const; - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t SetBitRateSafe(const int32_t rate); - - int16_t EnableDTX(); - - int16_t DisableDTX(); - - AMR_encinst_t_* encoder_inst_ptr_; - int16_t encoding_mode_; - int16_t encoding_rate_; - ACMAMRPackingFormat encoder_packing_format_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMR_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_amrwb.cc b/webrtc/modules/audio_coding/main/acm2/acm_amrwb.cc deleted file mode 100644 index 5d923fae3..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_amrwb.cc +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_amrwb.h" - -#ifdef WEBRTC_CODEC_AMRWB -// NOTE! GSM AMR-wb is not included in the open-source package. The -// following interface file is needed: -#include "webrtc/modules/audio_coding/main/codecs/amrwb/interface/amrwb_interface.h" -#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/rw_lock_wrapper.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// The API in the header file should match the one below. -// -// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** enc_inst); -// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** dec_inst); -// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* enc_inst); -// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* dec_inst); -// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* enc_inst, int16_t* input, -// int16_t len, int16_t* output, int16_t mode); -// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* enc_inst, -// int16_t dtx_mode); -// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* enc_inst, -// int format); -// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* dec_inst); -// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* dec_inst); -// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* dec_inst); -// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* dec_inst, -// int format); -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_AMRWB -ACMAMRwb::ACMAMRwb(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoding_mode_(-1), // invalid value - encoding_rate_(0), // invalid value - encoder_packing_format_(AMRBandwidthEfficient) { -} - -ACMAMRwb::~ACMAMRwb() {} - -int16_t ACMAMRwb::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMAMRwb::EnableDTX() { return -1; } - -int16_t ACMAMRwb::DisableDTX() { return -1; } - -int16_t ACMAMRwb::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMAMRwb::CreateInstance(void) { return NULL; } - -int16_t ACMAMRwb::InternalCreateEncoder() { return -1; } - -void ACMAMRwb::DestructEncoderSafe() { return; } - -int16_t ACMAMRwb::SetBitRateSafe(const int32_t /* rate */) { return -1; } - -int16_t ACMAMRwb::SetAMRwbEncoderPackingFormat( - ACMAMRPackingFormat /* packing_format */) { - return -1; -} - -ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const { - return AMRUndefined; -} - -int16_t ACMAMRwb::SetAMRwbDecoderPackingFormat( - ACMAMRPackingFormat /* packing_format */) { - return -1; -} - -ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const { - return AMRUndefined; -} - -#else //===================== Actual Implementation ======================= - -#define AMRWB_MODE_7k 0 -#define AMRWB_MODE_9k 1 -#define AMRWB_MODE_12k 2 -#define AMRWB_MODE_14k 3 -#define AMRWB_MODE_16k 4 -#define AMRWB_MODE_18k 5 -#define AMRWB_MODE_20k 6 -#define AMRWB_MODE_23k 7 -#define AMRWB_MODE_24k 8 - -ACMAMRwb::ACMAMRwb(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoding_mode_(-1), // invalid value - encoding_rate_(0) { // invalid value - codec_id_ = codec_id; - has_internal_dtx_ = true; - encoder_packing_format_ = AMRBandwidthEfficient; - return; -} - -ACMAMRwb::~ACMAMRwb() { - if (encoder_inst_ptr_ != NULL) { - WebRtcAmrWb_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMAMRwb::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - int16_t vad_decision = 1; - // sanity check, if the rate is set correctly. we might skip this - // sanity check. if rate is not set correctly, initialization flag - // should be false and should not be here. - if ((encoding_mode_ < AMRWB_MODE_7k) || (encoding_mode_ > AMRWB_MODE_24k)) { - *bitstream_len_byte = 0; - return -1; - } - *bitstream_len_byte = WebRtcAmrWb_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], frame_len_smpl_, - reinterpret_cast(bitstream), encoding_mode_); - - // Update VAD, if internal DTX is used - if (has_internal_dtx_ && dtx_enabled_) { - if (*bitstream_len_byte <= (7 * frame_len_smpl_ / 160)) { - vad_decision = 0; - } - for (int16_t n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { - vad_label_[n] = vad_decision; - } - } - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += frame_len_smpl_; - return *bitstream_len_byte; -} - -int16_t ACMAMRwb::EnableDTX() { - if (dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // enable DTX - if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 1) < 0) { - return -1; - } - dtx_enabled_ = true; - return 0; - } else { - return -1; - } -} - -int16_t ACMAMRwb::DisableDTX() { - if (!dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // disable DTX - if (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, 0) < 0) { - return -1; - } - dtx_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -int16_t ACMAMRwb::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // sanity check - if (encoder_inst_ptr_ == NULL) { - return -1; - } - - int16_t status = SetBitRateSafe((codec_params->codec_inst).rate); - status += (WebRtcAmrWb_EncoderInit(encoder_inst_ptr_, - ((codec_params->enable_dtx) ? 1 : 0)) < 0) - ? -1 - : 0; - status += (WebRtcAmrWb_EncodeBitmode(encoder_inst_ptr_, - encoder_packing_format_) < 0) - ? -1 - : 0; - return (status < 0) ? -1 : 0; -} - -ACMGenericCodec* ACMAMRwb::CreateInstance(void) { return NULL; } - -int16_t ACMAMRwb::InternalCreateEncoder() { - return WebRtcAmrWb_CreateEnc(&encoder_inst_ptr_); -} - -void ACMAMRwb::DestructEncoderSafe() { - if (encoder_inst_ptr_ != NULL) { - WebRtcAmrWb_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - // there is no encoder set the following - encoder_exist_ = false; - encoder_initialized_ = false; - encoding_mode_ = -1; // invalid value - encoding_rate_ = 0; -} - -int16_t ACMAMRwb::SetBitRateSafe(const int32_t rate) { - switch (rate) { - case 7000: { - encoding_mode_ = AMRWB_MODE_7k; - encoding_rate_ = 7000; - break; - } - case 9000: { - encoding_mode_ = AMRWB_MODE_9k; - encoding_rate_ = 9000; - break; - } - case 12000: { - encoding_mode_ = AMRWB_MODE_12k; - encoding_rate_ = 12000; - break; - } - case 14000: { - encoding_mode_ = AMRWB_MODE_14k; - encoding_rate_ = 14000; - break; - } - case 16000: { - encoding_mode_ = AMRWB_MODE_16k; - encoding_rate_ = 16000; - break; - } - case 18000: { - encoding_mode_ = AMRWB_MODE_18k; - encoding_rate_ = 18000; - break; - } - case 20000: { - encoding_mode_ = AMRWB_MODE_20k; - encoding_rate_ = 20000; - break; - } - case 23000: { - encoding_mode_ = AMRWB_MODE_23k; - encoding_rate_ = 23000; - break; - } - case 24000: { - encoding_mode_ = AMRWB_MODE_24k; - encoding_rate_ = 24000; - break; - } - default: { - return -1; - } - } - return 0; -} - -int16_t ACMAMRwb::SetAMRwbEncoderPackingFormat( - ACMAMRPackingFormat packing_format) { - if ((packing_format != AMRBandwidthEfficient) && - (packing_format != AMROctetAlligned) && - (packing_format != AMRFileStorage)) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Invalid AMRwb encoder packing-format."); - return -1; - } else { - if (WebRtcAmrWb_EncodeBitmode(encoder_inst_ptr_, packing_format) < 0) { - return -1; - } else { - encoder_packing_format_ = packing_format; - return 0; - } - } -} - -ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const { - return encoder_packing_format_; -} - -int16_t ACMAMRwb::SetAMRwbDecoderPackingFormat( - ACMAMRPackingFormat packing_format) { - // Not implemented. - return -1; -} - -ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const { - // Not implemented. - return AMRUndefined; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_amrwb.h b/webrtc/modules/audio_coding/main/acm2/acm_amrwb.h deleted file mode 100644 index 9e09b6b88..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_amrwb.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMRWB_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMRWB_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct AMRWB_encinst_t_; -struct AMRWB_decinst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMAMRwb : public ACMGenericCodec { - public: - ACMAMRwb(int16_t codec_id, bool enable_red); - ~ACMAMRwb(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - int16_t SetAMRwbEncoderPackingFormat( - const ACMAMRPackingFormat packing_format); - - ACMAMRPackingFormat AMRwbEncoderPackingFormat() const; - - int16_t SetAMRwbDecoderPackingFormat( - const ACMAMRPackingFormat packing_format); - - ACMAMRPackingFormat AMRwbDecoderPackingFormat() const; - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t SetBitRateSafe(const int32_t rate); - - int16_t EnableDTX(); - - int16_t DisableDTX(); - - AMRWB_encinst_t_* encoder_inst_ptr_; - - int16_t encoding_mode_; - int16_t encoding_rate_; - ACMAMRPackingFormat encoder_packing_format_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_AMRWB_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_cng.cc b/webrtc/modules/audio_coding/main/acm2/acm_cng.cc deleted file mode 100644 index acb6a3081..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_cng.cc +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_cng.h" - -#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -namespace webrtc { - -namespace acm2 { - -ACMCNG::ACMCNG(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - encoder_inst_ptr_ = NULL; - codec_id_ = codec_id; - samp_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_); - return; -} - -ACMCNG::~ACMCNG() { - if (encoder_inst_ptr_ != NULL) { - WebRtcCng_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -// CNG is not like a regular encoder, this function -// should not be called normally -// instead the following function is called from inside -// ACMGenericCodec::ProcessFrameVADDTX -int16_t ACMCNG::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -// CNG is not like a regular encoder, -// this function should not be called normally -// instead the following function is called from inside -// ACMGenericCodec::ProcessFrameVADDTX -int16_t ACMCNG::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMCNG::CreateInstance(void) { return NULL; } - -int16_t ACMCNG::InternalCreateEncoder() { - if (WebRtcCng_CreateEnc(&encoder_inst_ptr_) < 0) { - encoder_inst_ptr_ = NULL; - return -1; - } else { - return 0; - } -} - -void ACMCNG::DestructEncoderSafe() { - if (encoder_inst_ptr_ != NULL) { - WebRtcCng_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - encoder_exist_ = false; - encoder_initialized_ = false; -} - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_cng.h b/webrtc/modules/audio_coding/main/acm2/acm_cng.h deleted file mode 100644 index 374b0fc5e..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_cng.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CNG_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CNG_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct WebRtcCngEncInst; -struct WebRtcCngDecInst; - -namespace webrtc { - -namespace acm2 { - -class ACMCNG: public ACMGenericCodec { - public: - ACMCNG(int16_t codec_id, bool enable_red); - ~ACMCNG(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params); - - protected: - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalCreateEncoder(); - - int16_t EnableDTX() { - return -1; - } - - int16_t DisableDTX() { - return -1; - } - - WebRtcCngEncInst* encoder_inst_ptr_; - uint16_t samp_freq_hz_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CNG_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc index 5f6bcb5e8..bce8e5cc0 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc @@ -23,79 +23,6 @@ #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" #include "webrtc/system_wrappers/interface/trace.h" -// Includes needed to create the codecs. -// G711, PCM mu-law and A-law -#include "webrtc/modules/audio_coding/main/acm2/acm_pcma.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_pcmu.h" -#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" -// CNG -#include "webrtc/modules/audio_coding/codecs/cng/include/webrtc_cng.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_cng.h" -#ifdef WEBRTC_CODEC_ISAC -#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h" -#endif -#ifdef WEBRTC_CODEC_ISACFX -#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h" -#endif -#if (defined WEBRTC_CODEC_ISACFX) || (defined WEBRTC_CODEC_ISAC) -#include "webrtc/modules/audio_coding/main/acm2/acm_isac.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_isac_macros.h" -#endif -#ifdef WEBRTC_CODEC_PCM16 -#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_pcm16b.h" -#endif -#ifdef WEBRTC_CODEC_ILBC -#include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_ilbc.h" -#endif -#ifdef WEBRTC_CODEC_AMR -#include "webrtc/modules/audio_coding/codecs/amr/include/amr_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_amr.h" -#endif -#ifdef WEBRTC_CODEC_AMRWB -#include "webrtc/modules/audio_coding/codecs/amrwb/include/amrwb_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_amrwb.h" -#endif -#ifdef WEBRTC_CODEC_G722 -#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_g722.h" -#endif -#ifdef WEBRTC_CODEC_G722_1 -#include "webrtc/modules/audio_coding/codecs/g7221/include/g7221_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_g7221.h" -#endif -#ifdef WEBRTC_CODEC_G722_1C -#include "webrtc/modules/audio_coding/codecs/g7221c/include/g7221c_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_g7221c.h" -#endif -#ifdef WEBRTC_CODEC_G729 -#include "webrtc/modules/audio_coding/codecs/g729/include/g729_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_g729.h" -#endif -#ifdef WEBRTC_CODEC_G729_1 -#include "webrtc/modules/audio_coding/codecs/g7291/include/g7291_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_g7291.h" -#endif -#ifdef WEBRTC_CODEC_GSMFR -#include "webrtc/modules/audio_coding/codecs/gsmfr/include/gsmfr_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_gsmfr.h" -#endif -#ifdef WEBRTC_CODEC_OPUS -#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_opus.h" -#endif -#ifdef WEBRTC_CODEC_SPEEX -#include "webrtc/modules/audio_coding/codecs/speex/include/speex_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_speex.h" -#endif -#ifdef WEBRTC_CODEC_AVT -#include "webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.h" -#endif -#ifdef WEBRTC_CODEC_RED -#include "webrtc/modules/audio_coding/main/acm2/acm_red.h" -#endif - namespace webrtc { namespace acm2 { @@ -132,45 +59,16 @@ const CodecInst ACMCodecDB::database_[] = { #ifdef WEBRTC_CODEC_ILBC {102, "ILBC", 8000, 240, 1, 13300}, #endif -#ifdef WEBRTC_CODEC_AMR - {114, "AMR", 8000, 160, 1, 12200}, -#endif -#ifdef WEBRTC_CODEC_AMRWB - {115, "AMR-WB", 16000, 320, 1, 20000}, -#endif #ifdef WEBRTC_CODEC_G722 // Mono {9, "G722", 16000, 320, 1, 64000}, // Stereo {119, "G722", 16000, 320, 2, 64000}, #endif -#ifdef WEBRTC_CODEC_G722_1 - {92, "G7221", 16000, 320, 1, 32000}, - {91, "G7221", 16000, 320, 1, 24000}, - {90, "G7221", 16000, 320, 1, 16000}, -#endif -#ifdef WEBRTC_CODEC_G722_1C - {89, "G7221", 32000, 640, 1, 48000}, - {88, "G7221", 32000, 640, 1, 32000}, - {87, "G7221", 32000, 640, 1, 24000}, -#endif -#ifdef WEBRTC_CODEC_G729 - {18, "G729", 8000, 240, 1, 8000}, -#endif -#ifdef WEBRTC_CODEC_G729_1 - {86, "G7291", 16000, 320, 1, 32000}, -#endif -#ifdef WEBRTC_CODEC_GSMFR - {3, "GSM", 8000, 160, 1, 13200}, -#endif #ifdef WEBRTC_CODEC_OPUS // Opus internally supports 48, 24, 16, 12, 8 kHz. // Mono and stereo. {120, "opus", 48000, 960, 2, 64000}, -#endif -#ifdef WEBRTC_CODEC_SPEEX - {85, "speex", 8000, 160, 1, 11000}, - {84, "speex", 16000, 320, 1, 22000}, #endif // Comfort noise for four different sampling frequencies. {13, "CN", 8000, 240, 1, 0}, @@ -221,46 +119,17 @@ const ACMCodecDB::CodecSettings ACMCodecDB::codec_settings_[] = { #ifdef WEBRTC_CODEC_ILBC {4, {160, 240, 320, 480}, 0, 1, false}, #endif -#ifdef WEBRTC_CODEC_AMR - {3, {160, 320, 480}, 0, 1, true}, -#endif -#ifdef WEBRTC_CODEC_AMRWB - {3, {320, 640, 960}, 0, 1, true}, -#endif #ifdef WEBRTC_CODEC_G722 // Mono {6, {160, 320, 480, 640, 800, 960}, 0, 2, false}, // Stereo {6, {160, 320, 480, 640, 800, 960}, 0, 2, false}, #endif -#ifdef WEBRTC_CODEC_G722_1 - {1, {320}, 320, 1, false}, - {1, {320}, 320, 1, false}, - {1, {320}, 320, 1, false}, -#endif -#ifdef WEBRTC_CODEC_G722_1C - {1, {640}, 640, 1, false}, - {1, {640}, 640, 1, false}, - {1, {640}, 640, 1, false}, -#endif -#ifdef WEBRTC_CODEC_G729 - {6, {80, 160, 240, 320, 400, 480}, 0, 1, false}, -#endif -#ifdef WEBRTC_CODEC_G729_1 - {3, {320, 640, 960}, 0, 1, false}, -#endif -#ifdef WEBRTC_CODEC_GSMFR - {3, {160, 320, 480}, 160, 1, false}, -#endif #ifdef WEBRTC_CODEC_OPUS // Opus supports frames shorter than 10ms, // but it doesn't help us to use them. // Mono and stereo. {4, {480, 960, 1920, 2880}, 0, 2, false}, -#endif -#ifdef WEBRTC_CODEC_SPEEX - {3, {160, 320, 480}, 0, 1, false}, - {3, {320, 640, 960}, 0, 1, false}, #endif // Comfort noise for three different sampling frequencies. {1, {240}, 240, 1, false}, @@ -308,44 +177,15 @@ const NetEqDecoder ACMCodecDB::neteq_decoders_[] = { #ifdef WEBRTC_CODEC_ILBC kDecoderILBC, #endif -#ifdef WEBRTC_CODEC_AMR - kDecoderAMR, -#endif -#ifdef WEBRTC_CODEC_AMRWB - kDecoderAMRWB, -#endif #ifdef WEBRTC_CODEC_G722 // Mono kDecoderG722, // Stereo kDecoderG722_2ch, #endif -#ifdef WEBRTC_CODEC_G722_1 - kDecoderG722_1_32, - kDecoderG722_1_24, - kDecoderG722_1_16, -#endif -#ifdef WEBRTC_CODEC_G722_1C - kDecoderG722_1C_48, - kDecoderG722_1C_32, - kDecoderG722_1C_24, -#endif -#ifdef WEBRTC_CODEC_G729 - kDecoderG729, -#endif -#ifdef WEBRTC_CODEC_G729_1 - kDecoderG729_1, -#endif -#ifdef WEBRTC_CODEC_GSMFR - kDecoderGSMFR, -#endif #ifdef WEBRTC_CODEC_OPUS // Mono and stereo. kDecoderOpus, -#endif -#ifdef WEBRTC_CODEC_SPEEX - kDecoderSPEEX_8, - kDecoderSPEEX_16, #endif // Comfort noise for three different sampling frequencies. kDecoderCNGnb, @@ -589,108 +429,12 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst, return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb, cng_pt_swb, cng_pt_fb, enable_red, red_payload_type); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "AMR")) { -#ifdef WEBRTC_CODEC_AMR - return new ACMAMR(kGSMAMR, enable_red); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "AMR-WB")) { -#ifdef WEBRTC_CODEC_AMRWB - return new ACMAMRwb(kGSMAMRWB, enable_red); #endif } else if (!STR_CASE_CMP(codec_inst.plname, "G722")) { #ifdef WEBRTC_CODEC_G722 return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb, cng_pt_swb, cng_pt_fb, enable_red, red_payload_type); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "G7221")) { - switch (codec_inst.plfreq) { - case 16000: { -#ifdef WEBRTC_CODEC_G722_1 - int codec_id; - switch (codec_inst->rate) { - case 16000 : { - codec_id = kG722_1_16; - break; - } - case 24000 : { - codec_id = kG722_1_24; - break; - } - case 32000 : { - codec_id = kG722_1_32; - break; - } - default: { - return NULL; - } - } - return new ACMG722_1(codec_id, enable_red); -#endif - FALLTHROUGH(); - } - case 32000: { -#ifdef WEBRTC_CODEC_G722_1C - int codec_id; - switch (codec_inst->rate) { - case 24000 : { - codec_id = kG722_1C_24; - break; - } - case 32000 : { - codec_id = kG722_1C_32; - break; - } - case 48000 : { - codec_id = kG722_1C_48; - break; - } - default: { - return NULL; - } - } - return new ACMG722_1C(codec_id, enable_red); -#endif - FALLTHROUGH(); - } - default: - FATAL(); - } - } else if (!STR_CASE_CMP(codec_inst.plname, "CN")) { - // For CN we need to check sampling frequency to know what codec to create. - int codec_id; - switch (codec_inst.plfreq) { - case 8000: { - codec_id = kCNNB; - break; - } - case 16000: { - codec_id = kCNWB; - break; - } - case 32000: { - codec_id = kCNSWB; - break; - } -#ifdef ENABLE_48000_HZ - case 48000: { - codec_id = kCNFB; - break; - } -#endif - default: { - return NULL; - } - } - return new ACMCNG(codec_id, enable_red); - } else if (!STR_CASE_CMP(codec_inst.plname, "G729")) { -#ifdef WEBRTC_CODEC_G729 - return new ACMG729(kG729, enable_red); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "G7291")) { -#ifdef WEBRTC_CODEC_G729_1 - return new ACMG729_1(kG729_1, enable_red); #endif } else if (!STR_CASE_CMP(codec_inst.plname, "opus")) { #ifdef WEBRTC_CODEC_OPUS @@ -698,64 +442,11 @@ ACMGenericCodec* ACMCodecDB::CreateCodecInstance(const CodecInst& codec_inst, cng_pt_swb, cng_pt_fb, enable_red, red_payload_type); #endif - } else if (!STR_CASE_CMP(codec_inst.plname, "speex")) { -#ifdef WEBRTC_CODEC_SPEEX - int codec_id; - switch (codec_inst->plfreq) { - case 8000: { - codec_id = kSPEEX8; - break; - } - case 16000: { - codec_id = kSPEEX16; - break; - } - default: { - return NULL; - } - } - return new ACMSPEEX(codec_id, enable_red); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "CN")) { - // For CN we need to check sampling frequency to know what codec to create. - int codec_id; - switch (codec_inst.plfreq) { - case 8000: { - codec_id = kCNNB; - break; - } - case 16000: { - codec_id = kCNWB; - break; - } - case 32000: { - codec_id = kCNSWB; - break; - } -#ifdef ENABLE_48000_HZ - case 48000: { - codec_id = kCNFB; - break; - } -#endif - default: { - return NULL; - } - } - return new ACMCNG(codec_id, enable_red); } else if (!STR_CASE_CMP(codec_inst.plname, "L16")) { #ifdef WEBRTC_CODEC_PCM16 return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb, cng_pt_swb, cng_pt_fb, enable_red, red_payload_type); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "telephone-event")) { -#ifdef WEBRTC_CODEC_AVT - return new ACMDTMFPlayout(kAVT, enable_red); -#endif - } else if (!STR_CASE_CMP(codec_inst.plname, "red")) { -#ifdef WEBRTC_CODEC_RED - return new ACMRED(kRED, enable_red); #endif } return NULL; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h index 94cad5c11..ea7eb23ac 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h @@ -57,44 +57,15 @@ class ACMCodecDB { #ifdef WEBRTC_CODEC_ILBC , kILBC #endif -#ifdef WEBRTC_CODEC_AMR - , kGSMAMR -#endif -#ifdef WEBRTC_CODEC_AMRWB - , kGSMAMRWB -#endif #ifdef WEBRTC_CODEC_G722 // Mono , kG722 // Stereo , kG722_2ch #endif -#ifdef WEBRTC_CODEC_G722_1 - , kG722_1_32 - , kG722_1_24 - , kG722_1_16 -#endif -#ifdef WEBRTC_CODEC_G722_1C - , kG722_1C_48 - , kG722_1C_32 - , kG722_1C_24 -#endif -#ifdef WEBRTC_CODEC_G729 - , kG729 -#endif -#ifdef WEBRTC_CODEC_G729_1 - , kG729_1 -#endif -#ifdef WEBRTC_CODEC_GSMFR - , kGSMFR -#endif #ifdef WEBRTC_CODEC_OPUS // Mono and stereo , kOpus -#endif -#ifdef WEBRTC_CODEC_SPEEX - , kSPEEX8 - , kSPEEX16 #endif , kCNNB , kCNWB @@ -134,41 +105,12 @@ class ACMCodecDB { #ifndef WEBRTC_CODEC_ILBC enum {kILBC = -1}; #endif -#ifndef WEBRTC_CODEC_AMR - enum {kGSMAMR = -1}; -#endif -#ifndef WEBRTC_CODEC_AMRWB - enum {kGSMAMRWB = -1}; -#endif #ifndef WEBRTC_CODEC_G722 // Mono enum {kG722 = -1}; // Stereo enum {kG722_2ch = -1}; #endif -#ifndef WEBRTC_CODEC_G722_1 - enum {kG722_1_32 = -1}; - enum {kG722_1_24 = -1}; - enum {kG722_1_16 = -1}; -#endif -#ifndef WEBRTC_CODEC_G722_1C - enum {kG722_1C_48 = -1}; - enum {kG722_1C_32 = -1}; - enum {kG722_1C_24 = -1}; -#endif -#ifndef WEBRTC_CODEC_G729 - enum {kG729 = -1}; -#endif -#ifndef WEBRTC_CODEC_G729_1 - enum {kG729_1 = -1}; -#endif -#ifndef WEBRTC_CODEC_GSMFR - enum {kGSMFR = -1}; -#endif -#ifndef WEBRTC_CODEC_SPEEX - enum {kSPEEX8 = -1}; - enum {kSPEEX16 = -1}; -#endif #ifndef WEBRTC_CODEC_OPUS // Mono and stereo enum {kOpus = -1}; diff --git a/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.cc b/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.cc deleted file mode 100644 index 39331f218..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.h" - -#ifdef WEBRTC_CODEC_AVT -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_receiver.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_AVT - -ACMDTMFPlayout::ACMDTMFPlayout(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red) { -} - -ACMDTMFPlayout::~ACMDTMFPlayout() { return; } - -int16_t ACMDTMFPlayout::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMDTMFPlayout::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) { return NULL; } - -int16_t ACMDTMFPlayout::InternalCreateEncoder() { return -1; } - -void ACMDTMFPlayout::DestructEncoderSafe() { - return; -} - -#else //===================== Actual Implementation ======================= - -ACMDTMFPlayout::ACMDTMFPlayout(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - codec_id_ = codec_id; -} - -ACMDTMFPlayout::~ACMDTMFPlayout() { return; } - -int16_t ACMDTMFPlayout::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return 0; -} - -int16_t ACMDTMFPlayout::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - // This codec does not need initialization, - // DTMFPlayout has no instance - return 0; -} - -ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) { return NULL; } - -int16_t ACMDTMFPlayout::InternalCreateEncoder() { - // DTMFPlayout has no instance - return 0; -} - -void ACMDTMFPlayout::DestructEncoderSafe() { - // DTMFPlayout has no instance - return; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.h b/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.h deleted file mode 100644 index 72f201be1..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_dtmf_playout.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_DTMF_PLAYOUT_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_DTMF_PLAYOUT_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -namespace webrtc { - -namespace acm2 { - -class ACMDTMFPlayout : public ACMGenericCodec { - public: - ACMDTMFPlayout(int16_t codec_id, bool enable_red); - ~ACMDTMFPlayout(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_DTMF_PLAYOUT_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g722.cc b/webrtc/modules/audio_coding/main/acm2/acm_g722.cc deleted file mode 100644 index e27b99225..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g722.cc +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_g722.h" - -#ifdef WEBRTC_CODEC_G722 -#include "webrtc/modules/audio_coding/codecs/g722/include/g722_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_G722 - -ACMG722::ACMG722(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - ptr_enc_str_(NULL), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL) { -} - -ACMG722::~ACMG722() {} - -int32_t ACMG722::Add10MsDataSafe(const uint32_t /* timestamp */, - const int16_t* /* data */, - const uint16_t /* length_smpl */, - const uint8_t /* audio_channel */) { - return -1; -} - -int16_t ACMG722::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMG722::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMG722::CreateInstance(void) { return NULL; } - -int16_t ACMG722::InternalCreateEncoder() { return -1; } - -void ACMG722::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= - -// Encoder and decoder memory -struct ACMG722EncStr { - G722EncInst* inst; // instance for left channel in case of stereo - G722EncInst* inst_right; // instance for right channel in case of stereo -}; -struct ACMG722DecStr { - G722DecInst* inst; // instance for left channel in case of stereo - G722DecInst* inst_right; // instance for right channel in case of stereo -}; - -ACMG722::ACMG722(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL) { - ptr_enc_str_ = new ACMG722EncStr; - if (ptr_enc_str_ != NULL) { - ptr_enc_str_->inst = NULL; - ptr_enc_str_->inst_right = NULL; - } - codec_id_ = codec_id; - return; -} - -ACMG722::~ACMG722() { - // Encoder - if (ptr_enc_str_ != NULL) { - if (ptr_enc_str_->inst != NULL) { - WebRtcG722_FreeEncoder(ptr_enc_str_->inst); - ptr_enc_str_->inst = NULL; - } - if (ptr_enc_str_->inst_right != NULL) { - WebRtcG722_FreeEncoder(ptr_enc_str_->inst_right); - ptr_enc_str_->inst_right = NULL; - } - delete ptr_enc_str_; - ptr_enc_str_ = NULL; - } - return; -} - -int32_t ACMG722::Add10MsDataSafe(const uint32_t timestamp, - const int16_t* data, - const uint16_t length_smpl, - const uint8_t audio_channel) { - return ACMGenericCodec::Add10MsDataSafe( - (timestamp >> 1), data, length_smpl, audio_channel); -} - -int16_t ACMG722::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - // If stereo, split input signal in left and right channel before encoding - if (num_channels_ == 2) { - int16_t left_channel[960]; - int16_t right_channel[960]; - uint8_t out_left[480]; - uint8_t out_right[480]; - int16_t len_in_bytes; - for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) { - left_channel[j] = in_audio_[in_audio_ix_read_ + i]; - right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1]; - } - len_in_bytes = WebRtcG722_Encode( - encoder_inst_ptr_, left_channel, frame_len_smpl_, - out_left); - len_in_bytes += WebRtcG722_Encode(encoder_inst_ptr_right_, - right_channel, - frame_len_smpl_, - out_right); - *bitstream_len_byte = len_in_bytes; - - // Interleave the 4 bits per sample from left and right channel - for (int i = 0, j = 0; i < len_in_bytes; i += 2, j++) { - bitstream[i] = (out_left[j] & 0xF0) + (out_right[j] >> 4); - bitstream[i + 1] = ((out_left[j] & 0x0F) << 4) + (out_right[j] & 0x0F); - } - } else { - *bitstream_len_byte = WebRtcG722_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], frame_len_smpl_, - bitstream); - } - - // increment the read index this tell the caller how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += frame_len_smpl_ * num_channels_; - return *bitstream_len_byte; -} - -int16_t ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - if (codec_params->codec_inst.channels == 2) { - // Create codec struct for right channel - if (ptr_enc_str_->inst_right == NULL) { - WebRtcG722_CreateEncoder(&ptr_enc_str_->inst_right); - if (ptr_enc_str_->inst_right == NULL) { - return -1; - } - } - encoder_inst_ptr_right_ = ptr_enc_str_->inst_right; - if (WebRtcG722_EncoderInit(encoder_inst_ptr_right_) < 0) { - return -1; - } - } - - return WebRtcG722_EncoderInit(encoder_inst_ptr_); -} - -ACMGenericCodec* ACMG722::CreateInstance(void) { return NULL; } - -int16_t ACMG722::InternalCreateEncoder() { - if (ptr_enc_str_ == NULL) { - // this structure must be created at the costructor - // if it is still NULL then there is a probelm and - // we dont continue - return -1; - } - WebRtcG722_CreateEncoder(&ptr_enc_str_->inst); - if (ptr_enc_str_->inst == NULL) { - return -1; - } - encoder_inst_ptr_ = ptr_enc_str_->inst; - return 0; -} - -void ACMG722::DestructEncoderSafe() { - if (ptr_enc_str_ != NULL) { - if (ptr_enc_str_->inst != NULL) { - WebRtcG722_FreeEncoder(ptr_enc_str_->inst); - ptr_enc_str_->inst = NULL; - } - } - encoder_exist_ = false; - encoder_initialized_ = false; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g722.h b/webrtc/modules/audio_coding/main/acm2/acm_g722.h deleted file mode 100644 index 79ddf28bc..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g722.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G722_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G722_H_ - -#include "webrtc/base/thread_annotations.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -typedef struct WebRtcG722EncInst G722EncInst; -typedef struct WebRtcG722DecInst G722DecInst; - -namespace webrtc { - -namespace acm2 { - -// Forward declaration. -struct ACMG722EncStr; -struct ACMG722DecStr; - -class ACMG722 : public ACMGenericCodec { - public: - ACMG722(int16_t codec_id, bool enable_red); - ~ACMG722(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - int32_t Add10MsDataSafe(const uint32_t timestamp, - const int16_t* data, - const uint16_t length_smpl, - const uint8_t audio_channel) - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalCreateEncoder(); - - ACMG722EncStr* ptr_enc_str_; - - G722EncInst* encoder_inst_ptr_; - G722EncInst* encoder_inst_ptr_right_; // Prepared for stereo -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G722_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7221.cc b/webrtc/modules/audio_coding/main/acm2/acm_g7221.cc deleted file mode 100644 index 884a18902..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7221.cc +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_g7221.h" - -#ifdef WEBRTC_CODEC_G722_1 -// NOTE! G.722.1 is not included in the open-source package. The following -// interface file is needed: -#include "webrtc/modules/audio_coding/main/codecs/g7221/interface/g7221_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// The API in the header file should match the one below. -// -// int16_t WebRtcG7221_CreateEnc16(G722_1_16_encinst_t_** enc_inst); -// int16_t WebRtcG7221_CreateEnc24(G722_1_24_encinst_t_** enc_inst); -// int16_t WebRtcG7221_CreateEnc32(G722_1_32_encinst_t_** enc_inst); -// int16_t WebRtcG7221_CreateDec16(G722_1_16_decinst_t_** dec_inst); -// int16_t WebRtcG7221_CreateDec24(G722_1_24_decinst_t_** dec_inst); -// int16_t WebRtcG7221_CreateDec32(G722_1_32_decinst_t_** dec_inst); -// -// int16_t WebRtcG7221_FreeEnc16(G722_1_16_encinst_t_** enc_inst); -// int16_t WebRtcG7221_FreeEnc24(G722_1_24_encinst_t_** enc_inst); -// int16_t WebRtcG7221_FreeEnc32(G722_1_32_encinst_t_** enc_inst); -// int16_t WebRtcG7221_FreeDec16(G722_1_16_decinst_t_** dec_inst); -// int16_t WebRtcG7221_FreeDec24(G722_1_24_decinst_t_** dec_inst); -// int16_t WebRtcG7221_FreeDec32(G722_1_32_decinst_t_** dec_inst); -// -// int16_t WebRtcG7221_EncoderInit16(G722_1_16_encinst_t_* enc_inst); -// int16_t WebRtcG7221_EncoderInit24(G722_1_24_encinst_t_* enc_inst); -// int16_t WebRtcG7221_EncoderInit32(G722_1_32_encinst_t_* enc_inst); -// int16_t WebRtcG7221_DecoderInit16(G722_1_16_decinst_t_* dec_inst); -// int16_t WebRtcG7221_DecoderInit24(G722_1_24_decinst_t_* dec_inst); -// int16_t WebRtcG7221_DecoderInit32(G722_1_32_decinst_t_* dec_inst); -// -// int16_t WebRtcG7221_Encode16(G722_1_16_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221_Encode24(G722_1_24_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221_Encode32(G722_1_32_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// -// int16_t WebRtcG7221_Decode16(G722_1_16_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221_Decode24(G722_1_24_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221_Decode32(G722_1_32_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// -// int16_t WebRtcG7221_DecodePlc16(G722_1_16_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -// int16_t WebRtcG7221_DecodePlc24(G722_1_24_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -// int16_t WebRtcG7221_DecodePlc32(G722_1_32_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_G722_1 - -ACMG722_1::ACMG722_1(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - operational_rate_(-1), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL), - encoder_inst16_ptr_(NULL), - encoder_inst16_ptr_right_(NULL), - encoder_inst24_ptr_(NULL), - encoder_inst24_ptr_right_(NULL), - encoder_inst32_ptr_(NULL), - encoder_inst32_ptr_right_(NULL) { - return; -} - -ACMG722_1::~ACMG722_1() { return; } - -int16_t ACMG722_1::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMG722_1::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMG722_1::CreateInstance(void) { return NULL; } - -int16_t ACMG722_1::InternalCreateEncoder() { return -1; } - -void ACMG722_1::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= -ACMG722_1::ACMG722_1(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL), - encoder_inst16_ptr_(NULL), - encoder_inst16_ptr_right_(NULL), - encoder_inst24_ptr_(NULL), - encoder_inst24_ptr_right_(NULL), - encoder_inst32_ptr_(NULL), - encoder_inst32_ptr_right_(NULL) { - codec_id_ = codec_id; - if (codec_id_ == ACMCodecDB::kG722_1_16) { - operational_rate_ = 16000; - } else if (codec_id_ == ACMCodecDB::kG722_1_24) { - operational_rate_ = 24000; - } else if (codec_id_ == ACMCodecDB::kG722_1_32) { - operational_rate_ = 32000; - } else { - operational_rate_ = -1; - } - return; -} - -ACMG722_1::~ACMG722_1() { - if (encoder_inst_ptr_ != NULL) { - delete encoder_inst_ptr_; - encoder_inst_ptr_ = NULL; - } - if (encoder_inst_ptr_right_ != NULL) { - delete encoder_inst_ptr_right_; - encoder_inst_ptr_right_ = NULL; - } - - switch (operational_rate_) { - case 16000: { - encoder_inst16_ptr_ = NULL; - encoder_inst16_ptr_right_ = NULL; - break; - } - case 24000: { - encoder_inst24_ptr_ = NULL; - encoder_inst24_ptr_right_ = NULL; - break; - } - case 32000: { - encoder_inst32_ptr_ = NULL; - encoder_inst32_ptr_right_ = NULL; - break; - } - default: { - break; - } - } - return; -} - -int16_t ACMG722_1::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - int16_t left_channel[320]; - int16_t right_channel[320]; - int16_t len_in_bytes; - int16_t out_bits[160]; - - // If stereo, split input signal in left and right channel before encoding - if (num_channels_ == 2) { - for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) { - left_channel[j] = in_audio_[in_audio_ix_read_ + i]; - right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1]; - } - } else { - memcpy(left_channel, &in_audio_[in_audio_ix_read_], 320); - } - - switch (operational_rate_) { - case 16000: { - len_in_bytes = WebRtcG7221_Encode16(encoder_inst16_ptr_, left_channel, - 320, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221_Encode16(encoder_inst16_ptr_right_, - right_channel, 320, - &out_bits[len_in_bytes / 2]); - } - break; - } - case 24000: { - len_in_bytes = WebRtcG7221_Encode24(encoder_inst24_ptr_, left_channel, - 320, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221_Encode24(encoder_inst24_ptr_right_, - right_channel, 320, - &out_bits[len_in_bytes / 2]); - } - break; - } - case 32000: { - len_in_bytes = WebRtcG7221_Encode32(encoder_inst32_ptr_, left_channel, - 320, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221_Encode32(encoder_inst32_ptr_right_, - right_channel, 320, - &out_bits[len_in_bytes / 2]); - } - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalInitEncode: Wrong rate for G722_1."); - return -1; - } - } - memcpy(bitstream, out_bits, len_in_bytes); - *bitstream_len_byte = len_in_bytes; - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += 320 * num_channels_; - return *bitstream_len_byte; -} - -int16_t ACMG722_1::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - int16_t ret; - - switch (operational_rate_) { - case 16000: { - ret = WebRtcG7221_EncoderInit16(encoder_inst16_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221_EncoderInit16(encoder_inst16_ptr_); - } - case 24000: { - ret = WebRtcG7221_EncoderInit24(encoder_inst24_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221_EncoderInit24(encoder_inst24_ptr_); - } - case 32000: { - ret = WebRtcG7221_EncoderInit32(encoder_inst32_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221_EncoderInit32(encoder_inst32_ptr_); - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, - unique_id_, "InternalInitEncoder: Wrong rate for G722_1."); - return -1; - } - } -} - -ACMGenericCodec* ACMG722_1::CreateInstance(void) { return NULL; } - -int16_t ACMG722_1::InternalCreateEncoder() { - if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) { - return -1; - } - switch (operational_rate_) { - case 16000: { - WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_); - WebRtcG7221_CreateEnc16(&encoder_inst16_ptr_right_); - break; - } - case 24000: { - WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_); - WebRtcG7221_CreateEnc24(&encoder_inst24_ptr_right_); - break; - } - case 32000: { - WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_); - WebRtcG7221_CreateEnc32(&encoder_inst32_ptr_right_); - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalCreateEncoder: Wrong rate for G722_1."); - return -1; - } - } - return 0; -} - -void ACMG722_1::DestructEncoderSafe() { - encoder_exist_ = false; - encoder_initialized_ = false; - if (encoder_inst_ptr_ != NULL) { - delete encoder_inst_ptr_; - encoder_inst_ptr_ = NULL; - } - if (encoder_inst_ptr_right_ != NULL) { - delete encoder_inst_ptr_right_; - encoder_inst_ptr_right_ = NULL; - } - encoder_inst16_ptr_ = NULL; - encoder_inst24_ptr_ = NULL; - encoder_inst32_ptr_ = NULL; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7221.h b/webrtc/modules/audio_coding/main/acm2/acm_g7221.h deleted file mode 100644 index 10a49acd8..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7221.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct G722_1_16_encinst_t_; -struct G722_1_16_decinst_t_; -struct G722_1_24_encinst_t_; -struct G722_1_24_decinst_t_; -struct G722_1_32_encinst_t_; -struct G722_1_32_decinst_t_; -struct G722_1_Inst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMG722_1 : public ACMGenericCodec { - public: - ACMG722_1(int16_t codec_id, bool enable_red); - ~ACMG722_1(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int32_t operational_rate_; - - G722_1_Inst_t_* encoder_inst_ptr_; - G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode - - // Only one set of these pointer is valid at any instance - G722_1_16_encinst_t_* encoder_inst16_ptr_; - G722_1_16_encinst_t_* encoder_inst16_ptr_right_; - G722_1_24_encinst_t_* encoder_inst24_ptr_; - G722_1_24_encinst_t_* encoder_inst24_ptr_right_; - G722_1_32_encinst_t_* encoder_inst32_ptr_; - G722_1_32_encinst_t_* encoder_inst32_ptr_right_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7221c.cc b/webrtc/modules/audio_coding/main/acm2/acm_g7221c.cc deleted file mode 100644 index 43eb29008..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7221c.cc +++ /dev/null @@ -1,329 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_g7221c.h" - -#ifdef WEBRTC_CODEC_G722_1C -// NOTE! G.722.1C is not included in the open-source package. The following -// interface file is needed: -#include "webrtc/modules/audio_coding/main/codecs/g7221c/interface/g7221c_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// The API in the header file should match the one below. -// -// int16_t WebRtcG7221C_CreateEnc24(G722_1C_24_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_CreateEnc32(G722_1C_32_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_CreateEnc48(G722_1C_48_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_CreateDec24(G722_1C_24_decinst_t_** dec_inst); -// int16_t WebRtcG7221C_CreateDec32(G722_1C_32_decinst_t_** dec_inst); -// int16_t WebRtcG7221C_CreateDec48(G722_1C_48_decinst_t_** dec_inst); -// -// int16_t WebRtcG7221C_FreeEnc24(G722_1C_24_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_FreeEnc32(G722_1C_32_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_FreeEnc48(G722_1C_48_encinst_t_** enc_inst); -// int16_t WebRtcG7221C_FreeDec24(G722_1C_24_decinst_t_** dec_inst); -// int16_t WebRtcG7221C_FreeDec32(G722_1C_32_decinst_t_** dec_inst); -// int16_t WebRtcG7221C_FreeDec48(G722_1C_48_decinst_t_** dec_inst); -// -// int16_t WebRtcG7221C_EncoderInit24(G722_1C_24_encinst_t_* enc_inst); -// int16_t WebRtcG7221C_EncoderInit32(G722_1C_32_encinst_t_* enc_inst); -// int16_t WebRtcG7221C_EncoderInit48(G722_1C_48_encinst_t_* enc_inst); -// int16_t WebRtcG7221C_DecoderInit24(G722_1C_24_decinst_t_* dec_inst); -// int16_t WebRtcG7221C_DecoderInit32(G722_1C_32_decinst_t_* dec_inst); -// int16_t WebRtcG7221C_DecoderInit48(G722_1C_48_decinst_t_* dec_inst); -// -// int16_t WebRtcG7221C_Encode24(G722_1C_24_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221C_Encode32(G722_1C_32_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221C_Encode48(G722_1C_48_encinst_t_* enc_inst, -// int16_t* input, -// int16_t len, -// int16_t* output); -// -// int16_t WebRtcG7221C_Decode24(G722_1C_24_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221C_Decode32(G722_1C_32_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// int16_t WebRtcG7221C_Decode48(G722_1C_48_decinst_t_* dec_inst, -// int16_t* bitstream, -// int16_t len, -// int16_t* output); -// -// int16_t WebRtcG7221C_DecodePlc24(G722_1C_24_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -// int16_t WebRtcG7221C_DecodePlc32(G722_1C_32_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -// int16_t WebRtcG7221C_DecodePlc48(G722_1C_48_decinst_t_* dec_inst, -// int16_t* output, -// int16_t nr_lost_frames); -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_G722_1C - -ACMG722_1C::ACMG722_1C(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - operational_rate_(-1), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL), - encoder_inst24_ptr_(NULL), - encoder_inst24_ptr_right_(NULL), - encoder_inst32_ptr_(NULL), - encoder_inst32_ptr_right_(NULL), - encoder_inst48_ptr_(NULL), - encoder_inst48_ptr_right_(NULL) { - return; -} - -ACMG722_1C::~ACMG722_1C() { return; } - -int16_t ACMG722_1C::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMG722_1C::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMG722_1C::CreateInstance(void) { return NULL; } - -int16_t ACMG722_1C::InternalCreateEncoder() { return -1; } - -void ACMG722_1C::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= -ACMG722_1C::ACMG722_1C(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - encoder_inst_ptr_right_(NULL), - encoder_inst24_ptr_(NULL), - encoder_inst24_ptr_right_(NULL), - encoder_inst32_ptr_(NULL), - encoder_inst32_ptr_right_(NULL), - encoder_inst48_ptr_(NULL), - encoder_inst48_ptr_right_(NULL) { - codec_id_ = codec_id; - if (codec_id_ == ACMCodecDB::kG722_1C_24) { - operational_rate_ = 24000; - } else if (codec_id_ == ACMCodecDB::kG722_1C_32) { - operational_rate_ = 32000; - } else if (codec_id_ == ACMCodecDB::kG722_1C_48) { - operational_rate_ = 48000; - } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Wrong codec id for G722_1c."); - operational_rate_ = -1; - } - return; -} - -ACMG722_1C::~ACMG722_1C() { - if (encoder_inst_ptr_ != NULL) { - delete encoder_inst_ptr_; - encoder_inst_ptr_ = NULL; - } - if (encoder_inst_ptr_right_ != NULL) { - delete encoder_inst_ptr_right_; - encoder_inst_ptr_right_ = NULL; - } - - switch (operational_rate_) { - case 24000: { - encoder_inst24_ptr_ = NULL; - encoder_inst24_ptr_right_ = NULL; - break; - } - case 32000: { - encoder_inst32_ptr_ = NULL; - encoder_inst32_ptr_right_ = NULL; - break; - } - case 48000: { - encoder_inst48_ptr_ = NULL; - encoder_inst48_ptr_right_ = NULL; - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Wrong rate for G722_1c."); - break; - } - } - return; -} - -int16_t ACMG722_1C::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - int16_t left_channel[640]; - int16_t right_channel[640]; - int16_t len_in_bytes; - int16_t out_bits[240]; - - // If stereo, split input signal in left and right channel before encoding - if (num_channels_ == 2) { - for (int i = 0, j = 0; i < frame_len_smpl_ * 2; i += 2, j++) { - left_channel[j] = in_audio_[in_audio_ix_read_ + i]; - right_channel[j] = in_audio_[in_audio_ix_read_ + i + 1]; - } - } else { - memcpy(left_channel, &in_audio_[in_audio_ix_read_], 640); - } - - switch (operational_rate_) { - case 24000: { - len_in_bytes = WebRtcG7221C_Encode24(encoder_inst24_ptr_, left_channel, - 640, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221C_Encode24(encoder_inst24_ptr_right_, - right_channel, 640, - &out_bits[len_in_bytes / 2]); - } - break; - } - case 32000: { - len_in_bytes = WebRtcG7221C_Encode32(encoder_inst32_ptr_, left_channel, - 640, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221C_Encode32(encoder_inst32_ptr_right_, - right_channel, 640, - &out_bits[len_in_bytes / 2]); - } - break; - } - case 48000: { - len_in_bytes = WebRtcG7221C_Encode48(encoder_inst48_ptr_, left_channel, - 640, &out_bits[0]); - if (num_channels_ == 2) { - len_in_bytes += WebRtcG7221C_Encode48(encoder_inst48_ptr_right_, - right_channel, 640, - &out_bits[len_in_bytes / 2]); - } - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalEncode: Wrong rate for G722_1c."); - return -1; - } - } - - memcpy(bitstream, out_bits, len_in_bytes); - *bitstream_len_byte = len_in_bytes; - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += 640 * num_channels_; - - return *bitstream_len_byte; -} - -int16_t ACMG722_1C::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - int16_t ret; - - switch (operational_rate_) { - case 24000: { - ret = WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221C_EncoderInit24(encoder_inst24_ptr_); - } - case 32000: { - ret = WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221C_EncoderInit32(encoder_inst32_ptr_); - } - case 48000: { - ret = WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_right_); - if (ret < 0) { - return ret; - } - return WebRtcG7221C_EncoderInit48(encoder_inst48_ptr_); - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalInitEncode: Wrong rate for G722_1c."); - return -1; - } - } -} - -ACMGenericCodec* ACMG722_1C::CreateInstance(void) { return NULL; } - -int16_t ACMG722_1C::InternalCreateEncoder() { - if ((encoder_inst_ptr_ == NULL) || (encoder_inst_ptr_right_ == NULL)) { - return -1; - } - switch (operational_rate_) { - case 24000: { - WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_); - WebRtcG7221C_CreateEnc24(&encoder_inst24_ptr_right_); - break; - } - case 32000: { - WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_); - WebRtcG7221C_CreateEnc32(&encoder_inst32_ptr_right_); - break; - } - case 48000: { - WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_); - WebRtcG7221C_CreateEnc48(&encoder_inst48_ptr_right_); - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalCreateEncoder: Wrong rate for G722_1c."); - return -1; - } - } - return 0; -} - -void ACMG722_1C::DestructEncoderSafe() { - encoder_exist_ = false; - encoder_initialized_ = false; - if (encoder_inst_ptr_ != NULL) { - delete encoder_inst_ptr_; - encoder_inst_ptr_ = NULL; - } - if (encoder_inst_ptr_right_ != NULL) { - delete encoder_inst_ptr_right_; - encoder_inst_ptr_right_ = NULL; - } - encoder_inst24_ptr_ = NULL; - encoder_inst32_ptr_ = NULL; - encoder_inst48_ptr_ = NULL; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7221c.h b/webrtc/modules/audio_coding/main/acm2/acm_g7221c.h deleted file mode 100644 index e22790d78..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7221c.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221C_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221C_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct G722_1C_24_encinst_t_; -struct G722_1C_24_decinst_t_; -struct G722_1C_32_encinst_t_; -struct G722_1C_32_decinst_t_; -struct G722_1C_48_encinst_t_; -struct G722_1C_48_decinst_t_; -struct G722_1_Inst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMG722_1C : public ACMGenericCodec { - public: - ACMG722_1C(int16_t codec_id, bool enable_red); - ~ACMG722_1C(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int32_t operational_rate_; - - G722_1_Inst_t_* encoder_inst_ptr_; - G722_1_Inst_t_* encoder_inst_ptr_right_; // Used in stereo mode - - // Only one set of these pointer is valid at any instance - G722_1C_24_encinst_t_* encoder_inst24_ptr_; - G722_1C_24_encinst_t_* encoder_inst24_ptr_right_; - G722_1C_32_encinst_t_* encoder_inst32_ptr_; - G722_1C_32_encinst_t_* encoder_inst32_ptr_right_; - G722_1C_48_encinst_t_* encoder_inst48_ptr_; - G722_1C_48_encinst_t_* encoder_inst48_ptr_right_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7221C_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g729.cc b/webrtc/modules/audio_coding/main/acm2/acm_g729.cc deleted file mode 100644 index 52b0d1a8f..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g729.cc +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_g729.h" - -#ifdef WEBRTC_CODEC_G729 -// NOTE! G.729 is not included in the open-source package. Modify this file -// or your codec API to match the function calls and names of used G.729 API -// file. -#include "webrtc/modules/audio_coding/main/codecs/g729/interface/g729_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_receiver.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_G729 - -ACMG729::ACMG729(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), encoder_inst_ptr_(NULL) { -} - -ACMG729::~ACMG729() { return; } - -int16_t ACMG729::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMG729::EnableDTX() { return -1; } - -int16_t ACMG729::DisableDTX() { return -1; } - -int32_t ACMG729::ReplaceInternalDTXSafe(const bool /*replace_internal_dtx */) { - return -1; -} - -int32_t ACMG729::IsInternalDTXReplacedSafe(bool* /* internal_dtx_replaced */) { - return -1; -} - -int16_t ACMG729::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMG729::CreateInstance(void) { return NULL; } - -int16_t ACMG729::InternalCreateEncoder() { return -1; } - -void ACMG729::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= -ACMG729::ACMG729(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - codec_id_(codec_id), - has_internal_dtx_(), - encoder_inst_ptr_(NULL) { -} - -ACMG729::~ACMG729() { - if (encoder_inst_ptr_ != NULL) { - // Delete encoder memory - WebRtcG729_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMG729::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - // Initialize before entering the loop - int16_t num_encoded_samples = 0; - int16_t tmp_len_byte = 0; - int16_t vad_decision = 0; - *bitstream_len_byte = 0; - while (num_encoded_samples < frame_len_smpl_) { - // Call G.729 encoder with pointer to encoder memory, input - // audio, number of samples and bitsream - tmp_len_byte = WebRtcG729_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], 80, - reinterpret_cast(&(bitstream[*bitstream_len_byte]))); - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += 80; - - // sanity check - if (tmp_len_byte < 0) { - // error has happened - *bitstream_len_byte = 0; - return -1; - } - - // increment number of written bytes - *bitstream_len_byte += tmp_len_byte; - switch (tmp_len_byte) { - case 0: { - if (0 == num_encoded_samples) { - // this is the first 10 ms in this packet and there is - // no data generated, perhaps DTX is enabled and the - // codec is not generating any bit-stream for this 10 ms. - // we do not continue encoding this frame. - return 0; - } - break; - } - case 2: { - // check if G.729 internal DTX is enabled - if (has_internal_dtx_ && dtx_enabled_) { - vad_decision = 0; - for (int16_t n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { - vad_label_[n] = vad_decision; - } - } - // we got a SID and have to send out this packet no matter - // how much audio we have encoded - return *bitstream_len_byte; - } - case 10: { - vad_decision = 1; - // this is a valid length just continue encoding - break; - } - default: { - return -1; - } - } - - // update number of encoded samples - num_encoded_samples += 80; - } - - // update VAD decision vector - if (has_internal_dtx_ && !vad_decision && dtx_enabled_) { - for (int16_t n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) { - vad_label_[n] = vad_decision; - } - } - - // done encoding, return number of encoded bytes - return *bitstream_len_byte; -} - -int16_t ACMG729::EnableDTX() { - if (dtx_enabled_) { - // DTX already enabled, do nothing - return 0; - } else if (encoder_exist_) { - // Re-init the G.729 encoder to turn on DTX - if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 1) < 0) { - return -1; - } - dtx_enabled_ = true; - return 0; - } else { - return -1; - } -} - -int16_t ACMG729::DisableDTX() { - if (!dtx_enabled_) { - // DTX already dissabled, do nothing - return 0; - } else if (encoder_exist_) { - // Re-init the G.729 decoder to turn off DTX - if (WebRtcG729_EncoderInit(encoder_inst_ptr_, 0) < 0) { - return -1; - } - dtx_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -int32_t ACMG729::ReplaceInternalDTXSafe(const bool replace_internal_dtx) { - // This function is used to disable the G.729 built in DTX and use an - // external instead. - - if (replace_internal_dtx == has_internal_dtx_) { - // Make sure we keep the DTX/VAD setting if possible - bool old_enable_dtx = dtx_enabled_; - bool old_enable_vad = vad_enabled_; - ACMVADMode old_mode = vad_mode_; - if (replace_internal_dtx) { - // Disable internal DTX before enabling external DTX - DisableDTX(); - } else { - // Disable external DTX before enabling internal - ACMGenericCodec::DisableDTX(); - } - has_internal_dtx_ = !replace_internal_dtx; - int16_t status = SetVADSafe(old_enable_dtx, old_enable_vad, old_mode); - // Check if VAD status has changed from inactive to active, or if error was - // reported - if (status == 1) { - vad_enabled_ = true; - return status; - } else if (status < 0) { - has_internal_dtx_ = replace_internal_dtx; - return -1; - } - } - return 0; -} - -int32_t ACMG729::IsInternalDTXReplacedSafe(bool* internal_dtx_replaced) { - // Get status of wether DTX is replaced or not - *internal_dtx_replaced = !has_internal_dtx_; - return 0; -} - -int16_t ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // Init G.729 encoder - return WebRtcG729_EncoderInit(encoder_inst_ptr_, - ((codec_params->enable_dtx) ? 1 : 0)); -} - -ACMGenericCodec* ACMG729::CreateInstance(void) { - // Function not used - return NULL; -} - -int16_t ACMG729::InternalCreateEncoder() { - // Create encoder memory - return WebRtcG729_CreateEnc(&encoder_inst_ptr_); -} - -void ACMG729::DestructEncoderSafe() { - // Free encoder memory - encoder_exist_ = false; - encoder_initialized_ = false; - if (encoder_inst_ptr_ != NULL) { - WebRtcG729_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g729.h b/webrtc/modules/audio_coding/main/acm2/acm_g729.h deleted file mode 100644 index e19ce5a2b..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g729.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G729_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G729_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct G729_encinst_t_; -struct G729_decinst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMG729 : public ACMGenericCodec { - public: - ACMG729(int16_t codec_id, bool enable_red); - ~ACMG729(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t EnableDTX(); - - int16_t DisableDTX(); - - int32_t ReplaceInternalDTXSafe(const bool replace_internal_dtx); - - int32_t IsInternalDTXReplacedSafe(bool* internal_dtx_replaced); - - G729_encinst_t_* encoder_inst_ptr_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G729_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7291.cc b/webrtc/modules/audio_coding/main/acm2/acm_g7291.cc deleted file mode 100644 index bfc653a4c..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7291.cc +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_g7291.h" - -#ifdef WEBRTC_CODEC_G729_1 -// NOTE! G.729.1 is not included in the open-source package. Modify this file -// or your codec API to match the function calls and names of used G.729.1 API -// file. -#include "webrtc/modules/audio_coding/main/codecs/g7291/interface/g7291_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_G729_1 - -ACMG729_1::ACMG729_1(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - my_rate_(32000), - flag_8khz_(0), - flag_g729_mode_(0) { - return; -} - -ACMG729_1::~ACMG729_1() { return; } - -int16_t ACMG729_1::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMG729_1::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMG729_1::CreateInstance(void) { return NULL; } - -int16_t ACMG729_1::InternalCreateEncoder() { return -1; } - -void ACMG729_1::DestructEncoderSafe() { return; } - -int16_t ACMG729_1::SetBitRateSafe(const int32_t /*rate*/) { return -1; } - -#else //===================== Actual Implementation ======================= - -struct G729_1_inst_t_; - -ACMG729_1::ACMG729_1(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - my_rate_(32000), // Default rate. - flag_8khz_(0), - flag_g729_mode_(0) { - // TODO(tlegrand): We should add codec_id as a input variable to the - // constructor of ACMGenericCodec. - codec_id_ = codec_id; - return; -} - -ACMG729_1::~ACMG729_1() { - if (encoder_inst_ptr_ != NULL) { - WebRtcG7291_Free(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMG729_1::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - // Initialize before entering the loop - int16_t num_encoded_samples = 0; - *bitstream_len_byte = 0; - - int16_t byte_length_frame = 0; - - // Derive number of 20ms frames per encoded packet. - // [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples - int16_t num_20ms_frames = (frame_len_smpl_ / 320); - // Byte length for the frame. +1 is for rate information. - byte_length_frame = - my_rate_ / (8 * 50) * num_20ms_frames + (1 - flag_g729_mode_); - - // The following might be revised if we have G729.1 Annex C (support for DTX); - do { - *bitstream_len_byte = WebRtcG7291_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], - reinterpret_cast(bitstream), my_rate_, num_20ms_frames); - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += 160; - - // sanity check - if (*bitstream_len_byte < 0) { - // error has happened - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalEncode: Encode error for G729_1"); - *bitstream_len_byte = 0; - return -1; - } - - num_encoded_samples += 160; - } while (*bitstream_len_byte == 0); - - // This criteria will change if we have Annex C. - if (*bitstream_len_byte != byte_length_frame) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalEncode: Encode error for G729_1"); - *bitstream_len_byte = 0; - return -1; - } - - if (num_encoded_samples != frame_len_smpl_) { - *bitstream_len_byte = 0; - return -1; - } - - return *bitstream_len_byte; -} - -int16_t ACMG729_1::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // set the bit rate and initialize - my_rate_ = codec_params->codec_inst.rate; - return SetBitRateSafe((uint32_t)my_rate_); -} - -ACMGenericCodec* ACMG729_1::CreateInstance(void) { return NULL; } - -int16_t ACMG729_1::InternalCreateEncoder() { - if (WebRtcG7291_Create(&encoder_inst_ptr_) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "InternalCreateEncoder: create encoder failed for G729_1"); - return -1; - } - return 0; -} - -void ACMG729_1::DestructEncoderSafe() { - encoder_exist_ = false; - encoder_initialized_ = false; - if (encoder_inst_ptr_ != NULL) { - WebRtcG7291_Free(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } -} - -int16_t ACMG729_1::SetBitRateSafe(const int32_t rate) { - // allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000, - // 22000, 24000, 26000, 28000, 30000, 32000}; - // TODO(tlegrand): This check exists in one other place two. Should be - // possible to reuse code. - switch (rate) { - case 8000: { - my_rate_ = 8000; - break; - } - case 12000: { - my_rate_ = 12000; - break; - } - case 14000: { - my_rate_ = 14000; - break; - } - case 16000: { - my_rate_ = 16000; - break; - } - case 18000: { - my_rate_ = 18000; - break; - } - case 20000: { - my_rate_ = 20000; - break; - } - case 22000: { - my_rate_ = 22000; - break; - } - case 24000: { - my_rate_ = 24000; - break; - } - case 26000: { - my_rate_ = 26000; - break; - } - case 28000: { - my_rate_ = 28000; - break; - } - case 30000: { - my_rate_ = 30000; - break; - } - case 32000: { - my_rate_ = 32000; - break; - } - default: { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "SetBitRateSafe: Invalid rate G729_1"); - return -1; - } - } - - // Re-init with new rate - if (WebRtcG7291_EncoderInit(encoder_inst_ptr_, my_rate_, flag_8khz_, - flag_g729_mode_) >= 0) { - encoder_params_.codec_inst.rate = my_rate_; - return 0; - } else { - return -1; - } -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_g7291.h b/webrtc/modules/audio_coding/main/acm2/acm_g7291.h deleted file mode 100644 index 908e64f97..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_g7291.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7291_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7291_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct G729_1_inst_t_; -struct G729_1_inst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMG729_1 : public ACMGenericCodec { - public: - ACMG729_1(int16_t codec_id, bool enable_red); - ~ACMG729_1(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t SetBitRateSafe(const int32_t rate); - - G729_1_inst_t_* encoder_inst_ptr_; - - uint16_t my_rate_; - int16_t flag_8khz_; - int16_t flag_g729_mode_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_G7291_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.cc b/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.cc deleted file mode 100644 index ca28ef4f7..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.cc +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_gsmfr.h" - -#ifdef WEBRTC_CODEC_GSMFR -// NOTE! GSM-FR is not included in the open-source package. Modify this file -// or your codec API to match the function calls and names of used GSM-FR API -// file. -#include "webrtc/modules/audio_coding/main/codecs/gsmfr/interface/gsmfr_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_GSMFR - -ACMGSMFR::ACMGSMFR(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), encoder_inst_ptr_(NULL) { -} - -ACMGSMFR::~ACMGSMFR() { return; } - -int16_t ACMGSMFR::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMGSMFR::EnableDTX() { return -1; } - -int16_t ACMGSMFR::DisableDTX() { return -1; } - -int16_t ACMGSMFR::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMGSMFR::CreateInstance(void) { return NULL; } - -int16_t ACMGSMFR::InternalCreateEncoder() { return -1; } - -void ACMGSMFR::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= - -ACMGSMFR::ACMGSMFR(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - codec_id_(codec_id), - has_internal_dtx_(true), - encoder_inst_ptr_(NULL) { -} - -ACMGSMFR::~ACMGSMFR() { - if (encoder_inst_ptr_ != NULL) { - WebRtcGSMFR_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMGSMFR::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - *bitstream_len_byte = WebRtcGSMFR_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], frame_len_smpl_, - reinterpret_cast(bitstream)); - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += frame_len_smpl_; - return *bitstream_len_byte; -} - -int16_t ACMGSMFR::EnableDTX() { - if (dtx_enabled_) { - return 0; - } else if (encoder_exist_) { - if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 1) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "EnableDTX: cannot init encoder for GSMFR"); - return -1; - } - dtx_enabled_ = true; - return 0; - } else { - return -1; - } -} - -int16_t ACMGSMFR::DisableDTX() { - if (!dtx_enabled_) { - return 0; - } else if (encoder_exist_) { - if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, 0) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "DisableDTX: cannot init encoder for GSMFR"); - return -1; - } - dtx_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -int16_t ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - if (WebRtcGSMFR_EncoderInit(encoder_inst_ptr_, - ((codec_params->enable_dtx) ? 1 : 0)) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "InternalInitEncoder: cannot init encoder for GSMFR"); - } - return 0; -} - -ACMGenericCodec* ACMGSMFR::CreateInstance(void) { return NULL; } - -int16_t ACMGSMFR::InternalCreateEncoder() { - if (WebRtcGSMFR_CreateEnc(&encoder_inst_ptr_) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "InternalCreateEncoder: cannot create instance for GSMFR " - "encoder"); - return -1; - } - return 0; -} - -void ACMGSMFR::DestructEncoderSafe() { - if (encoder_inst_ptr_ != NULL) { - WebRtcGSMFR_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - encoder_exist_ = false; - encoder_initialized_ = false; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.h b/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.h deleted file mode 100644 index 5a84899e0..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_gsmfr.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_GSMFR_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_GSMFR_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct GSMFR_encinst_t_; -struct GSMFR_decinst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMGSMFR : public ACMGenericCodec { - public: - ACMGSMFR(int16_t codec_id, bool enable_red); - ~ACMGSMFR(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t EnableDTX(); - - int16_t DisableDTX(); - - GSMFR_encinst_t_* encoder_inst_ptr_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_GSMFR_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_ilbc.cc b/webrtc/modules/audio_coding/main/acm2/acm_ilbc.cc deleted file mode 100644 index bd5182bdd..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_ilbc.cc +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "webrtc/modules/audio_coding/main/acm2/acm_ilbc.h" - -#ifdef WEBRTC_CODEC_ILBC -#include "webrtc/modules/audio_coding/codecs/ilbc/interface/ilbc.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_ILBC - -ACMILBC::ACMILBC(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), encoder_inst_ptr_(NULL) { -} - -ACMILBC::~ACMILBC() { return; } - -int16_t ACMILBC::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMILBC::CreateInstance(void) { return NULL; } - -int16_t ACMILBC::InternalCreateEncoder() { return -1; } - -void ACMILBC::DestructEncoderSafe() { return; } - -int16_t ACMILBC::SetBitRateSafe(const int32_t /* rate */) { return -1; } - -#else //===================== Actual Implementation ======================= - -ACMILBC::ACMILBC(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), encoder_inst_ptr_(NULL) { - codec_id_ = codec_id; - return; -} - -ACMILBC::~ACMILBC() { - if (encoder_inst_ptr_ != NULL) { - WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMILBC::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - *bitstream_len_byte = WebRtcIlbcfix_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], frame_len_smpl_, - bitstream); - if (*bitstream_len_byte < 0) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "InternalEncode: error in encode for ILBC"); - return -1; - } - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += frame_len_smpl_; - return *bitstream_len_byte; -} - -int16_t ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // initialize with a correct processing block length - if ((160 == (codec_params->codec_inst).pacsize) || - (320 == (codec_params->codec_inst).pacsize)) { - // processing block of 20ms - return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20); - } else if ((240 == (codec_params->codec_inst).pacsize) || - (480 == (codec_params->codec_inst).pacsize)) { - // processing block of 30ms - return WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30); - } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalInitEncoder: invalid processing block"); - return -1; - } -} - -ACMGenericCodec* ACMILBC::CreateInstance(void) { return NULL; } - -int16_t ACMILBC::InternalCreateEncoder() { - if (WebRtcIlbcfix_EncoderCreate(&encoder_inst_ptr_) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "InternalCreateEncoder: cannot create instance for ILBC " - "encoder"); - return -1; - } - return 0; -} - -void ACMILBC::DestructEncoderSafe() { - encoder_initialized_ = false; - encoder_exist_ = false; - if (encoder_inst_ptr_ != NULL) { - WebRtcIlbcfix_EncoderFree(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } -} - -int16_t ACMILBC::SetBitRateSafe(const int32_t rate) { - // Check that rate is valid. No need to store the value - if (rate == 13300) { - WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 30); - } else if (rate == 15200) { - WebRtcIlbcfix_EncoderInit(encoder_inst_ptr_, 20); - } else { - return -1; - } - encoder_params_.codec_inst.rate = rate; - - return 0; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_ilbc.h b/webrtc/modules/audio_coding/main/acm2/acm_ilbc.h deleted file mode 100644 index 870b7c999..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_ilbc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ILBC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ILBC_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct iLBC_encinst_t_; -struct iLBC_decinst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMILBC : public ACMGenericCodec { - public: - ACMILBC(int16_t codec_id, bool enable_red); - ~ACMILBC(); - - // for FEC - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - int16_t SetBitRateSafe(const int32_t rate) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalCreateEncoder(); - - iLBC_encinst_t_* encoder_inst_ptr_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ILBC_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc b/webrtc/modules/audio_coding/main/acm2/acm_isac.cc deleted file mode 100644 index 68747fef3..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_isac.cc +++ /dev/null @@ -1,830 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "webrtc/modules/audio_coding/main/acm2/acm_isac.h" - -#include - -#include "webrtc/modules/audio_coding/codecs/audio_decoder.h" -#include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" -#include "webrtc/system_wrappers/interface/trace.h" - -#ifdef WEBRTC_CODEC_ISAC -#include "webrtc/modules/audio_coding/codecs/isac/main/interface/isac.h" -#endif - -#ifdef WEBRTC_CODEC_ISACFX -#include "webrtc/modules/audio_coding/codecs/isac/fix/interface/isacfix.h" -#endif - -#if defined (WEBRTC_CODEC_ISAC) || defined (WEBRTC_CODEC_ISACFX) -#include "webrtc/modules/audio_coding/main/acm2/acm_isac_macros.h" -#endif - -namespace webrtc { - -namespace acm2 { - -// we need this otherwise we cannot use forward declaration -// in the header file -#if (defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)) -struct ACMISACInst { - ACM_ISAC_STRUCT* inst; -}; -#endif - -#define ISAC_MIN_RATE 10000 -#define ISAC_MAX_RATE 56000 - -// Tables for bandwidth estimates -#define NR_ISAC_BANDWIDTHS 24 -static const int32_t kIsacRatesWb[NR_ISAC_BANDWIDTHS] = { - 10000, 11100, 12300, 13700, 15200, 16900, 18800, 20900, 23300, 25900, 28700, - 31900, 10100, 11200, 12400, 13800, 15300, 17000, 18900, 21000, 23400, 26000, - 28800, 32000}; - -static const int32_t kIsacRatesSwb[NR_ISAC_BANDWIDTHS] = { - 10000, 11000, 12400, 13800, 15300, 17000, 18900, 21000, 23200, 25400, 27600, - 29800, 32000, 34100, 36300, 38500, 40700, 42900, 45100, 47300, 49500, 51700, - 53900, 56000 }; - -#if (!defined(WEBRTC_CODEC_ISAC) && !defined(WEBRTC_CODEC_ISACFX)) - -ACMISAC::ACMISAC(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - codec_inst_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), - codec_inst_ptr_(NULL), - is_enc_initialized_(false), - isac_coding_mode_(CHANNEL_INDEPENDENT), - enforce_frame_size_(false), - isac_currentBN_(32000), - samples_in10MsAudio_(160), // Initiates to 16 kHz mode. - decoder_initialized_(false) { -} - -ACMISAC::~ACMISAC() { - return; -} - -ACMGenericCodec* ACMISAC::CreateInstance(void) { return NULL; } - -int16_t ACMISAC::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMISAC::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -int16_t ACMISAC::InternalInitDecoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -int16_t ACMISAC::InternalCreateEncoder() { return -1; } - -void ACMISAC::DestructEncoderSafe() { return; } - -int16_t ACMISAC::Transcode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */, - int16_t /* q_bwe */, - int32_t /* scale */, - bool /* is_red */) { - return -1; -} - -int16_t ACMISAC::SetBitRateSafe(int32_t /* bit_rate */) { return -1; } - -int32_t ACMISAC::GetEstimatedBandwidthSafe() { return -1; } - -int32_t ACMISAC::SetEstimatedBandwidthSafe(int32_t /* estimated_bandwidth */) { - return -1; -} - -int32_t ACMISAC::GetRedPayloadSafe(uint8_t* /* red_payload */, - int16_t* /* payload_bytes */) { - return -1; -} - -int16_t ACMISAC::UpdateDecoderSampFreq(int16_t /* codec_id */) { return -1; } - -int16_t ACMISAC::UpdateEncoderSampFreq(uint16_t /* encoder_samp_freq_hz */) { - return -1; -} - -int16_t ACMISAC::EncoderSampFreq(uint16_t* /* samp_freq_hz */) { return -1; } - -int32_t ACMISAC::ConfigISACBandwidthEstimator( - const uint8_t /* init_frame_size_msec */, - const uint16_t /* init_rate_bit_per_sec */, - const bool /* enforce_frame_size */) { - return -1; -} - -int32_t ACMISAC::SetISACMaxPayloadSize( - const uint16_t /* max_payload_len_bytes */) { - return -1; -} - -int32_t ACMISAC::SetISACMaxRate(const uint32_t /* max_rate_bit_per_sec */) { - return -1; -} - -void ACMISAC::UpdateFrameLen() { return; } - -void ACMISAC::CurrentRate(int32_t* /*rate_bit_per_sec */) { return; } - -bool ACMISAC::DecoderParamsSafe(WebRtcACMCodecParams* /* dec_params */, - const uint8_t /* payload_type */) { - return false; -} - -int16_t ACMISAC::REDPayloadISAC(const int32_t /* isac_rate */, - const int16_t /* isac_bw_estimate */, - uint8_t* /* payload */, - int16_t* /* payload_len_bytes */) { - return -1; -} - -AudioDecoder* ACMISAC::Decoder(int /* codec_id */) { return NULL; } - -#else //===================== Actual Implementation ======================= - -#ifdef WEBRTC_CODEC_ISACFX - -// How the scaling is computed. iSAC computes a gain based on the -// bottleneck. It follows the following expression for that -// -// G(BN_kbps) = pow(10, (a + b * BN_kbps + c * BN_kbps * BN_kbps) / 20.0) -// / 3.4641; -// -// Where for 30 ms framelength we have, -// -// a = -23; b = 0.48; c = 0; -// -// As the default encoder is operating at 32kbps we have the scale as -// -// S(BN_kbps) = G(BN_kbps) / G(32); - -#define ISAC_NUM_SUPPORTED_RATES 9 - -static const uint16_t kIsacSuportedRates[ISAC_NUM_SUPPORTED_RATES] = { - 32000, 30000, 26000, 23000, 21000, 19000, 17000, 15000, 12000}; - -static const float kIsacScale[ISAC_NUM_SUPPORTED_RATES] = { - 1.0f, 0.8954f, 0.7178f, 0.6081f, 0.5445f, - 0.4875f, 0.4365f, 0.3908f, 0.3311f -}; - -enum IsacSamplingRate { - kIsacWideband = 16, - kIsacSuperWideband = 32 -}; - -static float ACMISACFixTranscodingScale(uint16_t rate) { - // find the scale for transcoding, the scale is rounded - // downward - float scale = -1; - for (int16_t n = 0; n < ISAC_NUM_SUPPORTED_RATES; n++) { - if (rate >= kIsacSuportedRates[n]) { - scale = kIsacScale[n]; - break; - } - } - return scale; -} - -static void ACMISACFixGetSendBitrate(ACM_ISAC_STRUCT* inst, - int32_t* bottleneck) { - *bottleneck = WebRtcIsacfix_GetUplinkBw(inst); -} - -static int16_t ACMISACFixGetNewBitstream(ACM_ISAC_STRUCT* inst, - int16_t bwe_index, - int16_t /* jitter_index */, - int32_t rate, - uint8_t* bitstream, - bool is_red) { - if (is_red) { - // RED not supported with iSACFIX - return -1; - } - float scale = ACMISACFixTranscodingScale((uint16_t)rate); - return WebRtcIsacfix_GetNewBitStream(inst, bwe_index, scale, bitstream); -} - -static int16_t ACMISACFixGetSendBWE(ACM_ISAC_STRUCT* inst, - int16_t* rate_index, - int16_t* /* dummy */) { - int16_t local_rate_index; - int16_t status = WebRtcIsacfix_GetDownLinkBwIndex(inst, &local_rate_index); - if (status < 0) { - return -1; - } else { - *rate_index = local_rate_index; - return 0; - } -} - -static int16_t ACMISACFixControlBWE(ACM_ISAC_STRUCT* inst, - int32_t rate_bps, - int16_t frame_size_ms, - int16_t enforce_frame_size) { - return WebRtcIsacfix_ControlBwe( - inst, (int16_t)rate_bps, frame_size_ms, enforce_frame_size); -} - -static int16_t ACMISACFixControl(ACM_ISAC_STRUCT* inst, - int32_t rate_bps, - int16_t frame_size_ms) { - return WebRtcIsacfix_Control(inst, (int16_t)rate_bps, frame_size_ms); -} - -// The following two function should have the same signature as their counter -// part in iSAC floating-point, i.e. WebRtcIsac_EncSampRate & -// WebRtcIsac_DecSampRate. -static uint16_t ACMISACFixGetEncSampRate(ACM_ISAC_STRUCT* /* inst */) { - return 16000; -} - -static uint16_t ACMISACFixGetDecSampRate(ACM_ISAC_STRUCT* /* inst */) { - return 16000; -} - -#endif - -ACMISAC::ACMISAC(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - codec_inst_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), - is_enc_initialized_(false), - isac_coding_mode_(CHANNEL_INDEPENDENT), - enforce_frame_size_(false), - isac_current_bn_(32000), - samples_in_10ms_audio_(160), // Initiates to 16 kHz mode. - decoder_initialized_(false) { - codec_id_ = codec_id; - - // Create codec instance. - codec_inst_ptr_ = new ACMISACInst; - if (codec_inst_ptr_ == NULL) { - return; - } - codec_inst_ptr_->inst = NULL; -} - -ACMISAC::~ACMISAC() { - if (codec_inst_ptr_ != NULL) { - if (codec_inst_ptr_->inst != NULL) { - ACM_ISAC_FREE(codec_inst_ptr_->inst); - codec_inst_ptr_->inst = NULL; - } - delete codec_inst_ptr_; - codec_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMISAC::InternalInitDecoder(WebRtcACMCodecParams* codec_params) { - // set decoder sampling frequency. - if (codec_params->codec_inst.plfreq == 32000 || - codec_params->codec_inst.plfreq == 48000) { - UpdateDecoderSampFreq(ACMCodecDB::kISACSWB); - } else { - UpdateDecoderSampFreq(ACMCodecDB::kISAC); - } - - // in a one-way communication we may never register send-codec. - // However we like that the BWE to work properly so it has to - // be initialized. The BWE is initialized when iSAC encoder is initialized. - // Therefore, we need this. - if (!encoder_initialized_) { - // Since we don't require a valid rate or a valid packet size when - // initializing the decoder, we set valid values before initializing encoder - codec_params->codec_inst.rate = kIsacWbDefaultRate; - codec_params->codec_inst.pacsize = kIsacPacSize960; - if (InternalInitEncoder(codec_params) < 0) { - return -1; - } - encoder_initialized_ = true; - } - - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_DECODERINIT(codec_inst_ptr_->inst); -} - -ACMGenericCodec* ACMISAC::CreateInstance(void) { return NULL; } - -int16_t ACMISAC::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - // ISAC takes 10ms audio every time we call encoder, therefore, - // it should be treated like codecs with 'basic coding block' - // non-zero, and the following 'while-loop' should not be necessary. - // However, due to a mistake in the codec the frame-size might change - // at the first 10ms pushed in to iSAC if the bit-rate is low, this is - // sort of a bug in iSAC. to address this we treat iSAC as the - // following. - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (codec_inst_ptr_ == NULL) { - return -1; - } - *bitstream_len_byte = 0; - while ((*bitstream_len_byte == 0) && (in_audio_ix_read_ < frame_len_smpl_)) { - if (in_audio_ix_read_ > in_audio_ix_write_) { - // something is wrong. - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "The actual frame-size of iSAC appears to be larger that " - "expected. All audio pushed in but no bit-stream is " - "generated."); - return -1; - } - *bitstream_len_byte = ACM_ISAC_ENCODE( - codec_inst_ptr_->inst, - &in_audio_[in_audio_ix_read_], - bitstream); - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += samples_in_10ms_audio_; - } - if (*bitstream_len_byte == 0) { - WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, unique_id_, - "ISAC Has encoded the whole frame but no bit-stream is " - "generated."); - } - - // a packet is generated iSAC, is set in adaptive mode may change - // the frame length and we like to update the bottleneck value as - // well, although updating bottleneck is not crucial - if ((*bitstream_len_byte > 0) && (isac_coding_mode_ == ADAPTIVE)) { - ACM_ISAC_GETSENDBITRATE(codec_inst_ptr_->inst, &isac_current_bn_); - } - UpdateFrameLen(); - return *bitstream_len_byte; -} - -int16_t ACMISAC::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // if rate is set to -1 then iSAC has to be in adaptive mode - if (codec_params->codec_inst.rate == -1) { - isac_coding_mode_ = ADAPTIVE; - } else if ((codec_params->codec_inst.rate >= ISAC_MIN_RATE) && - (codec_params->codec_inst.rate <= ISAC_MAX_RATE)) { - // sanity check that rate is in acceptable range - isac_coding_mode_ = CHANNEL_INDEPENDENT; - isac_current_bn_ = codec_params->codec_inst.rate; - } else { - return -1; - } - - // we need to set the encoder sampling frequency. - if (UpdateEncoderSampFreq((uint16_t)codec_params->codec_inst.plfreq) < 0) { - return -1; - } - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (ACM_ISAC_ENCODERINIT(codec_inst_ptr_->inst, isac_coding_mode_) < 0) { - return -1; - } - - // apply the frame-size and rate if operating in - // channel-independent mode - if (isac_coding_mode_ == CHANNEL_INDEPENDENT) { - if (ACM_ISAC_CONTROL(codec_inst_ptr_->inst, - codec_params->codec_inst.rate, - codec_params->codec_inst.pacsize / - (codec_params->codec_inst.plfreq / 1000)) < 0) { - return -1; - } - } else { - // We need this for adaptive case and has to be called - // after initialization - ACM_ISAC_GETSENDBITRATE(codec_inst_ptr_->inst, &isac_current_bn_); - } - frame_len_smpl_ = ACM_ISAC_GETNEWFRAMELEN(codec_inst_ptr_->inst); - return 0; -} - -int16_t ACMISAC::InternalCreateEncoder() { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (codec_inst_ptr_ == NULL) { - return -1; - } - decoder_initialized_ = false; - int16_t status = ACM_ISAC_CREATE(&(codec_inst_ptr_->inst)); - - if (status < 0) - codec_inst_ptr_->inst = NULL; - return status; -} - -int16_t ACMISAC::Transcode(uint8_t* bitstream, - int16_t* bitstream_len_byte, - int16_t q_bwe, - int32_t rate, - bool is_red) { - int16_t jitter_info = 0; - // transcode from a higher rate to lower rate sanity check - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (codec_inst_ptr_ == NULL) { - return -1; - } - - *bitstream_len_byte = ACM_ISAC_GETNEWBITSTREAM( - codec_inst_ptr_->inst, q_bwe, jitter_info, rate, - bitstream, (is_red) ? 1 : 0); - - if (*bitstream_len_byte < 0) { - // error happened - *bitstream_len_byte = 0; - return -1; - } else { - return *bitstream_len_byte; - } -} - -void ACMISAC::UpdateFrameLen() { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - frame_len_smpl_ = ACM_ISAC_GETNEWFRAMELEN(codec_inst_ptr_->inst); - encoder_params_.codec_inst.pacsize = frame_len_smpl_; -} - -void ACMISAC::DestructEncoderSafe() { - // codec with shared instance cannot delete. - encoder_initialized_ = false; - return; -} - -int16_t ACMISAC::SetBitRateSafe(int32_t bit_rate) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (codec_inst_ptr_ == NULL) { - return -1; - } - uint16_t encoder_samp_freq; - EncoderSampFreq(&encoder_samp_freq); - bool reinit = false; - // change the BN of iSAC - if (bit_rate == -1) { - // ADAPTIVE MODE - // Check if it was already in adaptive mode - if (isac_coding_mode_ != ADAPTIVE) { - // was not in adaptive, then set the mode to adaptive - // and flag for re-initialization - isac_coding_mode_ = ADAPTIVE; - reinit = true; - } - } else if ((bit_rate >= ISAC_MIN_RATE) && (bit_rate <= ISAC_MAX_RATE)) { - // Sanity check if the rate valid - // check if it was in channel-independent mode before - if (isac_coding_mode_ != CHANNEL_INDEPENDENT) { - // was not in channel independent, set the mode to - // channel-independent and flag for re-initialization - isac_coding_mode_ = CHANNEL_INDEPENDENT; - reinit = true; - } - // store the bottleneck - isac_current_bn_ = (uint16_t)bit_rate; - } else { - // invlaid rate - return -1; - } - - int16_t status = 0; - if (reinit) { - // initialize and check if it is successful - if (ACM_ISAC_ENCODERINIT(codec_inst_ptr_->inst, isac_coding_mode_) < 0) { - // failed initialization - return -1; - } - } - if (isac_coding_mode_ == CHANNEL_INDEPENDENT) { - status = ACM_ISAC_CONTROL( - codec_inst_ptr_->inst, isac_current_bn_, - (encoder_samp_freq == 32000 || encoder_samp_freq == 48000) ? 30 : - (frame_len_smpl_ / 16)); - if (status < 0) { - status = -1; - } - } - - // Update encoder parameters - encoder_params_.codec_inst.rate = bit_rate; - - UpdateFrameLen(); - return status; -} - -int32_t ACMISAC::GetEstimatedBandwidthSafe() { - int16_t bandwidth_index = 0; - int16_t delay_index = 0; - int samp_rate; - - // Get bandwidth information - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - ACM_ISAC_GETSENDBWE(codec_inst_ptr_->inst, &bandwidth_index, &delay_index); - - // Validy check of index - if ((bandwidth_index < 0) || (bandwidth_index >= NR_ISAC_BANDWIDTHS)) { - return -1; - } - - // Check sample frequency - samp_rate = ACM_ISAC_GETDECSAMPRATE(codec_inst_ptr_->inst); - if (samp_rate == 16000) { - return kIsacRatesWb[bandwidth_index]; - } else { - return kIsacRatesSwb[bandwidth_index]; - } -} - -int32_t ACMISAC::SetEstimatedBandwidthSafe(int32_t estimated_bandwidth) { - int samp_rate; - int16_t bandwidth_index; - - // Check sample frequency and choose appropriate table - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - samp_rate = ACM_ISAC_GETENCSAMPRATE(codec_inst_ptr_->inst); - - if (samp_rate == 16000) { - // Search through the WB rate table to find the index - bandwidth_index = NR_ISAC_BANDWIDTHS / 2 - 1; - for (int i = 0; i < (NR_ISAC_BANDWIDTHS / 2); i++) { - if (estimated_bandwidth == kIsacRatesWb[i]) { - bandwidth_index = i; - break; - } else if (estimated_bandwidth - == kIsacRatesWb[i + NR_ISAC_BANDWIDTHS / 2]) { - bandwidth_index = i + NR_ISAC_BANDWIDTHS / 2; - break; - } else if (estimated_bandwidth < kIsacRatesWb[i]) { - bandwidth_index = i; - break; - } - } - } else { - // Search through the SWB rate table to find the index - bandwidth_index = NR_ISAC_BANDWIDTHS - 1; - for (int i = 0; i < NR_ISAC_BANDWIDTHS; i++) { - if (estimated_bandwidth <= kIsacRatesSwb[i]) { - bandwidth_index = i; - break; - } - } - } - - // Set iSAC Bandwidth Estimate - ACM_ISAC_SETBWE(codec_inst_ptr_->inst, bandwidth_index); - - return 0; -} - -int32_t ACMISAC::GetRedPayloadSafe( -#if (!defined(WEBRTC_CODEC_ISAC)) - uint8_t* /* red_payload */, - int16_t* /* payload_bytes */) { - return -1; -#else - uint8_t* red_payload, int16_t* payload_bytes) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - int16_t bytes = WebRtcIsac_GetRedPayload(codec_inst_ptr_->inst, red_payload); - if (bytes < 0) { - return -1; - } - *payload_bytes = bytes; - return 0; -#endif -} - -int16_t ACMISAC::UpdateDecoderSampFreq( -#ifdef WEBRTC_CODEC_ISAC - int16_t codec_id) { - // The decoder supports only wideband and super-wideband. - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (ACMCodecDB::kISAC == codec_id) { - return WebRtcIsac_SetDecSampRate(codec_inst_ptr_->inst, 16000); - } else if (ACMCodecDB::kISACSWB == codec_id || - ACMCodecDB::kISACFB == codec_id) { - return WebRtcIsac_SetDecSampRate(codec_inst_ptr_->inst, 32000); - } else { - return -1; - } -#else - int16_t /* codec_id */) { - return 0; -#endif -} - -int16_t ACMISAC::UpdateEncoderSampFreq( -#ifdef WEBRTC_CODEC_ISAC - uint16_t encoder_samp_freq_hz) { - uint16_t current_samp_rate_hz; - EncoderSampFreq(¤t_samp_rate_hz); - - if (current_samp_rate_hz != encoder_samp_freq_hz) { - if ((encoder_samp_freq_hz != 16000) && (encoder_samp_freq_hz != 32000) && - (encoder_samp_freq_hz != 48000)) { - return -1; - } else { - in_audio_ix_read_ = 0; - in_audio_ix_write_ = 0; - in_timestamp_ix_write_ = 0; - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - if (WebRtcIsac_SetEncSampRate(codec_inst_ptr_->inst, - encoder_samp_freq_hz) < 0) { - return -1; - } - samples_in_10ms_audio_ = encoder_samp_freq_hz / 100; - frame_len_smpl_ = ACM_ISAC_GETNEWFRAMELEN(codec_inst_ptr_->inst); - encoder_params_.codec_inst.pacsize = frame_len_smpl_; - encoder_params_.codec_inst.plfreq = encoder_samp_freq_hz; - return 0; - } - } -#else - uint16_t /* codec_id */) { -#endif - return 0; -} - -int16_t ACMISAC::EncoderSampFreq(uint16_t* samp_freq_hz) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - *samp_freq_hz = ACM_ISAC_GETENCSAMPRATE(codec_inst_ptr_->inst); - return 0; -} - -int32_t ACMISAC::ConfigISACBandwidthEstimator( - const uint8_t init_frame_size_msec, - const uint16_t init_rate_bit_per_sec, - const bool enforce_frame_size) { - int16_t status; - { - uint16_t samp_freq_hz; - EncoderSampFreq(&samp_freq_hz); - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - // TODO(turajs): at 32kHz we hardcode calling with 30ms and enforce - // the frame-size otherwise we might get error. Revise if - // control-bwe is changed. - if (samp_freq_hz == 32000 || samp_freq_hz == 48000) { - status = ACM_ISAC_CONTROL_BWE(codec_inst_ptr_->inst, - init_rate_bit_per_sec, 30, 1); - } else { - status = ACM_ISAC_CONTROL_BWE(codec_inst_ptr_->inst, - init_rate_bit_per_sec, - init_frame_size_msec, - enforce_frame_size ? 1 : 0); - } - } - if (status < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Couldn't config iSAC BWE."); - return -1; - } - { - WriteLockScoped wl(codec_wrapper_lock_); - UpdateFrameLen(); - } - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - ACM_ISAC_GETSENDBITRATE(codec_inst_ptr_->inst, &isac_current_bn_); - return 0; -} - -int32_t ACMISAC::SetISACMaxPayloadSize(const uint16_t max_payload_len_bytes) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_SETMAXPAYLOADSIZE(codec_inst_ptr_->inst, - max_payload_len_bytes); -} - -int32_t ACMISAC::SetISACMaxRate(const uint32_t max_rate_bit_per_sec) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_SETMAXRATE(codec_inst_ptr_->inst, max_rate_bit_per_sec); -} - -void ACMISAC::CurrentRate(int32_t* rate_bit_per_sec) { - if (isac_coding_mode_ == ADAPTIVE) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - ACM_ISAC_GETSENDBITRATE(codec_inst_ptr_->inst, rate_bit_per_sec); - } -} - -int16_t ACMISAC::REDPayloadISAC(const int32_t isac_rate, - const int16_t isac_bw_estimate, - uint8_t* payload, - int16_t* payload_len_bytes) { - int16_t status; - ReadLockScoped rl(codec_wrapper_lock_); - status = - Transcode(payload, payload_len_bytes, isac_bw_estimate, isac_rate, true); - return status; -} - -int ACMISAC::Decode(const uint8_t* encoded, - size_t encoded_len, - int16_t* decoded, - SpeechType* speech_type) { - int16_t temp_type = 1; // Default is speech. - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - int ret = - ACM_ISAC_DECODE_B(static_cast(codec_inst_ptr_->inst), - encoded, - static_cast(encoded_len), - decoded, - &temp_type); - *speech_type = ConvertSpeechType(temp_type); - return ret; -} - -int ACMISAC::DecodePlc(int num_frames, int16_t* decoded) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_DECODEPLC( - static_cast(codec_inst_ptr_->inst), - decoded, - static_cast(num_frames)); -} - -int ACMISAC::IncomingPacket(const uint8_t* payload, - size_t payload_len, - uint16_t rtp_sequence_number, - uint32_t rtp_timestamp, - uint32_t arrival_timestamp) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_DECODE_BWE( - static_cast(codec_inst_ptr_->inst), - payload, - static_cast(payload_len), - rtp_sequence_number, - rtp_timestamp, - arrival_timestamp); -} - -int ACMISAC::DecodeRedundant(const uint8_t* encoded, - size_t encoded_len, - int16_t* decoded, - SpeechType* speech_type) { - int16_t temp_type = 1; // Default is speech. - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - int16_t ret = - ACM_ISAC_DECODERCU(static_cast(codec_inst_ptr_->inst), - encoded, - static_cast(encoded_len), - decoded, - &temp_type); - *speech_type = ConvertSpeechType(temp_type); - return ret; -} - -int ACMISAC::ErrorCode() { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - return ACM_ISAC_GETERRORCODE( - static_cast(codec_inst_ptr_->inst)); -} - -AudioDecoder* ACMISAC::Decoder(int codec_id) { - // Create iSAC instance if it does not exist. - WriteLockScoped wl(codec_wrapper_lock_); - if (!encoder_exist_) { - CriticalSectionScoped lock(codec_inst_crit_sect_.get()); - assert(codec_inst_ptr_->inst == NULL); - encoder_initialized_ = false; - decoder_initialized_ = false; - if (ACM_ISAC_CREATE(&(codec_inst_ptr_->inst)) < 0) { - codec_inst_ptr_->inst = NULL; - return NULL; - } - encoder_exist_ = true; - } - - WebRtcACMCodecParams codec_params; - if (!encoder_initialized_ || !decoder_initialized_) { - ACMCodecDB::Codec(codec_id, &codec_params.codec_inst); - // The following three values are not used but we set them to valid values. - codec_params.enable_dtx = false; - codec_params.enable_vad = false; - codec_params.vad_mode = VADNormal; - } - - if (!encoder_initialized_) { - // Initialize encoder to make sure bandwidth estimator works. - if (InternalInitEncoder(&codec_params) < 0) - return NULL; - encoder_initialized_ = true; - } - - if (!decoder_initialized_) { - if (InternalInitDecoder(&codec_params) < 0) - return NULL; - decoder_initialized_ = true; - } - - return this; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac.h b/webrtc/modules/audio_coding/main/acm2/acm_isac.h deleted file mode 100644 index f614cfea4..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_isac.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_ - -#include "webrtc/base/thread_annotations.h" -#include "webrtc/modules/audio_coding/codecs/audio_decoder.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" -#include "webrtc/system_wrappers/interface/scoped_ptr.h" - -namespace webrtc { - -class CriticalSectionWrapper; - -namespace acm2 { - -struct ACMISACInst; - -enum IsacCodingMode { - ADAPTIVE, - CHANNEL_INDEPENDENT -}; - -class ACMISAC : public ACMGenericCodec, AudioDecoder { - public: - ACMISAC(int16_t codec_id, bool enable_red); - ~ACMISAC(); - - int16_t InternalInitDecoder(WebRtcACMCodecParams* codec_params) - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - // Methods below are inherited from ACMGenericCodec. - ACMGenericCodec* CreateInstance(void) OVERRIDE; - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t UpdateDecoderSampFreq(int16_t codec_id) OVERRIDE; - - int16_t UpdateEncoderSampFreq(uint16_t samp_freq_hz) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t EncoderSampFreq(uint16_t* samp_freq_hz) OVERRIDE; - - int32_t ConfigISACBandwidthEstimator(const uint8_t init_frame_size_msec, - const uint16_t init_rate_bit_per_sec, - const bool enforce_frame_size) OVERRIDE; - - int32_t SetISACMaxPayloadSize(const uint16_t max_payload_len_bytes) OVERRIDE; - - int32_t SetISACMaxRate(const uint32_t max_rate_bit_per_sec) OVERRIDE; - - int16_t REDPayloadISAC(const int32_t isac_rate, - const int16_t isac_bw_estimate, - uint8_t* payload, - int16_t* payload_len_bytes) OVERRIDE; - - // Methods below are inherited from AudioDecoder. - virtual int Decode(const uint8_t* encoded, - size_t encoded_len, - int16_t* decoded, - SpeechType* speech_type) OVERRIDE; - - virtual bool HasDecodePlc() const OVERRIDE { return true; } - - virtual int DecodePlc(int num_frames, int16_t* decoded) OVERRIDE; - - virtual int Init() OVERRIDE { return 0; } - - virtual int IncomingPacket(const uint8_t* payload, - size_t payload_len, - uint16_t rtp_sequence_number, - uint32_t rtp_timestamp, - uint32_t arrival_timestamp) OVERRIDE; - - virtual int DecodeRedundant(const uint8_t* encoded, - size_t encoded_len, - int16_t* decoded, - SpeechType* speech_type) OVERRIDE; - - virtual int ErrorCode() OVERRIDE; - - protected: - int16_t Transcode(uint8_t* bitstream, - int16_t* bitstream_len_byte, - int16_t q_bwe, - int32_t rate, - bool is_red); - - void UpdateFrameLen() EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - // Methods below are inherited from ACMGenericCodec. - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t SetBitRateSafe(const int32_t bit_rate) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int32_t GetEstimatedBandwidthSafe() OVERRIDE; - - int32_t SetEstimatedBandwidthSafe(int32_t estimated_bandwidth) OVERRIDE; - - int32_t GetRedPayloadSafe(uint8_t* red_payload, - int16_t* payload_bytes) OVERRIDE; - - int16_t InternalCreateEncoder() OVERRIDE; - - void CurrentRate(int32_t* rate_bit_per_sec) OVERRIDE; - - virtual AudioDecoder* Decoder(int codec_id) OVERRIDE; - - // |codec_inst_crit_sect_| protects |codec_inst_ptr_|. - const scoped_ptr codec_inst_crit_sect_; - ACMISACInst* codec_inst_ptr_ GUARDED_BY(codec_inst_crit_sect_); - bool is_enc_initialized_; - IsacCodingMode isac_coding_mode_; - bool enforce_frame_size_; - int32_t isac_current_bn_; - uint16_t samples_in_10ms_audio_; - bool decoder_initialized_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_isac_macros.h b/webrtc/modules/audio_coding/main/acm2/acm_isac_macros.h deleted file mode 100644 index df0309769..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_isac_macros.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_MACROS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_MACROS_H_ - -#include "webrtc/engine_configurations.h" - -namespace webrtc { - -namespace acm2 { - -#ifdef WEBRTC_CODEC_ISAC -#define ACM_ISAC_CREATE WebRtcIsac_Create -#define ACM_ISAC_FREE WebRtcIsac_Free -#define ACM_ISAC_ENCODERINIT WebRtcIsac_EncoderInit -#define ACM_ISAC_ENCODE WebRtcIsac_Encode -#define ACM_ISAC_DECODERINIT WebRtcIsac_DecoderInit -#define ACM_ISAC_DECODE_BWE WebRtcIsac_UpdateBwEstimate -#define ACM_ISAC_DECODE_B WebRtcIsac_Decode -#define ACM_ISAC_DECODEPLC WebRtcIsac_DecodePlc -#define ACM_ISAC_CONTROL WebRtcIsac_Control -#define ACM_ISAC_CONTROL_BWE WebRtcIsac_ControlBwe -#define ACM_ISAC_GETFRAMELEN WebRtcIsac_ReadFrameLen -#define ACM_ISAC_GETERRORCODE WebRtcIsac_GetErrorCode -#define ACM_ISAC_GETSENDBITRATE WebRtcIsac_GetUplinkBw -#define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsac_SetMaxPayloadSize -#define ACM_ISAC_SETMAXRATE WebRtcIsac_SetMaxRate -#define ACM_ISAC_GETNEWBITSTREAM WebRtcIsac_GetNewBitStream -#define ACM_ISAC_GETSENDBWE WebRtcIsac_GetDownLinkBwIndex -#define ACM_ISAC_SETBWE WebRtcIsac_UpdateUplinkBw -#define ACM_ISAC_GETBWE WebRtcIsac_ReadBwIndex -#define ACM_ISAC_GETNEWFRAMELEN WebRtcIsac_GetNewFrameLen -#define ACM_ISAC_STRUCT ISACStruct -#define ACM_ISAC_GETENCSAMPRATE WebRtcIsac_EncSampRate -#define ACM_ISAC_GETDECSAMPRATE WebRtcIsac_DecSampRate -#define ACM_ISAC_DECODERCU WebRtcIsac_DecodeRcu -#endif - -#ifdef WEBRTC_CODEC_ISACFX -#define ACM_ISAC_CREATE WebRtcIsacfix_Create -#define ACM_ISAC_FREE WebRtcIsacfix_Free -#define ACM_ISAC_ENCODERINIT WebRtcIsacfix_EncoderInit -#define ACM_ISAC_ENCODE WebRtcIsacfix_Encode -#define ACM_ISAC_DECODERINIT WebRtcIsacfix_DecoderInit -#define ACM_ISAC_DECODE_BWE WebRtcIsacfix_UpdateBwEstimate -#define ACM_ISAC_DECODE_B WebRtcIsacfix_Decode -#define ACM_ISAC_DECODEPLC WebRtcIsacfix_DecodePlc -#define ACM_ISAC_CONTROL ACMISACFixControl // Local Impl -#define ACM_ISAC_CONTROL_BWE ACMISACFixControlBWE // Local Impl -#define ACM_ISAC_GETFRAMELEN WebRtcIsacfix_ReadFrameLen -#define ACM_ISAC_GETERRORCODE WebRtcIsacfix_GetErrorCode -#define ACM_ISAC_GETSENDBITRATE ACMISACFixGetSendBitrate // Local Impl -#define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsacfix_SetMaxPayloadSize -#define ACM_ISAC_SETMAXRATE WebRtcIsacfix_SetMaxRate -#define ACM_ISAC_GETNEWBITSTREAM ACMISACFixGetNewBitstream // Local Impl -#define ACM_ISAC_GETSENDBWE ACMISACFixGetSendBWE // Local Impl -#define ACM_ISAC_SETBWE WebRtcIsacfix_UpdateUplinkBw -#define ACM_ISAC_GETBWE WebRtcIsacfix_ReadBwIndex -#define ACM_ISAC_GETNEWFRAMELEN WebRtcIsacfix_GetNewFrameLen -#define ACM_ISAC_STRUCT ISACFIX_MainStruct -#define ACM_ISAC_GETENCSAMPRATE ACMISACFixGetEncSampRate // Local Impl -#define ACM_ISAC_GETDECSAMPRATE ACMISACFixGetDecSampRate // Local Impl -#define ACM_ISAC_DECODERCU WebRtcIsacfix_Decode // No special RCU - // decoder -#endif - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_ISAC_MACROS_H_ - diff --git a/webrtc/modules/audio_coding/main/acm2/acm_opus.cc b/webrtc/modules/audio_coding/main/acm2/acm_opus.cc deleted file mode 100644 index 1942b00cd..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_opus.cc +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_opus.h" - -#ifdef WEBRTC_CODEC_OPUS -#include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_OPUS - -ACMOpus::ACMOpus(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - sample_freq_(0), - bitrate_(0), - channels_(1), - packet_loss_rate_(0) { - return; -} - -ACMOpus::~ACMOpus() { - return; -} - -int16_t ACMOpus::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMOpus::CreateInstance(void) { - return NULL; -} - -int16_t ACMOpus::InternalCreateEncoder() { - return -1; -} - -void ACMOpus::DestructEncoderSafe() { - return; -} - -int16_t ACMOpus::SetBitRateSafe(const int32_t /*rate*/) { - return -1; -} - -#else //===================== Actual Implementation ======================= - -ACMOpus::ACMOpus(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - sample_freq_(32000), // Default sampling frequency. - bitrate_(20000), // Default bit-rate. - channels_(1), // Default mono. - packet_loss_rate_(0), // Initial packet loss rate. - application_(kVoip) { // Initial application mode. - codec_id_ = codec_id; - // Opus has internal DTX, but we dont use it for now. - has_internal_dtx_ = false; - - has_internal_fec_ = true; - - if (codec_id_ != ACMCodecDB::kOpus) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Wrong codec id for Opus."); - sample_freq_ = 0xFFFF; - bitrate_ = -1; - } - return; -} - -ACMOpus::~ACMOpus() { - if (encoder_inst_ptr_ != NULL) { - WebRtcOpus_EncoderFree(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } -} - -int16_t ACMOpus::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - // Call Encoder. - *bitstream_len_byte = WebRtcOpus_Encode(encoder_inst_ptr_, - &in_audio_[in_audio_ix_read_], - frame_len_smpl_, - MAX_PAYLOAD_SIZE_BYTE, bitstream); - // Check for error reported from encoder. - if (*bitstream_len_byte < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "InternalEncode: Encode error for Opus"); - *bitstream_len_byte = 0; - return -1; - } - - // Increment the read index. This tells the caller how far - // we have gone forward in reading the audio buffer. - in_audio_ix_read_ += frame_len_smpl_ * channels_; - - return *bitstream_len_byte; -} - -int16_t ACMOpus::InitEncoderSafe(WebRtcACMCodecParams* codec_params, - bool force_initialization) { - // Determine target application if codec is not initialized or a forced - // initialization is requested. - if (!encoder_initialized_ || force_initialization) { - application_ = (codec_params->codec_inst.channels == 1) ? kVoip : kAudio; - } - return ACMGenericCodec::InitEncoderSafe(codec_params, force_initialization); -} - -int16_t ACMOpus::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - int16_t ret; - if (encoder_inst_ptr_ != NULL) { - WebRtcOpus_EncoderFree(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - ret = WebRtcOpus_EncoderCreate(&encoder_inst_ptr_, - codec_params->codec_inst.channels, - application_); - // Store number of channels. - channels_ = codec_params->codec_inst.channels; - - if (ret < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Encoder creation failed for Opus"); - return ret; - } - ret = WebRtcOpus_SetBitRate(encoder_inst_ptr_, - codec_params->codec_inst.rate); - if (ret < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Setting initial bitrate failed for Opus"); - return ret; - } - - // Store bitrate. - bitrate_ = codec_params->codec_inst.rate; - - // TODO(tlegrand): Remove this code when we have proper APIs to set the - // complexity at a higher level. -#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) - // If we are on Android, iOS and/or ARM, use a lower complexity setting as - // default, to save encoder complexity. - const int kOpusComplexity5 = 5; - WebRtcOpus_SetComplexity(encoder_inst_ptr_, kOpusComplexity5); - if (ret < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Setting complexity failed for Opus"); - return ret; - } -#endif - - return 0; -} - -ACMGenericCodec* ACMOpus::CreateInstance(void) { - return NULL; -} - -int16_t ACMOpus::InternalCreateEncoder() { - // Real encoder will be created in InternalInitEncoder. - return 0; -} - -void ACMOpus::DestructEncoderSafe() { - if (encoder_inst_ptr_) { - WebRtcOpus_EncoderFree(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } -} - -int16_t ACMOpus::SetBitRateSafe(const int32_t rate) { - if (rate < 6000 || rate > 510000) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "SetBitRateSafe: Invalid rate Opus"); - return -1; - } - - bitrate_ = rate; - - // Ask the encoder for the new rate. - if (WebRtcOpus_SetBitRate(encoder_inst_ptr_, bitrate_) >= 0) { - encoder_params_.codec_inst.rate = bitrate_; - return 0; - } - - return -1; -} - -int ACMOpus::SetFEC(bool enable_fec) { - // Ask the encoder to enable FEC. - if (enable_fec) { - if (WebRtcOpus_EnableFec(encoder_inst_ptr_) == 0) - return 0; - } else { - if (WebRtcOpus_DisableFec(encoder_inst_ptr_) == 0) - return 0; - } - return -1; -} - -int ACMOpus::SetPacketLossRate(int loss_rate) { - // Optimize the loss rate to configure Opus. Basically, optimized loss rate is - // the input loss rate rounded down to various levels, because a robustly good - // audio quality is achieved by lowering the packet loss down. - // Additionally, to prevent toggling, margins are used, i.e., when jumping to - // a loss rate from below, a higher threshold is used than jumping to the same - // level from above. - const int kPacketLossRate20 = 20; - const int kPacketLossRate10 = 10; - const int kPacketLossRate5 = 5; - const int kPacketLossRate1 = 1; - const int kLossRate20Margin = 2; - const int kLossRate10Margin = 1; - const int kLossRate5Margin = 1; - int opt_loss_rate; - if (loss_rate >= kPacketLossRate20 + kLossRate20Margin * - (kPacketLossRate20 - packet_loss_rate_ > 0 ? 1 : -1)) { - opt_loss_rate = kPacketLossRate20; - } else if (loss_rate >= kPacketLossRate10 + kLossRate10Margin * - (kPacketLossRate10 - packet_loss_rate_ > 0 ? 1 : -1)) { - opt_loss_rate = kPacketLossRate10; - } else if (loss_rate >= kPacketLossRate5 + kLossRate5Margin * - (kPacketLossRate5 - packet_loss_rate_ > 0 ? 1 : -1)) { - opt_loss_rate = kPacketLossRate5; - } else if (loss_rate >= kPacketLossRate1) { - opt_loss_rate = kPacketLossRate1; - } else { - opt_loss_rate = 0; - } - - if (packet_loss_rate_ == opt_loss_rate) { - return 0; - } - - // Ask the encoder to change the target packet loss rate. - if (WebRtcOpus_SetPacketLossRate(encoder_inst_ptr_, opt_loss_rate) == 0) { - packet_loss_rate_ = opt_loss_rate; - return 0; - } - - return -1; -} - -int ACMOpus::SetOpusMaxPlaybackRate(int frequency_hz) { - // Informs Opus encoder of the maximum playback rate the receiver will render. - return WebRtcOpus_SetMaxPlaybackRate(encoder_inst_ptr_, frequency_hz); -} - -int ACMOpus::SetOpusApplication(OpusApplicationMode application) { - WriteLockScoped lockCodec(codec_wrapper_lock_); - application_ = application; - // Set Opus application invokes a reset of the encoder. - return InternalResetEncoder(); -} - -#endif // WEBRTC_CODEC_OPUS - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_opus.h b/webrtc/modules/audio_coding/main/acm2/acm_opus.h deleted file mode 100644 index 89f1e1471..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_opus.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_OPUS_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_OPUS_H_ - -#include "webrtc/common_audio/resampler/include/resampler.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -struct WebRtcOpusEncInst; -struct WebRtcOpusDecInst; - -namespace webrtc { - -namespace acm2 { - -class ACMOpus : public ACMGenericCodec { - public: - ACMOpus(int16_t codec_id, bool enable_red); - ~ACMOpus(); - - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) override - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InitEncoderSafe(WebRtcACMCodecParams* codec_params, - bool force_initialization) override - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams *codec_params); - - int SetFEC(bool enable_fec) override; - - int SetOpusApplication(OpusApplicationMode mode) override; - - int SetPacketLossRate(int loss_rate) override; - - int SetOpusMaxPlaybackRate(int frequency_hz) override; - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t SetBitRateSafe(const int32_t rate) override - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - WebRtcOpusEncInst* encoder_inst_ptr_; - uint16_t sample_freq_; - int32_t bitrate_; - int channels_; - - int packet_loss_rate_; - - OpusApplicationMode application_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_OPUS_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.cc b/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.cc deleted file mode 100644 index 3621b9d37..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.cc +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_pcm16b.h" - -#ifdef WEBRTC_CODEC_PCM16 -#include "webrtc/modules/audio_coding/codecs/pcm16b/include/pcm16b.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_PCM16 - -ACMPCM16B::ACMPCM16B(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red) { -} - -ACMPCM16B::~ACMPCM16B() { return; } - -int16_t ACMPCM16B::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMPCM16B::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMPCM16B::CreateInstance(void) { return NULL; } - -int16_t ACMPCM16B::InternalCreateEncoder() { return -1; } - -void ACMPCM16B::DestructEncoderSafe() { return; } - -#else //===================== Actual Implementation ======================= -ACMPCM16B::ACMPCM16B(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - codec_id_ = codec_id; - sampling_freq_hz_ = ACMCodecDB::CodecFreq(codec_id_); -} - -ACMPCM16B::~ACMPCM16B() { return; } - -int16_t ACMPCM16B::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - *bitstream_len_byte = WebRtcPcm16b_Encode(&in_audio_[in_audio_ix_read_], - frame_len_smpl_ * num_channels_, - bitstream); - // Increment the read index to tell the caller that how far - // we have gone forward in reading the audio buffer. - in_audio_ix_read_ += frame_len_smpl_ * num_channels_; - return *bitstream_len_byte; -} - -int16_t ACMPCM16B::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - // This codec does not need initialization, PCM has no instance. - return 0; -} - -ACMGenericCodec* ACMPCM16B::CreateInstance(void) { return NULL; } - -int16_t ACMPCM16B::InternalCreateEncoder() { - // PCM has no instance. - return 0; -} - -void ACMPCM16B::DestructEncoderSafe() { - // PCM has no instance. - encoder_exist_ = false; - encoder_initialized_ = false; - return; -} - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.h b/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.h deleted file mode 100644 index 176dcc974..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcm16b.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCM16B_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCM16B_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -namespace webrtc { - -namespace acm2 { - -class ACMPCM16B : public ACMGenericCodec { - public: - ACMPCM16B(int16_t codec_id, bool enable_red); - ~ACMPCM16B(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalCreateEncoder(); - - int32_t sampling_freq_hz_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCM16B_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcma.cc b/webrtc/modules/audio_coding/main/acm2/acm_pcma.cc deleted file mode 100644 index 56742108f..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcma.cc +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_pcma.h" - -#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// Codec interface - -namespace webrtc { - -namespace acm2 { - -ACMPCMA::ACMPCMA(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - codec_id_ = codec_id; -} - -ACMPCMA::~ACMPCMA() { return; } - -int16_t ACMPCMA::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - *bitstream_len_byte = - WebRtcG711_EncodeA(&in_audio_[in_audio_ix_read_], - frame_len_smpl_ * num_channels_, bitstream); - // Increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer. - in_audio_ix_read_ += frame_len_smpl_ * num_channels_; - return *bitstream_len_byte; -} - -int16_t ACMPCMA::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - // This codec does not need initialization, PCM has no instance. - return 0; -} - -ACMGenericCodec* ACMPCMA::CreateInstance(void) { return NULL; } - -int16_t ACMPCMA::InternalCreateEncoder() { - // PCM has no instance. - return 0; -} - -void ACMPCMA::DestructEncoderSafe() { - // PCM has no instance. - return; -} - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcma.h b/webrtc/modules/audio_coding/main/acm2/acm_pcma.h deleted file mode 100644 index fa61ed5dc..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcma.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMA_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMA_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -namespace webrtc { - -namespace acm2 { - -class ACMPCMA : public ACMGenericCodec { - public: - ACMPCMA(int16_t codec_id, bool enable_red); - ~ACMPCMA(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMA_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcmu.cc b/webrtc/modules/audio_coding/main/acm2/acm_pcmu.cc deleted file mode 100644 index 4c50696c0..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcmu.cc +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_pcmu.h" - -#include "webrtc/modules/audio_coding/codecs/g711/include/g711_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -// Codec interface. - -namespace webrtc { - -namespace acm2 { - -ACMPCMU::ACMPCMU(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - codec_id_ = codec_id; -} - -ACMPCMU::~ACMPCMU() {} - -int16_t ACMPCMU::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - *bitstream_len_byte = - WebRtcG711_EncodeU(&in_audio_[in_audio_ix_read_], - frame_len_smpl_ * num_channels_, bitstream); - - // Increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer. - in_audio_ix_read_ += frame_len_smpl_ * num_channels_; - return *bitstream_len_byte; -} - -int16_t ACMPCMU::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - // This codec does not need initialization, PCM has no instance. - return 0; -} - -ACMGenericCodec* ACMPCMU::CreateInstance(void) { return NULL; } - -int16_t ACMPCMU::InternalCreateEncoder() { - // PCM has no instance. - return 0; -} - -void ACMPCMU::DestructEncoderSafe() { - // PCM has no instance. - encoder_exist_ = false; - encoder_initialized_ = false; -} - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_pcmu.h b/webrtc/modules/audio_coding/main/acm2/acm_pcmu.h deleted file mode 100644 index 88be95b1a..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_pcmu.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMU_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMU_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -namespace webrtc { - -namespace acm2 { - -class ACMPCMU : public ACMGenericCodec { - public: - ACMPCMU(int16_t codec_id, bool enable_red); - ~ACMPCMU(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe() OVERRIDE - EXCLUSIVE_LOCKS_REQUIRED(codec_wrapper_lock_); - - int16_t InternalCreateEncoder(); -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_PCMU_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc index ff43899a3..273bb5a33 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest.cc @@ -289,7 +289,7 @@ TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(PostdecodingVad)) { TEST_F(AcmReceiverTest, DISABLED_ON_ANDROID(LastAudioCodec)) { const int kCodecId[] = { ACMCodecDB::kISAC, ACMCodecDB::kPCMA, ACMCodecDB::kISACSWB, - ACMCodecDB::kPCM16Bswb32kHz, ACMCodecDB::kG722_1C_48, + ACMCodecDB::kPCM16Bswb32kHz, -1 // Terminator. }; AddSetOfCodecs(kCodecId); diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc index 8c37c9641..5b2c3cb6f 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc +++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver_unittest_oldapi.cc @@ -293,7 +293,7 @@ TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(PostdecodingVad)) { TEST_F(AcmReceiverTestOldApi, DISABLED_ON_ANDROID(LastAudioCodec)) { const int kCodecId[] = { ACMCodecDB::kISAC, ACMCodecDB::kPCMA, ACMCodecDB::kISACSWB, - ACMCodecDB::kPCM16Bswb32kHz, ACMCodecDB::kG722_1C_48, + ACMCodecDB::kPCM16Bswb32kHz, -1 // Terminator. }; AddSetOfCodecs(kCodecId); diff --git a/webrtc/modules/audio_coding/main/acm2/acm_red.cc b/webrtc/modules/audio_coding/main/acm2/acm_red.cc deleted file mode 100644 index 8025c7f31..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_red.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_red.h" - -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" - -namespace webrtc { - -namespace acm2 { - -ACMRED::ACMRED(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red) { - codec_id_ = codec_id; -} - -ACMRED::~ACMRED() {} - -int16_t ACMRED::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - // RED is never used as an encoder - // RED has no instance - return 0; -} - -int16_t ACMRED::InternalInitEncoder(WebRtcACMCodecParams* /* codec_params */) { - // This codec does not need initialization, - // RED has no instance - return 0; -} - -ACMGenericCodec* ACMRED::CreateInstance(void) { return NULL; } - -int16_t ACMRED::InternalCreateEncoder() { - // RED has no instance - return 0; -} - -void ACMRED::DestructEncoderSafe() { - // RED has no instance -} - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_red.h b/webrtc/modules/audio_coding/main/acm2/acm_red.h deleted file mode 100644 index 25cf053b2..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_red.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RED_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RED_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -namespace webrtc { - -namespace acm2 { - -class ACMRED : public ACMGenericCodec { - public: - ACMRED(int16_t codec_id, bool enable_red); - ~ACMRED(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_RED_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/acm_speex.cc b/webrtc/modules/audio_coding/main/acm2/acm_speex.cc deleted file mode 100644 index 6943079d7..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_speex.cc +++ /dev/null @@ -1,326 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "webrtc/modules/audio_coding/main/acm2/acm_speex.h" - -#ifdef WEBRTC_CODEC_SPEEX -// NOTE! Speex is not included in the open-source package. Modify this file or -// your codec API to match the function calls and names of used Speex API file. -#include "webrtc/modules/audio_coding/main/codecs/speex/interface/speex_interface.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" -#include "webrtc/system_wrappers/interface/trace.h" -#endif - -namespace webrtc { - -namespace acm2 { - -#ifndef WEBRTC_CODEC_SPEEX -ACMSPEEX::ACMSPEEX(int16_t /* codec_id */, bool enable_red) - : ACMGenericCodec(enable_red), - encoder_inst_ptr_(NULL), - compl_mode_(0), - vbr_enabled_(false), - encoding_rate_(-1), - sampling_frequency_(-1), - samples_in_20ms_audio_(0xFFFF) { - return; -} - -ACMSPEEX::~ACMSPEEX() { return; } - -int16_t ACMSPEEX::InternalEncode(uint8_t* /* bitstream */, - int16_t* /* bitstream_len_byte */) { - return -1; -} - -int16_t ACMSPEEX::EnableDTX() { return -1; } - -int16_t ACMSPEEX::DisableDTX() { return -1; } - -int16_t ACMSPEEX::InternalInitEncoder( - WebRtcACMCodecParams* /* codec_params */) { - return -1; -} - -ACMGenericCodec* ACMSPEEX::CreateInstance(void) { return NULL; } - -int16_t ACMSPEEX::InternalCreateEncoder() { return -1; } - -void ACMSPEEX::DestructEncoderSafe() { return; } - -int16_t ACMSPEEX::SetBitRateSafe(const int32_t /* rate */) { return -1; } - -#ifdef UNUSEDSPEEX -int16_t ACMSPEEX::EnableVBR() { return -1; } - -int16_t ACMSPEEX::DisableVBR() { return -1; } - -int16_t ACMSPEEX::SetComplMode(int16_t mode) { return -1; } -#endif - -#else //===================== Actual Implementation ======================= - -ACMSPEEX::ACMSPEEX(int16_t codec_id, bool enable_red) - : ACMGenericCodec(enable_red), encoder_inst_ptr_(NULL) { - codec_id_ = codec_id; - - // Set sampling frequency, frame size and rate Speex - if (codec_id_ == ACMCodecDB::kSPEEX8) { - sampling_frequency_ = 8000; - samples_in_20ms_audio_ = 160; - encoding_rate_ = 11000; - } else if (codec_id_ == ACMCodecDB::kSPEEX16) { - sampling_frequency_ = 16000; - samples_in_20ms_audio_ = 320; - encoding_rate_ = 22000; - } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Wrong codec id for Speex."); - - sampling_frequency_ = -1; - samples_in_20ms_audio_ = -1; - encoding_rate_ = -1; - } - - has_internal_dtx_ = true; - dtx_enabled_ = false; - vbr_enabled_ = false; - compl_mode_ = 3; // default complexity value - - return; -} - -ACMSPEEX::~ACMSPEEX() { - if (encoder_inst_ptr_ != NULL) { - WebRtcSpeex_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - return; -} - -int16_t ACMSPEEX::InternalEncode(uint8_t* bitstream, - int16_t* bitstream_len_byte) { - int16_t status; - int16_t num_encoded_samples = 0; - int16_t n = 0; - - while (num_encoded_samples < frame_len_smpl_) { - status = WebRtcSpeex_Encode( - encoder_inst_ptr_, &in_audio_[in_audio_ix_read_], encoding_rate_); - - // increment the read index this tell the caller that how far - // we have gone forward in reading the audio buffer - in_audio_ix_read_ += samples_in_20ms_audio_; - num_encoded_samples += samples_in_20ms_audio_; - - if (status < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Error in Speex encoder"); - return status; - } - - // Update VAD, if internal DTX is used - if (has_internal_dtx_ && dtx_enabled_) { - vad_label_[n++] = status; - vad_label_[n++] = status; - } - - if (status == 0) { - // This frame is detected as inactive. We need send whatever - // encoded so far. - *bitstream_len_byte = WebRtcSpeex_GetBitstream( - encoder_inst_ptr_, reinterpret_cast(bitstream)); - return *bitstream_len_byte; - } - } - - *bitstream_len_byte = WebRtcSpeex_GetBitstream( - encoder_inst_ptr_, reinterpret_cast(bitstream)); - return *bitstream_len_byte; -} - -int16_t ACMSPEEX::EnableDTX() { - if (dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // enable DTX - if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, vbr_enabled_ ? 1 : 0, - compl_mode_, 1) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Cannot enable DTX for Speex"); - return -1; - } - dtx_enabled_ = true; - return 0; - } else { - return -1; - } - - return 0; -} - -int16_t ACMSPEEX::DisableDTX() { - if (!dtx_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // disable DTX - if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, (vbr_enabled_ ? 1 : 0), - compl_mode_, 0) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Cannot disable DTX for Speex"); - return -1; - } - dtx_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } - - return 0; -} - -int16_t ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codec_params) { - // sanity check - if (encoder_inst_ptr_ == NULL) { - WEBRTC_TRACE(webrtc::kTraceError, - webrtc::kTraceAudioCoding, - unique_id_, - "Cannot initialize Speex encoder, instance does not exist"); - return -1; - } - - int16_t status = SetBitRateSafe((codec_params->codecInstant).rate); - status += (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, - vbr_enabled_, - compl_mode_, - ((codec_params->enable_dtx) ? 1 : 0)) < 0) - ? -1 - : 0; - - if (status >= 0) { - return 0; - } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Error in initialization of Speex encoder"); - return -1; - } -} - -ACMGenericCodec* ACMSPEEX::CreateInstance(void) { return NULL; } - -int16_t ACMSPEEX::InternalCreateEncoder() { - return WebRtcSpeex_CreateEnc(&encoder_inst_ptr_, sampling_frequency_); -} - -void ACMSPEEX::DestructEncoderSafe() { - if (encoder_inst_ptr_ != NULL) { - WebRtcSpeex_FreeEnc(encoder_inst_ptr_); - encoder_inst_ptr_ = NULL; - } - // there is no encoder set the following - encoder_exist_ = false; - encoder_initialized_ = false; - encoding_rate_ = 0; -} - -int16_t ACMSPEEX::SetBitRateSafe(const int32_t rate) { - // Check if changed rate - if (rate == encoding_rate_) { - return 0; - } else if (rate > 2000) { - encoding_rate_ = rate; - encoder_params_.codecInstant.rate = rate; - } else { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Unsupported encoding rate for Speex"); - - return -1; - } - - return 0; -} - -#ifdef UNUSEDSPEEX - -// This API is currently not in use. If requested to be able to enable/disable -// VBR an ACM API need to be added. -int16_t ACMSPEEX::EnableVBR() { - if (vbr_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // enable Variable Bit Rate (VBR) - if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 1, compl_mode_, - (dtx_enabled_ ? 1 : 0)) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Cannot enable VBR mode for Speex"); - - return -1; - } - vbr_enabled_ = true; - return 0; - } else { - return -1; - } -} - -// This API is currently not in use. If requested to be able to enable/disable -// VBR an ACM API need to be added. -int16_t ACMSPEEX::DisableVBR() { - if (!vbr_enabled_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // disable DTX - if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, compl_mode_, - (dtx_enabled_ ? 1 : 0)) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Cannot disable DTX for Speex"); - - return -1; - } - vbr_enabled_ = false; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -// This API is currently not in use. If requested to be able to set complexity -// an ACM API need to be added. -int16_t ACMSPEEX::SetComplMode(int16_t mode) { - // Check if new mode - if (mode == compl_mode_) { - return 0; - } else if (encoder_exist_) { // check if encoder exist - // Set new mode - if (WebRtcSpeex_EncoderInit(encoder_inst_ptr_, 0, mode, - (dtx_enabled_ ? 1 : 0)) < 0) { - WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, unique_id_, - "Error in complexity mode for Speex"); - return -1; - } - compl_mode_ = mode; - return 0; - } else { - // encoder doesn't exists, therefore disabling is harmless - return 0; - } -} - -#endif - -#endif - -} // namespace acm2 - -} // namespace webrtc diff --git a/webrtc/modules/audio_coding/main/acm2/acm_speex.h b/webrtc/modules/audio_coding/main/acm2/acm_speex.h deleted file mode 100644 index c72bdc86f..000000000 --- a/webrtc/modules/audio_coding/main/acm2/acm_speex.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SPEEX_H_ -#define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SPEEX_H_ - -#include "webrtc/modules/audio_coding/main/acm2/acm_generic_codec.h" - -// forward declaration -struct SPEEX_encinst_t_; -struct SPEEX_decinst_t_; - -namespace webrtc { - -namespace acm2 { - -class ACMSPEEX : public ACMGenericCodec { - public: - ACMSPEEX(int16_t codec_id, bool enable_red); - ~ACMSPEEX(); - - // For FEC. - ACMGenericCodec* CreateInstance(void); - - int16_t InternalEncode(uint8_t* bitstream, int16_t* bitstream_len_byte); - - int16_t InternalInitEncoder(WebRtcACMCodecParams* codec_params); - - protected: - void DestructEncoderSafe(); - - int16_t InternalCreateEncoder(); - - int16_t SetBitRateSafe(const int32_t rate); - - int16_t EnableDTX(); - - int16_t DisableDTX(); - -#ifdef UNUSEDSPEEX - int16_t EnableVBR(); - - int16_t DisableVBR(); - - int16_t SetComplMode(int16_t mode); -#endif - - SPEEX_encinst_t_* encoder_inst_ptr_; - int16_t compl_mode_; - bool vbr_enabled_; - int32_t encoding_rate_; - int16_t sampling_frequency_; - uint16_t samples_in_20ms_audio_; -}; - -} // namespace acm2 - -} // namespace webrtc - -#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_SPEEX_H_ diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi index db7142f39..44b6bb733 100644 --- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi +++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.gypi @@ -54,48 +54,11 @@ 'sources': [ '../interface/audio_coding_module.h', '../interface/audio_coding_module_typedefs.h', - 'acm_amr.cc', - 'acm_amr.h', - 'acm_amrwb.cc', - 'acm_amrwb.h', - 'acm_cng.cc', - 'acm_cng.h', 'acm_codec_database.cc', 'acm_codec_database.h', 'acm_common_defs.h', - 'acm_dtmf_playout.cc', - 'acm_dtmf_playout.h', - 'acm_g722.cc', - 'acm_g722.h', - 'acm_g7221.cc', - 'acm_g7221.h', - 'acm_g7221c.cc', - 'acm_g7221c.h', - 'acm_g729.cc', - 'acm_g729.h', - 'acm_g7291.cc', - 'acm_g7291.h', 'acm_generic_codec.cc', 'acm_generic_codec.h', - 'acm_gsmfr.cc', - 'acm_gsmfr.h', - 'acm_ilbc.cc', - 'acm_ilbc.h', - 'acm_isac.cc', - 'acm_isac.h', - 'acm_isac_macros.h', - 'acm_opus.cc', - 'acm_opus.h', - 'acm_speex.cc', - 'acm_speex.h', - 'acm_pcm16b.cc', - 'acm_pcm16b.h', - 'acm_pcma.cc', - 'acm_pcma.h', - 'acm_pcmu.cc', - 'acm_pcmu.h', - 'acm_red.cc', - 'acm_red.h', 'acm_receiver.cc', 'acm_receiver.h', 'acm_resampler.cc', diff --git a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc index c5ccf1c5f..17186b364 100644 --- a/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc +++ b/webrtc/modules/audio_coding/main/test/TestAllCodecs.cc @@ -152,126 +152,6 @@ void TestAllCodecs::Perform() { // All codecs are tested for all allowed sampling frequencies, rates and // packet sizes. -#ifdef WEBRTC_CODEC_AMR - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_amr[] = "AMR"; - RegisterSendCodec('A', codec_amr, 8000, 4750, 160, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 4750, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 4750, 480, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5150, 160, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5150, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5150, 480, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5900, 160, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5900, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 5900, 480, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 6700, 160, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 6700, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 6700, 480, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7400, 160, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7400, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7400, 480, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7950, 160, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7950, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 7950, 480, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 10200, 160, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 10200, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 10200, 480, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 12200, 160, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 12200, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amr, 8000, 12200, 480, 3); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif -#ifdef WEBRTC_CODEC_AMRWB - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - char codec_amrwb[] = "AMR-WB"; - OpenOutFile(test_count_); - RegisterSendCodec('A', codec_amrwb, 16000, 7000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 7000, 640, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 7000, 960, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 9000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 9000, 640, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 9000, 960, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 12000, 320, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 12000, 640, 6); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 12000, 960, 8); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 14000, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 14000, 640, 4); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 14000, 960, 5); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 16000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 16000, 640, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 16000, 960, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 18000, 320, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 18000, 640, 4); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 18000, 960, 5); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 20000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 20000, 640, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 20000, 960, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 23000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 23000, 640, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 23000, 960, 3); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 24000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 24000, 640, 2); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_amrwb, 16000, 24000, 960, 2); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif #ifdef WEBRTC_CODEC_G722 if (test_mode_ != 0) { printf("===============================================================\n"); @@ -293,153 +173,6 @@ void TestAllCodecs::Perform() { Run(channel_a_to_b_); outfile_b_.Close(); #endif -#ifdef WEBRTC_CODEC_G722_1 - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_g722_1[] = "G7221"; - RegisterSendCodec('A', codec_g722_1, 16000, 32000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g722_1, 16000, 24000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g722_1, 16000, 16000, 320, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif -#ifdef WEBRTC_CODEC_G722_1C - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_g722_1c[] = "G7221"; - RegisterSendCodec('A', codec_g722_1c, 32000, 48000, 640, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g722_1c, 32000, 32000, 640, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g722_1c, 32000, 24000, 640, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif -#ifdef WEBRTC_CODEC_G729 - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_g729[] = "G729"; - RegisterSendCodec('A', codec_g729, 8000, 8000, 80, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729, 8000, 8000, 160, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729, 8000, 8000, 240, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729, 8000, 8000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729, 8000, 8000, 400, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729, 8000, 8000, 480, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif -#ifdef WEBRTC_CODEC_G729_1 - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_g729_1[] = "G7291"; - RegisterSendCodec('A', codec_g729_1, 16000, 8000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 8000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 8000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 12000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 12000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 12000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 14000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 14000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 14000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 16000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 16000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 16000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 18000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 18000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 18000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 20000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 20000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 20000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 22000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 22000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 22000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 24000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 24000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 24000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 26000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 26000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 26000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 28000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 28000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 28000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 30000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 30000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 30000, 960, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 32000, 320, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 32000, 640, 1); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_g729_1, 16000, 32000, 960, 1); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif -#ifdef WEBRTC_CODEC_GSMFR - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_gsmfr[] = "GSM"; - RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 160, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_gsmfr, 8000, 13200, 480, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif #ifdef WEBRTC_CODEC_ILBC if (test_mode_ != 0) { printf("===============================================================\n"); @@ -566,34 +299,6 @@ void TestAllCodecs::Perform() { RegisterSendCodec('A', codec_pcmu, 8000, 64000, 480, 0); Run(channel_a_to_b_); outfile_b_.Close(); -#ifdef WEBRTC_CODEC_SPEEX - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - char codec_speex[] = "SPEEX"; - RegisterSendCodec('A', codec_speex, 8000, 2400, 160, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_speex, 8000, 8000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_speex, 8000, 18200, 480, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); - - if (test_mode_ != 0) { - printf("===============================================================\n"); - } - test_count_++; - OpenOutFile(test_count_); - RegisterSendCodec('A', codec_speex, 16000, 4000, 320, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_speex, 16000, 12800, 640, 0); - Run(channel_a_to_b_); - RegisterSendCodec('A', codec_speex, 16000, 34200, 960, 0); - Run(channel_a_to_b_); - outfile_b_.Close(); -#endif #ifdef WEBRTC_CODEC_OPUS if (test_mode_ != 0) { printf("===============================================================\n"); @@ -622,30 +327,9 @@ void TestAllCodecs::Perform() { /* Print out all codecs that were not tested in the run */ printf("The following codecs was not included in the test:\n"); -#ifndef WEBRTC_CODEC_AMR - printf(" GSMAMR\n"); -#endif -#ifndef WEBRTC_CODEC_AMRWB - printf(" GSMAMR-wb\n"); -#endif #ifndef WEBRTC_CODEC_G722 printf(" G.722\n"); #endif -#ifndef WEBRTC_CODEC_G722_1 - printf(" G.722.1\n"); -#endif -#ifndef WEBRTC_CODEC_G722_1C - printf(" G.722.1C\n"); -#endif -#ifndef WEBRTC_CODEC_G729 - printf(" G.729\n"); -#endif -#ifndef WEBRTC_CODEC_G729_1 - printf(" G.729.1\n"); -#endif -#ifndef WEBRTC_CODEC_GSMFR - printf(" GSMFR\n"); -#endif #ifndef WEBRTC_CODEC_ILBC printf(" iLBC\n"); #endif @@ -658,9 +342,6 @@ void TestAllCodecs::Perform() { #ifndef WEBRTC_CODEC_PCM16 printf(" PCM16\n"); #endif -#ifndef WEBRTC_CODEC_SPEEX - printf(" Speex\n"); -#endif printf("\nTo complete the test, listen to the %d number of output files.\n", test_count_); diff --git a/webrtc/modules/audio_coding/main/test/opus_test.cc b/webrtc/modules/audio_coding/main/test/opus_test.cc index 8fda4b386..09301df51 100644 --- a/webrtc/modules/audio_coding/main/test/opus_test.cc +++ b/webrtc/modules/audio_coding/main/test/opus_test.cc @@ -20,7 +20,6 @@ #include "webrtc/modules/audio_coding/codecs/opus/interface/opus_interface.h" #include "webrtc/modules/audio_coding/main/interface/audio_coding_module_typedefs.h" #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" -#include "webrtc/modules/audio_coding/main/acm2/acm_opus.h" #include "webrtc/modules/audio_coding/main/test/TestStereo.h" #include "webrtc/modules/audio_coding/main/test/utility.h" #include "webrtc/system_wrappers/interface/trace.h" diff --git a/webrtc/modules/audio_coding/main/test/opus_test.h b/webrtc/modules/audio_coding/main/test/opus_test.h index 9ee2b9372..227a5cd67 100644 --- a/webrtc/modules/audio_coding/main/test/opus_test.h +++ b/webrtc/modules/audio_coding/main/test/opus_test.h @@ -13,7 +13,6 @@ #include -#include "webrtc/modules/audio_coding/main/acm2/acm_opus.h" #include "webrtc/modules/audio_coding/main/acm2/acm_resampler.h" #include "webrtc/modules/audio_coding/main/test/ACMTest.h" #include "webrtc/modules/audio_coding/main/test/Channel.h" diff --git a/webrtc/modules/media_file/source/media_file_utility.cc b/webrtc/modules/media_file/source/media_file_utility.cc index 7bffd0a3a..73731006a 100644 --- a/webrtc/modules/media_file/source/media_file_utility.cc +++ b/webrtc/modules/media_file/source/media_file_utility.cc @@ -1309,8 +1309,7 @@ int32_t ModuleFileUtility::InitCompressedReading( start, stop); -#if defined(WEBRTC_CODEC_AMR) || defined(WEBRTC_CODEC_AMRWB) || \ - defined(WEBRTC_CODEC_ILBC) +#if defined(WEBRTC_CODEC_ILBC) int16_t read_len = 0; #endif _codecId = kCodecNoCodec; @@ -1320,13 +1319,6 @@ int32_t ModuleFileUtility::InitCompressedReading( _startPointInMs = start; _stopPointInMs = stop; -#ifdef WEBRTC_CODEC_AMR - int32_t AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; -#endif -#ifdef WEBRTC_CODEC_AMRWB - int32_t AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; -#endif - // Read the codec name int32_t cnt = 0; char buf[64]; @@ -1342,94 +1334,6 @@ int32_t ModuleFileUtility::InitCompressedReading( buf[cnt]=0; } -#ifdef WEBRTC_CODEC_AMR - if(!strcmp("#!AMR\n", buf)) - { - strcpy(codec_info_.plname, "amr"); - codec_info_.pacsize = 160; - _codecId = kCodecAmr; - codec_info_.pltype = 112; - codec_info_.rate = 12200; - codec_info_.plfreq = 8000; - codec_info_.channels = 1; - - int16_t mode = 0; - if(_startPointInMs > 0) - { - while (_playoutPositionMs <= _startPointInMs) - { - // First read byte contain the AMR mode. - read_len = in.Read(buf, 1); - if(read_len != 1) - { - return -1; - } - - mode = (buf[0]>>3)&0xF; - if((mode < 0) || (mode > 8)) - { - if(mode != 15) - { - return -1; - } - } - if(mode != 15) - { - read_len = in.Read(&buf[1], AMRmode2bytes[mode]); - if(read_len != AMRmode2bytes[mode]) - { - return -1; - } - } - _playoutPositionMs += 20; - } - } - } -#endif -#ifdef WEBRTC_CODEC_AMRWB - if(!strcmp("#!AMRWB\n", buf)) - { - strcpy(codec_info_.plname, "amr-wb"); - codec_info_.pacsize = 320; - _codecId = kCodecAmrWb; - codec_info_.pltype = 120; - codec_info_.rate = 20000; - codec_info_.plfreq = 16000; - codec_info_.channels = 1; - - int16_t mode = 0; - if(_startPointInMs > 0) - { - while (_playoutPositionMs <= _startPointInMs) - { - // First read byte contain the AMR mode. - read_len = in.Read(buf, 1); - if(read_len != 1) - { - return -1; - } - - mode = (buf[0]>>3)&0xF; - if((mode < 0) || (mode > 9)) - { - if(mode != 15) - { - return -1; - } - } - if(mode != 15) - { - read_len = in.Read(&buf[1], AMRWBmode2bytes[mode]); - if(read_len != AMRWBmode2bytes[mode]) - { - return -1; - } - } - _playoutPositionMs += 20; - } - } - } -#endif #ifdef WEBRTC_CODEC_ILBC if(!strcmp("#!iLBC20\n", buf)) { @@ -1507,12 +1411,6 @@ int32_t ModuleFileUtility::ReadCompressedData(InStream& in, outData, bufferSize); -#ifdef WEBRTC_CODEC_AMR - uint32_t AMRmode2bytes[9]={12,13,15,17,19,20,26,31,5}; -#endif -#ifdef WEBRTC_CODEC_AMRWB - uint32_t AMRWBmode2bytes[10]={17,23,32,36,40,46,50,58,60,6}; -#endif uint32_t bytesRead = 0; if(! _reading) @@ -1521,119 +1419,6 @@ int32_t ModuleFileUtility::ReadCompressedData(InStream& in, return -1; } -#ifdef WEBRTC_CODEC_AMR - if(_codecId == kCodecAmr) - { - int32_t res = in.Read(outData, 1); - if(res != 1) - { - if(!in.Rewind()) - { - InitCompressedReading(in, _startPointInMs, _stopPointInMs); - res = in.Read(outData, 1); - if(res != 1) - { - _reading = false; - return -1; - } - } - else - { - _reading = false; - return -1; - } - } - const int16_t mode = (outData[0]>>3)&0xF; - if((mode < 0) || - (mode > 8)) - { - if(mode != 15) - { - return -1; - } - } - if(mode != 15) - { - if(bufferSize < static_cast(AMRmode2bytes[mode] + 1)) - { - WEBRTC_TRACE( - kTraceError, - kTraceFile, - _id, - "output buffer is too short to read AMR compressed data."); - assert(false); - return -1; - } - bytesRead = in.Read(&outData[1], AMRmode2bytes[mode]); - if(bytesRead != AMRmode2bytes[mode]) - { - _reading = false; - return -1; - } - // Count the mode byte to bytes read. - bytesRead++; - } - else - { - bytesRead = 1; - } - } -#endif -#ifdef WEBRTC_CODEC_AMRWB - if(_codecId == kCodecAmrWb) - { - int32_t res = in.Read(outData, 1); - if(res != 1) - { - if(!in.Rewind()) - { - InitCompressedReading(in, _startPointInMs, _stopPointInMs); - res = in.Read(outData, 1); - if(res != 1) - { - _reading = false; - return -1; - } - } - else - { - _reading = false; - return -1; - } - } - int16_t mode = (outData[0]>>3)&0xF; - if((mode < 0) || - (mode > 8)) - { - if(mode != 15) - { - return -1; - } - } - if(mode != 15) - { - if(bufferSize < static_cast(AMRWBmode2bytes[mode] + 1)) - { - WEBRTC_TRACE(kTraceError, kTraceFile, _id, - "output buffer is too short to read AMRWB\ - compressed."); - assert(false); - return -1; - } - bytesRead = in.Read(&outData[1], AMRWBmode2bytes[mode]); - if(bytesRead != AMRWBmode2bytes[mode]) - { - _reading = false; - return -1; - } - bytesRead++; - } - else - { - bytesRead = 1; - } - } -#endif #ifdef WEBRTC_CODEC_ILBC if((_codecId == kCodecIlbc20Ms) || (_codecId == kCodecIlbc30Ms)) @@ -1711,32 +1496,6 @@ int32_t ModuleFileUtility::InitCompressedWriting( _writing = false; -#ifdef WEBRTC_CODEC_AMR - if(STR_CASE_CMP(codecInst.plname, "amr") == 0) - { - if(codecInst.pacsize == 160) - { - memcpy(&codec_info_,&codecInst,sizeof(CodecInst)); - _codecId = kCodecAmr; - out.Write("#!AMR\n",6); - _writing = true; - return 0; - } - } -#endif -#ifdef WEBRTC_CODEC_AMRWB - if(STR_CASE_CMP(codecInst.plname, "amr-wb") == 0) - { - if(codecInst.pacsize == 320) - { - memcpy(&codec_info_,&codecInst,sizeof(CodecInst)); - _codecId = kCodecAmrWb; - out.Write("#!AMRWB\n",8); - _writing = true; - return 0; - } - } -#endif #ifdef WEBRTC_CODEC_ILBC if(STR_CASE_CMP(codecInst.plname, "ilbc") == 0) { @@ -2075,18 +1834,6 @@ int32_t ModuleFileUtility::set_codec_info(const CodecInst& codecInst) _codecId = kCodecL16_32Khz; } } -#ifdef WEBRTC_CODEC_AMR - else if(STR_CASE_CMP(codecInst.plname, "amr") == 0) - { - _codecId = kCodecAmr; - } -#endif -#ifdef WEBRTC_CODEC_AMRWB - else if(STR_CASE_CMP(codecInst.plname, "amr-wb") == 0) - { - _codecId = kCodecAmrWb; - } -#endif #ifdef WEBRTC_CODEC_ILBC else if(STR_CASE_CMP(codecInst.plname, "ilbc") == 0) { @@ -2113,97 +1860,11 @@ int32_t ModuleFileUtility::set_codec_info(const CodecInst& codecInst) } } #endif -#ifdef WEBRTC_CODEC_ISACLC - else if(STR_CASE_CMP(codecInst.plname, "isaclc") == 0) - { - _codecId = kCodecIsacLc; - } -#endif #ifdef WEBRTC_CODEC_G722 else if(STR_CASE_CMP(codecInst.plname, "G722") == 0) { _codecId = kCodecG722; } -#endif - else if(STR_CASE_CMP(codecInst.plname, "G7221") == 0) - { -#ifdef WEBRTC_CODEC_G722_1 - if(codecInst.plfreq == 16000) - { - if(codecInst.rate == 16000) - { - _codecId = kCodecG722_1_16Kbps; - } - else if(codecInst.rate == 24000) - { - _codecId = kCodecG722_1_24Kbps; - } - else if(codecInst.rate == 32000) - { - _codecId = kCodecG722_1_32Kbps; - } - } -#endif -#ifdef WEBRTC_CODEC_G722_1C - if(codecInst.plfreq == 32000) - { - if(codecInst.rate == 48000) - { - _codecId = kCodecG722_1c_48; - } - else if(codecInst.rate == 32000) - { - _codecId = kCodecG722_1c_32; - } - else if(codecInst.rate == 24000) - { - _codecId = kCodecG722_1c_24; - } - } -#endif - } -#ifdef WEBRTC_CODEC_G726 - else if(STR_CASE_CMP(codecInst.plname, "G726-40") == 0) - { - _codecId = kCodecG726_40; - } - else if(STR_CASE_CMP(codecInst.plname, "G726-32") == 0) - { - _codecId = kCodecG726_24; - } - else if(STR_CASE_CMP(codecInst.plname, "G726-24") == 0) - { - _codecId = kCodecG726_32; - } - else if(STR_CASE_CMP(codecInst.plname, "G726-16") == 0) - { - _codecId = kCodecG726_16; - } -#endif -#ifdef WEBRTC_CODEC_G729 - else if(STR_CASE_CMP(codecInst.plname, "G729") == 0) - { - _codecId = kCodecG729; - } -#endif -#ifdef WEBRTC_CODEC_G729_1 - else if(STR_CASE_CMP(codecInst.plname, "G7291") == 0) - { - _codecId = kCodecG729_1; - } -#endif -#ifdef WEBRTC_CODEC_SPEEX - else if(STR_CASE_CMP(codecInst.plname, "speex") == 0) - { - if(codecInst.plfreq == 8000) - { - _codecId = kCodecSpeex8Khz; - } - else if(codecInst.plfreq == 16000) - { - _codecId = kCodecSpeex16Khz; - } - } #endif if(_codecId == kCodecNoCodec) { @@ -2297,124 +1958,6 @@ int32_t ModuleFileUtility::FileDurationMs(const char* fileName, { buf[cnt] = 0; } -#ifdef WEBRTC_CODEC_AMR - if(!strcmp("#!AMR\n", buf)) - { - uint8_t dummy; - read_len = inStreamObj->Read(&dummy, 1); - if(read_len != 1) - { - return -1; - } - - int16_t AMRMode = (dummy>>3)&0xF; - - // TODO (hellner): use tables instead of hardcoding like this! - // Additionally, this calculation does not - // take octet alignment into consideration. - switch (AMRMode) - { - // Mode 0: 4.75 kbit/sec -> 95 bits per 20 ms frame. - // 20 ms = 95 bits -> - // file size in bytes * 8 / 95 is the number of - // 20 ms frames in the file -> - // time_in_ms = file size * 8 / 95 * 20 - case 0: - time_in_ms = ((file_size.st_size)*160)/95; - break; - // Mode 1: 5.15 kbit/sec -> 103 bits per 20 ms frame. - case 1: - time_in_ms = ((file_size.st_size)*160)/103; - break; - // Mode 2: 5.90 kbit/sec -> 118 bits per 20 ms frame. - case 2: - time_in_ms = ((file_size.st_size)*160)/118; - break; - // Mode 3: 6.70 kbit/sec -> 134 bits per 20 ms frame. - case 3: - time_in_ms = ((file_size.st_size)*160)/134; - break; - // Mode 4: 7.40 kbit/sec -> 148 bits per 20 ms frame. - case 4: - time_in_ms = ((file_size.st_size)*160)/148; - break; - // Mode 5: 7.95 bit/sec -> 159 bits per 20 ms frame. - case 5: - time_in_ms = ((file_size.st_size)*160)/159; - break; - // Mode 6: 10.2 bit/sec -> 204 bits per 20 ms frame. - case 6: - time_in_ms = ((file_size.st_size)*160)/204; - break; - // Mode 7: 12.2 bit/sec -> 244 bits per 20 ms frame. - case 7: - time_in_ms = ((file_size.st_size)*160)/244; - break; - // Mode 8: SID Mode -> 39 bits per 20 ms frame. - case 8: - time_in_ms = ((file_size.st_size)*160)/39; - break; - default: - break; - } - } -#endif -#ifdef WEBRTC_CODEC_AMRWB - if(!strcmp("#!AMRWB\n", buf)) - { - uint8_t dummy; - read_len = inStreamObj->Read(&dummy, 1); - if(read_len != 1) - { - return -1; - } - - // TODO (hellner): use tables instead of hardcoding like this! - int16_t AMRWBMode = (dummy>>3)&0xF; - switch(AMRWBMode) - { - // Mode 0: 6.6 kbit/sec -> 132 bits per 20 ms frame. - case 0: - time_in_ms = ((file_size.st_size)*160)/132; - break; - // Mode 1: 8.85 kbit/sec -> 177 bits per 20 ms frame. - case 1: - time_in_ms = ((file_size.st_size)*160)/177; - break; - // Mode 2: 12.65 kbit/sec -> 253 bits per 20 ms frame. - case 2: - time_in_ms = ((file_size.st_size)*160)/253; - break; - // Mode 3: 14.25 kbit/sec -> 285 bits per 20 ms frame. - case 3: - time_in_ms = ((file_size.st_size)*160)/285; - break; - // Mode 4: 15.85 kbit/sec -> 317 bits per 20 ms frame. - case 4: - time_in_ms = ((file_size.st_size)*160)/317; - break; - // Mode 5: 18.25 kbit/sec -> 365 bits per 20 ms frame. - case 5: - time_in_ms = ((file_size.st_size)*160)/365; - break; - // Mode 6: 19.85 kbit/sec -> 397 bits per 20 ms frame. - case 6: - time_in_ms = ((file_size.st_size)*160)/397; - break; - // Mode 7: 23.05 kbit/sec -> 461 bits per 20 ms frame. - case 7: - time_in_ms = ((file_size.st_size)*160)/461; - break; - // Mode 8: 23.85 kbit/sec -> 477 bits per 20 ms frame. - case 8: - time_in_ms = ((file_size.st_size)*160)/477; - break; - default: - delete inStreamObj; - return -1; - } - } -#endif #ifdef WEBRTC_CODEC_ILBC if(!strcmp("#!iLBC20\n", buf)) {