This CL is divided in several patches, to make review easier.

Patch Set 1: Removing blanks at end of lines.
Patch Set 2: Removing tabs.
Patch Set 3: Fixing include-guards.
Patch Set 4-7: Formatting files in the list.
Patch Set 8: Formatting CNG.

Patch Set 9: 
* Fixing comments from code review
* Fixing formating in acm_dtmf_playout.cc
* Started fixing formating of acm_g7221.cc. More work needed, so don't spend too much time reviewing.
* Refactored constructor of ACMGenericCodec. Rest of file still to be fixed.
* Fixing break; after return ...; in several files.

Patch Set 10:
* Chaning from reintepret_cast to static_cast in three files, acm_amr.cc, acm_cng.cc and acm_g722.cc
NOTE! Not all files have the right format. That work will continue in separate CLs.

Review URL: http://webrtc-codereview.appspot.com/175002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@881 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org
2011-11-03 17:20:10 +00:00
parent a4b9660372
commit fb389e3b02
49 changed files with 4572 additions and 5660 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -8,13 +8,12 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef AUDIO_CODING_MODULE_TYPEDEFS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#define AUDIO_CODING_MODULE_TYPEDEFS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#include "typedefs.h" #include "typedefs.h"
namespace webrtc namespace webrtc {
{
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum AudioPlayoutMode // enum AudioPlayoutMode
@@ -36,41 +35,37 @@ namespace webrtc
// this mode can be used to improve the jitter robustness at // this mode can be used to improve the jitter robustness at
// the cost of increased delay. // the cost of increased delay.
// //
enum AudioPlayoutMode enum AudioPlayoutMode {
{ voice = 0,
voice = 0, fax = 1,
fax = 1, streaming = 2
streaming = 2
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMSpeechType // enum ACMSpeechType
// An enumerator for possible labels of a decoded frame. // An enumerator for possible labels of a decoded frame.
// //
// -normal : a normal speech frame. If VAD is enabled on the // -normal : a normal speech frame. If VAD is enabled on the
// incoming stream this label indicate that the // incoming stream this label indicate that the
// frame is active. // frame is active.
// -PLC : a PLC frame. The corresponding packet was lost // -PLC : a PLC frame. The corresponding packet was lost
// and this frame generated by PLC techniques. // and this frame generated by PLC techniques.
// -CNG : the frame is comfort noise. This happens if VAD // -CNG : the frame is comfort noise. This happens if VAD
// is enabled at the sender and we have received // is enabled at the sender and we have received
// SID. // SID.
// -PLCCNG : PLC will fade to comfort noise if the duration // -PLCCNG : PLC will fade to comfort noise if the duration
// of PLC is long. This labels such a case. // of PLC is long. This labels such a case.
// -VADPassive : the VAD at the receiver recognizes this frame as // -VADPassive : the VAD at the receiver recognizes this frame as
// passive. // passive.
// //
enum ACMSpeechType enum ACMSpeechType {
{ normal = 0,
normal = 0, PLC = 1,
PLC = 1, CNG = 2,
CNG = 2, PLCCNG = 3,
PLCCNG = 3, VADPassive = 4
VADPassive = 4
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMVADMode // enum ACMVADMode
// An enumerator for aggressiveness of VAD // An enumerator for aggressiveness of VAD
@@ -80,52 +75,50 @@ enum ACMSpeechType
// -VADAggr : an aggressive mode. // -VADAggr : an aggressive mode.
// -VADVeryAggr : the most agressive mode. // -VADVeryAggr : the most agressive mode.
// //
enum ACMVADMode enum ACMVADMode {
{ VADNormal = 0,
VADNormal = 0, VADLowBitrate = 1,
VADLowBitrate = 1, VADAggr = 2,
VADAggr = 2, VADVeryAggr = 3
VADVeryAggr = 3
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// enum ACMCountries // enum ACMCountries
// An enumerator for countries, used when enabling CPT for a specific country. // An enumerator for countries, used when enabling CPT for a specific country.
// //
enum ACMCountries enum ACMCountries {
{ ACMDisableCountryDetection = -1, // disable CPT detection
ACMDisableCountryDetection = -1, // disable CPT detection ACMUSA = 0,
ACMUSA = 0, ACMJapan,
ACMJapan, ACMCanada,
ACMCanada, ACMFrance,
ACMFrance, ACMGermany,
ACMGermany, ACMAustria,
ACMAustria, ACMBelgium,
ACMBelgium, ACMUK,
ACMUK, ACMCzech,
ACMCzech, ACMDenmark,
ACMDenmark, ACMFinland,
ACMFinland, ACMGreece,
ACMGreece, ACMHungary,
ACMHungary, ACMIceland,
ACMIceland , ACMIreland,
ACMIreland, ACMItaly,
ACMItaly, ACMLuxembourg,
ACMLuxembourg, ACMMexico,
ACMMexico, ACMNorway,
ACMNorway, ACMPoland,
ACMPoland, ACMPortugal,
ACMPortugal, ACMSpain,
ACMSpain, ACMSweden,
ACMSweden, ACMTurkey,
ACMTurkey, ACMChina,
ACMChina, ACMHongkong,
ACMHongkong, ACMTaiwan,
ACMTaiwan, ACMKorea,
ACMKorea, ACMSingapore,
ACMSingapore, ACMNonStandard1
ACMNonStandard1 // non-standard countries // non-standard countries
}; };
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -138,12 +131,11 @@ enum ACMCountries
// -AMROctetAlligned : Octet-alligned mode. // -AMROctetAlligned : Octet-alligned mode.
// -AMRFileStorage : file-storage mode. // -AMRFileStorage : file-storage mode.
// //
enum ACMAMRPackingFormat enum ACMAMRPackingFormat {
{ AMRUndefined = -1,
AMRUndefined = -1, AMRBandwidthEfficient = 0,
AMRBandwidthEfficient = 0, AMROctetAlligned = 1,
AMROctetAlligned = 1, AMRFileStorage = 2
AMRFileStorage = 2
}; };
@@ -155,20 +147,20 @@ enum ACMAMRPackingFormat
// -preferredBufferSize : preferred (optimal) buffer size in ms // -preferredBufferSize : preferred (optimal) buffer size in ms
// -currentPacketLossRate : loss rate (network + late) (in Q14) // -currentPacketLossRate : loss rate (network + late) (in Q14)
// -currentDiscardRate : late loss rate (in Q14) // -currentDiscardRate : late loss rate (in Q14)
// -currentExpandRate : fraction (of original stream) of synthesized speech // -currentExpandRate : fraction (of original stream) of synthesized
// inserted through expansion (in Q14) // speech inserted through expansion (in Q14)
// -currentPreemptiveRate : fraction of synthesized speech inserted through // -currentPreemptiveRate : fraction of synthesized speech inserted through
// pre-emptive expansion (in Q14) // pre-emptive expansion (in Q14)
// -currentAccelerateRate : fraction of data removed through acceleration (in Q14) // -currentAccelerateRate : fraction of data removed through acceleration
typedef struct // (in Q14)
{ typedef struct {
WebRtc_UWord16 currentBufferSize; WebRtc_UWord16 currentBufferSize;
WebRtc_UWord16 preferredBufferSize; WebRtc_UWord16 preferredBufferSize;
WebRtc_UWord16 currentPacketLossRate; WebRtc_UWord16 currentPacketLossRate;
WebRtc_UWord16 currentDiscardRate; WebRtc_UWord16 currentDiscardRate;
WebRtc_UWord16 currentExpandRate; WebRtc_UWord16 currentExpandRate;
WebRtc_UWord16 currentPreemptiveRate; WebRtc_UWord16 currentPreemptiveRate;
WebRtc_UWord16 currentAccelerateRate; WebRtc_UWord16 currentAccelerateRate;
} ACMNetworkStatistics; } ACMNetworkStatistics;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -178,50 +170,59 @@ typedef struct
// -jbMinSize : smallest Jitter Buffer size during call in ms // -jbMinSize : smallest Jitter Buffer size during call in ms
// -jbMaxSize : largest Jitter Buffer size during call in ms // -jbMaxSize : largest Jitter Buffer size during call in ms
// -jbAvgSize : the average JB size, measured over time - ms // -jbAvgSize : the average JB size, measured over time - ms
// -jbChangeCount : number of times the Jitter Buffer changed (using Accelerate or Pre-emptive Expand) // -jbChangeCount : number of times the Jitter Buffer changed (using
// Accelerate or Pre-emptive Expand)
// -lateLossMs : amount (in ms) of audio data received late // -lateLossMs : amount (in ms) of audio data received late
// -accelerateMs : milliseconds removed to reduce jitter buffer size // -accelerateMs : milliseconds removed to reduce jitter buffer size
// -flushedMs : milliseconds discarded through buffer flushing // -flushedMs : milliseconds discarded through buffer flushing
// -generatedSilentMs : milliseconds of generated silence // -generatedSilentMs : milliseconds of generated silence
// -interpolatedVoiceMs : milliseconds of synthetic audio data (non-background noise) // -interpolatedVoiceMs : milliseconds of synthetic audio data
// -interpolatedSilentMs : milliseconds of synthetic audio data (background noise level) // (non-background noise)
// -numExpandTiny : count of tiny expansions in output audio less than 250 ms*/ // -interpolatedSilentMs : milliseconds of synthetic audio data (background
// -numExpandSmall : count of small expansions in output audio 250 to 500 ms*/ // noise level)
// -numExpandMedium : count of medium expansions in output audio 500 to 2000 ms*/ // -numExpandTiny : count of tiny expansions in output audio less
// -numExpandLong : count of long expansions in output audio longer than 2000 // than 250 ms
// -numExpandSmall : count of small expansions in output audio 250 to
// 500 ms
// -numExpandMedium : count of medium expansions in output audio 500 to
// 2000 ms
// -numExpandLong : count of long expansions in output audio longer
// than 2000
// -longestExpandDurationMs : duration of longest audio drop-out // -longestExpandDurationMs : duration of longest audio drop-out
// -countIAT500ms : count of times we got small network outage (inter-arrival time in [500, 1000) ms) // -countIAT500ms : count of times we got small network outage
// -countIAT1000ms : count of times we got medium network outage (inter-arrival time in [1000, 2000) ms) // (inter-arrival time in [500, 1000) ms)
// -countIAT2000ms : count of times we got large network outage (inter-arrival time >= 2000 ms) // -countIAT1000ms : count of times we got medium network outage
// (inter-arrival time in [1000, 2000) ms)
// -countIAT2000ms : count of times we got large network outage
// (inter-arrival time >= 2000 ms)
// -longestIATms : longest packet inter-arrival time in ms // -longestIATms : longest packet inter-arrival time in ms
// -minPacketDelayMs : min time incoming Packet "waited" to be played // -minPacketDelayMs : min time incoming Packet "waited" to be played
// -maxPacketDelayMs : max time incoming Packet "waited" to be played // -maxPacketDelayMs : max time incoming Packet "waited" to be played
// -avgPacketDelayMs : avg time incoming Packet "waited" to be played // -avgPacketDelayMs : avg time incoming Packet "waited" to be played
// //
typedef struct typedef struct {
{ WebRtc_UWord32 jbMinSize;
WebRtc_UWord32 jbMinSize; WebRtc_UWord32 jbMaxSize;
WebRtc_UWord32 jbMaxSize; WebRtc_UWord32 jbAvgSize;
WebRtc_UWord32 jbAvgSize; WebRtc_UWord32 jbChangeCount;
WebRtc_UWord32 jbChangeCount; WebRtc_UWord32 lateLossMs;
WebRtc_UWord32 lateLossMs; WebRtc_UWord32 accelerateMs;
WebRtc_UWord32 accelerateMs; WebRtc_UWord32 flushedMs;
WebRtc_UWord32 flushedMs; WebRtc_UWord32 generatedSilentMs;
WebRtc_UWord32 generatedSilentMs; WebRtc_UWord32 interpolatedVoiceMs;
WebRtc_UWord32 interpolatedVoiceMs; WebRtc_UWord32 interpolatedSilentMs;
WebRtc_UWord32 interpolatedSilentMs; WebRtc_UWord32 numExpandTiny;
WebRtc_UWord32 numExpandTiny; WebRtc_UWord32 numExpandSmall;
WebRtc_UWord32 numExpandSmall; WebRtc_UWord32 numExpandMedium;
WebRtc_UWord32 numExpandMedium; WebRtc_UWord32 numExpandLong;
WebRtc_UWord32 numExpandLong; WebRtc_UWord32 longestExpandDurationMs;
WebRtc_UWord32 longestExpandDurationMs; WebRtc_UWord32 countIAT500ms;
WebRtc_UWord32 countIAT500ms; WebRtc_UWord32 countIAT1000ms;
WebRtc_UWord32 countIAT1000ms; WebRtc_UWord32 countIAT2000ms;
WebRtc_UWord32 countIAT2000ms; WebRtc_UWord32 longestIATms;
WebRtc_UWord32 longestIATms; WebRtc_UWord32 minPacketDelayMs;
WebRtc_UWord32 minPacketDelayMs; WebRtc_UWord32 maxPacketDelayMs;
WebRtc_UWord32 maxPacketDelayMs; WebRtc_UWord32 avgPacketDelayMs;
WebRtc_UWord32 avgPacketDelayMs;
} ACMJitterStatistics; } ACMJitterStatistics;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -232,14 +233,12 @@ typedef struct
// -Fade : noise fades to zero after some time // -Fade : noise fades to zero after some time
// -Off : background noise is always zero // -Off : background noise is always zero
// //
enum ACMBackgroundNoiseMode enum ACMBackgroundNoiseMode {
{ On,
On, Fade,
Fade, Off
Off
}; };
} // namespace webrtc
} // namespace webrtc #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_INTERFACE_AUDIO_CODING_MODULE_TYPEDEFS_H_
#endif

View File

@@ -18,192 +18,131 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_AMR #ifdef WEBRTC_CODEC_AMR
// NOTE! GSM AMR is not included in the open-source package. The following // NOTE! GSM AMR is not included in the open-source package. The following
// interface file is needed: // interface file is needed:
// //
// /modules/audio_coding/codecs/amr/main/interface/amr_interface.h // /modules/audio_coding/codecs/amr/main/interface/amr_interface.h
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst); // int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst);
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst); // int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst);
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst); // int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst);
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst,
// int16_t* input, // int16_t* input,
// int16_t len, // int16_t len,
// int16_t*output, // int16_t*output,
// int16_t mode); // int16_t mode);
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst,
// int16_t dtxMode); // int16_t dtxMode);
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst, // int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst,
// int format); // int format);
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst); // int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst, // int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst,
// int format); // int format);
// void WebRtcAmr_Version(char *versionStr, short len); // void WebRtcAmr_Version(char *versionStr, short len);
#include "amr_interface.h" #include "amr_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMR #ifndef WEBRTC_CODEC_AMR
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) {
{ return;
return;
} }
ACMAMR::~ACMAMR() {
ACMAMR::~ACMAMR() return;
{
return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMAMR::InternalEncode( return -1;
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16 /* bitStreamLenByte */,
ACMAMR::DecodeSafe( WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audio */, return -1;
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
} }
WebRtc_Word16 ACMAMR::EnableDTX() {
WebRtc_Word16 return -1;
ACMAMR::EnableDTX()
{
return -1;
} }
WebRtc_Word16 ACMAMR::DisableDTX() {
WebRtc_Word16 return -1;
ACMAMR::DisableDTX()
{
return -1;
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::InternalInitEncoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::InternalInitDecoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
ACMAMR::CodecDef( const CodecInst& /* codecInst */) {
WebRtcNetEQ_CodecDef& /* codecDef */, return -1;
const CodecInst& /* codecInst */)
{
return -1;
} }
ACMGenericCodec* ACMGenericCodec* ACMAMR::CreateInstance(void) {
ACMAMR::CreateInstance(void) return NULL;
{
return NULL;
} }
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
WebRtc_Word16 return -1;
ACMAMR::InternalCreateEncoder()
{
return -1;
} }
void ACMAMR::DestructEncoderSafe() {
void return;
ACMAMR::DestructEncoderSafe()
{
return;
} }
WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
WebRtc_Word16 return -1;
ACMAMR::InternalCreateDecoder()
{
return -1;
} }
void ACMAMR::DestructDecoderSafe() {
void return;
ACMAMR::DestructDecoderSafe()
{
return;
} }
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
WebRtc_Word16 return -1;
ACMAMR::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1;
} }
void ACMAMR::InternalDestructEncoderInst(void* /* ptrInst */) {
void return;
ACMAMR::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
} }
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
WebRtc_Word16 ACMAMRPackingFormat /* packingFormat */) {
ACMAMR::SetAMREncoderPackingFormat( return -1;
ACMAMRPackingFormat /* packingFormat */)
{
return -1;
} }
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
ACMAMRPackingFormat return AMRUndefined;
ACMAMR::AMREncoderPackingFormat() const
{
return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMR::SetAMRDecoderPackingFormat( ACMAMRPackingFormat /* packingFormat */) {
ACMAMRPackingFormat /* packingFormat */) return -1;
{
return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
ACMAMR::AMRDecoderPackingFormat() const return AMRUndefined;
{
return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMR::UnregisterFromNetEqSafe(ACMNetEQ* /* netEq */,
ACMAMR::UnregisterFromNetEqSafe( WebRtc_Word16 /* payloadType */) {
ACMNetEQ* /* netEq */, return -1;
WebRtc_Word16 /* payloadType */)
{
return -1;
} }
@@ -218,377 +157,282 @@ ACMAMR::UnregisterFromNetEqSafe(
#define WEBRTC_AMR_MR102 6 #define WEBRTC_AMR_MR102 6
#define WEBRTC_AMR_MR122 7 #define WEBRTC_AMR_MR122 7
ACMAMR::ACMAMR(WebRtc_Word16 codecID): ACMAMR::ACMAMR(WebRtc_Word16 codecID)
_encoderInstPtr(NULL), : _encoderInstPtr(NULL),
_decoderInstPtr(NULL), _decoderInstPtr(NULL),
_encodingMode(-1), // invalid value _encodingMode(-1), // invalid value
_encodingRate(0) // invalid value _encodingRate(0) { // invalid value
{ _codecID = codecID;
_codecID = codecID; _hasInternalDTX = true;
_hasInternalDTX = true; _encoderPackingFormat = AMRBandwidthEfficient;
_encoderPackingFormat = AMRBandwidthEfficient; _decoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient; return;
return;
} }
ACMAMR::~ACMAMR() {
ACMAMR::~ACMAMR() if (_encoderInstPtr != NULL) {
{ WebRtcAmr_FreeEnc(_encoderInstPtr);
if(_encoderInstPtr != NULL) _encoderInstPtr = NULL;
{ }
WebRtcAmr_FreeEnc(_encoderInstPtr); if (_decoderInstPtr != NULL) {
_encoderInstPtr = NULL; WebRtcAmr_FreeDec(_decoderInstPtr);
} _decoderInstPtr = NULL;
if(_decoderInstPtr != NULL) }
{ return;
WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
return;
} }
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) {
WebRtc_Word16 vadDecision = 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 ((_encodingMode < WEBRTC_AMR_MR475) ||
(_encodingMode > WEBRTC_AMR_MR122)) {
*bitStreamLenByte = 0;
return -1;
}
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead],
_frameLenSmpl,
(WebRtc_Word16*) bitStream,
_encodingMode);
WebRtc_Word16 // Update VAD, if internal DTX is used
ACMAMR::InternalEncode( if (_hasInternalDTX && _dtxEnabled) {
WebRtc_UWord8* bitStream, if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
WebRtc_Word16* bitStreamLenByte) vadDecision = 0;
{
WebRtc_Word16 vadDecision = 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((_encodingMode < WEBRTC_AMR_MR475) || (_encodingMode > WEBRTC_AMR_MR122))
{
*bitStreamLenByte = 0;
return -1;
} }
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr, for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream, _vadLabel[n] = vadDecision;
_encodingMode);
// Update VAD, if internal DTX is used
if(_hasInternalDTX && _dtxEnabled)
{
if(*bitStreamLenByte <= (7*_frameLenSmpl/160))
{
vadDecision = 0;
}
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
{
_vadLabel[n] = vadDecision;
}
} }
// increment the read index }
_inAudioIxRead += _frameLenSmpl; // increment the read index
return *bitStreamLenByte; _inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
} }
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return 0;
}
WebRtc_Word16 WebRtc_Word16 ACMAMR::EnableDTX() {
ACMAMR::DecodeSafe( if (_dtxEnabled) {
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
// enable DTX
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) {
WebRtc_Word16 return -1;
ACMAMR::EnableDTX()
{
if(_dtxEnabled)
{
return 0;
} }
else if(_encoderExist) // check if encoder exist _dtxEnabled = true;
{
// enable DTX
if(WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0)
{
return -1;
}
_dtxEnabled = true;
return 0;
}
else
{
return -1;
}
}
WebRtc_Word16
ACMAMR::DisableDTX()
{
if(!_dtxEnabled)
{
return 0;
}
else if(_encoderExist) // check if encoder exist
{
// disable DTX
if(WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0)
{
return -1;
}
_dtxEnabled = false;
return 0;
}
else
{
// encoder doesn't exists, therefore disabling is harmless
return 0;
}
}
WebRtc_Word16
ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
status += (WebRtcAmr_EncoderInit(_encoderInstPtr,
((codecParams->enableDTX)? 1:0)) < 0)? -1:0;
status += (WebRtcAmr_EncodeBitmode(_encoderInstPtr,
_encoderPackingFormat ) < 0)? -1:0;
return (status < 0)? -1:0;
}
WebRtc_Word16
ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
WebRtc_Word16 status = (
(WebRtcAmr_DecoderInit(_decoderInstPtr) < 0)? -1:0);
status +=
WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat);
return (status < 0)? -1:0;
}
WebRtc_Word32
ACMAMR::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo:
// log error
return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AMR_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAMR, codecInst.pltype,
_decoderInstPtr, 8000);
SET_AMR_FUNCTIONS((codecDef));
return 0; return 0;
} else {
return -1;
}
} }
WebRtc_Word16 ACMAMR::DisableDTX() {
ACMGenericCodec* if (!_dtxEnabled) {
ACMAMR::CreateInstance(void)
{
return NULL;
}
WebRtc_Word16
ACMAMR::InternalCreateEncoder()
{
return WebRtcAmr_CreateEnc(&_encoderInstPtr);
}
void
ACMAMR::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcAmr_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
// there is no encoder set the following
_encoderExist = false;
_encoderInitialized = false;
_encodingMode = -1; // invalid value
_encodingRate = 0; // invalid value
}
WebRtc_Word16
ACMAMR::InternalCreateDecoder()
{
return WebRtcAmr_CreateDec(&_decoderInstPtr);
}
void
ACMAMR::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
// there is no encoder instance set the followings
_decoderExist = false;
_decoderInitialized = false;
}
WebRtc_Word16
ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate)
{
switch(rate)
{
case 4750:
_encodingMode = WEBRTC_AMR_MR475;
_encodingRate = 4750;
break;
case 5150:
_encodingMode = WEBRTC_AMR_MR515;
_encodingRate = 5150;
break;
case 5900:
_encodingMode = WEBRTC_AMR_MR59;
_encodingRate = 5900;
break;
case 6700:
_encodingMode = WEBRTC_AMR_MR67;
_encodingRate = 6700;
break;
case 7400:
_encodingMode = WEBRTC_AMR_MR74;
_encodingRate = 7400;
break;
case 7950:
_encodingMode = WEBRTC_AMR_MR795;
_encodingRate = 7950;
break;
case 10200:
_encodingMode = WEBRTC_AMR_MR102;
_encodingRate = 10200;
break;
case 12200:
_encodingMode = WEBRTC_AMR_MR122;
_encodingRate = 12200;
break;
default:
return -1;
break;
}
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist
// disable DTX
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 0) < 0) {
return -1;
}
_dtxEnabled = false;
return 0;
} else {
// encoder doesn't exists, therefore disabling is harmless
return 0;
}
} }
WebRtc_Word16 ACMAMR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
void WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
ACMAMR::InternalDestructEncoderInst( status += (WebRtcAmr_EncoderInit(
void* ptrInst) _encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
{ status += (WebRtcAmr_EncodeBitmode(
// Free the memory where ptrInst is pointing to _encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
if(ptrInst != NULL) return (status < 0) ? -1 : 0;
{
WebRtcAmr_FreeEnc((AMR_encinst_t_*)ptrInst);
}
return;
} }
WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMAMR::SetAMREncoderPackingFormat( WebRtc_Word16 status =
ACMAMRPackingFormat packingFormat) ((WebRtcAmr_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
{ status += WebRtcAmr_DecodeBitmode(_decoderInstPtr, _decoderPackingFormat);
if((packingFormat != AMRBandwidthEfficient) && return (status < 0) ? -1 : 0;
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage))
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMR Encoder packing-format.");
return -1;
}
else
{
if(WebRtcAmr_EncodeBitmode(_encoderInstPtr,
packingFormat) < 0)
{
return -1;
}
else
{
_encoderPackingFormat = packingFormat;
return 0;
}
}
} }
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
ACMAMRPackingFormat const CodecInst& codecInst) {
ACMAMR::AMREncoderPackingFormat() const if (!_decoderInitialized) {
{ // Todo:
return _encoderPackingFormat; // log error
return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AMR_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAMR, codecInst.pltype, _decoderInstPtr,
8000);
SET_AMR_FUNCTIONS((codecDef));
return 0;
} }
WebRtc_Word16 ACMGenericCodec* ACMAMR::CreateInstance(void) {
ACMAMR::SetAMRDecoderPackingFormat( return NULL;
ACMAMRPackingFormat packingFormat)
{
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage))
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMR decoder packing-format.");
return -1;
}
else
{
if(WebRtcAmr_DecodeBitmode(_decoderInstPtr,
packingFormat) < 0)
{
return -1;
}
else
{
_decoderPackingFormat = packingFormat;
return 0;
}
}
} }
ACMAMRPackingFormat WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
ACMAMR::AMRDecoderPackingFormat() const return WebRtcAmr_CreateEnc(&_encoderInstPtr);
{
return _decoderPackingFormat;
} }
WebRtc_Word16 void ACMAMR::DestructEncoderSafe() {
ACMAMR::UnregisterFromNetEqSafe( if (_encoderInstPtr != NULL) {
ACMNetEQ* netEq, WebRtcAmr_FreeEnc(_encoderInstPtr);
WebRtc_Word16 payloadType) _encoderInstPtr = NULL;
{ }
if(payloadType != _decoderParams.codecInstant.pltype) // there is no encoder set the following
{ _encoderExist = false;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _encoderInitialized = false;
"Cannot unregister codec %s given payload-type %d does not match \ _encodingMode = -1; // invalid value
the stored payload type", _encodingRate = 0; // invalid value
_decoderParams.codecInstant.plname, }
payloadType,
_decoderParams.codecInstant.pltype); WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
return -1; return WebRtcAmr_CreateDec(&_decoderInstPtr);
}
void ACMAMR::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) {
WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
// there is no encoder instance set the followings
_decoderExist = false;
_decoderInitialized = false;
}
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 rate) {
switch (rate) {
case 4750: {
_encodingMode = WEBRTC_AMR_MR475;
_encodingRate = 4750;
break;
} }
return netEq->RemoveCodec(kDecoderAMR); case 5150: {
_encodingMode = WEBRTC_AMR_MR515;
_encodingRate = 5150;
break;
}
case 5900: {
_encodingMode = WEBRTC_AMR_MR59;
_encodingRate = 5900;
break;
}
case 6700: {
_encodingMode = WEBRTC_AMR_MR67;
_encodingRate = 6700;
break;
}
case 7400: {
_encodingMode = WEBRTC_AMR_MR74;
_encodingRate = 7400;
break;
}
case 7950: {
_encodingMode = WEBRTC_AMR_MR795;
_encodingRate = 7950;
break;
}
case 10200: {
_encodingMode = WEBRTC_AMR_MR102;
_encodingRate = 10200;
break;
}
case 12200: {
_encodingMode = WEBRTC_AMR_MR122;
_encodingRate = 12200;
break;
}
default: {
return -1;
}
}
return 0;
}
void ACMAMR::InternalDestructEncoderInst(void* ptrInst) {
// Free the memory where ptrInst is pointing to
if (ptrInst != NULL) {
WebRtcAmr_FreeEnc(reinterpret_cast<AMR_encinst_t_*>(ptrInst));
}
return;
}
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat packingFormat) {
if ((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMR Encoder packing-format.");
return -1;
} else {
if (WebRtcAmr_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) {
return -1;
} else {
_encoderPackingFormat = packingFormat;
return 0;
}
}
}
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
return _encoderPackingFormat;
}
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMRPackingFormat packingFormat) {
if ((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMR decoder packing-format.");
return -1;
} else {
if (WebRtcAmr_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) {
return -1;
} else {
_decoderPackingFormat = packingFormat;
return 0;
}
}
}
ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
return _decoderPackingFormat;
}
WebRtc_Word16 ACMAMR::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType) {
if (payloadType != _decoderParams.codecInstant.pltype) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not "
"match the stored payload type",
_decoderParams.codecInstant.plname, payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderAMR);
} }
#endif #endif
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_AMR_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#define ACM_AMR_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -21,76 +21,66 @@ namespace webrtc {
enum ACMAMRPackingFormat; enum ACMAMRPackingFormat;
class ACMAMR : public ACMGenericCodec class ACMAMR: public ACMGenericCodec {
{ public:
public: ACMAMR(WebRtc_Word16 codecID);
ACMAMR(WebRtc_Word16 codecID); ~ACMAMR();
~ACMAMR(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMREncoderPackingFormat() const; WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMRDecoderPackingFormat( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMRDecoderPackingFormat() const; WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
protected: ACMAMRPackingFormat AMREncoderPackingFormat() const;
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word16 SetAMRDecoderPackingFormat(
WebRtcNetEQ_CodecDef& codecDef, const ACMAMRPackingFormat packingFormat);
const CodecInst& codecInst);
void DestructEncoderSafe(); ACMAMRPackingFormat AMRDecoderPackingFormat() const;
void DestructDecoderSafe(); protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( void DestructEncoderSafe();
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
AMR_encinst_t_* _encoderInstPtr; void DestructDecoderSafe();
AMR_decinst_t_* _decoderInstPtr;
WebRtc_Word16 _encodingMode; WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat; WebRtc_Word16 InternalCreateDecoder();
ACMAMRPackingFormat _decoderPackingFormat;
void InternalDestructEncoderInst(void* ptrInst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
AMR_encinst_t_* _encoderInstPtr;
AMR_decinst_t_* _decoderInstPtr;
WebRtc_Word16 _encodingMode;
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat;
ACMAMRPackingFormat _decoderPackingFormat;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_AMR_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_

View File

@@ -18,176 +18,130 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_AMRWB #ifdef WEBRTC_CODEC_AMRWB
// NOTE! GSM AMR-wb is not included in the open-source package. The // NOTE! GSM AMR-wb is not included in the open-source package. The
// following interface file is needed: // following interface file is needed:
// //
// /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h // /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h
// //
// The API in the header file should match the one below. // The API in the header file should match the one below.
// //
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst); // int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst);
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst); // int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst);
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst); // int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst);
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input, // int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input,
// int16_t len, int16_t*output, int16_t mode); // int16_t len, int16_t* output, int16_t mode);
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst, // int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst,
// int16_t dtxMode); // int16_t dtxMode);
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst, // int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst,
// int format); // int format);
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst); // int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst, // int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst,
// int format); // int format);
// void WebRtcAmrWb_Version(char *versionStr, short len); // void WebRtcAmrWb_Version(char *versionStr, short len);
#include "amrwb_interface.h" #include "amrwb_interface.h"
#endif #endif
namespace webrtc { namespace webrtc {
#ifndef WEBRTC_CODEC_AMRWB #ifndef WEBRTC_CODEC_AMRWB
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) {
{ return;
return;
} }
ACMAMRwb::~ACMAMRwb() ACMAMRwb::~ACMAMRwb() {
{ return;
return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */, return -1;
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::DecodeSafe( WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audio */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16* /* audio */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audioSamples */, return -1;
WebRtc_Word8* /* speechType */)
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::EnableDTX() {
ACMAMRwb::EnableDTX() return -1;
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DisableDTX() {
ACMAMRwb::DisableDTX() return -1;
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
ACMAMRwb::InternalInitEncoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */) return -1;
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
ACMAMRwb::InternalInitDecoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */) return -1;
{
return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
ACMAMRwb::CodecDef( const CodecInst& /* codecInst */) {
WebRtcNetEQ_CodecDef& /* codecDef */, return -1;
const CodecInst& /* codecInst */)
{
return -1;
} }
ACMGenericCodec* ACMGenericCodec*
ACMAMRwb::CreateInstance(void) ACMAMRwb::CreateInstance(void) {
{ return NULL;
return NULL;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
return -1;
WebRtc_Word16
ACMAMRwb::InternalCreateEncoder()
{
return -1;
} }
void void ACMAMRwb::DestructEncoderSafe() {
ACMAMRwb::DestructEncoderSafe() return;
{
return;
} }
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
WebRtc_Word16 return -1;
ACMAMRwb::InternalCreateDecoder()
{
return -1;
} }
void void ACMAMRwb::DestructDecoderSafe() {
ACMAMRwb::DestructDecoderSafe() return;
{
return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
ACMAMRwb::SetBitRateSafe( return -1;
const WebRtc_Word32 /* rate */)
{
return -1;
} }
void void ACMAMRwb::InternalDestructEncoderInst(void* /* ptrInst */) {
ACMAMRwb::InternalDestructEncoderInst( return;
void* /* ptrInst */)
{
return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRwb::SetAMRwbEncoderPackingFormat( ACMAMRPackingFormat /* packingFormat */) {
ACMAMRPackingFormat /* packingFormat */) return -1;
{
return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
ACMAMRwb::AMRwbEncoderPackingFormat() const return AMRUndefined;
{
return AMRUndefined;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) ACMAMRPackingFormat /* packingFormat */) {
{ return -1;
return -1;
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
ACMAMRwb::AMRwbDecoderPackingFormat() const return AMRUndefined;
{
return AMRUndefined;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::UnregisterFromNetEqSafe(
ACMAMRwb::UnregisterFromNetEqSafe( ACMNetEQ* /* netEq */,
ACMNetEQ* /* netEq */, WebRtc_Word16 /* payloadType */) {
WebRtc_Word16 /* payloadType */) return -1;
{
return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
@@ -202,387 +156,288 @@ ACMAMRwb::UnregisterFromNetEqSafe(
#define AMRWB_MODE_23k 7 #define AMRWB_MODE_23k 7
#define AMRWB_MODE_24k 8 #define AMRWB_MODE_24k 8
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID): ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID)
_encoderInstPtr(NULL), : _encoderInstPtr(NULL),
_decoderInstPtr(NULL), _decoderInstPtr(NULL),
_encodingMode(-1), // invalid value _encodingMode(-1), // invalid value
_encodingRate(0) // invalid value _encodingRate(0) { // invalid value
{ _codecID = codecID;
_codecID = codecID; _hasInternalDTX = true;
_hasInternalDTX = true; _encoderPackingFormat = AMRBandwidthEfficient;
_encoderPackingFormat = AMRBandwidthEfficient; _decoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient; return;
return;
} }
ACMAMRwb::~ACMAMRwb() ACMAMRwb::~ACMAMRwb() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL) WebRtcAmrWb_FreeEnc(_encoderInstPtr);
{ _encoderInstPtr = NULL;
WebRtcAmrWb_FreeEnc(_encoderInstPtr); }
_encoderInstPtr = NULL; if (_decoderInstPtr != NULL) {
} WebRtcAmrWb_FreeDec(_decoderInstPtr);
if(_decoderInstPtr != NULL) _decoderInstPtr = NULL;
{ }
WebRtcAmrWb_FreeDec(_decoderInstPtr); return;
_decoderInstPtr = NULL;
}
return;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* bitStream,
ACMAMRwb::InternalEncode( WebRtc_Word16* bitStreamLenByte) {
WebRtc_UWord8* bitStream, WebRtc_Word16 vadDecision = 1;
WebRtc_Word16* bitStreamLenByte) // sanity check, if the rate is set correctly. we might skip this
{ // sanity check. if rate is not set correctly, initialization flag
WebRtc_Word16 vadDecision = 1; // should be false and should not be here.
// sanity check, if the rate is set correctly. we might skip this if ((_encodingMode < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) {
// sanity check. if rate is not set correctly, initialization flag *bitStreamLenByte = 0;
// should be false and should not be here. return -1;
if((_encodingMode < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) }
{ *bitStreamLenByte = WebRtcAmrWb_Encode(_encoderInstPtr,
*bitStreamLenByte = 0; &_inAudio[_inAudioIxRead],
return -1; _frameLenSmpl,
(WebRtc_Word16*) bitStream,
_encodingMode);
// Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) {
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
vadDecision = 0;
} }
*bitStreamLenByte = for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
WebRtcAmrWb_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], _vadLabel[n] = vadDecision;
_frameLenSmpl, (WebRtc_Word16*)bitStream, _encodingMode);
// Update VAD, if internal DTX is used
if(_hasInternalDTX && _dtxEnabled)
{
if (*bitStreamLenByte <= (7*_frameLenSmpl/160))
{
vadDecision = 0;
}
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
{
_vadLabel[n] = vadDecision;
}
} }
// increment the read index this tell the caller that how far }
// we have gone forward in reading the audio buffer // increment the read index this tell the caller that how far
_inAudioIxRead += _frameLenSmpl; // we have gone forward in reading the audio buffer
return *bitStreamLenByte; _inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMAMRwb::DecodeSafe( WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audio */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16* /* audio */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audioSamples */, return 0;
WebRtc_Word8* /* speechType */) }
{
WebRtc_Word16 ACMAMRwb::EnableDTX() {
if (_dtxEnabled) {
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
// enable DTX
WebRtc_Word16 if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) {
ACMAMRwb::EnableDTX() return -1;
{
if(_dtxEnabled)
{
return 0;
} }
else if(_encoderExist) // check if encoder exist _dtxEnabled = true;
{
// enable DTX
if(WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0)
{
return -1;
}
_dtxEnabled = true;
return 0;
}
else
{
return -1;
}
}
WebRtc_Word16
ACMAMRwb::DisableDTX()
{
if(!_dtxEnabled)
{
return 0;
}
else if(_encoderExist) // check if encoder exist
{
// disable DTX
if(WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0)
{
return -1;
}
_dtxEnabled = false;
return 0;
}
else
{
// encoder doesn't exists, therefore disabling is harmless
return 0;
}
}
WebRtc_Word16
ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// sanity check
if (_encoderInstPtr == NULL)
{
return -1;
}
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
status += (WebRtcAmrWb_EncoderInit(
_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)? -1:0;
status += (WebRtcAmrWb_EncodeBitmode(
_encoderInstPtr, _encoderPackingFormat ) < 0)? -1:0;
return (status < 0)? -1:0;
}
WebRtc_Word16
ACMAMRwb::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(
_decoderInstPtr, _decoderPackingFormat);
status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0)? -1:0);
return (status < 0)? -1:0;
}
WebRtc_Word32
ACMAMRwb::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo:
// log error
return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AMRWB_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAMRWB, codecInst.pltype,
_decoderInstPtr, 16000);
SET_AMRWB_FUNCTIONS((codecDef));
return 0; return 0;
} else {
return -1;
}
} }
ACMGenericCodec* WebRtc_Word16 ACMAMRwb::DisableDTX() {
ACMAMRwb::CreateInstance(void) if (!_dtxEnabled) {
{
return NULL;
}
WebRtc_Word16
ACMAMRwb::InternalCreateEncoder()
{
return WebRtcAmrWb_CreateEnc(&_encoderInstPtr);
}
void
ACMAMRwb::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
// there is no encoder set the following
_encoderExist = false;
_encoderInitialized = false;
_encodingMode = -1; // invalid value
_encodingRate = 0;
}
WebRtc_Word16
ACMAMRwb::InternalCreateDecoder()
{
return WebRtcAmrWb_CreateDec(&_decoderInstPtr);
}
void
ACMAMRwb::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
// there is no encoder instance set the followings
_decoderExist = false;
_decoderInitialized = false;
}
WebRtc_Word16
ACMAMRwb::SetBitRateSafe(
const WebRtc_Word32 rate)
{
switch(rate)
{
case 7000:
{
_encodingMode = AMRWB_MODE_7k;
_encodingRate = 7000;
break;
}
case 9000:
{
_encodingMode = AMRWB_MODE_9k;
_encodingRate = 9000;
break;
}
case 12000:
{
_encodingMode = AMRWB_MODE_12k;
_encodingRate = 12000;
break;
}
case 14000:
{
_encodingMode = AMRWB_MODE_14k;
_encodingRate = 14000;
break;
}
case 16000:
{
_encodingMode = AMRWB_MODE_16k;
_encodingRate = 16000;
break;
}
case 18000:
{
_encodingMode = AMRWB_MODE_18k;
_encodingRate = 18000;
break;
}
case 20000:
{
_encodingMode = AMRWB_MODE_20k;
_encodingRate = 20000;
break;
}
case 23000:
{
_encodingMode = AMRWB_MODE_23k;
_encodingRate = 23000;
break;
}
case 24000:
{
_encodingMode = AMRWB_MODE_24k;
_encodingRate = 24000;
break;
}
default:
{
return -1;
break;
}
}
return 0; return 0;
} else if (_encoderExist) { // check if encoder exist
// disable DTX
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 0) < 0) {
return -1;
}
_dtxEnabled = false;
return 0;
} else {
// encoder doesn't exists, therefore disabling is harmless
return 0;
}
} }
void WebRtc_Word16 ACMAMRwb::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
ACMAMRwb::InternalDestructEncoderInst( // sanity check
void* ptrInst) if (_encoderInstPtr == NULL) {
{ return -1;
if(ptrInst != NULL) }
{
WebRtcAmrWb_FreeEnc((AMRWB_encinst_t_*)ptrInst); WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
} status += (WebRtcAmrWb_EncoderInit(
return; _encoderInstPtr, ((codecParams->enableDTX) ? 1 : 0)) < 0) ? -1 : 0;
status += (WebRtcAmrWb_EncodeBitmode(
_encoderInstPtr, _encoderPackingFormat) < 0) ? -1 : 0;
return (status < 0) ? -1 : 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
ACMAMRwb::SetAMRwbEncoderPackingFormat( WebRtcACMCodecParams* /* codecParams */) {
ACMAMRPackingFormat packingFormat) WebRtc_Word16 status = WebRtcAmrWb_DecodeBitmode(_decoderInstPtr,
{ _decoderPackingFormat);
if((packingFormat != AMRBandwidthEfficient) && status += ((WebRtcAmrWb_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
(packingFormat != AMROctetAlligned) && return (status < 0) ? -1 : 0;
(packingFormat != AMRFileStorage))
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMRwb encoder packing-format.");
return -1;
}
else
{
if(WebRtcAmrWb_EncodeBitmode(_encoderInstPtr,
packingFormat) < 0)
{
return -1;
}
else
{
_encoderPackingFormat = packingFormat;
return 0;
}
}
} }
ACMAMRPackingFormat WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
ACMAMRwb::AMRwbEncoderPackingFormat() const const CodecInst& codecInst) {
{ if (!_decoderInitialized) {
return _encoderPackingFormat; return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AMRWB_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAMRWB, codecInst.pltype, _decoderInstPtr,
16000);
SET_AMRWB_FUNCTIONS((codecDef));
return 0;
}
ACMGenericCodec* ACMAMRwb::CreateInstance(void) {
return NULL;
}
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
return WebRtcAmrWb_CreateEnc(&_encoderInstPtr);
}
void ACMAMRwb::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) {
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
// there is no encoder set the following
_encoderExist = false;
_encoderInitialized = false;
_encodingMode = -1; // invalid value
_encodingRate = 0;
}
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
return WebRtcAmrWb_CreateDec(&_decoderInstPtr);
}
void ACMAMRwb::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) {
WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
// there is no encoder instance set the followings
_decoderExist = false;
_decoderInitialized = false;
}
WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 rate) {
switch (rate) {
case 7000: {
_encodingMode = AMRWB_MODE_7k;
_encodingRate = 7000;
break;
}
case 9000: {
_encodingMode = AMRWB_MODE_9k;
_encodingRate = 9000;
break;
}
case 12000: {
_encodingMode = AMRWB_MODE_12k;
_encodingRate = 12000;
break;
}
case 14000: {
_encodingMode = AMRWB_MODE_14k;
_encodingRate = 14000;
break;
}
case 16000: {
_encodingMode = AMRWB_MODE_16k;
_encodingRate = 16000;
break;
}
case 18000: {
_encodingMode = AMRWB_MODE_18k;
_encodingRate = 18000;
break;
}
case 20000: {
_encodingMode = AMRWB_MODE_20k;
_encodingRate = 20000;
break;
}
case 23000: {
_encodingMode = AMRWB_MODE_23k;
_encodingRate = 23000;
break;
}
case 24000: {
_encodingMode = AMRWB_MODE_24k;
_encodingRate = 24000;
break;
}
default: {
return -1;
}
}
return 0;
}
void ACMAMRwb::InternalDestructEncoderInst(void* ptrInst) {
if (ptrInst != NULL) {
WebRtcAmrWb_FreeEnc(static_cast<AMRWB_encinst_t_*>(ptrInst));
}
return;
}
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRPackingFormat packingFormat) {
if ((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMRwb encoder packing-format.");
return -1;
} else {
if (WebRtcAmrWb_EncodeBitmode(_encoderInstPtr, packingFormat) < 0) {
return -1;
} else {
_encoderPackingFormat = packingFormat;
return 0;
}
}
}
ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
return _encoderPackingFormat;
} }
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat( WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat packingFormat) ACMAMRPackingFormat packingFormat) {
{ if ((packingFormat != AMRBandwidthEfficient) &&
if((packingFormat != AMRBandwidthEfficient) && (packingFormat != AMROctetAlligned) &&
(packingFormat != AMROctetAlligned) && (packingFormat != AMRFileStorage)) {
(packingFormat != AMRFileStorage)) WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
{ "Invalid AMRwb decoder packing-format.");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, return -1;
"Invalid AMRwb decoder packing-format."); } else {
return -1; if (WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) {
} return -1;
else } else {
{ _decoderPackingFormat = packingFormat;
if(WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, return 0;
packingFormat) < 0)
{
return -1;
}
else
{
_decoderPackingFormat = packingFormat;
return 0;
}
} }
}
} }
ACMAMRPackingFormat ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
ACMAMRwb::AMRwbDecoderPackingFormat() const return _decoderPackingFormat;
{
return _decoderPackingFormat;
} }
WebRtc_Word16 WebRtc_Word16 ACMAMRwb::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMAMRwb::UnregisterFromNetEqSafe( WebRtc_Word16 payloadType) {
ACMNetEQ* netEq, if (payloadType != _decoderParams.codecInstant.pltype) {
WebRtc_Word16 payloadType) WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
{ "Cannot unregister codec %s given payload-type %d does not"
if(payloadType != _decoderParams.codecInstant.pltype) "match the stored payload type",
{ _decoderParams.codecInstant.plname, payloadType,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _decoderParams.codecInstant.pltype);
"Cannot unregister codec %s given payload-type %d does not match \ return -1;
the stored payload type", }
_decoderParams.codecInstant.plname, return netEq->RemoveCodec(kDecoderAMRWB);
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderAMRWB);
} }
#endif #endif

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_AMRWB_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#define ACM_AMRWB_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -21,77 +21,67 @@ namespace webrtc {
enum ACMAMRPackingFormat; enum ACMAMRPackingFormat;
class ACMAMRwb : public ACMGenericCodec class ACMAMRwb: public ACMGenericCodec {
{ public:
public: ACMAMRwb(WebRtc_Word16 codecID);
ACMAMRwb(WebRtc_Word16 codecID); ~ACMAMRwb();
~ACMAMRwb(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMRwbEncoderPackingFormat( WebRtc_Word16 SetAMRwbEncoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMRwbEncoderPackingFormat() const; ACMAMRPackingFormat AMRwbEncoderPackingFormat() const;
WebRtc_Word16 SetAMRwbDecoderPackingFormat( WebRtc_Word16 SetAMRwbDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat); const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const; ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audio, WebRtc_Word8* speechType);
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 InternalCreateDecoder();
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe( void InternalDestructEncoderInst(void* ptrInst);
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
AMRWB_encinst_t_* _encoderInstPtr; WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
AMRWB_decinst_t_* _decoderInstPtr;
WebRtc_Word16 _encodingMode; WebRtc_Word16 EnableDTX();
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat; WebRtc_Word16 DisableDTX();
ACMAMRPackingFormat _decoderPackingFormat;
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
AMRWB_encinst_t_* _encoderInstPtr;
AMRWB_decinst_t_* _decoderInstPtr;
WebRtc_Word16 _encodingMode;
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat;
ACMAMRPackingFormat _decoderPackingFormat;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_AMRWB_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_

View File

@@ -17,197 +17,141 @@
#include "webrtc_neteq.h" #include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
namespace webrtc namespace webrtc {
{
ACMCNG::ACMCNG(WebRtc_Word16 codecID) ACMCNG::ACMCNG(WebRtc_Word16 codecID) {
{ _encoderInstPtr = NULL;
_decoderInstPtr = NULL;
_codecID = codecID;
_sampFreqHz = ACMCodecDB::CodecFreq(_codecID);
return;
}
ACMCNG::~ACMCNG() {
if (_encoderInstPtr != NULL) {
WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
}
if (_decoderInstPtr != NULL) {
WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
_codecID = codecID; }
_sampFreqHz = ACMCodecDB::CodecFreq(_codecID); return;
return;
} }
ACMCNG::~ACMCNG()
{
if(_encoderInstPtr != NULL)
{
WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
if(_decoderInstPtr != NULL)
{
WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
return;
}
// CNG is not like a regular encoder, this function // CNG is not like a regular encoder, this function
// should not be called normally // should not be called normally
// instead the following function is called from inside // instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX // ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16 WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitStream */,
ACMCNG::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */, return -1;
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMCNG::DecodeSafe( WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audio */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16* /* audio */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audioSamples */, return 0;
WebRtc_Word8* /* speechType */)
{
return 0;
} }
// CNG is not like a regular encoder, // CNG is not like a regular encoder,
// this function should not be called normally // this function should not be called normally
// instead the following function is called from inside // instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX // ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16 WebRtc_Word16 ACMCNG::InternalInitEncoder(
ACMCNG::InternalInitEncoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */) return -1;
{ }
WebRtc_Word16 ACMCNG::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return WebRtcCng_InitDec(_decoderInstPtr);
}
WebRtc_Word32 ACMCNG::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) {
if (!_decoderInitialized) {
// TODO (tlegrand): log error
return -1; return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_CNG_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's
// database.
if (_sampFreqHz == 8000 || _sampFreqHz == 16000 || _sampFreqHz == 32000) {
SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype,
_decoderInstPtr, _sampFreqHz);
SET_CNG_FUNCTIONS((codecDef));
return 0;
} else {
return -1;
}
} }
ACMGenericCodec* ACMCNG::CreateInstance(void) {
WebRtc_Word16 return NULL;
ACMCNG::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return WebRtcCng_InitDec(_decoderInstPtr);
} }
WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
WebRtc_Word32 if (WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) {
ACMCNG::CodecDef( _encoderInstPtr = NULL;
WebRtcNetEQ_CodecDef& codecDef, return -1;
const CodecInst& codecInst) } else {
{ return 0;
if (!_decoderInitialized) }
{
// TODO (tlegrand): log error
return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_CNG_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's
// database.
if (_sampFreqHz == 8000 || _sampFreqHz == 16000 || _sampFreqHz == 32000)
{
SET_CODEC_PAR((codecDef), kDecoderCNG, codecInst.pltype,
_decoderInstPtr, _sampFreqHz);
SET_CNG_FUNCTIONS((codecDef));
return 0;
}
else
{
return -1;
}
} }
void ACMCNG::DestructEncoderSafe() {
ACMGenericCodec* ACMCNG::CreateInstance(void) if (_encoderInstPtr != NULL) {
{ WebRtcCng_FreeEnc(_encoderInstPtr);
return NULL; _encoderInstPtr = NULL;
}
_encoderExist = false;
_encoderInitialized = false;
} }
WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
WebRtc_Word16 if (WebRtcCng_CreateDec(&_decoderInstPtr) < 0) {
ACMCNG::InternalCreateEncoder() _decoderInstPtr = NULL;
{ return -1;
if(WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) } else {
{ return 0;
_encoderInstPtr = NULL; }
return -1;
}
else
{
return 0;
}
} }
void ACMCNG::DestructDecoderSafe() {
void if (_decoderInstPtr != NULL) {
ACMCNG::DestructEncoderSafe() WebRtcCng_FreeDec(_decoderInstPtr);
{ _decoderInstPtr = NULL;
if(_encoderInstPtr != NULL) }
{ _decoderExist = false;
WebRtcCng_FreeEnc(_encoderInstPtr); _decoderInitialized = false;
_encoderInstPtr = NULL;
}
_encoderExist = false;
_encoderInitialized = false;
} }
void ACMCNG::InternalDestructEncoderInst(void* ptrInst) {
WebRtc_Word16 if (ptrInst != NULL) {
ACMCNG::InternalCreateDecoder() WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptrInst));
{ }
if(WebRtcCng_CreateDec(&_decoderInstPtr) < 0) return;
{
_decoderInstPtr = NULL;
return -1;
}
else
{
return 0;
}
} }
WebRtc_Word16 ACMCNG::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
void WebRtc_Word16 payloadType) {
ACMCNG::DestructDecoderSafe() if (payloadType != _decoderParams.codecInstant.pltype) {
{ WEBRTC_TRACE(
if(_decoderInstPtr != NULL) webrtc::kTraceError,
{ webrtc::kTraceAudioCoding,
WebRtcCng_FreeDec(_decoderInstPtr); _uniqueID,
_decoderInstPtr = NULL; "Cannot unregister codec %s given payload-type %d does not "
} "match the stored payload type",
_decoderExist = false; _decoderParams.codecInstant.plname, payloadType,
_decoderInitialized = false; _decoderParams.codecInstant.pltype);
} return -1;
}
return netEq->RemoveCodec(kDecoderCNG);
void
ACMCNG::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcCng_FreeEnc((CNG_enc_inst*)ptrInst);
}
return;
}
WebRtc_Word16
ACMCNG::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
if(payloadType != _decoderParams.codecInstant.pltype)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderCNG);
} }
} // namespace webrtc } // namespace webrtc

View File

@@ -8,80 +8,66 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_CNG_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#define ACM_CNG_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
// forward declaration // forward declaration
struct WebRtcCngEncInst; struct WebRtcCngEncInst;
struct WebRtcCngDecInst; struct WebRtcCngDecInst;
namespace webrtc namespace webrtc {
{
class ACMCNG : public ACMGenericCodec class ACMCNG: public ACMGenericCodec {
{ public:
public: ACMCNG(WebRtc_Word16 codecID);
ACMCNG(WebRtc_Word16 codecID); ~ACMCNG();
~ACMCNG(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audio, WebRtc_Word8* speechType);
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 EnableDTX() WebRtc_Word16 EnableDTX() {
{ return -1;
return -1; }
}
WebRtc_Word16 DisableDTX() WebRtc_Word16 DisableDTX() {
{ return -1;
return -1; }
}
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
ACMNetEQ* netEq, WebRtc_Word16 payloadType);
WebRtc_Word16 payloadType);
WebRtcCngEncInst* _encoderInstPtr; WebRtcCngEncInst* _encoderInstPtr;
WebRtcCngDecInst* _decoderInstPtr; WebRtcCngDecInst* _decoderInstPtr;
WebRtc_Word16 _sampFreqHz; WebRtc_Word16 _sampFreqHz;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_CNG_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef WEBRTC_ACM_COMMON_DEFS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#define WEBRTC_ACM_COMMON_DEFS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#include <string.h> #include <string.h>
@@ -18,23 +18,21 @@
#include "engine_configurations.h" #include "engine_configurations.h"
#include "typedefs.h" #include "typedefs.h"
// Checks for enabled codecs, we prevent enabling codecs which are not // Checks for enabled codecs, we prevent enabling codecs which are not
// compatible. // compatible.
#if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX)) #if ((defined WEBRTC_CODEC_ISAC) && (defined WEBRTC_CODEC_ISACFX))
# error iSAC and iSACFX codecs cannot be enabled at the same time #error iSAC and iSACFX codecs cannot be enabled at the same time
#endif #endif
#ifdef WIN32 #ifdef WIN32
// OS-dependent case-insensitive string comparison // OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::_stricmp(x,y) #define STR_CASE_CMP(x,y) ::_stricmp(x,y)
#else #else
// OS-dependent case-insensitive string comparison // OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::strcasecmp(x,y) #define STR_CASE_CMP(x,y) ::strcasecmp(x,y)
#endif #endif
namespace webrtc namespace webrtc {
{
// 60 ms is the maximum block size we support. An extra 20 ms is considered // 60 ms is the maximum block size we support. An extra 20 ms is considered
// for safety if process() method is not called when it should be, i.e. we // for safety if process() method is not called when it should be, i.e. we
@@ -46,16 +44,16 @@ namespace webrtc
// audio if the sampling frequency is 8000 Hz (80 samples per block). // audio if the sampling frequency is 8000 Hz (80 samples per block).
// Therefore, The size of the buffer where we keep timestamps // Therefore, The size of the buffer where we keep timestamps
// is defined as follows // is defined as follows
#define TIMESTAMP_BUFFER_SIZE_W32 AUDIO_BUFFER_SIZE_W16/80 #define TIMESTAMP_BUFFER_SIZE_W32 (AUDIO_BUFFER_SIZE_W16/80)
// The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo // The maximum size of a payload, that is 60 ms of PCM-16 @ 32 kHz stereo
#define MAX_PAYLOAD_SIZE_BYTE 7680 #define MAX_PAYLOAD_SIZE_BYTE 7680
// General codec specific defines // General codec specific defines
#define ISACWB_DEFAULT_RATE 32000 const int kIsacWbDefaultRate = 32000;
#define ISACSWB_DEFAULT_RATE 56000 const int kIsacSwbDefaultRate = 56000;
#define ISACWB_PAC_SIZE 480 const int kIsacPacSize480 = 480;
#define ISACSWB_PAC_SIZE 960 const int kIsacPacSize960 = 960;
// An encoded bit-stream is labeled by one of the following enumerators. // An encoded bit-stream is labeled by one of the following enumerators.
// //
@@ -66,14 +64,13 @@ namespace webrtc
// kPassiveDTXWB : Passive audio frame coded by wide-band CN. // kPassiveDTXWB : Passive audio frame coded by wide-band CN.
// kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN. // kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN.
// //
enum WebRtcACMEncodingType enum WebRtcACMEncodingType {
{ kNoEncoding,
kNoEncoding, kActiveNormalEncoded,
kActiveNormalEncoded, kPassiveNormalEncoded,
kPassiveNormalEncoded, kPassiveDTXNB,
kPassiveDTXNB, kPassiveDTXWB,
kPassiveDTXWB, kPassiveDTXSWB
kPassiveDTXSWB
}; };
// A structure which contains codec parameters. For instance, used when // A structure which contains codec parameters. For instance, used when
@@ -85,12 +82,11 @@ enum WebRtcACMEncodingType
// enableVAD : set true to enable VAD. // enableVAD : set true to enable VAD.
// vadMode : VAD mode, c.f. audio_coding_module_typedefs.h // vadMode : VAD mode, c.f. audio_coding_module_typedefs.h
// for possible values. // for possible values.
struct WebRtcACMCodecParams struct WebRtcACMCodecParams {
{ CodecInst codecInstant;
CodecInst codecInstant; bool enableDTX;
bool enableDTX; bool enableVAD;
bool enableVAD; ACMVADMode vadMode;
ACMVADMode vadMode;
}; };
// A structure that encapsulates audio buffer and related parameters // A structure that encapsulates audio buffer and related parameters
@@ -104,17 +100,16 @@ struct WebRtcACMCodecParams
// lastTimestamp : same as ACMGenericCodec::_lastTimestamp // lastTimestamp : same as ACMGenericCodec::_lastTimestamp
// lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp // lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp
// //
struct WebRtcACMAudioBuff struct WebRtcACMAudioBuff {
{ WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16];
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16]; WebRtc_Word16 inAudioIxRead;
WebRtc_Word16 inAudioIxRead; WebRtc_Word16 inAudioIxWrite;
WebRtc_Word16 inAudioIxWrite; WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32];
WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32]; WebRtc_Word16 inTimestampIxWrite;
WebRtc_Word16 inTimestampIxWrite; WebRtc_UWord32 lastTimestamp;
WebRtc_UWord32 lastTimestamp; WebRtc_UWord32 lastInTimestamp;
WebRtc_UWord32 lastInTimestamp;
}; };
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_

View File

@@ -8,57 +8,37 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_dtmf_detection.h" #include "acm_dtmf_detection.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
namespace webrtc namespace webrtc {
{
ACMDTMFDetection::ACMDTMFDetection() ACMDTMFDetection::ACMDTMFDetection() {}
{
ACMDTMFDetection::~ACMDTMFDetection() {}
WebRtc_Word16 ACMDTMFDetection::Enable(ACMCountries /* cpt */) {
return -1;
} }
WebRtc_Word16 ACMDTMFDetection::Disable() {
ACMDTMFDetection::~ACMDTMFDetection() return -1;
{
} }
WebRtc_Word16 ACMDTMFDetection::Detect(
WebRtc_Word16 const WebRtc_Word16* /* inAudioBuff */,
ACMDTMFDetection::Enable(
ACMCountries /* cpt */)
{
return -1;
}
WebRtc_Word16
ACMDTMFDetection::Disable()
{
return -1;
}
WebRtc_Word16
ACMDTMFDetection::Detect(
const WebRtc_Word16* /* inAudioBuff */,
const WebRtc_UWord16 /* inBuffLenWord16 */, const WebRtc_UWord16 /* inBuffLenWord16 */,
const WebRtc_Word32 /* inFreqHz */, const WebRtc_Word32 /* inFreqHz */,
bool& /* toneDetected */, bool& /* toneDetected */,
WebRtc_Word16& /* tone */) WebRtc_Word16& /* tone */) {
{ return -1;
return -1;
} }
WebRtc_Word16 ACMDTMFDetection::GetVersion(
WebRtc_Word16 WebRtc_Word8* /* version */,
ACMDTMFDetection::GetVersion(
WebRtc_Word8* /* version */,
WebRtc_UWord32& /* remainingBufferInBytes */, WebRtc_UWord32& /* remainingBufferInBytes */,
WebRtc_UWord32& /* position */) WebRtc_UWord32& /* position */) {
{ return -1;
return -1;
} }
} // namespace webrtc } // namespace webrtc

View File

@@ -8,40 +8,36 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_DTMF_DETECTION_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#define ACM_DTMF_DETECTION_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#include "acm_resampler.h" #include "acm_resampler.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
#include "typedefs.h" #include "typedefs.h"
namespace webrtc namespace webrtc {
{
class ACMDTMFDetection class ACMDTMFDetection {
{ public:
public: ACMDTMFDetection();
ACMDTMFDetection(); ~ACMDTMFDetection();
~ACMDTMFDetection(); WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection); WebRtc_Word16 Disable();
WebRtc_Word16 Disable(); WebRtc_Word16 Detect(const WebRtc_Word16* inAudioBuff,
WebRtc_Word16 Detect( const WebRtc_UWord16 inBuffLenWord16,
const WebRtc_Word16* inAudioBuff, const WebRtc_Word32 inFreqHz,
const WebRtc_UWord16 inBuffLenWord16, bool& toneDetected,
const WebRtc_Word32 inFreqHz, WebRtc_Word16& tone);
bool& toneDetected,
WebRtc_Word16& tone);
static WebRtc_Word16 GetVersion(
WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position);
private: static WebRtc_Word16 GetVersion(WebRtc_Word8* version,
ACMResampler _resampler; WebRtc_UWord32& remainingBufferInBytes,
bool _init; WebRtc_UWord32& position);
private:
ACMResampler _resampler;
bool _init;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_DTMF_DETECTION_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_

View File

@@ -8,260 +8,177 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_common_defs.h"
#include "acm_dtmf_playout.h" #include "acm_dtmf_playout.h"
#include "acm_common_defs.h"
#include "acm_neteq.h" #include "acm_neteq.h"
#include "trace.h" #include "trace.h"
#include "webrtc_neteq.h" #include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
namespace webrtc namespace webrtc {
{
#ifndef WEBRTC_CODEC_AVT #ifndef WEBRTC_CODEC_AVT
ACMDTMFPlayout::ACMDTMFPlayout( ACMDTMFPlayout::ACMDTMFPlayout(
WebRtc_Word16 /* codecID */) WebRtc_Word16 /* codecID */) {
{ return;
return;
} }
ACMDTMFPlayout::~ACMDTMFPlayout() {
ACMDTMFPlayout::~ACMDTMFPlayout() return;
{
return;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_Word16 WebRtc_UWord8* /* bitStream */,
ACMDTMFPlayout::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */, return -1;
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16 /* bitStreamLenByte */,
ACMDTMFPlayout::DecodeSafe( WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audio */, return -1;
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitEncoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitDecoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMDTMFPlayout::CodecDef( return -1;
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
} }
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
ACMGenericCodec* return NULL;
ACMDTMFPlayout::CreateInstance(void)
{
return NULL;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
WebRtc_Word16 return -1;
ACMDTMFPlayout::InternalCreateEncoder()
{
return -1;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
WebRtc_Word16 return -1;
ACMDTMFPlayout::InternalCreateDecoder()
{
return -1;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
void return;
ACMDTMFPlayout::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
} }
void void ACMDTMFPlayout::DestructEncoderSafe() {
ACMDTMFPlayout::DestructEncoderSafe() return;
{
return;
} }
void void ACMDTMFPlayout::DestructDecoderSafe() {
ACMDTMFPlayout::DestructDecoderSafe() return;
{
return;
} }
WebRtc_Word16 ACMDTMFPlayout::UnregisterFromNetEqSafe(
WebRtc_Word16 ACMNetEQ* /* netEq */,
ACMDTMFPlayout::UnregisterFromNetEqSafe( WebRtc_Word16 /* payloadType */) {
ACMNetEQ* /* netEq */, return -1;
WebRtc_Word16 /* payloadType */)
{
return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMDTMFPlayout::ACMDTMFPlayout( ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codecID) {
WebRtc_Word16 codecID) _codecID = codecID;
{
_codecID = codecID;
} }
ACMDTMFPlayout::~ACMDTMFPlayout() {
ACMDTMFPlayout::~ACMDTMFPlayout() return;
{
return;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_Word16 WebRtc_UWord8* /* bitStream */,
ACMDTMFPlayout::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */, return 0;
WebRtc_Word16* /* bitStreamLenByte */)
{
return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16 /* bitStreamLenByte */,
ACMDTMFPlayout::DecodeSafe( WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audio */, return 0;
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitEncoder( // This codec does not need initialization,
WebRtcACMCodecParams* /* codecParams */) // DTMFPlayout has no instance
{ return 0;
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMDTMFPlayout::InternalInitDecoder( // This codec does not need initialization,
WebRtcACMCodecParams* /* codecParams */) // DTMFPlayout has no instance
{ return 0;
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
} }
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMDTMFPlayout::CodecDef( // Fill up the structure by calling
WebRtcNetEQ_CodecDef& codecDef, // "SET_CODEC_PAR" & "SET_AVT_FUNCTION."
const CodecInst& codecInst) // Then call NetEQ to add the codec to it's
{ // database.
// Fill up the structure by calling SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000);
// "SET_CODEC_PAR" & "SET_AVT_FUNCTION." SET_AVT_FUNCTIONS((codecDef));
// Then call NetEQ to add the codec to it's return 0;
// database.
SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000);
SET_AVT_FUNCTIONS((codecDef));
return 0;
} }
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
ACMGenericCodec* return NULL;
ACMDTMFPlayout::CreateInstance(void)
{
return NULL;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
WebRtc_Word16 // DTMFPlayout has no instance
ACMDTMFPlayout::InternalCreateEncoder() return 0;
{
// DTMFPlayout has no instance
return 0;
} }
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
WebRtc_Word16 // DTMFPlayout has no instance
ACMDTMFPlayout::InternalCreateDecoder() return 0;
{
// DTMFPlayout has no instance
return 0;
} }
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
void // DTMFPlayout has no instance
ACMDTMFPlayout::InternalDestructEncoderInst( return;
void* /* ptrInst */)
{
// DTMFPlayout has no instance
return;
} }
void ACMDTMFPlayout::DestructEncoderSafe() {
void // DTMFPlayout has no instance
ACMDTMFPlayout::DestructEncoderSafe() return;
{
// DTMFPlayout has no instance
return;
} }
void void ACMDTMFPlayout::DestructDecoderSafe() {
ACMDTMFPlayout::DestructDecoderSafe() // DTMFPlayout has no instance
{ return;
// DTMFPlayout has no instance
return;
} }
WebRtc_Word16 ACMDTMFPlayout::UnregisterFromNetEqSafe(
WebRtc_Word16
ACMDTMFPlayout::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType) {
{ if (payloadType != _decoderParams.codecInstant.pltype) {
if(payloadType != _decoderParams.codecInstant.pltype) WEBRTC_TRACE(webrtc::kTraceError,
{ webrtc::kTraceAudioCoding,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not "
the stored payload type", "match the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname, payloadType,
payloadType, _decoderParams.codecInstant.pltype);
_decoderParams.codecInstant.pltype); return -1;
return -1; }
} return netEq->RemoveCodec(kDecoderAVT);
return netEq->RemoveCodec(kDecoderAVT);
} }
#endif #endif

View File

@@ -8,61 +8,50 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_DTMF_PLAYOUT_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#define ACM_DTMF_PLAYOUT_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMDTMFPlayout : public ACMGenericCodec class ACMDTMFPlayout: public ACMGenericCodec {
{ public:
public: ACMDTMFPlayout(WebRtc_Word16 codecID);
ACMDTMFPlayout(WebRtc_Word16 codecID); ~ACMDTMFPlayout();
~ACMDTMFPlayout(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audio, WebRtc_Word8* speechType);
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void InternalDestructEncoderInst( void DestructDecoderSafe();
void* ptrInst);
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void InternalDestructEncoderInst(void* ptrInst);
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_DTMF_PLAYOUT_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_

View File

@@ -21,427 +21,307 @@ namespace webrtc {
#ifndef WEBRTC_CODEC_G722 #ifndef WEBRTC_CODEC_G722
ACMG722::ACMG722( ACMG722::ACMG722(WebRtc_Word16 /* codecID */) {
WebRtc_Word16 /* codecID */) return;
{
return;
} }
ACMG722::~ACMG722() {
ACMG722::~ACMG722() return;
{
return;
} }
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 /* timestamp */,
WebRtc_Word32 const WebRtc_Word16* /* data */,
ACMG722::Add10MsDataSafe( const WebRtc_UWord16 /* lengthSmpl */,
const WebRtc_UWord32 /* timestamp */, const WebRtc_UWord8 /* audioChannel */) {
const WebRtc_Word16* /* data */, return -1;
const WebRtc_UWord16 /* lengthSmpl */,
const WebRtc_UWord8 /* audioChannel */)
{
return -1;
} }
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMG722::InternalEncode( return -1;
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16 /* bitStreamLenByte */,
ACMG722::DecodeSafe( WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word8* /* speechType */) {
WebRtc_Word16* /* audio */, return -1;
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722::InternalInitEncoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG722::InternalInitDecoder( return -1;
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG722::CodecDef( return -1;
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
} }
ACMGenericCodec* ACMG722::CreateInstance(void) {
ACMGenericCodec* return NULL;
ACMG722::CreateInstance(void)
{
return NULL;
} }
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
WebRtc_Word16 return -1;
ACMG722::InternalCreateEncoder()
{
return -1;
} }
void ACMG722::DestructEncoderSafe() {
void return;
ACMG722::DestructEncoderSafe()
{
return;
} }
WebRtc_Word16 ACMG722::InternalCreateDecoder() {
WebRtc_Word16 return -1;
ACMG722::InternalCreateDecoder()
{
return -1;
} }
void ACMG722::DestructDecoderSafe() {
void return;
ACMG722::DestructDecoderSafe()
{
return;
} }
void ACMG722::InternalDestructEncoderInst(void* /* ptrInst */) {
void return;
ACMG722::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
} }
WebRtc_Word16 ACMG722::UnregisterFromNetEqSafe(
WebRtc_Word16 ACMNetEQ* /* netEq */,
ACMG722::UnregisterFromNetEqSafe( WebRtc_Word16 /* payloadType */) {
ACMNetEQ* /* netEq */, return -1;
WebRtc_Word16 /* payloadType */)
{
return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
// Encoder and decoder memory // Encoder and decoder memory
struct ACMG722EncStr { struct ACMG722EncStr {
G722EncInst* inst; // instance for left channel in case of stereo G722EncInst* inst; // instance for left channel in case of stereo
G722EncInst* instRight; // instance for right channel in case of stereo G722EncInst* instRight; // instance for right channel in case of stereo
}; };
struct ACMG722DecStr { struct ACMG722DecStr {
G722DecInst* inst; // instance for left channel in case of stereo G722DecInst* inst; // instance for left channel in case of stereo
G722DecInst* instRight; // instance for right channel in case of stereo G722DecInst* instRight; // instance for right channel in case of stereo
}; };
ACMG722::ACMG722( ACMG722::ACMG722(WebRtc_Word16 codecID) {
WebRtc_Word16 codecID) // Encoder
{ _ptrEncStr = new ACMG722EncStr;
// Encoder if (_ptrEncStr != NULL) {
_ptrEncStr = new ACMG722EncStr; _ptrEncStr->inst = NULL;
if(_ptrEncStr != NULL) _ptrEncStr->instRight = NULL;
{ }
_ptrEncStr->inst = NULL; // Decoder
_ptrEncStr->instRight = NULL; _ptrDecStr = new ACMG722DecStr;
if (_ptrDecStr != NULL) {
_ptrDecStr->inst = NULL;
_ptrDecStr->instRight = NULL; // Not used
}
_codecID = codecID;
return;
}
ACMG722::~ACMG722() {
// Encoder
if (_ptrEncStr != NULL) {
if (_ptrEncStr->inst != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL;
} }
// Decoder if (_ptrEncStr->instRight != NULL) {
_ptrDecStr = new ACMG722DecStr; WebRtcG722_FreeEncoder(_ptrEncStr->instRight);
if(_ptrDecStr != NULL) _ptrEncStr->instRight = NULL;
{
_ptrDecStr->inst = NULL;
_ptrDecStr->instRight = NULL; // Not used
} }
_codecID = codecID; delete _ptrEncStr;
return; _ptrEncStr = NULL;
} }
// Decoder
if (_ptrDecStr != NULL) {
ACMG722::~ACMG722() if (_ptrDecStr->inst != NULL) {
{ WebRtcG722_FreeDecoder(_ptrDecStr->inst);
if(_ptrEncStr != NULL) _ptrDecStr->inst = NULL;
{
if(_ptrEncStr->inst != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL;
}
if(_ptrEncStr->instRight != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->instRight);
_ptrEncStr->instRight = NULL;
}
delete _ptrEncStr;
_ptrEncStr = NULL;
} }
if(_ptrDecStr != NULL) if (_ptrDecStr->instRight != NULL) {
{ WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
if(_ptrDecStr->inst != NULL) _ptrDecStr->instRight = NULL;
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
if(_ptrDecStr->instRight != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
_ptrDecStr->instRight = NULL;
}
delete _ptrDecStr;
_ptrDecStr = NULL;
} }
return; delete _ptrDecStr;
_ptrDecStr = NULL;
}
return;
} }
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 timestamp,
WebRtc_Word32 const WebRtc_Word16* data,
ACMG722::Add10MsDataSafe( const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord32 timestamp, const WebRtc_UWord8 audioChannel) {
const WebRtc_Word16* data, return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, lengthSmpl,
const WebRtc_UWord16 lengthSmpl, audioChannel);
const WebRtc_UWord8 audioChannel)
{
return ACMGenericCodec::Add10MsDataSafe((timestamp>>1), data, lengthSmpl,
audioChannel);
} }
WebRtc_Word16 WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitStream,
ACMG722::InternalEncode( WebRtc_Word16* bitStreamLenByte) {
WebRtc_UWord8* bitStream, // If stereo, split input signal in left and right channel before encoding
WebRtc_Word16* bitStreamLenByte) if (_noChannels == 2) {
{ WebRtc_Word16 leftChannel[960];
// If stereo, split input signal in left and right channel before encoding WebRtc_Word16 rightChannel[960];
if(_noChannels == 2) { WebRtc_UWord8 outLeft[480];
WebRtc_Word16 leftChannel[960]; WebRtc_UWord8 outRight[480];
WebRtc_Word16 rightChannel[960]; WebRtc_Word16 lenInBytes;
WebRtc_UWord8 outLeft[480]; for (int i = 0, j = 0; i < _frameLenSmpl * 2; i += 2, j++) {
WebRtc_UWord8 outRight[480]; leftChannel[j] = _inAudio[_inAudioIxRead + i];
WebRtc_Word16 lenInBytes; rightChannel[j] = _inAudio[_inAudioIxRead + i + 1];
for (int i=0, j=0; i<_frameLenSmpl*2; i+=2, j++) {
leftChannel[j] = _inAudio[_inAudioIxRead+i];
rightChannel[j] = _inAudio[_inAudioIxRead+i+1];
}
lenInBytes = WebRtcG722_Encode(_encoderInstPtr,
leftChannel, _frameLenSmpl, (WebRtc_Word16*)outLeft);
lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight,
rightChannel, _frameLenSmpl, (WebRtc_Word16*)outRight);
*bitStreamLenByte = lenInBytes;
// Interleave the 4 bits per sample from left and right channel
for (int i=0, j=0; i<lenInBytes; i+=2, j++)
{
bitStream[i] = (outRight[j] & 0xF0) + (outLeft[j] >> 4);
bitStream[i+1] = ((outRight[j] & 0x0F) << 4) + (outLeft[j] & 0x0F);
}
} else {
*bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
} }
lenInBytes = WebRtcG722_Encode(_encoderInstPtr, leftChannel, _frameLenSmpl,
(WebRtc_Word16*) outLeft);
lenInBytes += WebRtcG722_Encode(_encoderInstPtrRight, rightChannel,
_frameLenSmpl, (WebRtc_Word16*) outRight);
*bitStreamLenByte = lenInBytes;
// increment the read index this tell the caller how far // Interleave the 4 bits per sample from left and right channel
// we have gone forward in reading the audio buffer for (int i = 0, j = 0; i < lenInBytes; i += 2, j++) {
_inAudioIxRead += _frameLenSmpl*_noChannels; bitStream[i] = (outRight[j] & 0xF0) + (outLeft[j] >> 4);
return *bitStreamLenByte; bitStream[i + 1] = ((outRight[j] & 0x0F) << 4) + (outLeft[j] & 0x0F);
}
WebRtc_Word16
ACMG722::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0;
}
WebRtc_Word16
ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
if(codecParams->codecInstant.channels == 2)
{
// Create codec struct for right channel
if (_ptrEncStr->instRight == NULL)
{
WebRtcG722_CreateEncoder(&_ptrEncStr->instRight);
if(_ptrEncStr->instRight == NULL)
{
return -1;
}
}
_encoderInstPtrRight = (G722EncInst*)_ptrEncStr->instRight;
if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0)
{
return -1;
}
} }
} else {
*bitStreamLenByte = WebRtcG722_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead],
_frameLenSmpl,
(WebRtc_Word16*) bitStream);
}
return WebRtcG722_EncoderInit(_encoderInstPtr); // increment the read index this tell the caller how far
// we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl * _noChannels;
return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16 /* bitStreamLenByte */,
ACMG722::InternalInitDecoder( WebRtc_Word16* /* audio */,
WebRtcACMCodecParams* /* codecParams */) WebRtc_Word16* /* audioSamples */,
{ WebRtc_Word8* /* speechType */) {
return WebRtcG722_DecoderInit(_decoderInstPtr); return 0;
} }
WebRtc_Word16 ACMG722::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word32 if (codecParams->codecInstant.channels == 2) {
ACMG722::CodecDef( // Create codec struct for right channel
WebRtcNetEQ_CodecDef& codecDef, if (_ptrEncStr->instRight == NULL) {
const CodecInst& codecInst) WebRtcG722_CreateEncoder(&_ptrEncStr->instRight);
{ if (_ptrEncStr->instRight == NULL) {
if (!_decoderInitialized)
{
// TODO: log error
return -1; return -1;
}
} }
// Fill up the structure by calling _encoderInstPtrRight = _ptrEncStr->instRight;
// "SET_CODEC_PAR" & "SET_G722_FUNCTION." if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) {
// Then call NetEQ to add the codec to it's return -1;
// database. }
SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype, }
_decoderInstPtr, 16000);
SET_G722_FUNCTIONS((codecDef)); return WebRtcG722_EncoderInit(_encoderInstPtr);
return 0;
} }
WebRtc_Word16 ACMG722::InternalInitDecoder(
ACMGenericCodec* WebRtcACMCodecParams* /* codecParams */) {
ACMG722::CreateInstance(void) return WebRtcG722_DecoderInit(_decoderInstPtr);
{
return NULL;
} }
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word16 const CodecInst& codecInst) {
ACMG722::InternalCreateEncoder() if (!_decoderInitialized) {
{ // TODO: log error
if(_ptrEncStr == NULL) return -1;
{ }
// this structure must be created at the costructor // Fill up the structure by calling
// if it is still NULL then there is a probelm and // "SET_CODEC_PAR" & "SET_G722_FUNCTION."
// we dont continue // Then call NetEQ to add the codec to it's
return -1; // database.
} SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype, _decoderInstPtr,
WebRtcG722_CreateEncoder(&_ptrEncStr->inst); 16000);
if(_ptrEncStr->inst == NULL) SET_G722_FUNCTIONS((codecDef));
{ return 0;
return -1;
}
_encoderInstPtr = (G722EncInst*)_ptrEncStr->inst;
return 0;
} }
ACMGenericCodec* ACMG722::CreateInstance(void) {
void return NULL;
ACMG722::DestructEncoderSafe()
{
if(_ptrEncStr != NULL)
{
if(_ptrEncStr->inst != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL;
}
}
_encoderExist = false;
_encoderInitialized = false;
} }
WebRtc_Word16 WebRtc_Word16 ACMG722::InternalCreateEncoder() {
ACMG722::InternalCreateDecoder() if (_ptrEncStr == NULL) {
{ // this structure must be created at the costructor
if(_ptrDecStr == NULL) // if it is still NULL then there is a probelm and
{ // we dont continue
// this structure must be created at the costructor return -1;
// if it is still NULL then there is a probelm and }
// we dont continue WebRtcG722_CreateEncoder(&_ptrEncStr->inst);
return -1; if (_ptrEncStr->inst == NULL) {
} return -1;
}
WebRtcG722_CreateDecoder(&_ptrDecStr->inst); _encoderInstPtr = _ptrEncStr->inst;
if(_ptrDecStr->inst == NULL) return 0;
{
return -1;
}
_decoderInstPtr = (G722DecInst*)_ptrDecStr->inst;
return 0;
} }
void void ACMG722::DestructEncoderSafe() {
ACMG722::DestructDecoderSafe() if (_ptrEncStr != NULL) {
{ if (_ptrEncStr->inst != NULL) {
_decoderExist = false; WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_decoderInitialized = false; _ptrEncStr->inst = NULL;
if(_ptrDecStr != NULL)
{
if(_ptrDecStr->inst != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
} }
}
_encoderExist = false;
_encoderInitialized = false;
} }
WebRtc_Word16 ACMG722::InternalCreateDecoder() {
if (_ptrDecStr == 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;
}
void WebRtcG722_CreateDecoder(&_ptrDecStr->inst);
ACMG722::InternalDestructEncoderInst( if (_ptrDecStr->inst == NULL) {
void* ptrInst) return -1;
{ }
if(ptrInst != NULL) _decoderInstPtr = _ptrDecStr->inst;
{ return 0;
WebRtcG722_FreeEncoder((G722EncInst*)ptrInst);
}
return;
} }
void ACMG722::DestructDecoderSafe() {
WebRtc_Word16 _decoderExist = false;
ACMG722::UnregisterFromNetEqSafe( _decoderInitialized = false;
ACMNetEQ* netEq, if (_ptrDecStr != NULL) {
WebRtc_Word16 payloadType) if (_ptrDecStr->inst != NULL) {
{ WebRtcG722_FreeDecoder(_ptrDecStr->inst);
if(payloadType != _decoderParams.codecInstant.pltype) _ptrDecStr->inst = NULL;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
} }
return netEq->RemoveCodec(kDecoderG722); }
}
void ACMG722::InternalDestructEncoderInst(void* ptrInst) {
if (ptrInst != NULL) {
WebRtcG722_FreeEncoder(static_cast<G722EncInst*>(ptrInst));
}
return;
}
WebRtc_Word16 ACMG722::UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType) {
if (payloadType != _decoderParams.codecInstant.pltype) {
WEBRTC_TRACE(webrtc::kTraceError,
webrtc::kTraceAudioCoding,
_uniqueID,
"Cannot unregister codec %s given payload-type %d does not "
"match the stored payload type",
_decoderParams.codecInstant.plname, payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderG722);
} }
#endif #endif

View File

@@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_G722_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#define ACM_G722_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
typedef struct WebRtcG722EncInst G722EncInst; typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst; typedef struct WebRtcG722DecInst G722DecInst;
namespace webrtc { namespace webrtc {
@@ -22,65 +22,55 @@ namespace webrtc {
struct ACMG722EncStr; struct ACMG722EncStr;
struct ACMG722DecStr; struct ACMG722DecStr;
class ACMG722 : public ACMGenericCodec class ACMG722: public ACMGenericCodec {
{ public:
public: ACMG722(WebRtc_Word16 codecID);
ACMG722(WebRtc_Word16 codecID); ~ACMG722();
~ACMG722(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audio, WebRtc_Word8* speechType);
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
const CodecInst& codecInst);
WebRtc_Word32 Add10MsDataSafe( WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_UWord32 timestamp, const WebRtc_Word16* data,
const WebRtc_Word16* data, const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord16 lengthSmpl, const WebRtc_UWord8 audioChannel);
const WebRtc_UWord8 audioChannel);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 InternalCreateEncoder();
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
ACMG722EncStr* _ptrEncStr; WebRtc_Word16 InternalCreateDecoder();
ACMG722DecStr* _ptrDecStr;
G722EncInst* _encoderInstPtr; void InternalDestructEncoderInst(void* ptrInst);
G722EncInst* _encoderInstPtrRight; // Prepared for stereo
G722DecInst* _decoderInstPtr; WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
ACMG722EncStr* _ptrEncStr;
ACMG722DecStr* _ptrDecStr;
G722EncInst* _encoderInstPtr;
G722EncInst* _encoderInstPtrRight; // Prepared for stereo
G722DecInst* _decoderInstPtr;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_G722_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_G722_1_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#define ACM_G722_1_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -24,71 +24,62 @@ struct G722_1_Inst_t_;
namespace webrtc { namespace webrtc {
class ACMG722_1 : public ACMGenericCodec class ACMG722_1: public ACMGenericCodec {
{ public:
public: ACMG722_1(WebRtc_Word16 codecID);
ACMG722_1(WebRtc_Word16 codecID); ~ACMG722_1();
~ACMG722_1(); // for FEC
// for FEC ACMGenericCodec* CreateInstance(void);
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream, WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16* audio, WebRtc_Word8* speechType);
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef, const CodecInst& codecInst);
const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 InternalCreateEncoder();
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
WebRtc_Word32 _operationalRate; WebRtc_Word16 InternalCreateDecoder();
G722_1_Inst_t_* _encoderInstPtr; void InternalDestructEncoderInst(void* ptrInst);
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
G722_1_Inst_t_* _decoderInstPtr;
// Only one set of these pointer is valid at any instance WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
G722_1_16_encinst_t_* _encoderInst16Ptr; WebRtc_Word16 payloadType);
G722_1_16_encinst_t_* _encoderInst16PtrR;
G722_1_24_encinst_t_* _encoderInst24Ptr;
G722_1_24_encinst_t_* _encoderInst24PtrR;
G722_1_32_encinst_t_* _encoderInst32Ptr;
G722_1_32_encinst_t_* _encoderInst32PtrR;
// Only one of these pointer is valid at any instance WebRtc_Word32 _operationalRate;
G722_1_16_decinst_t_* _decoderInst16Ptr;
G722_1_24_decinst_t_* _decoderInst24Ptr; G722_1_Inst_t_* _encoderInstPtr;
G722_1_32_decinst_t_* _decoderInst32Ptr; G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
G722_1_Inst_t_* _decoderInstPtr;
// Only one set of these pointer is valid at any instance
G722_1_16_encinst_t_* _encoderInst16Ptr;
G722_1_16_encinst_t_* _encoderInst16PtrR;
G722_1_24_encinst_t_* _encoderInst24Ptr;
G722_1_24_encinst_t_* _encoderInst24PtrR;
G722_1_32_encinst_t_* _encoderInst32Ptr;
G722_1_32_encinst_t_* _encoderInst32PtrR;
// Only one of these pointer is valid at any instance
G722_1_16_decinst_t_* _decoderInst16Ptr;
G722_1_24_decinst_t_* _decoderInst24Ptr;
G722_1_32_decinst_t_* _decoderInst32Ptr;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_G722_1_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_G722_1C_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#define ACM_G722_1C_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -33,7 +33,7 @@ public:
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream, WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(
@@ -45,23 +45,23 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
@@ -91,4 +91,4 @@ protected:
} // namespace webrtc; } // namespace webrtc;
#endif // ACM_G722_1C_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_G729_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#define ACM_G729_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -40,28 +40,28 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word32 ReplaceInternalDTXSafe( WebRtc_Word32 ReplaceInternalDTXSafe(
@@ -81,5 +81,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_G729_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_

View File

@@ -55,20 +55,20 @@ ACMG729_1::~ACMG729_1()
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalEncode( ACMG729_1::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */)
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::DecodeSafe( ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
@@ -76,7 +76,7 @@ ACMG729_1::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalInitEncoder( ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -84,7 +84,7 @@ ACMG729_1::InternalInitEncoder(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalInitDecoder( ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -92,51 +92,51 @@ ACMG729_1::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMG729_1::CodecDef( ACMG729_1::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec*
ACMG729_1::CreateInstance(void) ACMG729_1::CreateInstance(void)
{ {
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalCreateEncoder() ACMG729_1::InternalCreateEncoder()
{ {
return -1; return -1;
} }
void void
ACMG729_1::DestructEncoderSafe() ACMG729_1::DestructEncoderSafe()
{ {
return; return;
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalCreateDecoder() ACMG729_1::InternalCreateDecoder()
{ {
return -1; return -1;
} }
void void
ACMG729_1::DestructDecoderSafe() ACMG729_1::DestructDecoderSafe()
{ {
return; return;
} }
void void
ACMG729_1::InternalDestructEncoderInst( ACMG729_1::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -144,7 +144,7 @@ ACMG729_1::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::UnregisterFromNetEqSafe( ACMG729_1::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */)
@@ -152,11 +152,11 @@ ACMG729_1::UnregisterFromNetEqSafe(
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::SetBitRateSafe( ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 /*rate*/ ) const WebRtc_Word32 /*rate*/ )
{ {
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
@@ -173,10 +173,10 @@ _decoderInstPtr(NULL)
// which is DTX. // which is DTX.
_hasInternalDTX = false; _hasInternalDTX = false;
// Default rate // Default rate
_myRate = 32000; _myRate = 32000;
_flag8kHz = 0; _flag8kHz = 0;
_flagG729mode = 0; _flagG729mode = 0;
return; return;
} }
@@ -197,9 +197,9 @@ ACMG729_1::~ACMG729_1()
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalEncode( ACMG729_1::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
{ {
@@ -207,10 +207,10 @@ ACMG729_1::InternalEncode(
WebRtc_Word16 noEncodedSamples = 0; WebRtc_Word16 noEncodedSamples = 0;
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
WebRtc_Word16 byteLengthFrame = 0; WebRtc_Word16 byteLengthFrame = 0;
// Derive number of 20ms frames per encoded packet. // Derive number of 20ms frames per encoded packet.
// [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples // [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples
WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320); WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320);
// Byte length for the frame. +1 is for rate information. // Byte length for the frame. +1 is for rate information.
byteLengthFrame = _myRate/(8*50) * n20msFrames + (1 - _flagG729mode); byteLengthFrame = _myRate/(8*50) * n20msFrames + (1 - _flagG729mode);
@@ -219,30 +219,30 @@ ACMG729_1::InternalEncode(
do do
{ {
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], *bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
(WebRtc_Word16*)bitStream, _myRate, n20msFrames); (WebRtc_Word16*)bitStream, _myRate, n20msFrames);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 160; _inAudioIxRead += 160;
// sanity check // sanity check
if(*bitStreamLenByte < 0) if(*bitStreamLenByte < 0)
{ {
// error has happened // error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
noEncodedSamples += 160; noEncodedSamples += 160;
} while(*bitStreamLenByte == 0); } while(*bitStreamLenByte == 0);
// This criteria will change if we have Annex C. // This criteria will change if we have Annex C.
if(*bitStreamLenByte != byteLengthFrame) if(*bitStreamLenByte != byteLengthFrame)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
@@ -259,11 +259,11 @@ ACMG729_1::InternalEncode(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::DecodeSafe( ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
@@ -271,43 +271,43 @@ ACMG729_1::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalInitEncoder( ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) WebRtcACMCodecParams* codecParams)
{ {
//set the bit rate and initialize //set the bit rate and initialize
_myRate = codecParams->codecInstant.rate; _myRate = codecParams->codecInstant.rate;
return SetBitRateSafe( (WebRtc_UWord32)_myRate); return SetBitRateSafe( (WebRtc_UWord32)_myRate);
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalInitDecoder( ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0) if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: init decoder failed for G729_1"); "InternalInitDecoder: init decoder failed for G729_1");
return -1; return -1;
} }
return 0; return 0;
} }
WebRtc_Word32 WebRtc_Word32
ACMG729_1::CodecDef( ACMG729_1::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
{ {
if (!_decoderInitialized) if (!_decoderInitialized)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: Decoder uninitialized for G729_1"); "CodeDef: Decoder uninitialized for G729_1");
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -318,27 +318,27 @@ ACMG729_1::CodecDef(
} }
ACMGenericCodec* ACMGenericCodec*
ACMG729_1::CreateInstance(void) ACMG729_1::CreateInstance(void)
{ {
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalCreateEncoder() ACMG729_1::InternalCreateEncoder()
{ {
if (WebRtcG7291_Create(&_encoderInstPtr) < 0) if (WebRtcG7291_Create(&_encoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: create encoder failed for G729_1"); "InternalCreateEncoder: create encoder failed for G729_1");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMG729_1::DestructEncoderSafe() ACMG729_1::DestructEncoderSafe()
{ {
_encoderExist = false; _encoderExist = false;
@@ -351,20 +351,20 @@ ACMG729_1::DestructEncoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::InternalCreateDecoder() ACMG729_1::InternalCreateDecoder()
{ {
if (WebRtcG7291_Create(&_decoderInstPtr) < 0) if (WebRtcG7291_Create(&_decoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: create decoder failed for G729_1"); "InternalCreateDecoder: create decoder failed for G729_1");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMG729_1::DestructDecoderSafe() ACMG729_1::DestructDecoderSafe()
{ {
_decoderExist = false; _decoderExist = false;
@@ -377,10 +377,10 @@ ACMG729_1::DestructDecoderSafe()
} }
void void
ACMG729_1::InternalDestructEncoderInst( ACMG729_1::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
if(ptrInst != NULL) if(ptrInst != NULL)
{ {
//WebRtcG7291_Free((G729_1_inst_t*)ptrInst); //WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
@@ -389,25 +389,25 @@ ACMG729_1::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::UnregisterFromNetEqSafe( ACMG729_1::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: given payload-type does not match \ "Cannot unregister codec: given payload-type does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
return netEq->RemoveCodec(kDecoderG729_1); return netEq->RemoveCodec(kDecoderG729_1);
} }
WebRtc_Word16 WebRtc_Word16
ACMG729_1::SetBitRateSafe( ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 rate) const WebRtc_Word32 rate)
{ {
@@ -422,77 +422,76 @@ ACMG729_1::SetBitRateSafe(
_myRate = 8000; _myRate = 8000;
break; break;
} }
case 12000: case 12000:
{ {
_myRate = 12000; _myRate = 12000;
break; break;
} }
case 14000: case 14000:
{ {
_myRate = 14000; _myRate = 14000;
break; break;
} }
case 16000: case 16000:
{ {
_myRate = 16000; _myRate = 16000;
break; break;
} }
case 18000: case 18000:
{ {
_myRate = 18000; _myRate = 18000;
break; break;
} }
case 20000: case 20000:
{ {
_myRate = 20000; _myRate = 20000;
break; break;
} }
case 22000: case 22000:
{ {
_myRate = 22000; _myRate = 22000;
break; break;
} }
case 24000: case 24000:
{ {
_myRate = 24000; _myRate = 24000;
break; break;
} }
case 26000: case 26000:
{ {
_myRate = 26000; _myRate = 26000;
break; break;
} }
case 28000: case 28000:
{ {
_myRate = 28000; _myRate = 28000;
break; break;
} }
case 30000: case 30000:
{ {
_myRate = 30000; _myRate = 30000;
break; break;
} }
case 32000: case 32000:
{ {
_myRate = 32000; _myRate = 32000;
break; break;
} }
default: default:
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate G729_1"); "SetBitRateSafe: Invalid rate G729_1");
return -1; return -1;
break;
} }
} }
// Re-init with new rate // Re-init with new rate
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, _flagG729mode) >= 0) if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, _flagG729mode) >= 0)
{ {
_encoderParams.codecInstant.rate = _myRate; _encoderParams.codecInstant.rate = _myRate;
return 0; return 0;
} }
else else
{ {
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_G729_1_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
#define ACM_G729_1_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -28,7 +28,7 @@ public:
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream, WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(
@@ -39,24 +39,24 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
@@ -65,22 +65,21 @@ protected:
//WebRtc_Word16 DisableDTX(); //WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate); const WebRtc_Word32 rate);
G729_1_inst_t_* _encoderInstPtr; G729_1_inst_t_* _encoderInstPtr;
G729_1_inst_t_* _decoderInstPtr; G729_1_inst_t_* _decoderInstPtr;
WebRtc_UWord16 _myRate; WebRtc_UWord16 _myRate;
WebRtc_Word16 _flag8kHz; WebRtc_Word16 _flag8kHz;
WebRtc_Word16 _flagG729mode; WebRtc_Word16 _flagG729mode;
}; };
} // namespace webrtc } // namespace webrtc
#endif // ACM_G729_1_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_

View File

@@ -34,43 +34,42 @@ enum
// We set some of the variables to invalid values as a check point // We set some of the variables to invalid values as a check point
// if a proper initialization has happened. Another approach is // if a proper initialization has happened. Another approach is
// to initialize to a default codec that we are sure is always included. // to initialize to a default codec that we are sure is always included.
ACMGenericCodec::ACMGenericCodec(): ACMGenericCodec::ACMGenericCodec()
_inAudioIxWrite(0), : _inAudioIxWrite(0),
_inAudioIxRead(0), _inAudioIxRead(0),
_inTimestampIxWrite(0), _inTimestampIxWrite(0),
_inAudio(NULL), _inAudio(NULL),
_inTimestamp(NULL), _inTimestamp(NULL),
_frameLenSmpl(-1), // invalid value _frameLenSmpl(-1), // invalid value
_noChannels(1), _noChannels(1),
_codecID(-1), // invalid value _codecID(-1), // invalid value
_noMissedSamples(0), _noMissedSamples(0),
_encoderExist(false), _encoderExist(false),
_decoderExist(false), _decoderExist(false),
_encoderInitialized(false), _encoderInitialized(false),
_decoderInitialized(false), _decoderInitialized(false),
_registeredInNetEq(false), _registeredInNetEq(false),
_hasInternalDTX(false), _hasInternalDTX(false),
_ptrVADInst(NULL), _ptrVADInst(NULL),
_vadEnabled(false), _vadEnabled(false),
_vadMode(VADNormal), _vadMode(VADNormal),
_dtxEnabled(false), _dtxEnabled(false),
_ptrDTXInst(NULL), _ptrDTXInst(NULL),
_numLPCParams(kNewCNGNumPLCParams), _numLPCParams(kNewCNGNumPLCParams),
_sentCNPrevious(false), _sentCNPrevious(false),
_isMaster(true), _isMaster(true),
_netEqDecodeLock(NULL), _netEqDecodeLock(NULL),
_codecWrapperLock(*RWLockWrapper::CreateRWLock()), _codecWrapperLock(*RWLockWrapper::CreateRWLock()),
_lastEncodedTimestamp(0), _lastEncodedTimestamp(0),
_lastTimestamp(0), _lastTimestamp(0),
_isAudioBuffFresh(true), _isAudioBuffFresh(true),
_uniqueID(0) _uniqueID(0) {
{ _lastTimestamp = 0xD87F3F9F;
_lastTimestamp = 0xD87F3F9F; //NullifyCodecInstance();
//NullifyCodecInstance();
} }
ACMGenericCodec::~ACMGenericCodec() ACMGenericCodec::~ACMGenericCodec()
{ {
// Check all the members which are pointers and // Check all the members which are pointers and
// if they are not NULL delete/free them. // if they are not NULL delete/free them.
if(_ptrVADInst != NULL) if(_ptrVADInst != NULL)
@@ -78,13 +77,13 @@ ACMGenericCodec::~ACMGenericCodec()
WebRtcVad_Free(_ptrVADInst); WebRtcVad_Free(_ptrVADInst);
_ptrVADInst = NULL; _ptrVADInst = NULL;
} }
if (_inAudio != NULL) if (_inAudio != NULL)
{ {
delete [] _inAudio; delete [] _inAudio;
_inAudio = NULL; _inAudio = NULL;
} }
if (_inTimestamp != NULL) if (_inTimestamp != NULL)
{ {
delete [] _inTimestamp; delete [] _inTimestamp;
@@ -116,10 +115,10 @@ ACMGenericCodec::Add10MsDataSafe(
const WebRtc_UWord16 lengthSmpl, const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel) const WebRtc_UWord8 audioChannel)
{ {
// The codec expects to get data in correct sampling rate. // The codec expects to get data in correct sampling rate.
// get the sampling frequency of the codec // get the sampling frequency of the codec
WebRtc_UWord16 plFreqHz; WebRtc_UWord16 plFreqHz;
if(EncoderSampFreq(plFreqHz) < 0) if(EncoderSampFreq(plFreqHz) < 0)
{ {
// _codecID is not correct, perhaps the codec is not initialized yet. // _codecID is not correct, perhaps the codec is not initialized yet.
@@ -129,7 +128,7 @@ ACMGenericCodec::Add10MsDataSafe(
// Sanity check, if the length of the input corresponds to 10 ms. // Sanity check, if the length of the input corresponds to 10 ms.
if((plFreqHz / 100) != lengthSmpl) if((plFreqHz / 100) != lengthSmpl)
{ {
// This is not 10 ms of audio, given the sampling frequency of the // This is not 10 ms of audio, given the sampling frequency of the
// codec // codec
return -1; return -1;
} }
@@ -140,13 +139,13 @@ ACMGenericCodec::Add10MsDataSafe(
{ {
_inAudioIxWrite -= lengthSmpl; _inAudioIxWrite -= lengthSmpl;
_inTimestampIxWrite--; _inTimestampIxWrite--;
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID,
"Adding 10ms with previous timestamp, \ "Adding 10ms with previous timestamp, \
overwriting the previous 10ms"); overwriting the previous 10ms");
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID,
"Adding 10ms with previous timestamp, this will sound bad"); "Adding 10ms with previous timestamp, this will sound bad");
} }
} }
@@ -160,10 +159,10 @@ overwriting the previous 10ms");
AUDIO_BUFFER_SIZE_W16; AUDIO_BUFFER_SIZE_W16;
// Move the data (overwite the old data) // Move the data (overwite the old data)
memmove(_inAudio, _inAudio + missedSamples, memmove(_inAudio, _inAudio + missedSamples,
(AUDIO_BUFFER_SIZE_W16 - lengthSmpl*audioChannel)*sizeof(WebRtc_Word16)); (AUDIO_BUFFER_SIZE_W16 - lengthSmpl*audioChannel)*sizeof(WebRtc_Word16));
// Copy the new data // Copy the new data
memcpy(_inAudio + (AUDIO_BUFFER_SIZE_W16 - lengthSmpl*audioChannel), data, memcpy(_inAudio + (AUDIO_BUFFER_SIZE_W16 - lengthSmpl*audioChannel), data,
lengthSmpl*audioChannel * sizeof(WebRtc_Word16)); lengthSmpl*audioChannel * sizeof(WebRtc_Word16));
// Get the number of 10 ms blocks which are overwritten // Get the number of 10 ms blocks which are overwritten
@@ -171,7 +170,7 @@ overwriting the previous 10ms");
(WebRtc_Word16)((missedSamples/audioChannel * 100) / plFreqHz); (WebRtc_Word16)((missedSamples/audioChannel * 100) / plFreqHz);
// Move the timestamps // Move the timestamps
memmove(_inTimestamp, _inTimestamp + missed10MsecBlocks, memmove(_inTimestamp, _inTimestamp + missed10MsecBlocks,
(_inTimestampIxWrite - missed10MsecBlocks) * sizeof(WebRtc_UWord32)); (_inTimestampIxWrite - missed10MsecBlocks) * sizeof(WebRtc_UWord32));
_inTimestampIxWrite -= missed10MsecBlocks; _inTimestampIxWrite -= missed10MsecBlocks;
_inTimestamp[_inTimestampIxWrite] = timestamp; _inTimestamp[_inTimestampIxWrite] = timestamp;
@@ -204,7 +203,7 @@ ACMGenericCodec::Encode(
{ {
WriteLockScoped lockCodec(_codecWrapperLock); WriteLockScoped lockCodec(_codecWrapperLock);
ReadLockScoped lockNetEq(*_netEqDecodeLock); ReadLockScoped lockNetEq(*_netEqDecodeLock);
return EncodeSafe(bitStream, bitStreamLenByte, return EncodeSafe(bitStream, bitStreamLenByte,
timeStamp, encodingType); timeStamp, encodingType);
} }
@@ -228,19 +227,19 @@ ACMGenericCodec::EncodeSafe(
return 0; return 0;
} }
// Not all codecs accept the whole frame to be pushed into // Not all codecs accept the whole frame to be pushed into
// encoder at once. // encoder at once.
const WebRtc_Word16 myBasicCodingBlockSmpl = const WebRtc_Word16 myBasicCodingBlockSmpl =
ACMCodecDB::BasicCodingBlock(_codecID); ACMCodecDB::BasicCodingBlock(_codecID);
if((myBasicCodingBlockSmpl < 0) || if((myBasicCodingBlockSmpl < 0) ||
(!_encoderInitialized) || (!_encoderInitialized) ||
(!_encoderExist)) (!_encoderExist))
{ {
// This should not happen // This should not happen
*timeStamp = 0; *timeStamp = 0;
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
*encodingType = kNoEncoding; *encodingType = kNoEncoding;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EncodeSafe: error, basic coding sample block is negative"); "EncodeSafe: error, basic coding sample block is negative");
return -1; return -1;
} }
@@ -253,10 +252,10 @@ ACMGenericCodec::EncodeSafe(
// If VAD is disabled all labels are set to ONE (active) // If VAD is disabled all labels are set to ONE (active)
WebRtc_Word16 status = 0; WebRtc_Word16 status = 0;
WebRtc_Word16 dtxProcessedSamples = 0; WebRtc_Word16 dtxProcessedSamples = 0;
status = ProcessFrameVADDTX(bitStream, bitStreamLenByte, status = ProcessFrameVADDTX(bitStream, bitStreamLenByte,
&dtxProcessedSamples); &dtxProcessedSamples);
if(status < 0) if(status < 0)
{ {
*timeStamp = 0; *timeStamp = 0;
@@ -268,11 +267,11 @@ ACMGenericCodec::EncodeSafe(
if(dtxProcessedSamples > 0) if(dtxProcessedSamples > 0)
{ {
// Dtx have processed some samples may or may not a bit-stream // Dtx have processed some samples may or may not a bit-stream
// is generated we should not do any encoding (normally there // is generated we should not do any encoding (normally there
// will be not enough data) // will be not enough data)
// Setting the following makes that the move of audio data // Setting the following makes that the move of audio data
// and timestamps happen correctly // and timestamps happen correctly
_inAudioIxRead = dtxProcessedSamples; _inAudioIxRead = dtxProcessedSamples;
// This will let the owner of ACMGenericCodec to know that the // This will let the owner of ACMGenericCodec to know that the
// generated bit-stream is DTX to use correct payload type // generated bit-stream is DTX to use correct payload type
@@ -286,17 +285,17 @@ ACMGenericCodec::EncodeSafe(
*encodingType = kPassiveDTXSWB; *encodingType = kPassiveDTXSWB;
} else { } else {
status = -1; status = -1;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EncodeSafe: Wrong sampling frequency for DTX."); "EncodeSafe: Wrong sampling frequency for DTX.");
} }
// Transport empty frame if we have an empty bitstream // Transport empty frame if we have an empty bitstream
if ((*bitStreamLenByte == 0) if ((*bitStreamLenByte == 0)
&& (_sentCNPrevious || ((_inAudioIxWrite - _inAudioIxRead) <= 0)) && (_sentCNPrevious || ((_inAudioIxWrite - _inAudioIxRead) <= 0))
) )
{ {
// Makes sure we transmit an empty frame // Makes sure we transmit an empty frame
*bitStreamLenByte = 1; *bitStreamLenByte = 1;
*encodingType = kNoEncoding; *encodingType = kNoEncoding;
} }
_sentCNPrevious = true; _sentCNPrevious = true;
@@ -310,16 +309,16 @@ ACMGenericCodec::EncodeSafe(
// if any registered. // if any registered.
if(myBasicCodingBlockSmpl == 0) if(myBasicCodingBlockSmpl == 0)
{ {
// This codec can handle all allowed frame sizes as basic // This codec can handle all allowed frame sizes as basic
// coding block // coding block
status = InternalEncode(bitStream, bitStreamLenByte); status = InternalEncode(bitStream, bitStreamLenByte);
if(status < 0) if(status < 0)
{ {
// TODO: // TODO:
// Maybe reseting the encoder to be fresh for the next // Maybe reseting the encoder to be fresh for the next
// frame // frame
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EncodeSafe: error in internalEncode"); "EncodeSafe: error in internalEncode");
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
*encodingType = kNoEncoding; *encodingType = kNoEncoding;
@@ -327,9 +326,9 @@ ACMGenericCodec::EncodeSafe(
} }
else else
{ {
// A basic-coding-block for this codec is defined so we loop // A basic-coding-block for this codec is defined so we loop
// over the audio with the steps of the basic-coding-block. // over the audio with the steps of the basic-coding-block.
// It is not necessary that in each itteration // It is not necessary that in each itteration
WebRtc_Word16 tmpBitStreamLenByte; WebRtc_Word16 tmpBitStreamLenByte;
// Reset the variables which will be increamented in the loop // Reset the variables which will be increamented in the loop
@@ -337,35 +336,35 @@ ACMGenericCodec::EncodeSafe(
bool done = false; bool done = false;
while(!done) while(!done)
{ {
status = InternalEncode(&bitStream[*bitStreamLenByte], status = InternalEncode(&bitStream[*bitStreamLenByte],
&tmpBitStreamLenByte); &tmpBitStreamLenByte);
*bitStreamLenByte += tmpBitStreamLenByte; *bitStreamLenByte += tmpBitStreamLenByte;
// Guard Against errors and too large payloads // Guard Against errors and too large payloads
if((status < 0) || if((status < 0) ||
(*bitStreamLenByte > MAX_PAYLOAD_SIZE_BYTE)) (*bitStreamLenByte > MAX_PAYLOAD_SIZE_BYTE))
{ {
// Error has happened if we are in the middle of a full // Error has happened if we are in the middle of a full
// frame we have to exit. Before exiting, whatever bits // frame we have to exit. Before exiting, whatever bits
// are in the buffer are probably corruptred. Anyways // are in the buffer are probably corruptred. Anyways
// we ignore them. // we ignore them.
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
*encodingType = kNoEncoding; *encodingType = kNoEncoding;
// We might have come here because of the second // We might have come here because of the second
// condition. // condition.
status = -1; status = -1;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding,
_uniqueID, "EncodeSafe: error in InternalEncode"); _uniqueID, "EncodeSafe: error in InternalEncode");
// break from the loop // break from the loop
break; break;
} }
done = _inAudioIxRead >= _frameLenSmpl; done = _inAudioIxRead >= _frameLenSmpl;
} }
} }
if(status >= 0) if(status >= 0)
{ {
*encodingType = (_vadLabel[0] == 1)? *encodingType = (_vadLabel[0] == 1)?
kActiveNormalEncoded:kPassiveNormalEncoded; kActiveNormalEncoded:kPassiveNormalEncoded;
// Transport empty frame if we have an empty bitsteram // Transport empty frame if we have an empty bitsteram
if ((*bitStreamLenByte == 0) && ((_inAudioIxWrite - _inAudioIxRead) <= 0)) if ((*bitStreamLenByte == 0) && ((_inAudioIxWrite - _inAudioIxRead) <= 0))
@@ -377,17 +376,17 @@ ACMGenericCodec::EncodeSafe(
} }
} }
} }
// Move the timestampe buffer according to the number of 10 ms blocks // Move the timestampe buffer according to the number of 10 ms blocks
// which are read. // which are read.
WebRtc_UWord16 sampFreqHz; WebRtc_UWord16 sampFreqHz;
EncoderSampFreq(sampFreqHz); EncoderSampFreq(sampFreqHz);
WebRtc_Word16 num10MsecBlocks = WebRtc_Word16 num10MsecBlocks =
(WebRtc_Word16)((_inAudioIxRead/_noChannels * 100) / sampFreqHz); (WebRtc_Word16)((_inAudioIxRead/_noChannels * 100) / sampFreqHz);
if(_inTimestampIxWrite > num10MsecBlocks) if(_inTimestampIxWrite > num10MsecBlocks)
{ {
memmove(_inTimestamp, _inTimestamp + num10MsecBlocks, memmove(_inTimestamp, _inTimestamp + num10MsecBlocks,
(_inTimestampIxWrite - num10MsecBlocks) * sizeof(WebRtc_Word32)); (_inTimestampIxWrite - num10MsecBlocks) * sizeof(WebRtc_Word32));
} }
_inTimestampIxWrite -= num10MsecBlocks; _inTimestampIxWrite -= num10MsecBlocks;
@@ -396,7 +395,7 @@ ACMGenericCodec::EncodeSafe(
// of the buffer and accordingly adjust the read and write indices. // of the buffer and accordingly adjust the read and write indices.
if(_inAudioIxRead < _inAudioIxWrite) if(_inAudioIxRead < _inAudioIxWrite)
{ {
memmove(_inAudio, &_inAudio[_inAudioIxRead], memmove(_inAudio, &_inAudio[_inAudioIxRead],
(_inAudioIxWrite - _inAudioIxRead)*sizeof(WebRtc_Word16)); (_inAudioIxWrite - _inAudioIxRead)*sizeof(WebRtc_Word16));
} }
@@ -416,18 +415,18 @@ ACMGenericCodec::Decode(
WebRtc_Word8* speechType) WebRtc_Word8* speechType)
{ {
WriteLockScoped wl(_codecWrapperLock); WriteLockScoped wl(_codecWrapperLock);
return DecodeSafe(bitStream, bitStreamLenByte, audio, return DecodeSafe(bitStream, bitStreamLenByte, audio,
audioSamples, speechType); audioSamples, speechType);
} }
bool bool
ACMGenericCodec::EncoderInitialized() ACMGenericCodec::EncoderInitialized()
{ {
ReadLockScoped rl(_codecWrapperLock); ReadLockScoped rl(_codecWrapperLock);
return _encoderInitialized; return _encoderInitialized;
} }
bool bool
ACMGenericCodec::DecoderInitialized() ACMGenericCodec::DecoderInitialized()
{ {
ReadLockScoped rl(_codecWrapperLock); ReadLockScoped rl(_codecWrapperLock);
@@ -446,7 +445,7 @@ ACMGenericCodec::RegisterInNetEq(
if(CodecDef(codecDef, codecInst) < 0) if(CodecDef(codecDef, codecInst) < 0)
{ {
// Failed to register // Failed to register
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"RegisterInNetEq: error, failed to register"); "RegisterInNetEq: error, failed to register");
_registeredInNetEq = false; _registeredInNetEq = false;
return -1; return -1;
@@ -455,12 +454,12 @@ ACMGenericCodec::RegisterInNetEq(
{ {
if(netEq->AddCodec(&codecDef, _isMaster) < 0) if(netEq->AddCodec(&codecDef, _isMaster) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"RegisterInNetEq: error, failed to add codec"); "RegisterInNetEq: error, failed to add codec");
_registeredInNetEq = false; _registeredInNetEq = false;
return -1; return -1;
} }
// Registered // Registered
_registeredInNetEq = true; _registeredInNetEq = true;
return 0; return 0;
} }
@@ -494,13 +493,13 @@ ACMGenericCodec::EncoderParamsSafe(
encParams->codecInstant.pltype = -1; encParams->codecInstant.pltype = -1;
encParams->codecInstant.pacsize = 0; encParams->codecInstant.pacsize = 0;
encParams->codecInstant.rate = 0; encParams->codecInstant.rate = 0;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EncoderParamsSafe: error, encoder not initialized"); "EncoderParamsSafe: error, encoder not initialized");
return -1; return -1;
} }
} }
bool bool
ACMGenericCodec::DecoderParams( ACMGenericCodec::DecoderParams(
WebRtcACMCodecParams* decParams, WebRtcACMCodecParams* decParams,
const WebRtc_UWord8 payloadType) const WebRtc_UWord8 payloadType)
@@ -514,7 +513,7 @@ ACMGenericCodec::DecoderParamsSafe(
WebRtcACMCodecParams* decParams, WebRtcACMCodecParams* decParams,
const WebRtc_UWord8 payloadType) const WebRtc_UWord8 payloadType)
{ {
// Decoder parameters are valid only if decoder is initialized // Decoder parameters are valid only if decoder is initialized
if(_decoderInitialized) if(_decoderInitialized)
{ {
if(payloadType == _decoderParams.codecInstant.pltype) if(payloadType == _decoderParams.codecInstant.pltype)
@@ -564,24 +563,24 @@ ACMGenericCodec::ResetEncoderSafe()
// Reset the encoder // Reset the encoder
if(InternalResetEncoder() < 0) if(InternalResetEncoder() < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"ResetEncoderSafe: error in reset encoder"); "ResetEncoderSafe: error in reset encoder");
return -1; return -1;
} }
// Disable DTX & VAD this deletes the states // Disable DTX & VAD this deletes the states
// we like to have fresh start // we like to have fresh start
DisableDTX(); DisableDTX();
DisableVAD(); DisableVAD();
// Set DTX/VAD // Set DTX/VAD
return SetVADSafe(enableDTX, enableVAD, mode); return SetVADSafe(enableDTX, enableVAD, mode);
} }
WebRtc_Word16 WebRtc_Word16
ACMGenericCodec::InternalResetEncoder() ACMGenericCodec::InternalResetEncoder()
{ {
// For most of the codecs it is sufficient to // For most of the codecs it is sufficient to
// call their internal initialization. // call their internal initialization.
// There are some exceptions. // There are some exceptions.
// ---- // ----
@@ -613,7 +612,7 @@ ACMGenericCodec::InitEncoderSafe(
if(codecNumber < 0) if(codecNumber < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitEncoderSafe: error, codec number negative"); "InitEncoderSafe: error, codec number negative");
return -1; return -1;
} }
@@ -621,14 +620,14 @@ ACMGenericCodec::InitEncoderSafe(
if((_codecID >= 0) && (_codecID != codecNumber) && (_codecID != mirrorID)) if((_codecID >= 0) && (_codecID != codecNumber) && (_codecID != mirrorID))
{ {
// The current codec is not the same as the one given by codecParams // The current codec is not the same as the one given by codecParams
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitEncoderSafe: current codec is not the same as the one given by codecParams"); "InitEncoderSafe: current codec is not the same as the one given by codecParams");
return -1; return -1;
} }
if(!CanChangeEncodingParam(codecParams->codecInstant)) if(!CanChangeEncodingParam(codecParams->codecInstant))
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitEncoderSafe: cannot change encoding parameters"); "InitEncoderSafe: cannot change encoding parameters");
return -1; return -1;
} }
@@ -645,7 +644,7 @@ ACMGenericCodec::InitEncoderSafe(
status = CreateEncoder(); status = CreateEncoder();
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitEncoderSafe: cannot create encoder"); "InitEncoderSafe: cannot create encoder");
return -1; return -1;
} }
@@ -657,8 +656,8 @@ ACMGenericCodec::InitEncoderSafe(
_frameLenSmpl = (codecParams->codecInstant).pacsize; _frameLenSmpl = (codecParams->codecInstant).pacsize;
status = InternalInitEncoder(codecParams); status = InternalInitEncoder(codecParams);
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitEncoderSafe: error in init encoder"); "InitEncoderSafe: error in init encoder");
_encoderInitialized = false; _encoderInitialized = false;
return -1; return -1;
@@ -671,7 +670,7 @@ ACMGenericCodec::InitEncoderSafe(
{ {
_inAudio = new WebRtc_Word16[AUDIO_BUFFER_SIZE_W16]; _inAudio = new WebRtc_Word16[AUDIO_BUFFER_SIZE_W16];
if(_inAudio == NULL) if(_inAudio == NULL)
{ {
return -1; return -1;
} }
memset(_inAudio, 0, AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16)); memset(_inAudio, 0, AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16));
@@ -688,17 +687,17 @@ ACMGenericCodec::InitEncoderSafe(
} }
_isAudioBuffFresh = true; _isAudioBuffFresh = true;
} }
status = SetVADSafe(codecParams->enableDTX, codecParams->enableVAD, status = SetVADSafe(codecParams->enableDTX, codecParams->enableVAD,
codecParams->vadMode); codecParams->vadMode);
_noChannels = codecParams->codecInstant.channels; _noChannels = codecParams->codecInstant.channels;
return status; return status;
} }
bool bool
ACMGenericCodec::CanChangeEncodingParam( ACMGenericCodec::CanChangeEncodingParam(
CodecInst& /*codecInst*/) CodecInst& /*codecInst*/)
{ {
return true; return true;
} }
@@ -725,17 +724,17 @@ ACMGenericCodec::InitDecoderSafe(
if(codecNumber < 0) if(codecNumber < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitDecoderSafe: error, invalid codec number"); "InitDecoderSafe: error, invalid codec number");
return -1; return -1;
} }
// Check if the parameters are for this codec // Check if the parameters are for this codec
if((_codecID >= 0) && (_codecID != codecNumber) && (_codecID != mirrorID)) if((_codecID >= 0) && (_codecID != codecNumber) && (_codecID != mirrorID))
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitDecoderSafe: current codec is not the same as the one given " "InitDecoderSafe: current codec is not the same as the one given "
"by codecParams"); "by codecParams");
// The current codec is not the same as the one given by codecParams // The current codec is not the same as the one given by codecParams
return -1; return -1;
} }
@@ -753,7 +752,7 @@ ACMGenericCodec::InitDecoderSafe(
status = CreateDecoder(); status = CreateDecoder();
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitDecoderSafe: cannot create decoder"); "InitDecoderSafe: cannot create decoder");
return -1; return -1;
} }
@@ -765,8 +764,8 @@ ACMGenericCodec::InitDecoderSafe(
status = InternalInitDecoder(codecParams); status = InternalInitDecoder(codecParams);
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InitDecoderSafe: cannot init decoder"); "InitDecoderSafe: cannot init decoder");
_decoderInitialized = false; _decoderInitialized = false;
return -1; return -1;
@@ -796,22 +795,22 @@ ACMGenericCodec::ResetDecoderSafe(WebRtc_Word16 payloadType)
{ {
return 0; return 0;
} }
// Initialization of the decoder should work for all // Initialization of the decoder should work for all
// the codec. If there is a codec that has to keep // the codec. If there is a codec that has to keep
// some states then we need to define a virtual and // some states then we need to define a virtual and
// overwrite in that codec // overwrite in that codec
DecoderParamsSafe(&decoderParams, (WebRtc_UWord8) payloadType); DecoderParamsSafe(&decoderParams, (WebRtc_UWord8) payloadType);
return InternalInitDecoder(&decoderParams); return InternalInitDecoder(&decoderParams);
} }
void void
ACMGenericCodec::ResetNoMissedSamples() ACMGenericCodec::ResetNoMissedSamples()
{ {
WriteLockScoped cs(_codecWrapperLock); WriteLockScoped cs(_codecWrapperLock);
_noMissedSamples = 0; _noMissedSamples = 0;
} }
void void
ACMGenericCodec::IncreaseNoMissedSamples( ACMGenericCodec::IncreaseNoMissedSamples(
const WebRtc_Word16 noSamples) const WebRtc_Word16 noSamples)
{ {
@@ -825,11 +824,11 @@ ACMGenericCodec::NoMissedSamples() const
ReadLockScoped cs(_codecWrapperLock); ReadLockScoped cs(_codecWrapperLock);
return _noMissedSamples; return _noMissedSamples;
} }
void void
ACMGenericCodec::DestructEncoder() ACMGenericCodec::DestructEncoder()
{ {
WriteLockScoped wl(_codecWrapperLock); WriteLockScoped wl(_codecWrapperLock);
// Disable VAD and delete the instance // Disable VAD and delete the instance
if(_ptrVADInst != NULL) if(_ptrVADInst != NULL)
{ {
@@ -851,7 +850,7 @@ ACMGenericCodec::DestructEncoder()
DestructEncoderSafe(); DestructEncoderSafe();
} }
void void
ACMGenericCodec::DestructDecoder() ACMGenericCodec::DestructDecoder()
{ {
WriteLockScoped wl(_codecWrapperLock); WriteLockScoped wl(_codecWrapperLock);
@@ -877,13 +876,13 @@ ACMGenericCodec::SetBitRateSafe(
CodecInst codecParams; CodecInst codecParams;
if(ACMCodecDB::Codec(_codecID, &codecParams) < 0) if(ACMCodecDB::Codec(_codecID, &codecParams) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: error in ACMCodecDB::Codec"); "SetBitRateSafe: error in ACMCodecDB::Codec");
return -1; return -1;
} }
if(codecParams.rate != bitRateBPS) if(codecParams.rate != bitRateBPS)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: rate value is not acceptable"); "SetBitRateSafe: rate value is not acceptable");
return -1; return -1;
} }
@@ -946,14 +945,14 @@ ACMGenericCodec::CreateEncoder()
WebRtc_Word16 status = 0; WebRtc_Word16 status = 0;
if(!_encoderExist) if(!_encoderExist)
{ {
status = InternalCreateEncoder(); status = InternalCreateEncoder();
// We just created the codec and obviously it is not initialized // We just created the codec and obviously it is not initialized
_encoderInitialized = false; _encoderInitialized = false;
} }
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CreateEncoder: error in internal create encoder"); "CreateEncoder: error in internal create encoder");
_encoderExist = false; _encoderExist = false;
} }
@@ -970,14 +969,14 @@ ACMGenericCodec::CreateDecoder()
WebRtc_Word16 status = 0; WebRtc_Word16 status = 0;
if(!_decoderExist) if(!_decoderExist)
{ {
status = InternalCreateDecoder(); status = InternalCreateDecoder();
// Decoder just created and obviously it is not initialized // Decoder just created and obviously it is not initialized
_decoderInitialized = false; _decoderInitialized = false;
} }
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CreateDecoder: error in internal create decoder"); "CreateDecoder: error in internal create decoder");
_decoderExist = false; _decoderExist = false;
} }
@@ -1005,11 +1004,11 @@ ACMGenericCodec::AudioBuffer(
WebRtcACMAudioBuff& audioBuff) WebRtcACMAudioBuff& audioBuff)
{ {
ReadLockScoped cs(_codecWrapperLock); ReadLockScoped cs(_codecWrapperLock);
memcpy(audioBuff.inAudio, _inAudio, memcpy(audioBuff.inAudio, _inAudio,
AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16)); AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16));
audioBuff.inAudioIxRead = _inAudioIxRead; audioBuff.inAudioIxRead = _inAudioIxRead;
audioBuff.inAudioIxWrite = _inAudioIxWrite; audioBuff.inAudioIxWrite = _inAudioIxWrite;
memcpy(audioBuff.inTimestamp, _inTimestamp, memcpy(audioBuff.inTimestamp, _inTimestamp,
TIMESTAMP_BUFFER_SIZE_W32*sizeof(WebRtc_UWord32)); TIMESTAMP_BUFFER_SIZE_W32*sizeof(WebRtc_UWord32));
audioBuff.inTimestampIxWrite = _inTimestampIxWrite; audioBuff.inTimestampIxWrite = _inTimestampIxWrite;
audioBuff.lastTimestamp = _lastTimestamp; audioBuff.lastTimestamp = _lastTimestamp;
@@ -1022,11 +1021,11 @@ ACMGenericCodec::SetAudioBuffer(
WebRtcACMAudioBuff& audioBuff) WebRtcACMAudioBuff& audioBuff)
{ {
WriteLockScoped cs(_codecWrapperLock); WriteLockScoped cs(_codecWrapperLock);
memcpy(_inAudio, audioBuff.inAudio, memcpy(_inAudio, audioBuff.inAudio,
AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16)); AUDIO_BUFFER_SIZE_W16 * sizeof(WebRtc_Word16));
_inAudioIxRead = audioBuff.inAudioIxRead; _inAudioIxRead = audioBuff.inAudioIxRead;
_inAudioIxWrite = audioBuff.inAudioIxWrite; _inAudioIxWrite = audioBuff.inAudioIxWrite;
memcpy(_inTimestamp, audioBuff.inTimestamp, memcpy(_inTimestamp, audioBuff.inTimestamp,
TIMESTAMP_BUFFER_SIZE_W32*sizeof(WebRtc_UWord32)); TIMESTAMP_BUFFER_SIZE_W32*sizeof(WebRtc_UWord32));
_inTimestampIxWrite = audioBuff.inTimestampIxWrite; _inTimestampIxWrite = audioBuff.inTimestampIxWrite;
_lastTimestamp = audioBuff.lastTimestamp; _lastTimestamp = audioBuff.lastTimestamp;
@@ -1075,7 +1074,7 @@ ACMGenericCodec::SetVADSafe(
{ {
if (ACMGenericCodec::EnableDTX() < 0) if (ACMGenericCodec::EnableDTX() < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetVADSafe: error in enable DTX"); "SetVADSafe: error in enable DTX");
return -1; return -1;
} }
@@ -1084,7 +1083,7 @@ ACMGenericCodec::SetVADSafe(
{ {
if(EnableDTX() < 0) if(EnableDTX() < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetVADSafe: error in enable DTX"); "SetVADSafe: error in enable DTX");
return -1; return -1;
} }
@@ -1096,7 +1095,7 @@ ACMGenericCodec::SetVADSafe(
// however, we let the user to turn it on if they need call-backs // however, we let the user to turn it on if they need call-backs
// on silence. Store VAD mode for future even if VAD is off. // on silence. Store VAD mode for future even if VAD is off.
_vadMode = mode; _vadMode = mode;
return (enableVAD)? EnableVAD(mode):DisableVAD(); return (enableVAD)? EnableVAD(mode):DisableVAD();
} }
else else
{ {
@@ -1109,11 +1108,11 @@ ACMGenericCodec::SetVADSafe(
{ {
DisableDTX(); DisableDTX();
} }
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetVADSafe: error in enable VAD"); "SetVADSafe: error in enable VAD");
return -1; return -1;
} }
// Return '1', to let the caller know VAD was turned on, even if the // Return '1', to let the caller know VAD was turned on, even if the
// function was called with VAD='false' // function was called with VAD='false'
if (enableVAD == false) { if (enableVAD == false) {
@@ -1134,7 +1133,7 @@ ACMGenericCodec::SetVADSafe(
{ {
DisableDTX(); DisableDTX();
} }
return (enableVAD)? EnableVAD(mode):DisableVAD(); return (enableVAD)? EnableVAD(mode):DisableVAD();
} }
} }
@@ -1195,7 +1194,7 @@ ACMGenericCodec::EnableVAD(
{ {
if((mode < VADNormal) || (mode > VADVeryAggr)) if((mode < VADNormal) || (mode > VADVeryAggr))
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableVAD: error in VAD mode range"); "EnableVAD: error in VAD mode range");
return -1; return -1;
} }
@@ -1205,7 +1204,7 @@ ACMGenericCodec::EnableVAD(
if(WebRtcVad_Create(&_ptrVADInst) < 0) if(WebRtcVad_Create(&_ptrVADInst) < 0)
{ {
_ptrVADInst = NULL; _ptrVADInst = NULL;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableVAD: error in create VAD"); "EnableVAD: error in create VAD");
return -1; return -1;
} }
@@ -1213,7 +1212,7 @@ ACMGenericCodec::EnableVAD(
{ {
WebRtcVad_Free(_ptrVADInst); WebRtcVad_Free(_ptrVADInst);
_ptrVADInst = NULL; _ptrVADInst = NULL;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableVAD: error in init VAD"); "EnableVAD: error in init VAD");
return -1; return -1;
} }
@@ -1233,7 +1232,7 @@ ACMGenericCodec::EnableVAD(
WebRtcVad_Free(_ptrVADInst); WebRtcVad_Free(_ptrVADInst);
_ptrVADInst = NULL; _ptrVADInst = NULL;
} }
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, _uniqueID,
"EnableVAD: failed to set the VAD mode"); "EnableVAD: failed to set the VAD mode");
return -1; return -1;
} }
@@ -1314,14 +1313,14 @@ ACMGenericCodec::ProcessFrameVADDTX(
// Calculate number of VAD-blocks to process, and number of samples in each block. // Calculate number of VAD-blocks to process, and number of samples in each block.
int noSamplesToProcess[2]; int noSamplesToProcess[2];
if (frameLenMsec == 40) if (frameLenMsec == 40)
{ {
// 20 ms in each VAD block // 20 ms in each VAD block
noSamplesToProcess[0] = noSamplesToProcess[1] = 2*samplesIn10Msec; noSamplesToProcess[0] = noSamplesToProcess[1] = 2*samplesIn10Msec;
} }
else else
{ {
// For 10-30 ms framesizes, second VAD block will be size zero ms, // For 10-30 ms framesizes, second VAD block will be size zero ms,
// for 50 and 60 ms first VAD block will be 30 ms. // for 50 and 60 ms first VAD block will be 30 ms.
noSamplesToProcess[0] = (frameLenMsec > 30)? 3*samplesIn10Msec : _frameLenSmpl; noSamplesToProcess[0] = (frameLenMsec > 30)? 3*samplesIn10Msec : _frameLenSmpl;
noSamplesToProcess[1] = _frameLenSmpl-noSamplesToProcess[0]; noSamplesToProcess[1] = _frameLenSmpl-noSamplesToProcess[0];
@@ -1340,20 +1339,20 @@ ACMGenericCodec::ProcessFrameVADDTX(
// Mono, copy data from _inAudio to continue work on // Mono, copy data from _inAudio to continue work on
memcpy(audio, _inAudio, sizeof(WebRtc_Word16)*noSamplesToProcess[i]); memcpy(audio, _inAudio, sizeof(WebRtc_Word16)*noSamplesToProcess[i]);
} }
// Call VAD // Call VAD
status = WebRtcVad_Process(_ptrVADInst, (WebRtc_Word16)freqHz, status = WebRtcVad_Process(_ptrVADInst, (WebRtc_Word16)freqHz,
audio, noSamplesToProcess[i]); audio, noSamplesToProcess[i]);
_vadLabel[i] = status; _vadLabel[i] = status;
if(status < 0) if(status < 0)
{ {
// This will force that the data be removed from the buffer // This will force that the data be removed from the buffer
*samplesProcessed += noSamplesToProcess[i]; *samplesProcessed += noSamplesToProcess[i];
return -1; return -1;
} }
// If VAD decision non-active, update DTX. NOTE! We only do this if the first part of // If VAD decision non-active, update DTX. NOTE! We only do this if the first part of
// a frame gets the VAD decision "inactive". Otherwise DTX might say it is time to // a frame gets the VAD decision "inactive". Otherwise DTX might say it is time to
// transmit SID frame, but we will encode the whole frame, because the first part is // transmit SID frame, but we will encode the whole frame, because the first part is
@@ -1418,8 +1417,8 @@ ACMGenericCodec::UnregisterFromNetEq(
} }
if(UnregisterFromNetEqSafe(netEq, payloadType) < 0) if(UnregisterFromNetEqSafe(netEq, payloadType) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"UnregisterFromNetEq: error, cannot unregister from NetEq"); "UnregisterFromNetEq: error, cannot unregister from NetEq");
_registeredInNetEq = true; _registeredInNetEq = true;
return -1; return -1;
} }
@@ -1430,7 +1429,7 @@ ACMGenericCodec::UnregisterFromNetEq(
} }
} }
void void
ACMGenericCodec::SetUniqueID( ACMGenericCodec::SetUniqueID(
const WebRtc_UWord32 id) const WebRtc_UWord32 id)
{ {
@@ -1441,7 +1440,7 @@ bool
ACMGenericCodec::IsAudioBufferFresh() const ACMGenericCodec::IsAudioBufferFresh() const
{ {
ReadLockScoped rl(_codecWrapperLock); ReadLockScoped rl(_codecWrapperLock);
return _isAudioBuffFresh; return _isAudioBuffFresh;
} }
// This function is replaced by codec specific functions for some codecs // This function is replaced by codec specific functions for some codecs
@@ -1452,8 +1451,8 @@ ACMGenericCodec::EncoderSampFreq(WebRtc_UWord16& sampFreqHz)
f = ACMCodecDB::CodecFreq(_codecID); f = ACMCodecDB::CodecFreq(_codecID);
if(f < 0) if(f < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EncoderSampFreq: codec frequency is negative"); "EncoderSampFreq: codec frequency is negative");
return -1; return -1;
} }
else else
@@ -1470,7 +1469,7 @@ ACMGenericCodec::ConfigISACBandwidthEstimator(
const WebRtc_UWord16 /* initRateBitPerSec */, const WebRtc_UWord16 /* initRateBitPerSec */,
const bool /* enforceFrameSize */) const bool /* enforceFrameSize */)
{ {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID,
"The send-codec is not iSAC, failed to config iSAC bandwidth estimator."); "The send-codec is not iSAC, failed to config iSAC bandwidth estimator.");
return -1; return -1;
} }
@@ -1479,16 +1478,16 @@ WebRtc_Word32
ACMGenericCodec::SetISACMaxRate( ACMGenericCodec::SetISACMaxRate(
const WebRtc_UWord32 /* maxRateBitPerSec */) const WebRtc_UWord32 /* maxRateBitPerSec */)
{ {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID,
"The send-codec is not iSAC, failed to set iSAC max rate."); "The send-codec is not iSAC, failed to set iSAC max rate.");
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32
ACMGenericCodec::SetISACMaxPayloadSize( ACMGenericCodec::SetISACMaxPayloadSize(
const WebRtc_UWord16 /* maxPayloadLenBytes */) const WebRtc_UWord16 /* maxPayloadLenBytes */)
{ {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _uniqueID,
"The send-codec is not iSAC, failed to set iSAC max payload-size."); "The send-codec is not iSAC, failed to set iSAC max payload-size.");
return -1; return -1;
} }
@@ -1514,7 +1513,7 @@ WebRtc_Word16
ACMGenericCodec::UpdateEncoderSampFreq( ACMGenericCodec::UpdateEncoderSampFreq(
WebRtc_UWord16 /* encoderSampFreqHz */) WebRtc_UWord16 /* encoderSampFreqHz */)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"It is asked for a change in smapling frequency while the \ "It is asked for a change in smapling frequency while the \
current send-codec supports only one sampling rate."); current send-codec supports only one sampling rate.");
return -1; return -1;
@@ -1538,7 +1537,7 @@ ACMGenericCodec::REDPayloadISAC(
WebRtc_UWord8* /* payload */, WebRtc_UWord8* /* payload */,
WebRtc_Word16* /* payloadLenBytes */) WebRtc_Word16* /* payloadLenBytes */)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error: REDPayloadISAC is an iSAC specific function"); "Error: REDPayloadISAC is an iSAC specific function");
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_GENERIC_CODEC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#define ACM_GENERIC_CODEC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#include "acm_common_defs.h" #include "acm_common_defs.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
@@ -322,7 +322,7 @@ public:
// 0 if the rate is adjusted successfully // 0 if the rate is adjusted successfully
// //
WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS); WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// DestructEncoderInst() // DestructEncoderInst()
@@ -411,7 +411,7 @@ public:
const bool enableDTX = true, const bool enableDTX = true,
const bool enableVAD = false, const bool enableVAD = false,
const ACMVADMode mode = VADNormal); const ACMVADMode mode = VADNormal);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReplaceInternalDTX() // WebRtc_Word32 ReplaceInternalDTX()
@@ -451,9 +451,9 @@ public:
// -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM. // -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM.
// //
void SetNetEqDecodeLock( void SetNetEqDecodeLock(
RWLockWrapper* netEqDecodeLock) RWLockWrapper* netEqDecodeLock)
{ {
_netEqDecodeLock = netEqDecodeLock; _netEqDecodeLock = netEqDecodeLock;
} }
@@ -465,7 +465,7 @@ public:
// true if the codec has an internal DTX, e.g. G729, // true if the codec has an internal DTX, e.g. G729,
// false otherwise. // false otherwise.
// //
bool HasInternalDTX() const bool HasInternalDTX() const
{ {
return _hasInternalDTX; return _hasInternalDTX;
} }
@@ -481,7 +481,7 @@ public:
// >0 estimated bandwidth in bits/sec. // >0 estimated bandwidth in bits/sec.
// //
WebRtc_Word32 GetEstimatedBandwidth(); WebRtc_Word32 GetEstimatedBandwidth();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetEstimatedBandwidth() // WebRtc_Word32 SetEstimatedBandwidth()
@@ -514,7 +514,7 @@ public:
WebRtc_UWord8* redPayload, WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes); WebRtc_Word16* payloadBytes);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 ResetEncoder() // WebRtc_Word16 ResetEncoder()
// By calling this function you would re-initialize the encoder with the // By calling this function you would re-initialize the encoder with the
@@ -540,7 +540,7 @@ public:
WebRtc_Word16 ResetDecoder( WebRtc_Word16 ResetDecoder(
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void DestructEncoder() // void DestructEncoder()
// This function is called to delete the encoder instance, if possible, to // This function is called to delete the encoder instance, if possible, to
@@ -581,7 +581,7 @@ public:
// //
WebRtc_UWord32 LastEncodedTimestamp() const; WebRtc_UWord32 LastEncodedTimestamp() const;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 UnregisterFromNetEq() // WebRtc_Word32 UnregisterFromNetEq()
// To remove the codec from NetEQ. If the codec (or the decoder instance) // To remove the codec from NetEQ. If the codec (or the decoder instance)
@@ -654,7 +654,7 @@ public:
return 0; return 0;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// UpdateEncoderSampFreq() // UpdateEncoderSampFreq()
// Call this function to update the encoder sampling frequency. This // Call this function to update the encoder sampling frequency. This
@@ -757,7 +757,7 @@ public:
// //
virtual WebRtc_Word32 SetISACMaxRate( virtual WebRtc_Word32 SetISACMaxRate(
const WebRtc_UWord32 maxRateBitPerSec); const WebRtc_UWord32 maxRateBitPerSec);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SaveDecoderParamS() // SaveDecoderParamS()
@@ -779,7 +779,7 @@ public:
void SetIsMaster(bool isMaster); void SetIsMaster(bool isMaster);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// REDPayloadISAC() // REDPayloadISAC()
@@ -810,7 +810,7 @@ public:
const WebRtc_Word16 isacBwEstimate, const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload, WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenBytes); WebRtc_Word16* payloadLenBytes);
protected: protected:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// All the functions with FunctionNameSafe(...) contain the actual // All the functions with FunctionNameSafe(...) contain the actual
@@ -840,7 +840,7 @@ protected:
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType) = 0; WebRtc_Word8* speechType) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See Add10MsSafe() for the description of function, input(s)/output(s) // See Add10MsSafe() for the description of function, input(s)/output(s)
// and return value. // and return value.
@@ -850,22 +850,22 @@ protected:
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 length, const WebRtc_UWord16 length,
const WebRtc_UWord8 audioChannel); const WebRtc_UWord8 audioChannel);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See RegisterInNetEq() for the description of function, // See RegisterInNetEq() for the description of function,
// input(s)/output(s) and return value. // input(s)/output(s) and return value.
// //
virtual WebRtc_Word32 CodecDef( virtual WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) = 0; const CodecInst& codecInst) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See EncoderParam() for the description of function, input(s)/output(s) // See EncoderParam() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 EncoderParamsSafe( WebRtc_Word16 EncoderParamsSafe(
WebRtcACMCodecParams *encParams); WebRtcACMCodecParams *encParams);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See DecoderParam for the description of function, input(s)/output(s) // See DecoderParam for the description of function, input(s)/output(s)
// and return value. // and return value.
@@ -883,13 +883,13 @@ protected:
virtual bool DecoderParamsSafe( virtual bool DecoderParamsSafe(
WebRtcACMCodecParams *decParams, WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See ResetEncoder() for the description of function, input(s)/output(s) // See ResetEncoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 ResetEncoderSafe(); WebRtc_Word16 ResetEncoderSafe();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See InitEncoder() for the description of function, input(s)/output(s) // See InitEncoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
@@ -905,14 +905,14 @@ protected:
WebRtc_Word16 InitDecoderSafe( WebRtc_Word16 InitDecoderSafe(
WebRtcACMCodecParams *codecParams, WebRtcACMCodecParams *codecParams,
bool forceInitialization); bool forceInitialization);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See ResetDecoder() for the description of function, input(s)/output(s) // See ResetDecoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 ResetDecoderSafe( WebRtc_Word16 ResetDecoderSafe(
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See DestructEncoder() for the description of function, // See DestructEncoder() for the description of function,
// input(s)/output(s) and return value. // input(s)/output(s) and return value.
@@ -924,7 +924,7 @@ protected:
// input(s)/output(s) and return value. // input(s)/output(s) and return value.
// //
virtual void DestructDecoderSafe() = 0; virtual void DestructDecoderSafe() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See SetBitRate() for the description of function, input(s)/output(s) // See SetBitRate() for the description of function, input(s)/output(s)
// and return value. // and return value.
@@ -933,19 +933,19 @@ protected:
// //
virtual WebRtc_Word16 SetBitRateSafe( virtual WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 bitRateBPS); const WebRtc_Word32 bitRateBPS);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See GetEstimatedBandwidth() for the description of function, input(s)/output(s) // See GetEstimatedBandwidth() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
virtual WebRtc_Word32 GetEstimatedBandwidthSafe(); virtual WebRtc_Word32 GetEstimatedBandwidthSafe();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See SetEstimatedBandwidth() for the description of function, input(s)/output(s) // See SetEstimatedBandwidth() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
virtual WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth); virtual WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See GetRedPayload() for the description of function, input(s)/output(s) // See GetRedPayload() for the description of function, input(s)/output(s)
// and return value. // and return value.
@@ -1145,7 +1145,7 @@ protected:
// //
virtual WebRtc_Word16 InternalCreateEncoder() = 0; virtual WebRtc_Word16 InternalCreateEncoder() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalCreateDecoder() // WebRtc_Word16 InternalCreateDecoder()
// This is a codec-specific method called in CreateDecoderSafe() it is // This is a codec-specific method called in CreateDecoderSafe() it is
@@ -1175,7 +1175,7 @@ protected:
// 0 if succeeded. // 0 if succeeded.
// //
virtual void InternalDestructEncoderInst( virtual void InternalDestructEncoderInst(
void* ptrInst) = 0; void* ptrInst) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@@ -1230,7 +1230,7 @@ protected:
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitStreamLenByte,
WebRtc_Word16* samplesProcessed); WebRtc_Word16* samplesProcessed);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// CanChangeEncodingParam() // CanChangeEncodingParam()
// Check if the codec parameters can be changed. In conferencing normally // Check if the codec parameters can be changed. In conferencing normally
@@ -1242,7 +1242,7 @@ protected:
// //
virtual bool CanChangeEncodingParam(CodecInst& codecInst); virtual bool CanChangeEncodingParam(CodecInst& codecInst);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// CurrentRate() // CurrentRate()
// Call to get the current encoding rate of the encoder. This function // Call to get the current encoding rate of the encoder. This function
@@ -1256,24 +1256,23 @@ protected:
virtual void CurrentRate( virtual void CurrentRate(
WebRtc_Word32& /* rateBitPerSec */) WebRtc_Word32& /* rateBitPerSec */)
{ {
return; return;
} }
virtual void SaveDecoderParamSafe( virtual void SaveDecoderParamSafe(
const WebRtcACMCodecParams* codecParams); const WebRtcACMCodecParams* codecParams);
// &_inAudio[_inAudioIxWrite] always point to where new audio can be // &_inAudio[_inAudioIxWrite] always point to where new audio can be
// written to // written to
WebRtc_Word16 _inAudioIxWrite; WebRtc_Word16 _inAudioIxWrite;
// &_inAudio[_inAudioIxRead] points to where audio has to be read from // &_inAudio[_inAudioIxRead] points to where audio has to be read from
WebRtc_Word16 _inAudioIxRead; WebRtc_Word16 _inAudioIxRead;
WebRtc_Word16 _inTimestampIxWrite; WebRtc_Word16 _inTimestampIxWrite;
// Where the audio is stored before encoding, // Where the audio is stored before encoding,
// To save memory the following buffer can be allocated // To save memory the following buffer can be allocated
// dynamically for 80ms depending on the sampling frequency // dynamically for 80ms depending on the sampling frequency
// of the codec. // of the codec.
@@ -1285,12 +1284,12 @@ protected:
// This will point to a static database of the supported codecs // This will point to a static database of the supported codecs
WebRtc_Word16 _codecID; WebRtc_Word16 _codecID;
// This will account for the No of samples were not encoded // This will account for the No of samples were not encoded
// the case is rare, either samples are missed due to overwite // the case is rare, either samples are missed due to overwite
// at input buffer or due to encoding error // at input buffer or due to encoding error
WebRtc_UWord32 _noMissedSamples; WebRtc_UWord32 _noMissedSamples;
// True if the encoder instance created // True if the encoder instance created
bool _encoderExist; bool _encoderExist;
bool _decoderExist; bool _decoderExist;
@@ -1330,4 +1329,4 @@ protected:
} // namespace webrt } // namespace webrt
#endif // ACM_GENERIC_CODEC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_

View File

@@ -55,42 +55,42 @@ ACMGSMFR::~ACMGSMFR()
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalEncode( ACMGSMFR::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */)
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::DecodeSafe( ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::EnableDTX() ACMGSMFR::EnableDTX()
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::DisableDTX() ACMGSMFR::DisableDTX()
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalInitEncoder( ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -98,7 +98,7 @@ ACMGSMFR::InternalInitEncoder(
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalInitDecoder( ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -106,51 +106,51 @@ ACMGSMFR::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMGSMFR::CodecDef( ACMGSMFR::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec*
ACMGSMFR::CreateInstance(void) ACMGSMFR::CreateInstance(void)
{ {
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalCreateEncoder() ACMGSMFR::InternalCreateEncoder()
{ {
return -1; return -1;
} }
void void
ACMGSMFR::DestructEncoderSafe() ACMGSMFR::DestructEncoderSafe()
{ {
return; return;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalCreateDecoder() ACMGSMFR::InternalCreateDecoder()
{ {
return -1; return -1;
} }
void void
ACMGSMFR::DestructDecoderSafe() ACMGSMFR::DestructDecoderSafe()
{ {
return; return;
} }
void void
ACMGSMFR::InternalDestructEncoderInst( ACMGSMFR::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -158,7 +158,7 @@ ACMGSMFR::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::UnregisterFromNetEqSafe( ACMGSMFR::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */)
@@ -196,33 +196,33 @@ ACMGSMFR::~ACMGSMFR()
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalEncode( ACMGSMFR::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
{ {
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream); &_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; _inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::DecodeSafe( ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::EnableDTX() ACMGSMFR::EnableDTX()
{ {
if(_dtxEnabled) if(_dtxEnabled)
@@ -233,8 +233,8 @@ ACMGSMFR::EnableDTX()
{ {
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableDTX: cannot init encoder for GSMFR"); "EnableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
@@ -247,7 +247,7 @@ ACMGSMFR::EnableDTX()
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::DisableDTX() ACMGSMFR::DisableDTX()
{ {
if(!_dtxEnabled) if(!_dtxEnabled)
@@ -258,8 +258,8 @@ ACMGSMFR::DisableDTX()
{ {
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"DisableDTX: cannot init encoder for GSMFR"); "DisableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
@@ -273,45 +273,45 @@ ACMGSMFR::DisableDTX()
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalInitEncoder( ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) WebRtcACMCodecParams* codecParams)
{ {
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0) if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: cannot init encoder for GSMFR"); "InternalInitEncoder: cannot init encoder for GSMFR");
} }
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalInitDecoder( ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0) if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: cannot init decoder for GSMFR"); "InternalInitDecoder: cannot init decoder for GSMFR");
return -1; return -1;
} }
return 0; return 0;
} }
WebRtc_Word32 WebRtc_Word32
ACMGSMFR::CodecDef( ACMGSMFR::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
{ {
if (!_decoderInitialized) if (!_decoderInitialized)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodecDef: decoder is not initialized for GSMFR"); "CodecDef: decoder is not initialized for GSMFR");
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION." // "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -322,27 +322,27 @@ ACMGSMFR::CodecDef(
} }
ACMGenericCodec* ACMGenericCodec*
ACMGSMFR::CreateInstance(void) ACMGSMFR::CreateInstance(void)
{ {
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalCreateEncoder() ACMGSMFR::InternalCreateEncoder()
{ {
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for GSMFR encoder"); "InternalCreateEncoder: cannot create instance for GSMFR encoder");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMGSMFR::DestructEncoderSafe() ACMGSMFR::DestructEncoderSafe()
{ {
if(_encoderInstPtr != NULL) if(_encoderInstPtr != NULL)
@@ -355,20 +355,20 @@ ACMGSMFR::DestructEncoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::InternalCreateDecoder() ACMGSMFR::InternalCreateDecoder()
{ {
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for GSMFR decoder"); "InternalCreateDecoder: cannot create instance for GSMFR decoder");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMGSMFR::DestructDecoderSafe() ACMGSMFR::DestructDecoderSafe()
{ {
if(_decoderInstPtr != NULL) if(_decoderInstPtr != NULL)
@@ -381,7 +381,7 @@ ACMGSMFR::DestructDecoderSafe()
} }
void void
ACMGSMFR::InternalDestructEncoderInst( ACMGSMFR::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
@@ -393,18 +393,18 @@ ACMGSMFR::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMGSMFR::UnregisterFromNetEqSafe( ACMGSMFR::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: payload-type does not match \ "Cannot unregister codec: payload-type does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_GSMFR_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#define ACM_GSMFR_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -28,7 +28,7 @@ public:
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream, WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(
@@ -39,29 +39,29 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
@@ -74,5 +74,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_GSMFR_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_

View File

@@ -76,7 +76,7 @@ ACMILBC::InternalInitDecoder(
WebRtc_Word32 WebRtc_Word32
ACMILBC::CodecDef( ACMILBC::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
@@ -97,7 +97,7 @@ ACMILBC::InternalCreateEncoder()
} }
void void
ACMILBC::DestructEncoderSafe() ACMILBC::DestructEncoderSafe()
{ {
return; return;
@@ -111,14 +111,14 @@ ACMILBC::InternalCreateDecoder()
} }
void void
ACMILBC::DestructDecoderSafe() ACMILBC::DestructDecoderSafe()
{ {
return; return;
} }
void void
ACMILBC::InternalDestructEncoderInst( ACMILBC::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -175,15 +175,15 @@ ACMILBC::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
{ {
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream); &_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
if (*bitStreamLenByte < 0) if (*bitStreamLenByte < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: error in encode for ILBC"); "InternalEncode: error in encode for ILBC");
return -1; return -1;
} }
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; _inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte; return *bitStreamLenByte;
@@ -207,7 +207,7 @@ ACMILBC::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) WebRtcACMCodecParams* codecParams)
{ {
// initialize with a correct processing block length // initialize with a correct processing block length
if((160 == (codecParams->codecInstant).pacsize) || if((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) (320 == (codecParams->codecInstant).pacsize))
{ {
// processing block of 20ms // processing block of 20ms
@@ -221,8 +221,8 @@ ACMILBC::InternalInitEncoder(
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: invalid processing block"); "InternalInitEncoder: invalid processing block");
return -1; return -1;
} }
} }
@@ -233,13 +233,13 @@ ACMILBC::InternalInitDecoder(
WebRtcACMCodecParams* codecParams) WebRtcACMCodecParams* codecParams)
{ {
// initialize with a correct processing block length // initialize with a correct processing block length
if((160 == (codecParams->codecInstant).pacsize) || if((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) (320 == (codecParams->codecInstant).pacsize))
{ {
// processing block of 20ms // processing block of 20ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20); return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
} }
else if((240 == (codecParams->codecInstant).pacsize) || else if((240 == (codecParams->codecInstant).pacsize) ||
(480 == (codecParams->codecInstant).pacsize)) (480 == (codecParams->codecInstant).pacsize))
{ {
// processing block of 30ms // processing block of 30ms
@@ -247,8 +247,8 @@ ACMILBC::InternalInitDecoder(
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: invalid processing block"); "InternalInitDecoder: invalid processing block");
return -1; return -1;
} }
} }
@@ -261,15 +261,15 @@ ACMILBC::CodecDef(
{ {
if (!_decoderInitialized) if (!_decoderInitialized)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: decoder not initialized for ILBC"); "CodeDef: decoder not initialized for ILBC");
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION." // "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype,
_decoderInstPtr, 8000); _decoderInstPtr, 8000);
SET_ILBC_FUNCTIONS((codecDef)); SET_ILBC_FUNCTIONS((codecDef));
return 0; return 0;
@@ -288,15 +288,15 @@ ACMILBC::InternalCreateEncoder()
{ {
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for ILBC encoder"); "InternalCreateEncoder: cannot create instance for ILBC encoder");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMILBC::DestructEncoderSafe() ACMILBC::DestructEncoderSafe()
{ {
_encoderInitialized = false; _encoderInitialized = false;
@@ -314,15 +314,15 @@ ACMILBC::InternalCreateDecoder()
{ {
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for ILBC decoder"); "InternalCreateDecoder: cannot create instance for ILBC decoder");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMILBC::DestructDecoderSafe() ACMILBC::DestructDecoderSafe()
{ {
_decoderInitialized = false; _decoderInitialized = false;
@@ -335,7 +335,7 @@ ACMILBC::DestructDecoderSafe()
} }
void void
ACMILBC::InternalDestructEncoderInst( ACMILBC::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
@@ -350,10 +350,10 @@ WebRtc_Word16
ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate)
{ {
// Check that rate is valid. No need to store the value // Check that rate is valid. No need to store the value
if (rate == 13300) if (rate == 13300)
{ {
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30); WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
} }
else if (rate == 15200) else if (rate == 15200)
{ {
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20); WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
@@ -374,11 +374,11 @@ ACMILBC::UnregisterFromNetEqSafe(
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: given payload-type does not match \ "Cannot unregister codec: given payload-type does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_ILBC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#define ACM_ILBC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -47,21 +47,21 @@ protected:
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate); const WebRtc_Word32 rate);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
@@ -75,5 +75,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_ILBC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_

View File

@@ -43,10 +43,10 @@ struct ACMISACInst
#define ISAC_MAX_RATE 56000 #define ISAC_MAX_RATE 56000
// How the scaling is computed. iSAC computes a gain based on the // How the scaling is computed. iSAC computes a gain based on the
// bottleneck. It follows the following expression for that // bottleneck. It follows the following expression for that
// //
// G(BN_kbps) = pow(10, (a + b * BN_kbps + c * BN_kbps * BN_kbps) / 20.0) // G(BN_kbps) = pow(10, (a + b * BN_kbps + c * BN_kbps * BN_kbps) / 20.0)
// / 3.4641; // / 3.4641;
// //
// Where for 30 ms framelength we have, // Where for 30 ms framelength we have,
@@ -59,11 +59,11 @@ struct ACMISACInst
#define ISAC_NUM_SUPPORTED_RATES 9 #define ISAC_NUM_SUPPORTED_RATES 9
const WebRtc_UWord16 isacSuportedRates[ISAC_NUM_SUPPORTED_RATES] = { const WebRtc_UWord16 isacSuportedRates[ISAC_NUM_SUPPORTED_RATES] = {
32000, 30000, 26000, 23000, 21000, 32000, 30000, 26000, 23000, 21000,
19000, 17000, 15000, 12000}; 19000, 17000, 15000, 12000};
const float isacScale[ISAC_NUM_SUPPORTED_RATES] = { const float isacScale[ISAC_NUM_SUPPORTED_RATES] = {
1.0f, 0.8954f, 0.7178f, 0.6081f, 0.5445f, 1.0f, 0.8954f, 0.7178f, 0.6081f, 0.5445f,
0.4875f, 0.4365f, 0.3908f, 0.3311f}; 0.4875f, 0.4365f, 0.3908f, 0.3311f};
// Tables for bandwidth estimates // Tables for bandwidth estimates
@@ -78,10 +78,10 @@ const WebRtc_Word32 isacRatesWB[NR_ISAC_BANDWIDTHS] =
const WebRtc_Word32 isacRatesSWB[NR_ISAC_BANDWIDTHS] = const WebRtc_Word32 isacRatesSWB[NR_ISAC_BANDWIDTHS] =
{ {
10000, 11000, 12400, 13800, 15300, 17000, 10000, 11000, 12400, 13800, 15300, 17000,
18900, 21000, 23200, 25400, 27600, 29800, 18900, 21000, 23200, 25400, 27600, 29800,
32000, 34100, 36300, 38500, 40700, 42900, 32000, 34100, 36300, 38500, 40700, 42900,
45100, 47300, 49500, 51700, 53900, 56000, 45100, 47300, 49500, 51700, 53900, 56000,
}; };
#if (!defined(WEBRTC_CODEC_ISAC) && !defined(WEBRTC_CODEC_ISACFX)) #if (!defined(WEBRTC_CODEC_ISAC) && !defined(WEBRTC_CODEC_ISACFX))
@@ -150,7 +150,7 @@ ACMISAC::InternalCreateDecoder()
} }
void void
ACMISAC::DestructDecoderSafe() ACMISAC::DestructDecoderSafe()
{ {
return; return;
@@ -164,7 +164,7 @@ ACMISAC::InternalCreateEncoder()
} }
void void
ACMISAC::DestructEncoderSafe() ACMISAC::DestructEncoderSafe()
{ {
return; return;
@@ -173,14 +173,14 @@ ACMISAC::DestructEncoderSafe()
WebRtc_Word32 WebRtc_Word32
ACMISAC::CodecDef( ACMISAC::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
} }
void void
ACMISAC::InternalDestructEncoderInst( ACMISAC::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -286,7 +286,7 @@ ACMISAC::SetISACMaxPayloadSize(
{ {
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32
ACMISAC::SetISACMaxRate( ACMISAC::SetISACMaxRate(
const WebRtc_UWord32 /* maxRateBitPerSec */) const WebRtc_UWord32 /* maxRateBitPerSec */)
@@ -295,20 +295,20 @@ ACMISAC::SetISACMaxRate(
} }
void void
ACMISAC::UpdateFrameLen() ACMISAC::UpdateFrameLen()
{ {
return; return;
} }
void void
ACMISAC::CurrentRate( ACMISAC::CurrentRate(
WebRtc_Word32& /*rateBitPerSec */) WebRtc_Word32& /*rateBitPerSec */)
{ {
return; return;
} }
bool bool
ACMISAC::DecoderParamsSafe( ACMISAC::DecoderParamsSafe(
WebRtcACMCodecParams* /* decParams */, WebRtcACMCodecParams* /* decParams */,
const WebRtc_UWord8 /* payloadType */) const WebRtc_UWord8 /* payloadType */)
@@ -316,7 +316,7 @@ ACMISAC::DecoderParamsSafe(
return false; return false;
} }
void void
ACMISAC::SaveDecoderParamSafe( ACMISAC::SaveDecoderParamSafe(
const WebRtcACMCodecParams* /* codecParams */) const WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -346,17 +346,17 @@ enum IsacSamplingRate
kIsacSuperWideband = 32 kIsacSuperWideband = 32
}; };
static float static float
ACMISACFixTranscodingScale( ACMISACFixTranscodingScale(
WebRtc_UWord16 rate) WebRtc_UWord16 rate)
{ {
// find the scale for transcoding, the scale is rounded // find the scale for transcoding, the scale is rounded
// downward // downward
float scale = -1; float scale = -1;
for(WebRtc_Word16 n=0; n < ISAC_NUM_SUPPORTED_RATES; n++) for(WebRtc_Word16 n=0; n < ISAC_NUM_SUPPORTED_RATES; n++)
{ {
if(rate >= isacSuportedRates[n]) if(rate >= isacSuportedRates[n])
{ {
scale = isacScale[n]; scale = isacScale[n];
break; break;
} }
@@ -364,7 +364,7 @@ ACMISACFixTranscodingScale(
return scale; return scale;
} }
static void static void
ACMISACFixGetSendBitrate( ACMISACFixGetSendBitrate(
ACM_ISAC_STRUCT* inst, ACM_ISAC_STRUCT* inst,
WebRtc_Word32* bottleNeck) WebRtc_Word32* bottleNeck)
@@ -506,9 +506,9 @@ ACMISAC::InternalEncode(
// it should be treated like codecs with 'basic coding block' // it should be treated like codecs with 'basic coding block'
// non-zero, and the following 'while-loop' should not be necessary. // non-zero, and the following 'while-loop' should not be necessary.
// However, due to a mistake in the codec the frame-size might change // 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 // 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 // sort of a bug in iSAC. to address this we treat iSAC as the
// following. // following.
if (_codecInstPtr == NULL) if (_codecInstPtr == NULL)
{ {
@@ -527,7 +527,7 @@ pushed in but no bit-stream is generated.");
} }
*bitStreamLenByte = ACM_ISAC_ENCODE(_codecInstPtr->inst, *bitStreamLenByte = ACM_ISAC_ENCODE(_codecInstPtr->inst,
&_inAudio[_inAudioIxRead], (WebRtc_Word16*)bitstream); &_inAudio[_inAudioIxRead], (WebRtc_Word16*)bitstream);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _samplesIn10MsAudio; _inAudioIxRead += _samplesIn10MsAudio;
} }
@@ -571,9 +571,9 @@ ACMISAC::InternalInitEncoder(
{ {
_isacCodingMode = ADAPTIVE; _isacCodingMode = ADAPTIVE;
} }
// sanity check that rate is in acceptable range // sanity check that rate is in acceptable range
else if((codecParams->codecInstant.rate >= ISAC_MIN_RATE) && else if((codecParams->codecInstant.rate >= ISAC_MIN_RATE) &&
(codecParams->codecInstant.rate <= ISAC_MAX_RATE)) (codecParams->codecInstant.rate <= ISAC_MAX_RATE))
{ {
_isacCodingMode = CHANNEL_INDEPENDENT; _isacCodingMode = CHANNEL_INDEPENDENT;
@@ -584,7 +584,7 @@ ACMISAC::InternalInitEncoder(
return -1; return -1;
} }
// we need to set the encoder sampling frequency. // we need to set the encoder sampling frequency.
if(UpdateEncoderSampFreq((WebRtc_UWord16)codecParams->codecInstant.plfreq) < 0) if(UpdateEncoderSampFreq((WebRtc_UWord16)codecParams->codecInstant.plfreq) < 0)
{ {
return -1; return -1;
@@ -599,8 +599,8 @@ ACMISAC::InternalInitEncoder(
if(_isacCodingMode == CHANNEL_INDEPENDENT) if(_isacCodingMode == CHANNEL_INDEPENDENT)
{ {
if(ACM_ISAC_CONTROL(_codecInstPtr->inst, if(ACM_ISAC_CONTROL(_codecInstPtr->inst,
codecParams->codecInstant.rate, codecParams->codecInstant.rate,
codecParams->codecInstant.pacsize / codecParams->codecInstant.pacsize /
(codecParams->codecInstant.plfreq / 1000)) < 0) (codecParams->codecInstant.plfreq / 1000)) < 0)
{ {
return -1; return -1;
@@ -608,7 +608,7 @@ ACMISAC::InternalInitEncoder(
} }
else else
{ {
// We need this for adaptive case and has to be called // We need this for adaptive case and has to be called
// after initialization // after initialization
ACM_ISAC_GETSENDBITRATE( ACM_ISAC_GETSENDBITRATE(
_codecInstPtr->inst, &_isacCurrentBN); _codecInstPtr->inst, &_isacCurrentBN);
@@ -637,15 +637,15 @@ ACMISAC::InternalInitDecoder(
} }
// in a one-way communication we may never register send-codec. // in a one-way communication we may never register send-codec.
// However we like that the BWE to work properly so it has to // However we like that the BWE to work properly so it has to
// be initialized. The BWE is initialized when iSAC encoder is initialized. // be initialized. The BWE is initialized when iSAC encoder is initialized.
// Therefore, we need this. // Therefore, we need this.
if(!_encoderInitialized) if(!_encoderInitialized)
{ {
// Since we don't require a valid rate or a valid packet size when initializing // Since we don't require a valid rate or a valid packet size when initializing
// the decoder, we set valid values before initializing encoder // the decoder, we set valid values before initializing encoder
codecParams->codecInstant.rate = ISACWB_DEFAULT_RATE; codecParams->codecInstant.rate = kIsacWbDefaultRate;
codecParams->codecInstant.pacsize = ISACSWB_PAC_SIZE; codecParams->codecInstant.pacsize = kIsacPacSize960;
if(InternalInitEncoder(codecParams) < 0) if(InternalInitEncoder(codecParams) < 0)
{ {
return -1; return -1;
@@ -670,7 +670,7 @@ ACMISAC::InternalCreateDecoder()
_encoderInitialized = false; _encoderInitialized = false;
if(status < 0) if(status < 0)
{ {
_encoderExist = false; _encoderExist = false;
} }
else else
{ {
@@ -680,7 +680,7 @@ ACMISAC::InternalCreateDecoder()
} }
void void
ACMISAC::DestructDecoderSafe() ACMISAC::DestructDecoderSafe()
{ {
// codec with shared instance cannot delete. // codec with shared instance cannot delete.
@@ -712,7 +712,7 @@ ACMISAC::InternalCreateEncoder()
} }
void void
ACMISAC::DestructEncoderSafe() ACMISAC::DestructEncoderSafe()
{ {
// codec with shared instance cannot delete. // codec with shared instance cannot delete.
@@ -737,7 +737,7 @@ ACMISAC::CodecDef(
// log error // log error
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_ISAC_FUNCTION." // "SET_CODEC_PAR" & "SET_ISAC_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -766,7 +766,7 @@ ACMISAC::CodecDef(
} }
void void
ACMISAC::InternalDestructEncoderInst( ACMISAC::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
@@ -821,7 +821,7 @@ ACMISAC::SetBitRateSafe(
bool reinit = false; bool reinit = false;
// change the BN of iSAC // change the BN of iSAC
if(bitRate == -1) if(bitRate == -1)
{ {
// ADAPTIVE MODE // ADAPTIVE MODE
// Check if it was already in adaptive mode // Check if it was already in adaptive mode
if(_isacCodingMode != ADAPTIVE) if(_isacCodingMode != ADAPTIVE)
@@ -833,13 +833,13 @@ ACMISAC::SetBitRateSafe(
} }
} }
// Sanity check if the rate valid // Sanity check if the rate valid
else if((bitRate >= ISAC_MIN_RATE) && else if((bitRate >= ISAC_MIN_RATE) &&
(bitRate <= ISAC_MAX_RATE)) (bitRate <= ISAC_MAX_RATE))
{ {
//check if it was in channel-independent mode before //check if it was in channel-independent mode before
if(_isacCodingMode != CHANNEL_INDEPENDENT) if(_isacCodingMode != CHANNEL_INDEPENDENT)
{ {
// was not in channel independent, set the mode to // was not in channel independent, set the mode to
// channel-independent and flag for re-initialization // channel-independent and flag for re-initialization
_isacCodingMode = CHANNEL_INDEPENDENT; _isacCodingMode = CHANNEL_INDEPENDENT;
reinit = true; reinit = true;
@@ -867,13 +867,13 @@ ACMISAC::SetBitRateSafe(
{ {
status = ACM_ISAC_CONTROL(_codecInstPtr->inst, _isacCurrentBN, status = ACM_ISAC_CONTROL(_codecInstPtr->inst, _isacCurrentBN,
(encoderSampFreq == 32000)? 30:(_frameLenSmpl / 16)); (encoderSampFreq == 32000)? 30:(_frameLenSmpl / 16));
if(status < 0) if(status < 0)
{ {
status = -1; status = -1;
} }
} }
// Update encoder parameters // Update encoder parameters
_encoderParams.codecInstant.rate = bitRate; _encoderParams.codecInstant.rate = bitRate;
@@ -889,9 +889,9 @@ ACMISAC::GetEstimatedBandwidthSafe()
WebRtc_Word16 delayIndex; WebRtc_Word16 delayIndex;
IsacSamplingRate sampRate; IsacSamplingRate sampRate;
// Get bandwidth information // Get bandwidth information
ACM_ISAC_GETSENDBWE(_codecInstPtr->inst, &bandwidthIndex, &delayIndex); ACM_ISAC_GETSENDBWE(_codecInstPtr->inst, &bandwidthIndex, &delayIndex);
// Validy check of index // Validy check of index
if ((bandwidthIndex < 0) || (bandwidthIndex > NR_ISAC_BANDWIDTHS)) if ((bandwidthIndex < 0) || (bandwidthIndex > NR_ISAC_BANDWIDTHS))
{ {
@@ -921,11 +921,11 @@ ACMISAC::SetEstimatedBandwidthSafe(
sampRate = ACM_ISAC_GETENCSAMPRATE(_codecInstPtr->inst); sampRate = ACM_ISAC_GETENCSAMPRATE(_codecInstPtr->inst);
if(sampRate == kIsacWideband) if(sampRate == kIsacWideband)
{ {
// Search through the WB rate table to find the index // Search through the WB rate table to find the index
bandwidthIndex = NR_ISAC_BANDWIDTHS/2 - 1; bandwidthIndex = NR_ISAC_BANDWIDTHS/2 - 1;
for (int i=0; i<(NR_ISAC_BANDWIDTHS/2); i++) for (int i=0; i<(NR_ISAC_BANDWIDTHS/2); i++)
{ {
if (estimatedBandwidth == isacRatesWB[i]) if (estimatedBandwidth == isacRatesWB[i])
{ {
@@ -936,7 +936,7 @@ ACMISAC::SetEstimatedBandwidthSafe(
bandwidthIndex = i + NR_ISAC_BANDWIDTHS/2; bandwidthIndex = i + NR_ISAC_BANDWIDTHS/2;
break; break;
} else if (estimatedBandwidth < isacRatesWB[i]) } else if (estimatedBandwidth < isacRatesWB[i])
{ {
bandwidthIndex = i; bandwidthIndex = i;
break; break;
} }
@@ -946,7 +946,7 @@ ACMISAC::SetEstimatedBandwidthSafe(
{ {
// Search through the SWB rate table to find the index // Search through the SWB rate table to find the index
bandwidthIndex = NR_ISAC_BANDWIDTHS - 1; bandwidthIndex = NR_ISAC_BANDWIDTHS - 1;
for (int i=0; i<NR_ISAC_BANDWIDTHS; i++) for (int i=0; i<NR_ISAC_BANDWIDTHS; i++)
{ {
if(estimatedBandwidth <= isacRatesSWB[i]) if(estimatedBandwidth <= isacRatesSWB[i])
{ {
@@ -973,7 +973,7 @@ ACMISAC::GetRedPayloadSafe(
WebRtc_UWord8* redPayload, WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes) WebRtc_Word16* payloadBytes)
{ {
WebRtc_Word16 bytes = WebRtcIsac_GetRedPayload(_codecInstPtr->inst, (WebRtc_Word16*)redPayload); WebRtc_Word16 bytes = WebRtcIsac_GetRedPayload(_codecInstPtr->inst, (WebRtc_Word16*)redPayload);
if (bytes < 0) if (bytes < 0)
{ {
@@ -996,15 +996,15 @@ ACMISAC::UnregisterFromNetEqSafe(
} }
else if(payloadType == _decoderParams32kHz.codecInstant.pltype) else if(payloadType == _decoderParams32kHz.codecInstant.pltype)
{ {
return netEq->RemoveCodec(kDecoderISACswb); return netEq->RemoveCodec(kDecoderISACswb);
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not match \
the stored payload type %d or %d", the stored payload type %d or %d",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype, _decoderParams.codecInstant.pltype,
_decoderParams32kHz.codecInstant.pltype); _decoderParams32kHz.codecInstant.pltype);
@@ -1066,7 +1066,7 @@ ACMISAC::UpdateEncoderSampFreq(
} }
_samplesIn10MsAudio = 160; _samplesIn10MsAudio = 160;
} }
else else
{ {
if(WebRtcIsac_SetEncSampRate(_codecInstPtr->inst, kIsacSuperWideband) < 0) if(WebRtcIsac_SetEncSampRate(_codecInstPtr->inst, kIsacSuperWideband) < 0)
@@ -1084,7 +1084,7 @@ ACMISAC::UpdateEncoderSampFreq(
#else #else
WebRtc_UWord16 /* codecId */) WebRtc_UWord16 /* codecId */)
{ {
#endif #endif
return 0; return 0;
} }
@@ -1116,8 +1116,8 @@ ACMISAC::ConfigISACBandwidthEstimator(
WebRtc_UWord16 sampFreqHz; WebRtc_UWord16 sampFreqHz;
EncoderSampFreq(sampFreqHz); EncoderSampFreq(sampFreqHz);
// @TODO: at 32kHz we hardcode calling with 30ms and enforce // @TODO: at 32kHz we hardcode calling with 30ms and enforce
// the frame-size otherwise we might get error. Revise if // the frame-size otherwise we might get error. Revise if
// control-bwe is changed. // control-bwe is changed.
if(sampFreqHz == 32000) if(sampFreqHz == 32000)
{ {
status = ACM_ISAC_CONTROL_BWE(_codecInstPtr->inst, status = ACM_ISAC_CONTROL_BWE(_codecInstPtr->inst,
@@ -1146,7 +1146,7 @@ ACMISAC::SetISACMaxPayloadSize(
{ {
return ACM_ISAC_SETMAXPAYLOADSIZE(_codecInstPtr->inst, maxPayloadLenBytes); return ACM_ISAC_SETMAXPAYLOADSIZE(_codecInstPtr->inst, maxPayloadLenBytes);
} }
WebRtc_Word32 WebRtc_Word32
ACMISAC::SetISACMaxRate( ACMISAC::SetISACMaxRate(
const WebRtc_UWord32 maxRateBitPerSec) const WebRtc_UWord32 maxRateBitPerSec)
@@ -1155,14 +1155,14 @@ ACMISAC::SetISACMaxRate(
} }
void void
ACMISAC::UpdateFrameLen() ACMISAC::UpdateFrameLen()
{ {
_frameLenSmpl = ACM_ISAC_GETNEWFRAMELEN(_codecInstPtr->inst); _frameLenSmpl = ACM_ISAC_GETNEWFRAMELEN(_codecInstPtr->inst);
_encoderParams.codecInstant.pacsize = _frameLenSmpl; _encoderParams.codecInstant.pacsize = _frameLenSmpl;
} }
void void
ACMISAC::CurrentRate(WebRtc_Word32& rateBitPerSec) ACMISAC::CurrentRate(WebRtc_Word32& rateBitPerSec)
{ {
if(_isacCodingMode == ADAPTIVE) if(_isacCodingMode == ADAPTIVE)
@@ -1172,7 +1172,7 @@ ACMISAC::CurrentRate(WebRtc_Word32& rateBitPerSec)
} }
bool bool
ACMISAC::DecoderParamsSafe( ACMISAC::DecoderParamsSafe(
WebRtcACMCodecParams* decParams, WebRtcACMCodecParams* decParams,
const WebRtc_UWord8 payloadType) const WebRtc_UWord8 payloadType)
@@ -1186,7 +1186,7 @@ ACMISAC::DecoderParamsSafe(
} }
if(payloadType == _decoderParams32kHz.codecInstant.pltype) if(payloadType == _decoderParams32kHz.codecInstant.pltype)
{ {
memcpy(decParams, &_decoderParams32kHz, memcpy(decParams, &_decoderParams32kHz,
sizeof(WebRtcACMCodecParams)); sizeof(WebRtcACMCodecParams));
return true; return true;
} }
@@ -1194,10 +1194,10 @@ ACMISAC::DecoderParamsSafe(
return false; return false;
} }
void void
ACMISAC::SaveDecoderParamSafe( ACMISAC::SaveDecoderParamSafe(
const WebRtcACMCodecParams* codecParams) const WebRtcACMCodecParams* codecParams)
{ {
// set decoder sampling frequency. // set decoder sampling frequency.
if(codecParams->codecInstant.plfreq == 32000) if(codecParams->codecInstant.plfreq == 32000)
{ {

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_ISAC_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#define ACM_ISAC_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -32,7 +32,7 @@ public:
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream, WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams); WebRtcACMCodecParams *codecParams);
@@ -52,7 +52,7 @@ public:
WebRtc_Word16* /* bitStreamLenByte */, WebRtc_Word16* /* bitStreamLenByte */,
WebRtc_UWord32* /* timestamp */, WebRtc_UWord32* /* timestamp */,
WebRtcACMEncodingType* /* encodingType */) WebRtcACMEncodingType* /* encodingType */)
{ {
return -1; return -1;
} }
@@ -91,13 +91,13 @@ protected:
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 bitRate); const WebRtc_Word32 bitRate);
@@ -110,9 +110,9 @@ protected:
WebRtc_Word16* payloadBytes); WebRtc_Word16* payloadBytes);
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
@@ -130,7 +130,7 @@ protected:
void CurrentRate(WebRtc_Word32& rateBitPerSec); void CurrentRate(WebRtc_Word32& rateBitPerSec);
void UpdateFrameLen(); void UpdateFrameLen();
bool DecoderParamsSafe( bool DecoderParamsSafe(
WebRtcACMCodecParams *decParams, WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payloadType);
@@ -150,4 +150,4 @@ protected:
} //namespace } //namespace
#endif // ACM_ISAC_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_ISAC_MACROS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#define ACM_ISAC_MACROS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#include "engine_configurations.h" #include "engine_configurations.h"
@@ -72,5 +72,5 @@ namespace webrtc
} //namespace } //namespace
#endif // ACM_ISAC_MACROS_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_

View File

@@ -122,7 +122,7 @@ ACMNetEQ::Init()
// Has to enable VAD // Has to enable VAD
if(EnableVADByIdxSafe(idx) < 0) if(EnableVADByIdxSafe(idx) < 0)
{ {
// Failed to enable VAD. // Failed to enable VAD.
// Delete VAD instance, if it is created // Delete VAD instance, if it is created
if(_ptrVADInst[idx] != NULL) if(_ptrVADInst[idx] != NULL)
{ {
@@ -164,7 +164,7 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = malloc(memorySizeBytes); _instMem[idx] = malloc(memorySizeBytes);
if (_instMem[idx] == NULL) if (_instMem[idx] == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not allocate memory for NetEq"); "InitByIdxSafe: NetEq Initialization error: could not allocate memory for NetEq");
_isInitialized[idx] = false; _isInitialized[idx] = false;
return -1; return -1;
@@ -176,8 +176,8 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = NULL; _instMem[idx] = NULL;
} }
LogError("Assign", idx); LogError("Assign", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not Assign"); "InitByIdxSafe: NetEq Initialization error: could not Assign");
_isInitialized[idx] = false; _isInitialized[idx] = false;
return -1; return -1;
} }
@@ -188,8 +188,8 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = NULL; _instMem[idx] = NULL;
} }
LogError("Init", idx); LogError("Init", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not initialize NetEq"); "InitByIdxSafe: NetEq Initialization error: could not initialize NetEq");
_isInitialized[idx] = false; _isInitialized[idx] = false;
return -1; return -1;
} }
@@ -206,28 +206,28 @@ ACMNetEQ::EnableVADByIdxSafe(
if(WebRtcVad_Create(&_ptrVADInst[idx]) < 0) if(WebRtcVad_Create(&_ptrVADInst[idx]) < 0)
{ {
_ptrVADInst[idx] = NULL; _ptrVADInst[idx] = NULL;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not create VAD"); "EnableVADByIdxSafe: NetEq Initialization error: could not create VAD");
return -1; return -1;
} }
} }
if(WebRtcNetEQ_SetVADInstance(_inst[idx], _ptrVADInst[idx], if(WebRtcNetEQ_SetVADInstance(_inst[idx], _ptrVADInst[idx],
(WebRtcNetEQ_VADInitFunction) WebRtcVad_Init, (WebRtcNetEQ_VADInitFunction) WebRtcVad_Init,
(WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode, (WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode,
(WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0) (WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0)
{ {
LogError("setVADinstance", idx); LogError("setVADinstance", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD instance"); "EnableVADByIdxSafe: NetEq Initialization error: could not set VAD instance");
return -1; return -1;
} }
if(WebRtcNetEQ_SetVADMode(_inst[idx], _vadMode) < 0) if(WebRtcNetEQ_SetVADMode(_inst[idx], _vadMode) < 0)
{ {
LogError("setVADmode", idx); LogError("setVADmode", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD mode"); "EnableVADByIdxSafe: NetEq Initialization error: could not set VAD mode");
return -1; return -1;
} }
return 0; return 0;
@@ -238,18 +238,18 @@ ACMNetEQ::EnableVADByIdxSafe(
WebRtc_Word32 WebRtc_Word32
ACMNetEQ::AllocatePacketBuffer( ACMNetEQ::AllocatePacketBuffer(
WebRtcNetEQDecoder* usedCodecs, WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs) WebRtc_Word16 noOfCodecs)
{ {
// Due to WebRtcNetEQ_GetRecommendedBufferSize // Due to WebRtcNetEQ_GetRecommendedBufferSize
// the following has to be int otherwise we will have compiler error // the following has to be int otherwise we will have compiler error
// if not casted // if not casted
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++) for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
{ {
if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, idx) < 0) if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, idx) < 0)
{ {
return -1; return -1;
} }
} }
@@ -258,7 +258,7 @@ ACMNetEQ::AllocatePacketBuffer(
WebRtc_Word16 WebRtc_Word16
ACMNetEQ::AllocatePacketBufferByIdxSafe( ACMNetEQ::AllocatePacketBufferByIdxSafe(
WebRtcNetEQDecoder* usedCodecs, WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs, WebRtc_Word16 noOfCodecs,
const WebRtc_Word16 idx) const WebRtc_Word16 idx)
{ {
@@ -267,11 +267,11 @@ ACMNetEQ::AllocatePacketBufferByIdxSafe(
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AllocatePacketBufferByIdxSafe: NetEq is not initialized."); "AllocatePacketBufferByIdxSafe: NetEq is not initialized.");
return -1; return -1;
} }
if (WebRtcNetEQ_GetRecommendedBufferSize(_inst[idx], usedCodecs, noOfCodecs, if (WebRtcNetEQ_GetRecommendedBufferSize(_inst[idx], usedCodecs, noOfCodecs,
kTCPLargeJitter , &maxNoPackets, &bufferSizeInBytes) kTCPLargeJitter , &maxNoPackets, &bufferSizeInBytes)
!= 0) != 0)
{ {
@@ -286,8 +286,8 @@ ACMNetEQ::AllocatePacketBufferByIdxSafe(
_netEqPacketBuffer[idx] = (WebRtc_Word16 *)malloc(bufferSizeInBytes); _netEqPacketBuffer[idx] = (WebRtc_Word16 *)malloc(bufferSizeInBytes);
if (_netEqPacketBuffer[idx] == NULL) if (_netEqPacketBuffer[idx] == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AllocatePacketBufferByIdxSafe: NetEq Initialization error: could not allocate " "AllocatePacketBufferByIdxSafe: NetEq Initialization error: could not allocate "
"memory for NetEq Packet Buffer"); "memory for NetEq Packet Buffer");
return -1; return -1;
@@ -319,7 +319,7 @@ ACMNetEQ::SetExtraDelay(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetExtraDelay: NetEq is not initialized."); "SetExtraDelay: NetEq is not initialized.");
return -1; return -1;
} }
@@ -329,7 +329,7 @@ ACMNetEQ::SetExtraDelay(
return -1; return -1;
} }
} }
return 0; return 0;
} }
@@ -344,7 +344,7 @@ ACMNetEQ::SetAVTPlayout(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetAVTPlayout: NetEq is not initialized."); "SetAVTPlayout: NetEq is not initialized.");
return -1; return -1;
} }
@@ -373,7 +373,7 @@ ACMNetEQ::CurrentSampFreqHz() const
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"CurrentSampFreqHz: NetEq is not initialized."); "CurrentSampFreqHz: NetEq is not initialized.");
return -1; return -1;
} }
@@ -392,7 +392,7 @@ ACMNetEQ::SetPlayoutMode(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq is not initialized."); "SetPlayoutMode: NetEq is not initialized.");
return -1; return -1;
} }
@@ -410,10 +410,9 @@ ACMNetEQ::SetPlayoutMode(
playoutMode = kPlayoutStreaming; playoutMode = kPlayoutStreaming;
break; break;
default: default:
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq Error playout mode not recognized"); "SetPlayoutMode: NetEq Error playout mode not recognized");
return -1; return -1;
break;
} }
if(WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0) if(WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0)
{ {
@@ -443,7 +442,7 @@ ACMNetEQ::NetworkStatistics(
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"NetworkStatistics: NetEq is not initialized."); "NetworkStatistics: NetEq is not initialized.");
return -1; return -1;
} }
@@ -474,7 +473,7 @@ ACMNetEQ::JitterStatistics(
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"JitterStatistics: NetEq is not initialized."); "JitterStatistics: NetEq is not initialized.");
return -1; return -1;
} }
@@ -555,7 +554,7 @@ ACMNetEQ::RecIn(
netEqRTPInfo.markerBit = rtpInfo.header.markerBit; netEqRTPInfo.markerBit = rtpInfo.header.markerBit;
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
// Down-cast the time to (32-6)-bit since we only care about // Down-cast the time to (32-6)-bit since we only care about
// the least significant bits. (32-6) bits cover 2^(32-6) = 67108864 ms. // the least significant bits. (32-6) bits cover 2^(32-6) = 67108864 ms.
// we masked 6 most significant bits of 32-bit so we don't loose resolution // we masked 6 most significant bits of 32-bit so we don't loose resolution
// when do the following multiplication. // when do the following multiplication.
@@ -565,23 +564,23 @@ ACMNetEQ::RecIn(
(_currentSampFreqKHz * nowInMs); (_currentSampFreqKHz * nowInMs);
int status; int status;
if(rtpInfo.type.Audio.channel == 1) if(rtpInfo.type.Audio.channel == 1)
{ {
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq is not initialized."); "RecIn: NetEq is not initialized.");
return -1; return -1;
} }
// PUSH into Master // PUSH into Master
status = WebRtcNetEQ_RecInRTPStruct(_inst[0], &netEqRTPInfo, status = WebRtcNetEQ_RecInRTPStruct(_inst[0], &netEqRTPInfo,
(WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength, (WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength,
recvTimestamp); recvTimestamp);
if(status < 0) if(status < 0)
{ {
LogError("RecInRTPStruct", 0); LogError("RecInRTPStruct", 0);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq, error in pushing in Master"); "RecIn: NetEq, error in pushing in Master");
return -1; return -1;
} }
@@ -590,27 +589,27 @@ ACMNetEQ::RecIn(
{ {
if(!_isInitialized[1]) if(!_isInitialized[1])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq is not initialized."); "RecIn: NetEq is not initialized.");
return -1; return -1;
} }
// PUSH into Slave // PUSH into Slave
status = WebRtcNetEQ_RecInRTPStruct(_inst[1], &netEqRTPInfo, status = WebRtcNetEQ_RecInRTPStruct(_inst[1], &netEqRTPInfo,
(WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength, (WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength,
recvTimestamp); recvTimestamp);
if(status < 0) if(status < 0)
{ {
LogError("RecInRTPStruct", 1); LogError("RecInRTPStruct", 1);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq, error in pushing in Slave"); "RecIn: NetEq, error in pushing in Slave");
return -1; return -1;
} }
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq, error invalid numbe of channels %d \ "RecIn: NetEq, error invalid numbe of channels %d \
(1, for Master stream, and 2, for slave stream, are valid values)", (1, for Master stream, and 2, for slave stream, are valid values)",
rtpInfo.type.Audio.channel); rtpInfo.type.Audio.channel);
return -1; return -1;
} }
@@ -635,13 +634,13 @@ ACMNetEQ::RecOut(
{ {
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq is not initialized."); "RecOut: NetEq is not initialized.");
return -1; return -1;
} }
{ {
WriteLockScoped lockCodec(*_decodeLock); WriteLockScoped lockCodec(*_decodeLock);
if(WebRtcNetEQ_RecOut(_inst[0], &(audioFrame._payloadData[0]), if(WebRtcNetEQ_RecOut(_inst[0], &(audioFrame._payloadData[0]),
&payloadLenSample) != 0) &payloadLenSample) != 0)
{ {
LogError("RecOut", 0); LogError("RecOut", 0);
@@ -665,7 +664,7 @@ ACMNetEQ::RecOut(
{ {
if(!_isInitialized[0] || !_isInitialized[1]) if(!_isInitialized[0] || !_isInitialized[1])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq is not initialized."); "RecOut: NetEq is not initialized.");
return -1; return -1;
} }
@@ -673,11 +672,11 @@ ACMNetEQ::RecOut(
WebRtc_Word16 payloadSlave[480]; WebRtc_Word16 payloadSlave[480];
{ {
WriteLockScoped lockCodec(*_decodeLock); WriteLockScoped lockCodec(*_decodeLock);
if(WebRtcNetEQ_RecOutMasterSlave(_inst[0], payloadMaster, if(WebRtcNetEQ_RecOutMasterSlave(_inst[0], payloadMaster,
&payloadLenSample, _masterSlaveInfo, 1) != 0) &payloadLenSample, _masterSlaveInfo, 1) != 0)
{ {
LogError("RecOutMasterSlave", 0); LogError("RecOutMasterSlave", 0);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq, error in pulling out for master"); "RecOut: NetEq, error in pulling out for master");
// Check for errors that can be recovered from: // Check for errors that can be recovered from:
@@ -689,11 +688,11 @@ ACMNetEQ::RecOut(
return -1; return -1;
} }
} }
if(WebRtcNetEQ_RecOutMasterSlave(_inst[1], payloadSlave, if(WebRtcNetEQ_RecOutMasterSlave(_inst[1], payloadSlave,
&payloadLenSampleSlave, _masterSlaveInfo, 0) != 0) &payloadLenSampleSlave, _masterSlaveInfo, 0) != 0)
{ {
LogError("RecOutMasterSlave", 1); LogError("RecOutMasterSlave", 1);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq, error in pulling out for slave"); "RecOut: NetEq, error in pulling out for slave");
// Check for errors that can be recovered from: // Check for errors that can be recovered from:
@@ -708,15 +707,15 @@ ACMNetEQ::RecOut(
} }
if(payloadLenSample != payloadLenSampleSlave) if(payloadLenSample != payloadLenSampleSlave)
{ {
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _id,
"RecOut: mismatch between the lenght of the decoded \ "RecOut: mismatch between the lenght of the decoded \
audio by Master (%d samples) and Slave (%d samples).", audio by Master (%d samples) and Slave (%d samples).",
payloadLenSample, payloadLenSampleSlave); payloadLenSample, payloadLenSampleSlave);
if(payloadLenSample > payloadLenSampleSlave) if(payloadLenSample > payloadLenSampleSlave)
{ {
memset(&payloadSlave[payloadLenSampleSlave], 0, memset(&payloadSlave[payloadLenSampleSlave], 0,
(payloadLenSample - payloadLenSampleSlave) * sizeof(WebRtc_Word16)); (payloadLenSample - payloadLenSampleSlave) * sizeof(WebRtc_Word16));
} }
} }
for(WebRtc_Word16 n = 0; n < payloadLenSample; n++) for(WebRtc_Word16 n = 0; n < payloadLenSample; n++)
@@ -728,12 +727,12 @@ audio by Master (%d samples) and Slave (%d samples).",
WebRtcNetEQ_GetSpeechOutputType(_inst[0], &typeMaster); WebRtcNetEQ_GetSpeechOutputType(_inst[0], &typeMaster);
WebRtcNetEQ_GetSpeechOutputType(_inst[1], &typeSlave); WebRtcNetEQ_GetSpeechOutputType(_inst[1], &typeSlave);
if((typeMaster == kOutputNormal) || if((typeMaster == kOutputNormal) ||
(typeSlave == kOutputNormal)) (typeSlave == kOutputNormal))
{ {
type = kOutputNormal; type = kOutputNormal;
} }
else else
{ {
type = typeMaster; type = typeMaster;
} }
@@ -741,7 +740,7 @@ audio by Master (%d samples) and Slave (%d samples).",
audioFrame._payloadDataLengthInSamples = static_cast<WebRtc_UWord16>(payloadLenSample); audioFrame._payloadDataLengthInSamples = static_cast<WebRtc_UWord16>(payloadLenSample);
// NetEq always returns 10 ms of audio. // NetEq always returns 10 ms of audio.
_currentSampFreqKHz = static_cast<float>(audioFrame._payloadDataLengthInSamples) / 10.0f; _currentSampFreqKHz = static_cast<float>(audioFrame._payloadDataLengthInSamples) / 10.0f;
audioFrame._frequencyInHz = audioFrame._payloadDataLengthInSamples * 100; audioFrame._frequencyInHz = audioFrame._payloadDataLengthInSamples * 100;
if(_vadStatus) if(_vadStatus)
{ {
@@ -796,7 +795,7 @@ audio by Master (%d samples) and Slave (%d samples).",
{ {
// type is kOutputVADPassive which // type is kOutputVADPassive which
// we don't expect to get if _vadStatus is false // we don't expect to get if _vadStatus is false
WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceWarning, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq returned kVadPassive while _vadStatus is false."); "RecOut: NetEq returned kVadPassive while _vadStatus is false.");
audioFrame._vadActivity = AudioFrame::kVadUnknown; audioFrame._vadActivity = AudioFrame::kVadUnknown;
audioFrame._speechType = AudioFrame::kNormalSpeech; audioFrame._speechType = AudioFrame::kNormalSpeech;
@@ -816,7 +815,7 @@ ACMNetEQ::AddCodec(
{ {
if (codecDef == NULL) if (codecDef == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"ACMNetEQ::AddCodec: error, codecDef is NULL"); "ACMNetEQ::AddCodec: error, codecDef is NULL");
return -1; return -1;
} }
@@ -834,14 +833,14 @@ ACMNetEQ::AddCodec(
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"ACMNetEQ::AddCodec: NetEq is not initialized."); "ACMNetEQ::AddCodec: NetEq is not initialized.");
return -1; return -1;
} }
if(WebRtcNetEQ_CodecDbAdd(_inst[idx], codecDef) < 0) if(WebRtcNetEQ_CodecDbAdd(_inst[idx], codecDef) < 0)
{ {
LogError("CodecDB_Add", idx); LogError("CodecDB_Add", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"ACMNetEQ::AddCodec: NetEq, error in adding codec"); "ACMNetEQ::AddCodec: NetEq, error in adding codec");
return -1; return -1;
} }
@@ -863,50 +862,50 @@ ACMNetEQ::RTPPack(
WebRtc_Word32 idx = 0; WebRtc_Word32 idx = 0;
WEBRTC_SPL_SET_BYTE(rtpPacket, (WebRtc_Word8)0x80, idx); WEBRTC_SPL_SET_BYTE(rtpPacket, (WebRtc_Word8)0x80, idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, rtpInfo.header.payloadType, idx); WEBRTC_SPL_SET_BYTE(rtpPacket, rtpInfo.header.payloadType, idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.sequenceNumber), 1), idx); &(rtpInfo.header.sequenceNumber), 1), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.sequenceNumber), 0), idx); &(rtpInfo.header.sequenceNumber), 0), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 3), idx); &(rtpInfo.header.timestamp), 3), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 2), idx); &(rtpInfo.header.timestamp), 2), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 1), idx); &(rtpInfo.header.timestamp), 1), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 0), idx); &(rtpInfo.header.timestamp), 0), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 3), idx); &(rtpInfo.header.ssrc), 3), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 2), idx); &(rtpInfo.header.ssrc), 2), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 1), idx); &(rtpInfo.header.ssrc), 1), idx);
idx++; idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE( WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 0), idx); &(rtpInfo.header.ssrc), 0), idx);
idx++; idx++;
for (WebRtc_Word16 i=0; i < payloadLengthW8; i++) for (WebRtc_Word16 i=0; i < payloadLengthW8; i++)
{ {
WEBRTC_SPL_SET_BYTE(rtpPacket, payload[i], idx); WEBRTC_SPL_SET_BYTE(rtpPacket, payload[i], idx);
@@ -921,7 +920,7 @@ ACMNetEQ::RTPPack(
} }
bool bool
ACMNetEQ::VADStatus() const ACMNetEQ::VADStatus() const
{ {
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
@@ -938,16 +937,16 @@ ACMNetEQ::SetVADStatus(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetVADStatus: NetEq is not initialized."); "SetVADStatus: NetEq is not initialized.");
return -1; return -1;
} }
if(_vadStatus && !status) if(_vadStatus && !status)
{ {
// We have been using VAD but we want to stop using it calling the // We have been using VAD but we want to stop using it calling the
// following function with NULL as VAD instance switches off the // following function with NULL as VAD instance switches off the
// post-decode VAD // post-decode VAD
if(WebRtcNetEQ_SetVADInstance(_inst[idx], NULL, if(WebRtcNetEQ_SetVADInstance(_inst[idx], NULL,
(WebRtcNetEQ_VADInitFunction) WebRtcVad_Init, (WebRtcNetEQ_VADInitFunction) WebRtcVad_Init,
(WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode, (WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode,
(WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0) (WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0)
@@ -972,7 +971,7 @@ ACMNetEQ::SetVADStatus(
{ {
return -1; return -1;
} }
// Set previous VAD status to PASSIVE // Set previous VAD status to PASSIVE
_previousAudioActivity = AudioFrame::kVadPassive; _previousAudioActivity = AudioFrame::kVadPassive;
} }
@@ -997,7 +996,7 @@ ACMNetEQ::SetVADMode(
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if((mode < VADNormal) || (mode > VADVeryAggr)) if((mode < VADNormal) || (mode > VADVeryAggr))
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetVADMode: NetEq error: could not set VAD mode, mode is not supported"); "SetVADMode: NetEq error: could not set VAD mode, mode is not supported");
return -1; return -1;
} }
@@ -1007,7 +1006,7 @@ ACMNetEQ::SetVADMode(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetVADMode: NetEq is not initialized."); "SetVADMode: NetEq is not initialized.");
return -1; return -1;
} }
@@ -1031,7 +1030,7 @@ ACMNetEQ::FlushBuffers()
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"FlushBuffers: NetEq is not initialized."); "FlushBuffers: NetEq is not initialized.");
return -1; return -1;
} }
@@ -1081,22 +1080,22 @@ ACMNetEQ::RemoveCodec(
WebRtcNetEQDecoder codecIdx, WebRtcNetEQDecoder codecIdx,
bool isStereo) bool isStereo)
{ {
// sanity check // sanity check
if((codecIdx <= kDecoderReservedStart) || if((codecIdx <= kDecoderReservedStart) ||
(codecIdx >= kDecoderReservedEnd)) (codecIdx >= kDecoderReservedEnd))
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RemoveCodec: NetEq error: could not Remove Codec, codec index out of range"); "RemoveCodec: NetEq error: could not Remove Codec, codec index out of range");
return -1; return -1;
} }
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RemoveCodec: NetEq is not initialized."); "RemoveCodec: NetEq is not initialized.");
return -1; return -1;
} }
if(WebRtcNetEQ_CodecDbRemove(_inst[0], codecIdx) < 0) if(WebRtcNetEQ_CodecDbRemove(_inst[0], codecIdx) < 0)
{ {
LogError("CodecDB_Remove", 0); LogError("CodecDB_Remove", 0);
@@ -1122,7 +1121,7 @@ ACMNetEQ::Delay(
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Delay: NetEq is not initialized."); "Delay: NetEq is not initialized.");
return -1; return -1;
} }
@@ -1147,7 +1146,7 @@ ACMNetEQ::SetBackgroundNoiseMode(
{ {
if(!_isInitialized[idx]) if(!_isInitialized[idx])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetBackgroundNoiseMode: NetEq is not initialized."); "SetBackgroundNoiseMode: NetEq is not initialized.");
return -1; return -1;
} }
@@ -1168,7 +1167,7 @@ ACMNetEQ::BackgroundNoiseMode(
CriticalSectionScoped lock(*_netEqCritSect); CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0]) if(!_isInitialized[0])
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"BackgroundNoiseMode: NetEq is not initialized."); "BackgroundNoiseMode: NetEq is not initialized.");
return -1; return -1;
} }
@@ -1193,7 +1192,7 @@ ACMNetEQ::SetUniqueId(
} }
void void
ACMNetEQ::LogError( ACMNetEQ::LogError(
const WebRtc_Word8* neteqFuncName, const WebRtc_Word8* neteqFuncName,
const WebRtc_Word16 idx) const const WebRtc_Word16 idx) const
@@ -1205,8 +1204,8 @@ ACMNetEQ::LogError(
strncpy(myFuncName, neteqFuncName, 49); strncpy(myFuncName, neteqFuncName, 49);
errorName[NETEQ_ERR_MSG_LEN_BYTE - 1] = '\0'; errorName[NETEQ_ERR_MSG_LEN_BYTE - 1] = '\0';
myFuncName[49] = '\0'; myFuncName[49] = '\0';
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"NetEq-%d Error in function %s, error-code: %d, error-string: %s", "NetEq-%d Error in function %s, error-code: %d, error-string: %s",
idx, idx,
myFuncName, myFuncName,
neteqErrorCode, neteqErrorCode,
@@ -1242,19 +1241,19 @@ ACMNetEQ::AddSlave(
// initialize the receiver, this also sets up VAD. // initialize the receiver, this also sets up VAD.
if(InitByIdxSafe(slaveIdx) < 0) if(InitByIdxSafe(slaveIdx) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Initialize"); "AddSlave: AddSlave Failed, Could not Initialize");
return -1; return -1;
} }
// Allocate buffer. // Allocate buffer.
if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, slaveIdx) < 0) if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, slaveIdx) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Allocate Packet Buffer"); "AddSlave: AddSlave Failed, Could not Allocate Packet Buffer");
return -1; return -1;
} }
if(_masterSlaveInfo != NULL) if(_masterSlaveInfo != NULL)
{ {
free(_masterSlaveInfo); free(_masterSlaveInfo);
@@ -1262,15 +1261,15 @@ ACMNetEQ::AddSlave(
} }
int msInfoSize = WebRtcNetEQ_GetMasterSlaveInfoSize(); int msInfoSize = WebRtcNetEQ_GetMasterSlaveInfoSize();
_masterSlaveInfo = malloc(msInfoSize); _masterSlaveInfo = malloc(msInfoSize);
if(_masterSlaveInfo == NULL) if(_masterSlaveInfo == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Allocate memory for Master-Slave Info"); "AddSlave: AddSlave Failed, Could not Allocate memory for Master-Slave Info");
return -1; return -1;
} }
// We accept this as initialized NetEQ, the rest is to synchronize // We accept this as initialized NetEQ, the rest is to synchronize
// Slave with Master. // Slave with Master.
_numSlaves = 1; _numSlaves = 1;
_isInitialized[slaveIdx] = true; _isInitialized[slaveIdx] = true;
@@ -1280,14 +1279,14 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_GetCurrentDelay(_inst[0], &currentDelayMs) < 0) if(WebRtcNetEQ_GetCurrentDelay(_inst[0], &currentDelayMs) < 0)
{ {
LogError("GetCurrentDelay", 0); LogError("GetCurrentDelay", 0);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Get Current Delay from Master."); "AddSlave: AddSlave Failed, Could not Get Current Delay from Master.");
return -1; return -1;
} }
if(WebRtcNetEQ_SetExtraDelay(_inst[slaveIdx], currentDelayMs) < 0) if(WebRtcNetEQ_SetExtraDelay(_inst[slaveIdx], currentDelayMs) < 0)
{ {
LogError("SetExtraDelay", slaveIdx); LogError("SetExtraDelay", slaveIdx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not set delay"); "AddSlave: AddSlave Failed, Could not set delay");
return -1; return -1;
} }
@@ -1296,7 +1295,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_SetAVTPlayout(_inst[slaveIdx], (_avtPlayout) ? 1 : 0) < 0) if(WebRtcNetEQ_SetAVTPlayout(_inst[slaveIdx], (_avtPlayout) ? 1 : 0) < 0)
{ {
LogError("SetAVTPlayout", slaveIdx); LogError("SetAVTPlayout", slaveIdx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not set AVT playout."); "AddSlave: AddSlave Failed, Could not set AVT playout.");
return -1; return -1;
} }
@@ -1306,7 +1305,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_GetBGNMode(_inst[0], &currentMode) < 0) if(WebRtcNetEQ_GetBGNMode(_inst[0], &currentMode) < 0)
{ {
LogError("GetBGNMode", 0); LogError("GetBGNMode", 0);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AAddSlave: AddSlave Failed, Could not Get BGN form Master."); "AAddSlave: AddSlave Failed, Could not Get BGN form Master.");
return -1; return -1;
} }
@@ -1314,7 +1313,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_SetBGNMode(_inst[slaveIdx], (WebRtcNetEQBGNMode)currentMode) < 0) if(WebRtcNetEQ_SetBGNMode(_inst[slaveIdx], (WebRtcNetEQBGNMode)currentMode) < 0)
{ {
LogError("SetBGNMode", slaveIdx); LogError("SetBGNMode", slaveIdx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not set BGN mode."); "AddSlave: AddSlave Failed, Could not set BGN mode.");
return -1; return -1;
} }
@@ -1332,15 +1331,14 @@ ACMNetEQ::AddSlave(
playoutMode = kPlayoutStreaming; playoutMode = kPlayoutStreaming;
break; break;
default: default:
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: NetEq Error, playout mode not recognized"); "AddSlave: NetEq Error, playout mode not recognized");
return -1; return -1;
break;
} }
if(WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0) if(WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0)
{ {
LogError("SetPlayoutMode", 1); LogError("SetPlayoutMode", 1);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Set Playout Mode."); "AddSlave: AddSlave Failed, Could not Set Playout Mode.");
return -1; return -1;
} }
@@ -1365,4 +1363,3 @@ ACMNetEQ::NumSlaves()
} }
} // namespace webrtc } // namespace webrtc

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_NETEQ_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#define ACM_NETEQ_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "audio_coding_module_typedefs.h" #include "audio_coding_module_typedefs.h"
@@ -69,7 +69,7 @@ public:
// if out of memory. // if out of memory.
// //
WebRtc_Word32 Init(); WebRtc_Word32 Init();
// //
// RecIn() // RecIn()
// Gives the payload to NetEQ. // Gives the payload to NetEQ.
@@ -132,7 +132,7 @@ public:
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 AllocatePacketBuffer( WebRtc_Word32 AllocatePacketBuffer(
WebRtcNetEQDecoder* usedCodecs, WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 noOfCodecs);
// //
@@ -298,9 +298,9 @@ public:
// //
// Return value : Pointer to the decode lock. // Return value : Pointer to the decode lock.
// //
RWLockWrapper* DecodeLock() const RWLockWrapper* DecodeLock() const
{ {
return _decodeLock; return _decodeLock;
} }
// //
@@ -372,13 +372,13 @@ public:
void SetReceivedStereo( void SetReceivedStereo(
bool receivedStereo); bool receivedStereo);
WebRtc_UWord8 NumSlaves(); WebRtc_UWord8 NumSlaves();
enum JB {masterJB = 0, slaveJB = 1}; enum JB {masterJB = 0, slaveJB = 1};
WebRtc_Word16 AddSlave( WebRtc_Word16 AddSlave(
WebRtcNetEQDecoder* usedCodecs, WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 noOfCodecs);
private: private:
@@ -426,7 +426,7 @@ private:
bool _avtPlayout; bool _avtPlayout;
AudioPlayoutMode _playoutMode; AudioPlayoutMode _playoutMode;
CriticalSectionWrapper* _netEqCritSect; CriticalSectionWrapper* _netEqCritSect;
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1]; WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1];
bool _vadStatus; bool _vadStatus;
@@ -443,4 +443,4 @@ private:
} //namespace webrtc } //namespace webrtc
#endif //ACM_NETEQ_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_

View File

@@ -39,7 +39,7 @@ ACMOPUS::~ACMOPUS()
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalEncode( ACMOPUS::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */)
@@ -48,11 +48,11 @@ ACMOPUS::InternalEncode(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::DecodeSafe( ACMOPUS::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
@@ -60,7 +60,7 @@ ACMOPUS::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalInitEncoder( ACMOPUS::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -68,7 +68,7 @@ ACMOPUS::InternalInitEncoder(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalInitDecoder( ACMOPUS::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -76,9 +76,9 @@ ACMOPUS::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMOPUS::CodecDef( ACMOPUS::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
@@ -92,35 +92,35 @@ ACMOPUS::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalCreateEncoder() ACMOPUS::InternalCreateEncoder()
{ {
return -1; return -1;
} }
void void
ACMOPUS::DestructEncoderSafe() ACMOPUS::DestructEncoderSafe()
{ {
return; return;
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalCreateDecoder() ACMOPUS::InternalCreateDecoder()
{ {
return -1; return -1;
} }
void void
ACMOPUS::DestructDecoderSafe() ACMOPUS::DestructDecoderSafe()
{ {
return; return;
} }
void void
ACMOPUS::InternalDestructEncoderInst( ACMOPUS::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -128,7 +128,7 @@ ACMOPUS::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::UnregisterFromNetEqSafe( ACMOPUS::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */)
@@ -136,7 +136,7 @@ ACMOPUS::UnregisterFromNetEqSafe(
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::SetBitRateSafe( ACMOPUS::SetBitRateSafe(
const WebRtc_Word32 /*rate*/ ) const WebRtc_Word32 /*rate*/ )
{ {
@@ -172,14 +172,14 @@ _opusMode(1), // default mode is the hybrid mode
_flagVBR(0) // default VBR off _flagVBR(0) // default VBR off
{ {
_codecID = codecID; _codecID = codecID;
// Current implementation doesn't have DTX. That might change. // Current implementation doesn't have DTX. That might change.
_hasInternalDTX = false; _hasInternalDTX = false;
// Default sampling frequency // Default sampling frequency
_mySampFreq = 48000; _mySampFreq = 48000;
// default rate // default rate
_myRate = 50000; _myRate = 50000;
return; return;
@@ -201,7 +201,7 @@ ACMOPUS::~ACMOPUS()
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalEncode( ACMOPUS::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
@@ -212,14 +212,14 @@ ACMOPUS::InternalEncode(
WebRtc_Word16 byteLengthFrame = 0; WebRtc_Word16 byteLengthFrame = 0;
// Derive what byte-length is requested // Derive what byte-length is requested
byteLengthFrame = _myRate*_frameLenSmpl/(8*_mySampFreq); byteLengthFrame = _myRate*_frameLenSmpl/(8*_mySampFreq);
// Call Encoder // Call Encoder
*bitStreamLenByte = WebRtcOpus_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], *bitStreamLenByte = WebRtcOpus_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
(WebRtc_Word16*)bitStream, _frameLenSmpl, byteLengthFrame); (WebRtc_Word16*)bitStream, _frameLenSmpl, byteLengthFrame);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; _inAudioIxRead += _frameLenSmpl;
@@ -227,8 +227,8 @@ ACMOPUS::InternalEncode(
if(*bitStreamLenByte < 0) if(*bitStreamLenByte < 0)
{ {
// error has happened // error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for Opus"); "InternalEncode: Encode error for Opus");
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
@@ -238,11 +238,11 @@ ACMOPUS::InternalEncode(
WebRtc_Word16 WebRtc_Word16
ACMOPUS::DecodeSafe( ACMOPUS::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
{ {
@@ -250,7 +250,7 @@ ACMOPUS::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalInitEncoder( ACMOPUS::InternalInitEncoder(
WebRtcACMCodecParams* codecParams) WebRtcACMCodecParams* codecParams)
{ {
@@ -260,7 +260,7 @@ ACMOPUS::InternalInitEncoder(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalInitDecoder( ACMOPUS::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -274,7 +274,7 @@ ACMOPUS::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMOPUS::CodecDef( ACMOPUS::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
@@ -286,7 +286,7 @@ ACMOPUS::CodecDef(
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -304,7 +304,7 @@ ACMOPUS::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalCreateEncoder() ACMOPUS::InternalCreateEncoder()
{ {
if (WebRtcOpus_CreateEnc(&_encoderInstPtr, _mySampFreq) < 0) if (WebRtcOpus_CreateEnc(&_encoderInstPtr, _mySampFreq) < 0)
@@ -317,7 +317,7 @@ ACMOPUS::InternalCreateEncoder()
} }
void void
ACMOPUS::DestructEncoderSafe() ACMOPUS::DestructEncoderSafe()
{ {
_encoderExist = false; _encoderExist = false;
@@ -330,12 +330,12 @@ ACMOPUS::DestructEncoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::InternalCreateDecoder() ACMOPUS::InternalCreateDecoder()
{ {
if (WebRtcOpus_CreateDec(&_decoderInstPtr, _mySampFreq) < 0) if (WebRtcOpus_CreateDec(&_decoderInstPtr, _mySampFreq) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: create decoder failed for Opus"); "InternalCreateDecoder: create decoder failed for Opus");
return -1; return -1;
} }
@@ -343,7 +343,7 @@ ACMOPUS::InternalCreateDecoder()
} }
void void
ACMOPUS::DestructDecoderSafe() ACMOPUS::DestructDecoderSafe()
{ {
_decoderExist = false; _decoderExist = false;
@@ -356,10 +356,10 @@ ACMOPUS::DestructDecoderSafe()
} }
void void
ACMOPUS::InternalDestructEncoderInst( ACMOPUS::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
if(ptrInst != NULL) if(ptrInst != NULL)
{ {
WebRtcOpus_FreeEnc((OPUS_inst_t*)ptrInst); WebRtcOpus_FreeEnc((OPUS_inst_t*)ptrInst);
@@ -368,25 +368,25 @@ ACMOPUS::InternalDestructEncoderInst(
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::UnregisterFromNetEqSafe( ACMOPUS::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: given payload-type does not match \ "Cannot unregister codec: given payload-type does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
return netEq->RemoveCodec(kDecoderOpus); return netEq->RemoveCodec(kDecoderOpus);
} }
WebRtc_Word16 WebRtc_Word16
ACMOPUS::SetBitRateSafe( ACMOPUS::SetBitRateSafe(
const WebRtc_Word32 rate) const WebRtc_Word32 rate)
{ {
@@ -459,17 +459,16 @@ ACMOPUS::SetBitRateSafe(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate Opus"); "SetBitRateSafe: Invalid rate Opus");
return -1; return -1;
break;
} }
} }
// Re-init with new rate // Re-init with new rate
if (WebRtcOpus_EncoderInit(_encoderInstPtr, _mySampFreq, _opusMode, _flagVBR) >= 0) if (WebRtcOpus_EncoderInit(_encoderInstPtr, _mySampFreq, _opusMode, _flagVBR) >= 0)
{ {
_encoderParams.codecInstant.rate = _myRate; _encoderParams.codecInstant.rate = _myRate;
return 0; return 0;
} }
else else
{ {
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_OPUS_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#define ACM_OPUS_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -41,23 +41,23 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
@@ -80,5 +80,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_OPUS_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_

View File

@@ -38,7 +38,7 @@ ACMPCM16B::~ACMPCM16B()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalEncode( ACMPCM16B::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */)
@@ -47,10 +47,10 @@ ACMPCM16B::InternalEncode(
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::DecodeSafe( ACMPCM16B::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
@@ -59,15 +59,15 @@ ACMPCM16B::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalInitEncoder( ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalInitDecoder( ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -75,9 +75,9 @@ ACMPCM16B::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMPCM16B::CodecDef( ACMPCM16B::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */, WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) const CodecInst& /* codecInst */)
{ {
return -1; return -1;
@@ -91,21 +91,21 @@ ACMPCM16B::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalCreateEncoder() ACMPCM16B::InternalCreateEncoder()
{ {
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalCreateDecoder() ACMPCM16B::InternalCreateDecoder()
{ {
return -1; return -1;
} }
void void
ACMPCM16B::InternalDestructEncoderInst( ACMPCM16B::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -113,20 +113,20 @@ ACMPCM16B::InternalDestructEncoderInst(
} }
void void
ACMPCM16B::DestructEncoderSafe() ACMPCM16B::DestructEncoderSafe()
{ {
return; return;
} }
void void
ACMPCM16B::DestructDecoderSafe() ACMPCM16B::DestructDecoderSafe()
{ {
return; return;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::UnregisterFromNetEqSafe( ACMPCM16B::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */, ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) WebRtc_Word16 /* payloadType */)
@@ -153,7 +153,7 @@ ACMPCM16B::~ACMPCM16B()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalEncode( ACMPCM16B::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
@@ -168,10 +168,10 @@ ACMPCM16B::InternalEncode(
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::DecodeSafe( ACMPCM16B::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
@@ -180,17 +180,17 @@ ACMPCM16B::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalInitEncoder( ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
// This codec does not need initialization, // This codec does not need initialization,
// PCM has no instance // PCM has no instance
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalInitDecoder( ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -200,12 +200,12 @@ ACMPCM16B::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMPCM16B::CodecDef( ACMPCM16B::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
{ {
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -248,7 +248,7 @@ ACMPCM16B::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalCreateEncoder() ACMPCM16B::InternalCreateEncoder()
{ {
// PCM has no instance // PCM has no instance
@@ -256,7 +256,7 @@ ACMPCM16B::InternalCreateEncoder()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::InternalCreateDecoder() ACMPCM16B::InternalCreateDecoder()
{ {
// PCM has no instance // PCM has no instance
@@ -264,7 +264,7 @@ ACMPCM16B::InternalCreateDecoder()
} }
void void
ACMPCM16B::InternalDestructEncoderInst( ACMPCM16B::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -273,7 +273,7 @@ ACMPCM16B::InternalDestructEncoderInst(
} }
void void
ACMPCM16B::DestructEncoderSafe() ACMPCM16B::DestructEncoderSafe()
{ {
// PCM has no instance // PCM has no instance
@@ -282,7 +282,7 @@ ACMPCM16B::DestructEncoderSafe()
return; return;
} }
void void
ACMPCM16B::DestructDecoderSafe() ACMPCM16B::DestructDecoderSafe()
{ {
// PCM has no instance // PCM has no instance
@@ -292,18 +292,18 @@ ACMPCM16B::DestructDecoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCM16B::UnregisterFromNetEqSafe( ACMPCM16B::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
@@ -313,17 +313,14 @@ the stored payload type",
case 8000: case 8000:
{ {
return netEq->RemoveCodec(kDecoderPCM16B); return netEq->RemoveCodec(kDecoderPCM16B);
break;
} }
case 16000: case 16000:
{ {
return netEq->RemoveCodec(kDecoderPCM16Bwb); return netEq->RemoveCodec(kDecoderPCM16Bwb);
break;
} }
case 32000: case 32000:
{ {
return netEq->RemoveCodec(kDecoderPCM16Bswb32kHz); return netEq->RemoveCodec(kDecoderPCM16Bswb32kHz);
break;
} }
default: default:
{ {

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_PCM16B_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#define ACM_PCM16B_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -37,23 +37,23 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
@@ -66,5 +66,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCM16B_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_PCMA_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#define ACM_PCMA_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -37,13 +37,13 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@@ -51,9 +51,9 @@ protected:
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCMA_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_

View File

@@ -33,24 +33,24 @@ ACMPCMU::~ACMPCMU()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::InternalEncode( ACMPCMU::InternalEncode(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) WebRtc_Word16* bitStreamLenByte)
{ {
*bitStreamLenByte = WebRtcG711_EncodeU(NULL, &_inAudio[_inAudioIxRead], *bitStreamLenByte = WebRtcG711_EncodeU(NULL, &_inAudio[_inAudioIxRead],
_frameLenSmpl*_noChannels, (WebRtc_Word16*)bitStream); _frameLenSmpl*_noChannels, (WebRtc_Word16*)bitStream);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl*_noChannels; _inAudioIxRead += _frameLenSmpl*_noChannels;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::DecodeSafe( ACMPCMU::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
@@ -59,17 +59,17 @@ ACMPCMU::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::InternalInitEncoder( ACMPCMU::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
// This codec does not need initialization, // This codec does not need initialization,
// PCM has no instance // PCM has no instance
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::InternalInitDecoder( ACMPCMU::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -79,12 +79,12 @@ ACMPCMU::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMPCMU::CodecDef( ACMPCMU::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
{ {
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -101,7 +101,7 @@ ACMPCMU::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::InternalCreateEncoder() ACMPCMU::InternalCreateEncoder()
{ {
// PCM has no instance // PCM has no instance
@@ -109,7 +109,7 @@ ACMPCMU::InternalCreateEncoder()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::InternalCreateDecoder() ACMPCMU::InternalCreateDecoder()
{ {
// PCM has no instance // PCM has no instance
@@ -117,7 +117,7 @@ ACMPCMU::InternalCreateDecoder()
} }
void void
ACMPCMU::InternalDestructEncoderInst( ACMPCMU::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -126,7 +126,7 @@ ACMPCMU::InternalDestructEncoderInst(
} }
void void
ACMPCMU::DestructEncoderSafe() ACMPCMU::DestructEncoderSafe()
{ {
// PCM has no instance // PCM has no instance
@@ -144,7 +144,7 @@ void ACMPCMU::DestructDecoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMPCMU::UnregisterFromNetEqSafe( ACMPCMU::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
@@ -152,15 +152,15 @@ ACMPCMU::UnregisterFromNetEqSafe(
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
return netEq->RemoveCodec(kDecoderPCMu); return netEq->RemoveCodec(kDecoderPCMu);
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_PCMU_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#define ACM_PCMU_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -37,23 +37,23 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_PCMU_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_

View File

@@ -30,7 +30,7 @@ ACMRED::~ACMRED()
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::InternalEncode( ACMRED::InternalEncode(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) WebRtc_Word16* /* bitStreamLenByte */)
@@ -41,10 +41,10 @@ ACMRED::InternalEncode(
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::DecodeSafe( ACMRED::DecodeSafe(
WebRtc_UWord8* /* bitStream */, WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */)
@@ -53,17 +53,17 @@ ACMRED::DecodeSafe(
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::InternalInitEncoder( ACMRED::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
// This codec does not need initialization, // This codec does not need initialization,
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::InternalInitDecoder( ACMRED::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
@@ -73,7 +73,7 @@ ACMRED::InternalInitDecoder(
} }
WebRtc_Word32 WebRtc_Word32
ACMRED::CodecDef( ACMRED::CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) const CodecInst& codecInst)
@@ -85,7 +85,7 @@ ACMRED::CodecDef(
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION." // "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -102,7 +102,7 @@ ACMRED::CreateInstance(void)
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::InternalCreateEncoder() ACMRED::InternalCreateEncoder()
{ {
// RED has no instance // RED has no instance
@@ -110,7 +110,7 @@ ACMRED::InternalCreateEncoder()
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::InternalCreateDecoder() ACMRED::InternalCreateDecoder()
{ {
// RED has no instance // RED has no instance
@@ -118,7 +118,7 @@ ACMRED::InternalCreateDecoder()
} }
void void
ACMRED::InternalDestructEncoderInst( ACMRED::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -127,7 +127,7 @@ ACMRED::InternalDestructEncoderInst(
} }
void void
ACMRED::DestructEncoderSafe() ACMRED::DestructEncoderSafe()
{ {
// RED has no instance // RED has no instance
@@ -141,18 +141,18 @@ void ACMRED::DestructDecoderSafe()
} }
WebRtc_Word16 WebRtc_Word16
ACMRED::UnregisterFromNetEqSafe( ACMRED::UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType) WebRtc_Word16 payloadType)
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_RED_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#define ACM_RED_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -37,23 +37,23 @@ public:
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream, WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef, WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
@@ -64,5 +64,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif //ACM_RED_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_

View File

@@ -32,15 +32,15 @@ ACMResampler::~ACMResampler()
} }
WebRtc_Word16 WebRtc_Word16
ACMResampler::Resample10Msec( ACMResampler::Resample10Msec(
const WebRtc_Word16* inAudio, const WebRtc_Word16* inAudio,
WebRtc_Word32 inFreqHz, WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio, WebRtc_Word16* outAudio,
WebRtc_Word32 outFreqHz, WebRtc_Word32 outFreqHz,
WebRtc_UWord8 numAudioChannels) WebRtc_UWord8 numAudioChannels)
{ {
CriticalSectionScoped cs(_resamplerCritSect); CriticalSectionScoped cs(_resamplerCritSect);
if(inFreqHz == outFreqHz) if(inFreqHz == outFreqHz)
@@ -55,20 +55,20 @@ ACMResampler::Resample10Msec(
WebRtc_Word32 ret; WebRtc_Word32 ret;
ResamplerType type; ResamplerType type;
type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo; type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo;
ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type); ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type);
if (ret < 0) if (ret < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in reset of resampler"); "Error in reset of resampler");
return -1; return -1;
} }
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen); ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
if (ret < 0 ) if (ret < 0 )
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in resampler: resampler.Push"); "Error in resampler: resampler.Push");
return -1; return -1;
} }
@@ -79,11 +79,11 @@ ACMResampler::Resample10Msec(
} }
void void
ACMResampler::SetUniqueId( ACMResampler::SetUniqueId(
WebRtc_Word32 id) WebRtc_Word32 id)
{ {
CriticalSectionScoped lock(_resamplerCritSect); CriticalSectionScoped lock(_resamplerCritSect);
_id = id; _id = id;
} }

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_RESAMPLER_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#define ACM_RESAMPLER_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#include "resampler.h" #include "resampler.h"
#include "typedefs.h" #include "typedefs.h"
@@ -23,14 +23,14 @@ class ACMResampler
public: public:
ACMResampler(); ACMResampler();
~ACMResampler(); ~ACMResampler();
WebRtc_Word16 Resample10Msec( WebRtc_Word16 Resample10Msec(
const WebRtc_Word16* inAudio, const WebRtc_Word16* inAudio,
const WebRtc_Word32 inFreqHz, const WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio, WebRtc_Word16* outAudio,
const WebRtc_Word32 outFreqHz, const WebRtc_Word32 outFreqHz,
WebRtc_UWord8 numAudioChannels); WebRtc_UWord8 numAudioChannels);
void SetUniqueId( void SetUniqueId(
WebRtc_Word32 id); WebRtc_Word32 id);
@@ -44,4 +44,4 @@ private:
} // namespace webrtc } // namespace webrtc
#endif //ACM_RESAMPLER_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_

View File

@@ -127,7 +127,7 @@ ACMSPEEX::InternalCreateEncoder()
return -1; return -1;
} }
void void
ACMSPEEX::DestructEncoderSafe() ACMSPEEX::DestructEncoderSafe()
{ {
return; return;
@@ -140,7 +140,7 @@ ACMSPEEX::InternalCreateDecoder()
return -1; return -1;
} }
void void
ACMSPEEX::DestructDecoderSafe() ACMSPEEX::DestructDecoderSafe()
{ {
return; return;
@@ -153,7 +153,7 @@ ACMSPEEX::SetBitRateSafe(
return -1; return -1;
} }
void void
ACMSPEEX::InternalDestructEncoderInst( ACMSPEEX::InternalDestructEncoderInst(
void* /* ptrInst */) void* /* ptrInst */)
{ {
@@ -196,7 +196,7 @@ _encoderInstPtr(NULL),
_decoderInstPtr(NULL) _decoderInstPtr(NULL)
{ {
_codecID = codecID; _codecID = codecID;
// Set sampling frequency, frame size and rate Speex // Set sampling frequency, frame size and rate Speex
if(_codecID == ACMCodecDB::kSPEEX8) if(_codecID == ACMCodecDB::kSPEEX8)
{ {
@@ -212,7 +212,7 @@ _decoderInstPtr(NULL)
} }
else else
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Wrong codec id for Speex."); "Wrong codec id for Speex.");
_samplingFrequency = -1; _samplingFrequency = -1;
@@ -257,14 +257,14 @@ ACMSPEEX::InternalEncode(
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
_encodingRate); _encodingRate);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _samplesIn20MsAudio; _inAudioIxRead += _samplesIn20MsAudio;
numEncodedSamples += _samplesIn20MsAudio; numEncodedSamples += _samplesIn20MsAudio;
if(status < 0) if(status < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in Speex encoder"); "Error in Speex encoder");
return status; return status;
} }
@@ -315,7 +315,7 @@ ACMSPEEX::EnableDTX()
// enable DTX // enable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 1) < 0) if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 1) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot enable DTX for Speex"); "Cannot enable DTX for Speex");
return -1; return -1;
} }
@@ -342,7 +342,7 @@ ACMSPEEX::DisableDTX()
// disable DTX // disable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 0) < 0) if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 0) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
return -1; return -1;
} }
@@ -365,7 +365,7 @@ ACMSPEEX::InternalInitEncoder(
// sanity check // sanity check
if (_encoderInstPtr == NULL) if (_encoderInstPtr == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot initialize Speex encoder, instance does not exist"); "Cannot initialize Speex encoder, instance does not exist");
return -1; return -1;
} }
@@ -376,7 +376,7 @@ ACMSPEEX::InternalInitEncoder(
if (status >= 0) { if (status >= 0) {
return 0; return 0;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in initialization of Speex encoder"); "Error in initialization of Speex encoder");
return -1; return -1;
} }
@@ -387,20 +387,20 @@ ACMSPEEX::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) WebRtcACMCodecParams* /* codecParams */)
{ {
WebRtc_Word16 status; WebRtc_Word16 status;
// sanity check // sanity check
if (_decoderInstPtr == NULL) if (_decoderInstPtr == NULL)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot initialize Speex decoder, instance does not exist"); "Cannot initialize Speex decoder, instance does not exist");
return -1; return -1;
} }
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0)? -1:0); status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0)? -1:0);
if (status >= 0) { if (status >= 0) {
return 0; return 0;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in initialization of Speex decoder"); "Error in initialization of Speex decoder");
return -1; return -1;
} }
@@ -413,12 +413,12 @@ ACMSPEEX::CodecDef(
{ {
if (!_decoderInitialized) if (!_decoderInitialized)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error, Speex decoder is not initialized"); "Error, Speex decoder is not initialized");
return -1; return -1;
} }
// Fill up the structure by calling // Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_SPEEX_FUNCTION." // "SET_CODEC_PAR" & "SET_SPEEX_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
@@ -439,14 +439,13 @@ ACMSPEEX::CodecDef(
} }
default: default:
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Unsupported sampling frequency for Speex"); "Unsupported sampling frequency for Speex");
return -1; return -1;
break;
} }
} }
SET_SPEEX_FUNCTIONS((codecDef)); SET_SPEEX_FUNCTIONS((codecDef));
return 0; return 0;
} }
@@ -463,7 +462,7 @@ ACMSPEEX::InternalCreateEncoder()
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency); return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
} }
void void
ACMSPEEX::DestructEncoderSafe() ACMSPEEX::DestructEncoderSafe()
{ {
if(_encoderInstPtr != NULL) if(_encoderInstPtr != NULL)
@@ -484,7 +483,7 @@ ACMSPEEX::InternalCreateDecoder()
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1); return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
} }
void void
ACMSPEEX::DestructDecoderSafe() ACMSPEEX::DestructDecoderSafe()
{ {
if(_decoderInstPtr != NULL) if(_decoderInstPtr != NULL)
@@ -508,17 +507,17 @@ ACMSPEEX::SetBitRateSafe(
_encodingRate = rate; _encodingRate = rate;
_encoderParams.codecInstant.rate = rate; _encoderParams.codecInstant.rate = rate;
} else { } else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Unsupported encoding rate for Speex"); "Unsupported encoding rate for Speex");
return -1; return -1;
} }
return 0; return 0;
} }
void void
ACMSPEEX::InternalDestructEncoderInst( ACMSPEEX::InternalDestructEncoderInst(
void* ptrInst) void* ptrInst)
{ {
@@ -537,11 +536,11 @@ ACMSPEEX::UnregisterFromNetEqSafe(
{ {
if(payloadType != _decoderParams.codecInstant.pltype) if(payloadType != _decoderParams.codecInstant.pltype)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec %s given payload-type %d does not match \ "Cannot unregister codec %s given payload-type %d does not match \
the stored payload type", the stored payload type",
_decoderParams.codecInstant.plname, _decoderParams.codecInstant.plname,
payloadType, payloadType,
_decoderParams.codecInstant.pltype); _decoderParams.codecInstant.pltype);
return -1; return -1;
} }
@@ -559,7 +558,7 @@ the stored payload type",
} }
default: default:
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Could not unregister Speex from NetEQ. Sampling frequency doesn't match"); "Could not unregister Speex from NetEQ. Sampling frequency doesn't match");
return -1; return -1;
} }
@@ -583,9 +582,9 @@ ACMSPEEX::EnableVBR()
// enable Variable Bit Rate (VBR) // enable Variable Bit Rate (VBR)
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode, (_dtxEnabled? 1:0)) < 0) if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode, (_dtxEnabled? 1:0)) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot enable VBR mode for Speex"); "Cannot enable VBR mode for Speex");
return -1; return -1;
} }
_vbrEnabled = true; _vbrEnabled = true;
@@ -612,7 +611,7 @@ ACMSPEEX::DisableVBR()
// disable DTX // disable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode, (_dtxEnabled? 1:0)) < 0) if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode, (_dtxEnabled? 1:0)) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
return -1; return -1;
@@ -643,7 +642,7 @@ ACMSPEEX::SetComplMode(
// Set new mode // Set new mode
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled? 1:0)) < 0) if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled? 1:0)) < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in complexity mode for Speex"); "Error in complexity mode for Speex");
return -1; return -1;
} }
@@ -662,4 +661,3 @@ ACMSPEEX::SetComplMode(
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef ACM_SPEEX_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#define ACM_SPEEX_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
@@ -54,28 +54,28 @@ protected:
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(
void* ptrInst); void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate); const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
#ifdef UNUSEDSPEEX #ifdef UNUSEDSPEEX
WebRtc_Word16 EnableVBR(); WebRtc_Word16 EnableVBR();
WebRtc_Word16 DisableVBR(); WebRtc_Word16 DisableVBR();
WebRtc_Word16 SetComplMode( WebRtc_Word16 SetComplMode(
WebRtc_Word16 mode); WebRtc_Word16 mode);
#endif #endif
WebRtc_Word16 UnregisterFromNetEqSafe( WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq, ACMNetEQ* netEq,
WebRtc_Word16 payloadType); WebRtc_Word16 payloadType);
@@ -91,4 +91,4 @@ protected:
} // namespace webrtc } // namespace webrtc
#endif // ACM_SPEEX_H #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_

View File

@@ -18,7 +18,7 @@ namespace webrtc
{ {
// Create module // Create module
AudioCodingModule* AudioCodingModule*
AudioCodingModule::Create( AudioCodingModule::Create(
const WebRtc_Word32 id) const WebRtc_Word32 id)
{ {
@@ -26,7 +26,7 @@ AudioCodingModule::Create(
} }
// Destroy module // Destroy module
void void
AudioCodingModule::Destroy( AudioCodingModule::Destroy(
AudioCodingModule* module) AudioCodingModule* module)
{ {
@@ -34,10 +34,10 @@ AudioCodingModule::Destroy(
} }
// Returns version of the module and its components. // Returns version of the module and its components.
WebRtc_Word32 WebRtc_Word32
AudioCodingModule::GetVersion( AudioCodingModule::GetVersion(
WebRtc_Word8* version, WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes, WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position) WebRtc_UWord32& position)
{ {
WebRtc_Word32 len = position; WebRtc_Word32 len = position;
@@ -45,7 +45,7 @@ AudioCodingModule::GetVersion(
position = static_cast<WebRtc_UWord32>(strlen(version)); position = static_cast<WebRtc_UWord32>(strlen(version));
remainingBufferInBytes -= (position - len); remainingBufferInBytes -= (position - len);
// Get NetEQ version. // Get NetEQ version.
if(ACMNetEQ::GetVersion(version, if(ACMNetEQ::GetVersion(version,
remainingBufferInBytes, position) < 0) remainingBufferInBytes, position) < 0)
@@ -72,32 +72,32 @@ AudioCodingModule::GetVersion(
// Get number of supported codecs // Get number of supported codecs
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() WebRtc_UWord8 AudioCodingModule::NumberOfCodecs()
{ {
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"NumberOfCodecs()"); "NumberOfCodecs()");
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs); return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
} }
// Get supported codec param with id // Get supported codec param with id
WebRtc_Word32 WebRtc_Word32
AudioCodingModule::Codec( AudioCodingModule::Codec(
const WebRtc_UWord8 listId, const WebRtc_UWord8 listId,
CodecInst& codec) CodecInst& codec)
{ {
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"Codec(const WebRtc_UWord8 listId, CodecInst& codec)"); "Codec(const WebRtc_UWord8 listId, CodecInst& codec)");
// Get the codec settings for the codec with the given list ID // Get the codec settings for the codec with the given list ID
return ACMCodecDB::Codec(listId, &codec); return ACMCodecDB::Codec(listId, &codec);
} }
// Get supported codec Param with name // Get supported codec Param with name
WebRtc_Word32 WebRtc_Word32
AudioCodingModule::Codec( AudioCodingModule::Codec(
const WebRtc_Word8* payloadName, const WebRtc_Word8* payloadName,
CodecInst& codec, CodecInst& codec,
const WebRtc_Word32 samplingFreqHz) const WebRtc_Word32 samplingFreqHz)
{ {
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"Codec(const WebRtc_Word8* payloadName, CodecInst& codec)"); "Codec(const WebRtc_Word8* payloadName, CodecInst& codec)");
// Search through codec list for a matching name // Search through codec list for a matching name
@@ -108,7 +108,7 @@ AudioCodingModule::Codec(
if(!STR_CASE_CMP(codec.plname, payloadName)) if(!STR_CASE_CMP(codec.plname, payloadName))
{ {
// If samplingFreqHz is set (!= -1), check if frequency matches // If samplingFreqHz is set (!= -1), check if frequency matches
if((samplingFreqHz == codec.plfreq) || (samplingFreqHz == -1)) if((samplingFreqHz == codec.plfreq) || (samplingFreqHz == -1))
{ {
// We found a match, return OK // We found a match, return OK
@@ -118,7 +118,7 @@ AudioCodingModule::Codec(
} }
// if we are here we couldn't find anything // if we are here we couldn't find anything
// set the params to unacceptable values // set the params to unacceptable values
codec.plname[0] = '\0'; codec.plname[0] = '\0';
codec.pltype = -1; codec.pltype = -1;
codec.pacsize = 0; codec.pacsize = 0;
@@ -133,7 +133,7 @@ AudioCodingModule::Codec(
const WebRtc_Word8* payloadName, const WebRtc_Word8* payloadName,
const WebRtc_Word32 samplingFreqHz) const WebRtc_Word32 samplingFreqHz)
{ {
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"Codec(const WebRtc_Word8* payloadName)"); "Codec(const WebRtc_Word8* payloadName)");
CodecInst codec; CodecInst codec;
@@ -145,10 +145,10 @@ AudioCodingModule::Codec(
if(!STR_CASE_CMP(codec.plname, payloadName)) if(!STR_CASE_CMP(codec.plname, payloadName))
{ {
// If samplingFreqHz is set (!= -1), check if frequency matches // If samplingFreqHz is set (!= -1), check if frequency matches
if((samplingFreqHz == codec.plfreq) || (samplingFreqHz == -1)) if((samplingFreqHz == codec.plfreq) || (samplingFreqHz == -1))
{ {
// We found a match, return codec list number (index) // We found a match, return codec list number (index)
return codecCntr; return codecCntr;
} }
} }
@@ -159,17 +159,17 @@ AudioCodingModule::Codec(
} }
// Checks the validity of the parameters of the given codec // Checks the validity of the parameters of the given codec
bool bool
AudioCodingModule::IsCodecValid( AudioCodingModule::IsCodecValid(
const CodecInst& codec) const CodecInst& codec)
{ {
int mirrorID; int mirrorID;
char errMsg[500]; char errMsg[500];
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1, WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"IsCodecValid(const CodecInst& codec)"); "IsCodecValid(const CodecInst& codec)");
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500); int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
if(codecNumber < 0) if(codecNumber < 0)
{ {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg); WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);

View File

@@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#ifndef AUDIO_CODING_MODULE_IMPL_H #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#define AUDIO_CODING_MODULE_IMPL_H #define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#include "acm_codec_database.h" #include "acm_codec_database.h"
#include "acm_neteq.h" #include "acm_neteq.h"
@@ -59,9 +59,9 @@ public:
WebRtc_Word32 TimeUntilNextProcess(); WebRtc_Word32 TimeUntilNextProcess();
// Process any pending tasks such as timeouts // Process any pending tasks such as timeouts
WebRtc_Word32 Process(); WebRtc_Word32 Process();
// used in conference to go to and from active encoding, hence // used in conference to go to and from active encoding, hence
// in and out of mix // in and out of mix
WebRtc_Word32 SetMode( WebRtc_Word32 SetMode(
const bool passive); const bool passive);
@@ -94,7 +94,7 @@ public:
// return there longterm avarage or their fixed rate. // return there longterm avarage or their fixed rate.
WebRtc_Word32 SendBitrate() const; WebRtc_Word32 SendBitrate() const;
// set available bandwidth, inform the encoder about the // set available bandwidth, inform the encoder about the
// estimated bandwidth received from the remote party // estimated bandwidth received from the remote party
virtual WebRtc_Word32 SetReceivedEstimatedBandwidth( virtual WebRtc_Word32 SetReceivedEstimatedBandwidth(
const WebRtc_Word32 bw); const WebRtc_Word32 bw);
@@ -123,7 +123,7 @@ public:
ACMBackgroundNoiseMode& mode); ACMBackgroundNoiseMode& mode);
///////////////////////////////////////// /////////////////////////////////////////
// (FEC) Forward Error Correction // (FEC) Forward Error Correction
// //
// configure FEC status i.e on/off // configure FEC status i.e on/off
@@ -193,7 +193,7 @@ public:
CodecInst& currentReceiveCodec) const; CodecInst& currentReceiveCodec) const;
// incoming packet from network parsed and ready for decode // incoming packet from network parsed and ready for decode
WebRtc_Word32 IncomingPacket( WebRtc_Word32 IncomingPacket(
const WebRtc_Word8* incomingPayload, const WebRtc_Word8* incomingPayload,
const WebRtc_Word32 payloadLength, const WebRtc_Word32 payloadLength,
const WebRtcRTPHeader& rtpInfo); const WebRtcRTPHeader& rtpInfo);
@@ -222,7 +222,7 @@ public:
// Estimate the Bandwidth based on the incoming stream // Estimate the Bandwidth based on the incoming stream
// This is also done in the RTP module // This is also done in the RTP module
// need this for one way audio where the RTCP send the BW estimate // need this for one way audio where the RTCP send the BW estimate
WebRtc_Word32 DecoderEstimatedBandwidth() const; WebRtc_Word32 DecoderEstimatedBandwidth() const;
// Set playout mode voice, fax // Set playout mode voice, fax
@@ -261,21 +261,21 @@ public:
void DestructEncoderInst(void* ptrInst); void DestructEncoderInst(void* ptrInst);
WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff); WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff);
// GET RED payload for iSAC. The method id called // GET RED payload for iSAC. The method id called
// when 'this' ACM is default ACM. // when 'this' ACM is default ACM.
WebRtc_Word32 REDPayloadISAC( WebRtc_Word32 REDPayloadISAC(
const WebRtc_Word32 isacRate, const WebRtc_Word32 isacRate,
const WebRtc_Word16 isacBwEstimate, const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload, WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenByte); WebRtc_Word16* payloadLenByte);
WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff); WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff);
WebRtc_UWord32 EarliestTimestamp() const; WebRtc_UWord32 EarliestTimestamp() const;
WebRtc_Word32 LastEncodedTimestamp(WebRtc_UWord32& timestamp) const; WebRtc_Word32 LastEncodedTimestamp(WebRtc_UWord32& timestamp) const;
WebRtc_Word32 ReplaceInternalDTXWithWebRtc( WebRtc_Word32 ReplaceInternalDTXWithWebRtc(
const bool useWebRtcDTX); const bool useWebRtcDTX);
@@ -361,15 +361,15 @@ private:
WebRtc_UWord32 _lastFECTimestamp; WebRtc_UWord32 _lastFECTimestamp;
WebRtc_UWord8 _redPayloadType; WebRtc_UWord8 _redPayloadType;
// if no RED is registered as receive codec this // if no RED is registered as receive codec this
// will have an invalid value. // will have an invalid value.
WebRtc_UWord8 _receiveREDPayloadType; WebRtc_UWord8 _receiveREDPayloadType;
// This is to keep track of CN instances where we can send DTMFs // This is to keep track of CN instances where we can send DTMFs
WebRtc_UWord8 _previousPayloadType; WebRtc_UWord8 _previousPayloadType;
// This keeps track of payload types associated with _codecs[]. // This keeps track of payload types associated with _codecs[].
// We define it as signed variable and initialize with -1 to indicate // We define it as signed variable and initialize with -1 to indicate
// unused elements. // unused elements.
WebRtc_Word16 _registeredPlTypes[ACMCodecDB::kMaxNumCodecs]; WebRtc_Word16 _registeredPlTypes[ACMCodecDB::kMaxNumCodecs];
// Used when payloads are pushed into ACM without any RTP info // Used when payloads are pushed into ACM without any RTP info
@@ -380,7 +380,7 @@ private:
bool _receiverInitialized; bool _receiverInitialized;
ACMDTMFDetection* _dtmfDetector; ACMDTMFDetection* _dtmfDetector;
AudioCodingFeedback* _dtmfCallback; AudioCodingFeedback* _dtmfCallback;
WebRtc_Word16 _lastDetectedTone; WebRtc_Word16 _lastDetectedTone;
CriticalSectionWrapper* _callbackCritSect; CriticalSectionWrapper* _callbackCritSect;
@@ -397,4 +397,4 @@ private:
} // namespace webrtc } // namespace webrtc
#endif #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_