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

View File

@ -18,192 +18,131 @@
#include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_AMR
// NOTE! GSM AMR is not included in the open-source package. The following
// interface file is needed:
//
// /modules/audio_coding/codecs/amr/main/interface/amr_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst);
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst);
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst);
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst,
// int16_t* input,
// int16_t len,
// int16_t*output,
// int16_t mode);
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst,
// int16_t dtxMode);
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst,
// int format);
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst,
// int format);
// void WebRtcAmr_Version(char *versionStr, short len);
#include "amr_interface.h"
// NOTE! GSM AMR is not included in the open-source package. The following
// interface file is needed:
//
// /modules/audio_coding/codecs/amr/main/interface/amr_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcAmr_CreateEnc(AMR_encinst_t_** encInst);
// int16_t WebRtcAmr_CreateDec(AMR_decinst_t_** decInst);
// int16_t WebRtcAmr_FreeEnc(AMR_encinst_t_* encInst);
// int16_t WebRtcAmr_FreeDec(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_Encode(AMR_encinst_t_* encInst,
// int16_t* input,
// int16_t len,
// int16_t*output,
// int16_t mode);
// int16_t WebRtcAmr_EncoderInit(AMR_encinst_t_* encInst,
// int16_t dtxMode);
// int16_t WebRtcAmr_EncodeBitmode(AMR_encinst_t_* encInst,
// int format);
// int16_t WebRtcAmr_Decode(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodePlc(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecoderInit(AMR_decinst_t_* decInst);
// int16_t WebRtcAmr_DecodeBitmode(AMR_decinst_t_* decInst,
// int format);
// void WebRtcAmr_Version(char *versionStr, short len);
#include "amr_interface.h"
#endif
namespace webrtc {
#ifndef WEBRTC_CODEC_AMR
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */)
{
return;
ACMAMR::ACMAMR(WebRtc_Word16 /* codecID */) {
return;
}
ACMAMR::~ACMAMR()
{
return;
ACMAMR::~ACMAMR() {
return;
}
WebRtc_Word16
ACMAMR::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
WebRtc_Word16 ACMAMR::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return -1;
}
WebRtc_Word16
ACMAMR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
WebRtc_Word16 ACMAMR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return -1;
}
WebRtc_Word16
ACMAMR::EnableDTX()
{
return -1;
WebRtc_Word16 ACMAMR::EnableDTX() {
return -1;
}
WebRtc_Word16
ACMAMR::DisableDTX()
{
return -1;
WebRtc_Word16 ACMAMR::DisableDTX() {
return -1;
}
WebRtc_Word16
ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMAMR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word16
ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMAMR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word32
ACMAMR::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
WebRtc_Word32 ACMAMR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) {
return -1;
}
ACMGenericCodec*
ACMAMR::CreateInstance(void)
{
return NULL;
ACMGenericCodec* ACMAMR::CreateInstance(void) {
return NULL;
}
WebRtc_Word16
ACMAMR::InternalCreateEncoder()
{
return -1;
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
return -1;
}
void
ACMAMR::DestructEncoderSafe()
{
return;
void ACMAMR::DestructEncoderSafe() {
return;
}
WebRtc_Word16
ACMAMR::InternalCreateDecoder()
{
return -1;
WebRtc_Word16 ACMAMR::InternalCreateDecoder() {
return -1;
}
void
ACMAMR::DestructDecoderSafe()
{
return;
void ACMAMR::DestructDecoderSafe() {
return;
}
WebRtc_Word16
ACMAMR::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1;
WebRtc_Word16 ACMAMR::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
return -1;
}
void
ACMAMR::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
void ACMAMR::InternalDestructEncoderInst(void* /* ptrInst */) {
return;
}
WebRtc_Word16
ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */)
{
return -1;
WebRtc_Word16 ACMAMR::SetAMREncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) {
return -1;
}
ACMAMRPackingFormat
ACMAMR::AMREncoderPackingFormat() const
{
return AMRUndefined;
ACMAMRPackingFormat ACMAMR::AMREncoderPackingFormat() const {
return AMRUndefined;
}
WebRtc_Word16
ACMAMR::SetAMRDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */)
{
return -1;
WebRtc_Word16 ACMAMR::SetAMRDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) {
return -1;
}
ACMAMRPackingFormat
ACMAMR::AMRDecoderPackingFormat() const
{
return AMRUndefined;
ACMAMRPackingFormat ACMAMR::AMRDecoderPackingFormat() const {
return AMRUndefined;
}
WebRtc_Word16
ACMAMR::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1;
WebRtc_Word16 ACMAMR::UnregisterFromNetEqSafe(ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) {
return -1;
}
@ -218,377 +157,282 @@ ACMAMR::UnregisterFromNetEqSafe(
#define WEBRTC_AMR_MR102 6
#define WEBRTC_AMR_MR122 7
ACMAMR::ACMAMR(WebRtc_Word16 codecID):
_encoderInstPtr(NULL),
_decoderInstPtr(NULL),
_encodingMode(-1), // invalid value
_encodingRate(0) // invalid value
{
_codecID = codecID;
_hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient;
return;
ACMAMR::ACMAMR(WebRtc_Word16 codecID)
: _encoderInstPtr(NULL),
_decoderInstPtr(NULL),
_encodingMode(-1), // invalid value
_encodingRate(0) { // invalid value
_codecID = codecID;
_hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient;
return;
}
ACMAMR::~ACMAMR()
{
if(_encoderInstPtr != NULL)
{
WebRtcAmr_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
if(_decoderInstPtr != NULL)
{
WebRtcAmr_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
return;
ACMAMR::~ACMAMR() {
if (_encoderInstPtr != NULL) {
WebRtcAmr_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
if (_decoderInstPtr != NULL) {
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
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;
// Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) {
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
vadDecision = 0;
}
*bitStreamLenByte = WebRtcAmr_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _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;
}
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
_vadLabel[n] = vadDecision;
}
// increment the read index
_inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
}
// increment the read index
_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
ACMAMR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
WebRtc_Word16 ACMAMR::EnableDTX() {
if (_dtxEnabled) {
return 0;
}
WebRtc_Word16
ACMAMR::EnableDTX()
{
if(_dtxEnabled)
{
return 0;
} else if (_encoderExist) { // check if encoder exist
// enable DTX
if (WebRtcAmr_EncoderInit(_encoderInstPtr, 1) < 0) {
return -1;
}
else if(_encoderExist) // check if encoder exist
{
// 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));
_dtxEnabled = true;
return 0;
} else {
return -1;
}
}
ACMGenericCodec*
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;
}
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;
}
}
void
ACMAMR::InternalDestructEncoderInst(
void* ptrInst)
{
// Free the memory where ptrInst is pointing to
if(ptrInst != NULL)
{
WebRtcAmr_FreeEnc((AMR_encinst_t_*)ptrInst);
}
return;
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::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;
}
}
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;
}
ACMAMRPackingFormat
ACMAMR::AMREncoderPackingFormat() const
{
return _encoderPackingFormat;
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;
}
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;
}
}
ACMGenericCodec* ACMAMR::CreateInstance(void) {
return NULL;
}
ACMAMRPackingFormat
ACMAMR::AMRDecoderPackingFormat() const
{
return _decoderPackingFormat;
WebRtc_Word16 ACMAMR::InternalCreateEncoder() {
return WebRtcAmr_CreateEnc(&_encoderInstPtr);
}
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;
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;
}
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
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_AMR_H
#define ACM_AMR_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMR_H_
#include "acm_generic_codec.h"
@ -21,76 +21,66 @@ namespace webrtc {
enum ACMAMRPackingFormat;
class ACMAMR : public ACMGenericCodec
{
public:
ACMAMR(WebRtc_Word16 codecID);
~ACMAMR();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMAMR: public ACMGenericCodec {
public:
ACMAMR(WebRtc_Word16 codecID);
~ACMAMR();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
ACMAMRPackingFormat AMREncoderPackingFormat() const;
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 SetAMRDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
ACMAMRPackingFormat AMRDecoderPackingFormat() const;
WebRtc_Word16 SetAMREncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
ACMAMRPackingFormat AMREncoderPackingFormat() const;
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word16 SetAMRDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
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_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void DestructEncoderSafe();
AMR_encinst_t_* _encoderInstPtr;
AMR_decinst_t_* _decoderInstPtr;
WebRtc_Word16 _encodingMode;
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat;
ACMAMRPackingFormat _decoderPackingFormat;
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
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
#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"
#ifdef WEBRTC_CODEC_AMRWB
// NOTE! GSM AMR-wb is not included in the open-source package. The
// following interface file is needed:
//
// /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst);
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst);
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst);
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input,
// int16_t len, int16_t*output, int16_t mode);
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst,
// int16_t dtxMode);
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst,
// int format);
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst,
// int format);
// void WebRtcAmrWb_Version(char *versionStr, short len);
#include "amrwb_interface.h"
// NOTE! GSM AMR-wb is not included in the open-source package. The
// following interface file is needed:
//
// /modules/audio_coding/codecs/amrwb/main/interface/amrwb_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcAmrWb_CreateEnc(AMRWB_encinst_t_** encInst);
// int16_t WebRtcAmrWb_CreateDec(AMRWB_decinst_t_** decInst);
// int16_t WebRtcAmrWb_FreeEnc(AMRWB_encinst_t_* encInst);
// int16_t WebRtcAmrWb_FreeDec(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_Encode(AMRWB_encinst_t_* encInst, int16_t* input,
// int16_t len, int16_t* output, int16_t mode);
// int16_t WebRtcAmrWb_EncoderInit(AMRWB_encinst_t_* encInst,
// int16_t dtxMode);
// int16_t WebRtcAmrWb_EncodeBitmode(AMRWB_encinst_t_* encInst,
// int format);
// int16_t WebRtcAmrWb_Decode(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodePlc(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecoderInit(AMRWB_decinst_t_* decInst);
// int16_t WebRtcAmrWb_DecodeBitmode(AMRWB_decinst_t_* decInst,
// int format);
// void WebRtcAmrWb_Version(char *versionStr, short len);
#include "amrwb_interface.h"
#endif
namespace webrtc {
#ifndef WEBRTC_CODEC_AMRWB
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/)
{
return;
ACMAMRwb::ACMAMRwb(WebRtc_Word16 /* codecID*/) {
return;
}
ACMAMRwb::~ACMAMRwb()
{
return;
ACMAMRwb::~ACMAMRwb() {
return;
}
WebRtc_Word16
ACMAMRwb::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
WebRtc_Word16 ACMAMRwb::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return -1;
}
WebRtc_Word16
ACMAMRwb::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return -1;
}
WebRtc_Word16
ACMAMRwb::EnableDTX()
{
return -1;
WebRtc_Word16 ACMAMRwb::EnableDTX() {
return -1;
}
WebRtc_Word16
ACMAMRwb::DisableDTX()
{
return -1;
WebRtc_Word16 ACMAMRwb::DisableDTX() {
return -1;
}
WebRtc_Word16
ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMAMRwb::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word16
ACMAMRwb::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMAMRwb::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word32
ACMAMRwb::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) {
return -1;
}
ACMGenericCodec*
ACMAMRwb::CreateInstance(void)
{
return NULL;
ACMAMRwb::CreateInstance(void) {
return NULL;
}
WebRtc_Word16
ACMAMRwb::InternalCreateEncoder()
{
return -1;
WebRtc_Word16 ACMAMRwb::InternalCreateEncoder() {
return -1;
}
void
ACMAMRwb::DestructEncoderSafe()
{
return;
void ACMAMRwb::DestructEncoderSafe() {
return;
}
WebRtc_Word16
ACMAMRwb::InternalCreateDecoder()
{
return -1;
WebRtc_Word16 ACMAMRwb::InternalCreateDecoder() {
return -1;
}
void
ACMAMRwb::DestructDecoderSafe()
{
return;
void ACMAMRwb::DestructDecoderSafe() {
return;
}
WebRtc_Word16
ACMAMRwb::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1;
WebRtc_Word16 ACMAMRwb::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
return -1;
}
void
ACMAMRwb::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
void ACMAMRwb::InternalDestructEncoderInst(void* /* ptrInst */) {
return;
}
WebRtc_Word16
ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */)
{
return -1;
WebRtc_Word16 ACMAMRwb::SetAMRwbEncoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */) {
return -1;
}
ACMAMRPackingFormat
ACMAMRwb::AMRwbEncoderPackingFormat() const
{
return AMRUndefined;
ACMAMRPackingFormat ACMAMRwb::AMRwbEncoderPackingFormat() const {
return AMRUndefined;
}
WebRtc_Word16 ACMAMRwb::SetAMRwbDecoderPackingFormat(
ACMAMRPackingFormat /* packingFormat */)
{
return -1;
ACMAMRPackingFormat /* packingFormat */) {
return -1;
}
ACMAMRPackingFormat
ACMAMRwb::AMRwbDecoderPackingFormat() const
{
return AMRUndefined;
ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
return AMRUndefined;
}
WebRtc_Word16
ACMAMRwb::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1;
WebRtc_Word16 ACMAMRwb::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) {
return -1;
}
#else //===================== Actual Implementation =======================
@ -202,387 +156,288 @@ ACMAMRwb::UnregisterFromNetEqSafe(
#define AMRWB_MODE_23k 7
#define AMRWB_MODE_24k 8
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID):
_encoderInstPtr(NULL),
_decoderInstPtr(NULL),
_encodingMode(-1), // invalid value
_encodingRate(0) // invalid value
{
_codecID = codecID;
_hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient;
return;
ACMAMRwb::ACMAMRwb(WebRtc_Word16 codecID)
: _encoderInstPtr(NULL),
_decoderInstPtr(NULL),
_encodingMode(-1), // invalid value
_encodingRate(0) { // invalid value
_codecID = codecID;
_hasInternalDTX = true;
_encoderPackingFormat = AMRBandwidthEfficient;
_decoderPackingFormat = AMRBandwidthEfficient;
return;
}
ACMAMRwb::~ACMAMRwb()
{
if(_encoderInstPtr != NULL)
{
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
if(_decoderInstPtr != NULL)
{
WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
return;
ACMAMRwb::~ACMAMRwb() {
if (_encoderInstPtr != NULL) {
WebRtcAmrWb_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
if (_decoderInstPtr != NULL) {
WebRtcAmrWb_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
return;
}
WebRtc_Word16
ACMAMRwb::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 < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k))
{
*bitStreamLenByte = 0;
return -1;
WebRtc_Word16 ACMAMRwb::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 < AMRWB_MODE_7k) || (_encodingMode > AMRWB_MODE_24k)) {
*bitStreamLenByte = 0;
return -1;
}
*bitStreamLenByte = WebRtcAmrWb_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead],
_frameLenSmpl,
(WebRtc_Word16*) bitStream,
_encodingMode);
// Update VAD, if internal DTX is used
if (_hasInternalDTX && _dtxEnabled) {
if (*bitStreamLenByte <= (7 * _frameLenSmpl / 160)) {
vadDecision = 0;
}
*bitStreamLenByte =
WebRtcAmrWb_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
_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;
}
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
_inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
}
// increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
}
WebRtc_Word16
ACMAMRwb::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
WebRtc_Word16 ACMAMRwb::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return 0;
}
WebRtc_Word16 ACMAMRwb::EnableDTX() {
if (_dtxEnabled) {
return 0;
}
WebRtc_Word16
ACMAMRwb::EnableDTX()
{
if(_dtxEnabled)
{
return 0;
} else if (_encoderExist) { // check if encoder exist
// enable DTX
if (WebRtcAmrWb_EncoderInit(_encoderInstPtr, 1) < 0) {
return -1;
}
else if(_encoderExist) // check if encoder exist
{
// 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));
_dtxEnabled = true;
return 0;
} else {
return -1;
}
}
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;
break;
}
}
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;
}
}
void
ACMAMRwb::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcAmrWb_FreeEnc((AMRWB_encinst_t_*)ptrInst);
}
return;
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::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;
}
}
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;
}
ACMAMRPackingFormat
ACMAMRwb::AMRwbEncoderPackingFormat() const
{
return _encoderPackingFormat;
WebRtc_Word32 ACMAMRwb::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) {
if (!_decoderInitialized) {
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(
ACMAMRPackingFormat packingFormat)
{
if((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage))
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMRwb decoder packing-format.");
return -1;
}
else
{
if(WebRtcAmrWb_DecodeBitmode(_decoderInstPtr,
packingFormat) < 0)
{
return -1;
}
else
{
_decoderPackingFormat = packingFormat;
return 0;
}
ACMAMRPackingFormat packingFormat) {
if ((packingFormat != AMRBandwidthEfficient) &&
(packingFormat != AMROctetAlligned) &&
(packingFormat != AMRFileStorage)) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Invalid AMRwb decoder packing-format.");
return -1;
} else {
if (WebRtcAmrWb_DecodeBitmode(_decoderInstPtr, packingFormat) < 0) {
return -1;
} else {
_decoderPackingFormat = packingFormat;
return 0;
}
}
}
ACMAMRPackingFormat
ACMAMRwb::AMRwbDecoderPackingFormat() const
{
return _decoderPackingFormat;
ACMAMRPackingFormat ACMAMRwb::AMRwbDecoderPackingFormat() const {
return _decoderPackingFormat;
}
WebRtc_Word16
ACMAMRwb::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(kDecoderAMRWB);
WebRtc_Word16 ACMAMRwb::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(kDecoderAMRWB);
}
#endif

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_AMRWB_H
#define ACM_AMRWB_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_AMRWB_H_
#include "acm_generic_codec.h"
@ -21,77 +21,67 @@ namespace webrtc {
enum ACMAMRPackingFormat;
class ACMAMRwb : public ACMGenericCodec
{
public:
ACMAMRwb(WebRtc_Word16 codecID);
~ACMAMRwb();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMAMRwb: public ACMGenericCodec {
public:
ACMAMRwb(WebRtc_Word16 codecID);
~ACMAMRwb();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams* codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams* codecParams);
WebRtc_Word16 SetAMRwbEncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
WebRtc_Word16 SetAMRwbEncoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMRwbEncoderPackingFormat() const;
ACMAMRPackingFormat AMRwbEncoderPackingFormat() const;
WebRtc_Word16 SetAMRwbDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
WebRtc_Word16 SetAMRwbDecoderPackingFormat(
const ACMAMRPackingFormat packingFormat);
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
ACMAMRPackingFormat AMRwbDecoderPackingFormat() const;
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructEncoderSafe();
void DestructDecoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void InternalDestructEncoderInst(void* ptrInst);
AMRWB_encinst_t_* _encoderInstPtr;
AMRWB_decinst_t_* _decoderInstPtr;
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
WebRtc_Word16 _encodingMode;
WebRtc_Word16 _encodingRate;
ACMAMRPackingFormat _encoderPackingFormat;
ACMAMRPackingFormat _decoderPackingFormat;
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
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
#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_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;
}
if (_decoderInstPtr != NULL) {
WebRtcCng_FreeDec(_decoderInstPtr);
_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
// should not be called normally
// instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16
ACMCNG::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
WebRtc_Word16 ACMCNG::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return -1;
}
WebRtc_Word16
ACMCNG::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0;
WebRtc_Word16 ACMCNG::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return 0;
}
// CNG is not like a regular encoder,
// this function should not be called normally
// instead the following function is called from inside
// ACMGenericCodec::ProcessFrameVADDTX
WebRtc_Word16
ACMCNG::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
WebRtc_Word16 ACMCNG::InternalInitEncoder(
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;
}
// 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;
}
}
WebRtc_Word16
ACMCNG::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return WebRtcCng_InitDec(_decoderInstPtr);
ACMGenericCodec* ACMCNG::CreateInstance(void) {
return NULL;
}
WebRtc_Word32
ACMCNG::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
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;
}
WebRtc_Word16 ACMCNG::InternalCreateEncoder() {
if (WebRtcCng_CreateEnc(&_encoderInstPtr) < 0) {
_encoderInstPtr = NULL;
return -1;
} else {
return 0;
}
}
ACMGenericCodec* ACMCNG::CreateInstance(void)
{
return NULL;
void ACMCNG::DestructEncoderSafe() {
if (_encoderInstPtr != NULL) {
WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
_encoderExist = false;
_encoderInitialized = false;
}
WebRtc_Word16
ACMCNG::InternalCreateEncoder()
{
if(WebRtcCng_CreateEnc(&_encoderInstPtr) < 0)
{
_encoderInstPtr = NULL;
return -1;
}
else
{
return 0;
}
WebRtc_Word16 ACMCNG::InternalCreateDecoder() {
if (WebRtcCng_CreateDec(&_decoderInstPtr) < 0) {
_decoderInstPtr = NULL;
return -1;
} else {
return 0;
}
}
void
ACMCNG::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcCng_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL;
}
_encoderExist = false;
_encoderInitialized = false;
void ACMCNG::DestructDecoderSafe() {
if (_decoderInstPtr != NULL) {
WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
_decoderExist = false;
_decoderInitialized = false;
}
WebRtc_Word16
ACMCNG::InternalCreateDecoder()
{
if(WebRtcCng_CreateDec(&_decoderInstPtr) < 0)
{
_decoderInstPtr = NULL;
return -1;
}
else
{
return 0;
}
void ACMCNG::InternalDestructEncoderInst(void* ptrInst) {
if (ptrInst != NULL) {
WebRtcCng_FreeEnc(static_cast<CNG_enc_inst*>(ptrInst));
}
return;
}
void
ACMCNG::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcCng_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL;
}
_decoderExist = false;
_decoderInitialized = false;
}
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);
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

View File

@ -8,80 +8,66 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_CNG_H
#define ACM_CNG_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_CNG_H_
#include "acm_generic_codec.h"
// forward declaration
struct WebRtcCngEncInst;
struct WebRtcCngDecInst;
namespace webrtc
{
namespace webrtc {
class ACMCNG : public ACMGenericCodec
{
public:
ACMCNG(WebRtc_Word16 codecID);
~ACMCNG();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMCNG: public ACMGenericCodec {
public:
ACMCNG(WebRtc_Word16 codecID);
~ACMCNG();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
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* ptrInst);
void InternalDestructEncoderInst(void* ptrInst);
WebRtc_Word16 EnableDTX()
{
return -1;
}
WebRtc_Word16 EnableDTX() {
return -1;
}
WebRtc_Word16 DisableDTX()
{
return -1;
}
WebRtc_Word16 DisableDTX() {
return -1;
}
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
WebRtcCngEncInst* _encoderInstPtr;
WebRtcCngDecInst* _decoderInstPtr;
WebRtc_Word16 _sampFreqHz;
WebRtcCngEncInst* _encoderInstPtr;
WebRtcCngDecInst* _decoderInstPtr;
WebRtc_Word16 _sampFreqHz;
};
} // 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.
*/
#ifndef WEBRTC_ACM_COMMON_DEFS_H
#define WEBRTC_ACM_COMMON_DEFS_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_COMMON_DEFS_H_
#include <string.h>
@ -18,23 +18,21 @@
#include "engine_configurations.h"
#include "typedefs.h"
// Checks for enabled codecs, we prevent enabling codecs which are not
// compatible.
#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
#ifdef WIN32
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::_stricmp(x,y)
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::_stricmp(x,y)
#else
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::strcasecmp(x,y)
// OS-dependent case-insensitive string comparison
#define STR_CASE_CMP(x,y) ::strcasecmp(x,y)
#endif
namespace webrtc
{
namespace webrtc {
// 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
@ -46,16 +44,16 @@ namespace webrtc
// audio if the sampling frequency is 8000 Hz (80 samples per block).
// Therefore, The size of the buffer where we keep timestamps
// 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
#define MAX_PAYLOAD_SIZE_BYTE 7680
#define MAX_PAYLOAD_SIZE_BYTE 7680
// General codec specific defines
#define ISACWB_DEFAULT_RATE 32000
#define ISACSWB_DEFAULT_RATE 56000
#define ISACWB_PAC_SIZE 480
#define ISACSWB_PAC_SIZE 960
const int kIsacWbDefaultRate = 32000;
const int kIsacSwbDefaultRate = 56000;
const int kIsacPacSize480 = 480;
const int kIsacPacSize960 = 960;
// 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.
// kPassiveDTXSWB : Passive audio frame coded by super-wide-band CN.
//
enum WebRtcACMEncodingType
{
kNoEncoding,
kActiveNormalEncoded,
kPassiveNormalEncoded,
kPassiveDTXNB,
kPassiveDTXWB,
kPassiveDTXSWB
enum WebRtcACMEncodingType {
kNoEncoding,
kActiveNormalEncoded,
kPassiveNormalEncoded,
kPassiveDTXNB,
kPassiveDTXWB,
kPassiveDTXSWB
};
// A structure which contains codec parameters. For instance, used when
@ -85,12 +82,11 @@ enum WebRtcACMEncodingType
// enableVAD : set true to enable VAD.
// vadMode : VAD mode, c.f. audio_coding_module_typedefs.h
// for possible values.
struct WebRtcACMCodecParams
{
CodecInst codecInstant;
bool enableDTX;
bool enableVAD;
ACMVADMode vadMode;
struct WebRtcACMCodecParams {
CodecInst codecInstant;
bool enableDTX;
bool enableVAD;
ACMVADMode vadMode;
};
// A structure that encapsulates audio buffer and related parameters
@ -104,17 +100,16 @@ struct WebRtcACMCodecParams
// lastTimestamp : same as ACMGenericCodec::_lastTimestamp
// lastInTimestamp : same as AudioCodingModuleImpl::_lastInTimestamp
//
struct WebRtcACMAudioBuff
{
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16];
WebRtc_Word16 inAudioIxRead;
WebRtc_Word16 inAudioIxWrite;
WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32];
WebRtc_Word16 inTimestampIxWrite;
WebRtc_UWord32 lastTimestamp;
WebRtc_UWord32 lastInTimestamp;
struct WebRtcACMAudioBuff {
WebRtc_Word16 inAudio[AUDIO_BUFFER_SIZE_W16];
WebRtc_Word16 inAudioIxRead;
WebRtc_Word16 inAudioIxWrite;
WebRtc_UWord32 inTimestamp[TIMESTAMP_BUFFER_SIZE_W32];
WebRtc_Word16 inTimestampIxWrite;
WebRtc_UWord32 lastTimestamp;
WebRtc_UWord32 lastInTimestamp;
};
} // 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.
*/
#include "acm_dtmf_detection.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;
}
ACMDTMFDetection::~ACMDTMFDetection()
{
WebRtc_Word16 ACMDTMFDetection::Disable() {
return -1;
}
WebRtc_Word16
ACMDTMFDetection::Enable(
ACMCountries /* cpt */)
{
return -1;
}
WebRtc_Word16
ACMDTMFDetection::Disable()
{
return -1;
}
WebRtc_Word16
ACMDTMFDetection::Detect(
const WebRtc_Word16* /* inAudioBuff */,
WebRtc_Word16 ACMDTMFDetection::Detect(
const WebRtc_Word16* /* inAudioBuff */,
const WebRtc_UWord16 /* inBuffLenWord16 */,
const WebRtc_Word32 /* inFreqHz */,
bool& /* toneDetected */,
WebRtc_Word16& /* tone */)
{
return -1;
const WebRtc_Word32 /* inFreqHz */,
bool& /* toneDetected */,
WebRtc_Word16& /* tone */) {
return -1;
}
WebRtc_Word16
ACMDTMFDetection::GetVersion(
WebRtc_Word8* /* version */,
WebRtc_Word16 ACMDTMFDetection::GetVersion(
WebRtc_Word8* /* version */,
WebRtc_UWord32& /* remainingBufferInBytes */,
WebRtc_UWord32& /* position */)
{
return -1;
WebRtc_UWord32& /* position */) {
return -1;
}
} // namespace webrtc

View File

@ -8,40 +8,36 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_DTMF_DETECTION_H
#define ACM_DTMF_DETECTION_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_DETECTION_H_
#include "acm_resampler.h"
#include "audio_coding_module_typedefs.h"
#include "typedefs.h"
namespace webrtc
{
namespace webrtc {
class ACMDTMFDetection
{
public:
ACMDTMFDetection();
~ACMDTMFDetection();
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
WebRtc_Word16 Disable();
WebRtc_Word16 Detect(
const WebRtc_Word16* inAudioBuff,
const WebRtc_UWord16 inBuffLenWord16,
const WebRtc_Word32 inFreqHz,
bool& toneDetected,
WebRtc_Word16& tone);
static WebRtc_Word16 GetVersion(
WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position);
class ACMDTMFDetection {
public:
ACMDTMFDetection();
~ACMDTMFDetection();
WebRtc_Word16 Enable(ACMCountries cpt = ACMDisableCountryDetection);
WebRtc_Word16 Disable();
WebRtc_Word16 Detect(const WebRtc_Word16* inAudioBuff,
const WebRtc_UWord16 inBuffLenWord16,
const WebRtc_Word32 inFreqHz,
bool& toneDetected,
WebRtc_Word16& tone);
private:
ACMResampler _resampler;
bool _init;
static WebRtc_Word16 GetVersion(WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position);
private:
ACMResampler _resampler;
bool _init;
};
} // 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.
*/
#include "acm_common_defs.h"
#include "acm_dtmf_playout.h"
#include "acm_common_defs.h"
#include "acm_neteq.h"
#include "trace.h"
#include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h"
namespace webrtc
{
namespace webrtc {
#ifndef WEBRTC_CODEC_AVT
ACMDTMFPlayout::ACMDTMFPlayout(
WebRtc_Word16 /* codecID */)
{
return;
WebRtc_Word16 /* codecID */) {
return;
}
ACMDTMFPlayout::~ACMDTMFPlayout()
{
return;
ACMDTMFPlayout::~ACMDTMFPlayout() {
return;
}
WebRtc_Word16
ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return -1;
}
WebRtc_Word16
ACMDTMFPlayout::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return -1;
}
WebRtc_Word16
ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word16
ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word32
ACMDTMFPlayout::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) {
return -1;
}
ACMGenericCodec*
ACMDTMFPlayout::CreateInstance(void)
{
return NULL;
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
return NULL;
}
WebRtc_Word16
ACMDTMFPlayout::InternalCreateEncoder()
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
return -1;
}
WebRtc_Word16
ACMDTMFPlayout::InternalCreateDecoder()
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
return -1;
}
void
ACMDTMFPlayout::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
return;
}
void
ACMDTMFPlayout::DestructEncoderSafe()
{
return;
void ACMDTMFPlayout::DestructEncoderSafe() {
return;
}
void
ACMDTMFPlayout::DestructDecoderSafe()
{
return;
void ACMDTMFPlayout::DestructDecoderSafe() {
return;
}
WebRtc_Word16
ACMDTMFPlayout::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1;
WebRtc_Word16 ACMDTMFPlayout::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) {
return -1;
}
#else //===================== Actual Implementation =======================
ACMDTMFPlayout::ACMDTMFPlayout(
WebRtc_Word16 codecID)
{
_codecID = codecID;
ACMDTMFPlayout::ACMDTMFPlayout(WebRtc_Word16 codecID) {
_codecID = codecID;
}
ACMDTMFPlayout::~ACMDTMFPlayout()
{
return;
ACMDTMFPlayout::~ACMDTMFPlayout() {
return;
}
WebRtc_Word16
ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return 0;
WebRtc_Word16 ACMDTMFPlayout::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return 0;
}
WebRtc_Word16
ACMDTMFPlayout::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0;
WebRtc_Word16 ACMDTMFPlayout::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return 0;
}
WebRtc_Word16
ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
WebRtc_Word16 ACMDTMFPlayout::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) {
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
}
WebRtc_Word16
ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
WebRtc_Word16 ACMDTMFPlayout::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
// This codec does not need initialization,
// DTMFPlayout has no instance
return 0;
}
WebRtc_Word32
ACMDTMFPlayout::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AVT_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000);
SET_AVT_FUNCTIONS((codecDef));
return 0;
WebRtc_Word32 ACMDTMFPlayout::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) {
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_AVT_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderAVT, codecInst.pltype, NULL, 8000);
SET_AVT_FUNCTIONS((codecDef));
return 0;
}
ACMGenericCodec*
ACMDTMFPlayout::CreateInstance(void)
{
return NULL;
ACMGenericCodec* ACMDTMFPlayout::CreateInstance(void) {
return NULL;
}
WebRtc_Word16
ACMDTMFPlayout::InternalCreateEncoder()
{
// DTMFPlayout has no instance
return 0;
WebRtc_Word16 ACMDTMFPlayout::InternalCreateEncoder() {
// DTMFPlayout has no instance
return 0;
}
WebRtc_Word16
ACMDTMFPlayout::InternalCreateDecoder()
{
// DTMFPlayout has no instance
return 0;
WebRtc_Word16 ACMDTMFPlayout::InternalCreateDecoder() {
// DTMFPlayout has no instance
return 0;
}
void
ACMDTMFPlayout::InternalDestructEncoderInst(
void* /* ptrInst */)
{
// DTMFPlayout has no instance
return;
void ACMDTMFPlayout::InternalDestructEncoderInst(void* /* ptrInst */) {
// DTMFPlayout has no instance
return;
}
void
ACMDTMFPlayout::DestructEncoderSafe()
{
// DTMFPlayout has no instance
return;
void ACMDTMFPlayout::DestructEncoderSafe() {
// DTMFPlayout has no instance
return;
}
void
ACMDTMFPlayout::DestructDecoderSafe()
{
// DTMFPlayout has no instance
return;
void ACMDTMFPlayout::DestructDecoderSafe() {
// DTMFPlayout has no instance
return;
}
WebRtc_Word16
ACMDTMFPlayout::UnregisterFromNetEqSafe(
WebRtc_Word16 ACMDTMFPlayout::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(kDecoderAVT);
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(kDecoderAVT);
}
#endif

View File

@ -8,61 +8,50 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_DTMF_PLAYOUT_H
#define ACM_DTMF_PLAYOUT_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_DTMF_PLAYOUT_H_
#include "acm_generic_codec.h"
namespace webrtc
{
namespace webrtc {
class ACMDTMFPlayout : public ACMGenericCodec
{
public:
ACMDTMFPlayout(WebRtc_Word16 codecID);
~ACMDTMFPlayout();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMDTMFPlayout: public ACMGenericCodec {
public:
ACMDTMFPlayout(WebRtc_Word16 codecID);
~ACMDTMFPlayout();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void DestructEncoderSafe();
void InternalDestructEncoderInst(
void* ptrInst);
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
void InternalDestructEncoderInst(void* ptrInst);
};
} // 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
ACMG722::ACMG722(
WebRtc_Word16 /* codecID */)
{
return;
ACMG722::ACMG722(WebRtc_Word16 /* codecID */) {
return;
}
ACMG722::~ACMG722()
{
return;
ACMG722::~ACMG722() {
return;
}
WebRtc_Word32
ACMG722::Add10MsDataSafe(
const WebRtc_UWord32 /* timestamp */,
const WebRtc_Word16* /* data */,
const WebRtc_UWord16 /* lengthSmpl */,
const WebRtc_UWord8 /* audioChannel */)
{
return -1;
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 /* timestamp */,
const WebRtc_Word16* /* data */,
const WebRtc_UWord16 /* lengthSmpl */,
const WebRtc_UWord8 /* audioChannel */) {
return -1;
}
WebRtc_Word16
ACMG722::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */) {
return -1;
}
WebRtc_Word16
ACMG722::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return -1;
}
WebRtc_Word16
ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMG722::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word16
ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return -1;
}
WebRtc_Word32
ACMG722::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */) {
return -1;
}
ACMGenericCodec*
ACMG722::CreateInstance(void)
{
return NULL;
ACMGenericCodec* ACMG722::CreateInstance(void) {
return NULL;
}
WebRtc_Word16
ACMG722::InternalCreateEncoder()
{
return -1;
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
return -1;
}
void
ACMG722::DestructEncoderSafe()
{
return;
void ACMG722::DestructEncoderSafe() {
return;
}
WebRtc_Word16
ACMG722::InternalCreateDecoder()
{
return -1;
WebRtc_Word16 ACMG722::InternalCreateDecoder() {
return -1;
}
void
ACMG722::DestructDecoderSafe()
{
return;
void ACMG722::DestructDecoderSafe() {
return;
}
void
ACMG722::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return;
void ACMG722::InternalDestructEncoderInst(void* /* ptrInst */) {
return;
}
WebRtc_Word16
ACMG722::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
{
return -1;
WebRtc_Word16 ACMG722::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */) {
return -1;
}
#else //===================== Actual Implementation =======================
// Encoder and decoder memory
struct ACMG722EncStr {
G722EncInst* inst; // instance for left channel in case of stereo
G722EncInst* instRight; // instance for right 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
};
struct ACMG722DecStr {
G722DecInst* inst; // instance for left channel in case of stereo
G722DecInst* instRight; // instance for right 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
};
ACMG722::ACMG722(
WebRtc_Word16 codecID)
{
// Encoder
_ptrEncStr = new ACMG722EncStr;
if(_ptrEncStr != NULL)
{
_ptrEncStr->inst = NULL;
_ptrEncStr->instRight = NULL;
ACMG722::ACMG722(WebRtc_Word16 codecID) {
// Encoder
_ptrEncStr = new ACMG722EncStr;
if (_ptrEncStr != NULL) {
_ptrEncStr->inst = NULL;
_ptrEncStr->instRight = NULL;
}
// Decoder
_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
_ptrDecStr = new ACMG722DecStr;
if(_ptrDecStr != NULL)
{
_ptrDecStr->inst = NULL;
_ptrDecStr->instRight = NULL; // Not used
if (_ptrEncStr->instRight != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->instRight);
_ptrEncStr->instRight = NULL;
}
_codecID = codecID;
return;
}
ACMG722::~ACMG722()
{
if(_ptrEncStr != 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;
delete _ptrEncStr;
_ptrEncStr = NULL;
}
// Decoder
if (_ptrDecStr != NULL) {
if (_ptrDecStr->inst != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
if(_ptrDecStr != NULL)
{
if(_ptrDecStr->inst != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
if(_ptrDecStr->instRight != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
_ptrDecStr->instRight = NULL;
}
delete _ptrDecStr;
_ptrDecStr = NULL;
if (_ptrDecStr->instRight != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->instRight);
_ptrDecStr->instRight = NULL;
}
return;
delete _ptrDecStr;
_ptrDecStr = NULL;
}
return;
}
WebRtc_Word32
ACMG722::Add10MsDataSafe(
const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel)
{
return ACMGenericCodec::Add10MsDataSafe((timestamp>>1), data, lengthSmpl,
audioChannel);
WebRtc_Word32 ACMG722::Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel) {
return ACMGenericCodec::Add10MsDataSafe((timestamp >> 1), data, lengthSmpl,
audioChannel);
}
WebRtc_Word16
ACMG722::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
// If stereo, split input signal in left and right channel before encoding
if(_noChannels == 2) {
WebRtc_Word16 leftChannel[960];
WebRtc_Word16 rightChannel[960];
WebRtc_UWord8 outLeft[480];
WebRtc_UWord8 outRight[480];
WebRtc_Word16 lenInBytes;
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);
WebRtc_Word16 ACMG722::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) {
// If stereo, split input signal in left and right channel before encoding
if (_noChannels == 2) {
WebRtc_Word16 leftChannel[960];
WebRtc_Word16 rightChannel[960];
WebRtc_UWord8 outLeft[480];
WebRtc_UWord8 outRight[480];
WebRtc_Word16 lenInBytes;
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;
// 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 /* 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;
}
// 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);
}
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::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return WebRtcG722_DecoderInit(_decoderInstPtr);
WebRtc_Word16 ACMG722::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) {
return 0;
}
WebRtc_Word32
ACMG722::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// TODO: log error
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;
}
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G722_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype,
_decoderInstPtr, 16000);
SET_G722_FUNCTIONS((codecDef));
return 0;
_encoderInstPtrRight = _ptrEncStr->instRight;
if (WebRtcG722_EncoderInit(_encoderInstPtrRight) < 0) {
return -1;
}
}
return WebRtcG722_EncoderInit(_encoderInstPtr);
}
ACMGenericCodec*
ACMG722::CreateInstance(void)
{
return NULL;
WebRtc_Word16 ACMG722::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */) {
return WebRtcG722_DecoderInit(_decoderInstPtr);
}
WebRtc_Word16
ACMG722::InternalCreateEncoder()
{
if(_ptrEncStr == NULL)
{
// this structure must be created at the costructor
// if it is still NULL then there is a probelm and
// we dont continue
return -1;
}
WebRtcG722_CreateEncoder(&_ptrEncStr->inst);
if(_ptrEncStr->inst == NULL)
{
return -1;
}
_encoderInstPtr = (G722EncInst*)_ptrEncStr->inst;
return 0;
WebRtc_Word32 ACMG722::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) {
if (!_decoderInitialized) {
// TODO: log error
return -1;
}
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G722_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderG722, codecInst.pltype, _decoderInstPtr,
16000);
SET_G722_FUNCTIONS((codecDef));
return 0;
}
void
ACMG722::DestructEncoderSafe()
{
if(_ptrEncStr != NULL)
{
if(_ptrEncStr->inst != NULL)
{
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->inst = NULL;
}
}
_encoderExist = false;
_encoderInitialized = false;
ACMGenericCodec* ACMG722::CreateInstance(void) {
return NULL;
}
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;
}
WebRtcG722_CreateDecoder(&_ptrDecStr->inst);
if(_ptrDecStr->inst == NULL)
{
return -1;
}
_decoderInstPtr = (G722DecInst*)_ptrDecStr->inst;
return 0;
WebRtc_Word16 ACMG722::InternalCreateEncoder() {
if (_ptrEncStr == NULL) {
// this structure must be created at the costructor
// if it is still NULL then there is a probelm and
// we dont continue
return -1;
}
WebRtcG722_CreateEncoder(&_ptrEncStr->inst);
if (_ptrEncStr->inst == NULL) {
return -1;
}
_encoderInstPtr = _ptrEncStr->inst;
return 0;
}
void
ACMG722::DestructDecoderSafe()
{
_decoderExist = false;
_decoderInitialized = false;
if(_ptrDecStr != NULL)
{
if(_ptrDecStr->inst != NULL)
{
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
void ACMG722::DestructEncoderSafe() {
if (_ptrEncStr != NULL) {
if (_ptrEncStr->inst != NULL) {
WebRtcG722_FreeEncoder(_ptrEncStr->inst);
_ptrEncStr->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
ACMG722::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcG722_FreeEncoder((G722EncInst*)ptrInst);
}
return;
WebRtcG722_CreateDecoder(&_ptrDecStr->inst);
if (_ptrDecStr->inst == NULL) {
return -1;
}
_decoderInstPtr = _ptrDecStr->inst;
return 0;
}
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;
void ACMG722::DestructDecoderSafe() {
_decoderExist = false;
_decoderInitialized = false;
if (_ptrDecStr != NULL) {
if (_ptrDecStr->inst != NULL) {
WebRtcG722_FreeDecoder(_ptrDecStr->inst);
_ptrDecStr->inst = NULL;
}
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

View File

@ -8,13 +8,13 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_G722_H
#define ACM_G722_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_H_
#include "acm_generic_codec.h"
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
typedef struct WebRtcG722EncInst G722EncInst;
typedef struct WebRtcG722DecInst G722DecInst;
namespace webrtc {
@ -22,65 +22,55 @@ namespace webrtc {
struct ACMG722EncStr;
struct ACMG722DecStr;
class ACMG722 : public ACMGenericCodec
{
public:
ACMG722(WebRtc_Word16 codecID);
~ACMG722();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMG722: public ACMGenericCodec {
public:
ACMG722(WebRtc_Word16 codecID);
~ACMG722();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 Add10MsDataSafe(
const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel);
WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timestamp,
const WebRtc_Word16* data,
const WebRtc_UWord16 lengthSmpl,
const WebRtc_UWord8 audioChannel);
void DestructEncoderSafe();
void DestructDecoderSafe();
void DestructEncoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
void DestructDecoderSafe();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
WebRtc_Word16 InternalCreateEncoder();
ACMG722EncStr* _ptrEncStr;
ACMG722DecStr* _ptrDecStr;
WebRtc_Word16 InternalCreateDecoder();
G722EncInst* _encoderInstPtr;
G722EncInst* _encoderInstPtrRight; // Prepared for stereo
G722DecInst* _decoderInstPtr;
void InternalDestructEncoderInst(void* ptrInst);
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
ACMG722EncStr* _ptrEncStr;
ACMG722DecStr* _ptrDecStr;
G722EncInst* _encoderInstPtr;
G722EncInst* _encoderInstPtrRight; // Prepared for stereo
G722DecInst* _decoderInstPtr;
};
} // 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.
*/
#ifndef ACM_G722_1_H
#define ACM_G722_1_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1_H_
#include "acm_generic_codec.h"
@ -24,71 +24,62 @@ struct G722_1_Inst_t_;
namespace webrtc {
class ACMG722_1 : public ACMGenericCodec
{
public:
ACMG722_1(WebRtc_Word16 codecID);
~ACMG722_1();
// for FEC
ACMGenericCodec* CreateInstance(void);
class ACMG722_1: public ACMGenericCodec {
public:
ACMG722_1(WebRtc_Word16 codecID);
~ACMG722_1();
// for FEC
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
protected:
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
void DestructEncoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
void DestructDecoderSafe();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word32 _operationalRate;
WebRtc_Word16 InternalCreateDecoder();
G722_1_Inst_t_* _encoderInstPtr;
G722_1_Inst_t_* _encoderInstPtrRight; //Used in stereo mode
G722_1_Inst_t_* _decoderInstPtr;
void InternalDestructEncoderInst(void* ptrInst);
// 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;
WebRtc_Word16 UnregisterFromNetEqSafe(ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
// 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;
WebRtc_Word32 _operationalRate;
G722_1_Inst_t_* _encoderInstPtr;
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
#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.
*/
#ifndef ACM_G722_1C_H
#define ACM_G722_1C_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G722_1C_H_
#include "acm_generic_codec.h"
@ -33,7 +33,7 @@ public:
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
@ -45,23 +45,23 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
@ -91,4 +91,4 @@ protected:
} // 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.
*/
#ifndef ACM_G729_H
#define ACM_G729_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
#include "acm_generic_codec.h"
@ -40,28 +40,28 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word32 ReplaceInternalDTXSafe(
@ -81,5 +81,4 @@ protected:
} // 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(
WebRtc_UWord8* /* bitStream */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
@ -76,7 +76,7 @@ ACMG729_1::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -84,7 +84,7 @@ ACMG729_1::InternalInitEncoder(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -92,51 +92,51 @@ ACMG729_1::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMG729_1::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
}
ACMGenericCodec*
ACMGenericCodec*
ACMG729_1::CreateInstance(void)
{
return NULL;
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalCreateEncoder()
{
return -1;
}
void
void
ACMG729_1::DestructEncoderSafe()
{
return;
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalCreateDecoder()
{
return -1;
}
void
void
ACMG729_1::DestructDecoderSafe()
{
return;
}
void
void
ACMG729_1::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -144,7 +144,7 @@ ACMG729_1::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
@ -152,11 +152,11 @@ ACMG729_1::UnregisterFromNetEqSafe(
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 /*rate*/ )
{
return -1;
return -1;
}
#else //===================== Actual Implementation =======================
@ -173,10 +173,10 @@ _decoderInstPtr(NULL)
// which is DTX.
_hasInternalDTX = false;
// Default rate
// Default rate
_myRate = 32000;
_flag8kHz = 0;
_flag8kHz = 0;
_flagG729mode = 0;
return;
}
@ -197,9 +197,9 @@ ACMG729_1::~ACMG729_1()
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
@ -207,10 +207,10 @@ ACMG729_1::InternalEncode(
WebRtc_Word16 noEncodedSamples = 0;
*bitStreamLenByte = 0;
WebRtc_Word16 byteLengthFrame = 0;
WebRtc_Word16 byteLengthFrame = 0;
// 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);
// Byte length for the frame. +1 is for rate information.
byteLengthFrame = _myRate/(8*50) * n20msFrames + (1 - _flagG729mode);
@ -219,30 +219,30 @@ ACMG729_1::InternalEncode(
do
{
*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
// we have gone forward in reading the audio buffer
_inAudioIxRead += 160;
// increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer
_inAudioIxRead += 160;
// sanity check
// sanity check
if(*bitStreamLenByte < 0)
{
// error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1");
// error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0;
return -1;
}
}
noEncodedSamples += 160;
noEncodedSamples += 160;
} while(*bitStreamLenByte == 0);
// This criteria will change if we have Annex C.
if(*bitStreamLenByte != byteLengthFrame)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0;
return -1;
@ -259,11 +259,11 @@ ACMG729_1::InternalEncode(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
@ -271,43 +271,43 @@ ACMG729_1::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
//set the bit rate and initialize
_myRate = codecParams->codecInstant.rate;
{
//set the bit rate and initialize
_myRate = codecParams->codecInstant.rate;
return SetBitRateSafe( (WebRtc_UWord32)_myRate);
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: init decoder failed for G729_1");
return -1;
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: init decoder failed for G729_1");
return -1;
}
return 0;
}
WebRtc_Word32
WebRtc_Word32
ACMG729_1::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: Decoder uninitialized for G729_1");
return -1;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: Decoder uninitialized for G729_1");
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -318,27 +318,27 @@ ACMG729_1::CodecDef(
}
ACMGenericCodec*
ACMGenericCodec*
ACMG729_1::CreateInstance(void)
{
return NULL;
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalCreateEncoder()
{
if (WebRtcG7291_Create(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: create encoder failed for G729_1");
return -1;
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: create encoder failed for G729_1");
return -1;
}
return 0;
}
void
void
ACMG729_1::DestructEncoderSafe()
{
_encoderExist = false;
@ -351,20 +351,20 @@ ACMG729_1::DestructEncoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::InternalCreateDecoder()
{
{
if (WebRtcG7291_Create(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: create decoder failed for G729_1");
return -1;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: create decoder failed for G729_1");
return -1;
}
return 0;
}
void
void
ACMG729_1::DestructDecoderSafe()
{
_decoderExist = false;
@ -377,10 +377,10 @@ ACMG729_1::DestructDecoderSafe()
}
void
void
ACMG729_1::InternalDestructEncoderInst(
void* ptrInst)
{
{
if(ptrInst != NULL)
{
//WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
@ -389,25 +389,25 @@ ACMG729_1::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
if(payloadType != _decoderParams.codecInstant.pltype)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: given payload-type does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: given payload-type does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderG729_1);
}
WebRtc_Word16
WebRtc_Word16
ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 rate)
{
@ -422,77 +422,76 @@ ACMG729_1::SetBitRateSafe(
_myRate = 8000;
break;
}
case 12000:
case 12000:
{
_myRate = 12000;
break;
}
case 14000:
case 14000:
{
_myRate = 14000;
break;
}
case 16000:
case 16000:
{
_myRate = 16000;
break;
}
case 18000:
case 18000:
{
_myRate = 18000;
break;
}
case 20000:
case 20000:
{
_myRate = 20000;
break;
}
case 22000:
case 22000:
{
_myRate = 22000;
break;
}
case 24000:
case 24000:
{
_myRate = 24000;
break;
}
case 26000:
}
case 26000:
{
_myRate = 26000;
break;
}
case 28000:
case 28000:
{
_myRate = 28000;
break;
}
case 30000:
case 30000:
{
_myRate = 30000;
break;
}
case 32000:
case 32000:
{
_myRate = 32000;
break;
}
default:
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate G729_1");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate G729_1");
return -1;
break;
}
}
// Re-init with new rate
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, _flagG729mode) >= 0)
{
_encoderParams.codecInstant.rate = _myRate;
return 0;
}
else
}
else
{
return -1;
}

View File

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

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_GENERIC_CODEC_H
#define ACM_GENERIC_CODEC_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GENERIC_CODEC_H_
#include "acm_common_defs.h"
#include "audio_coding_module_typedefs.h"
@ -322,7 +322,7 @@ public:
// 0 if the rate is adjusted successfully
//
WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS);
///////////////////////////////////////////////////////////////////////////
// DestructEncoderInst()
@ -411,7 +411,7 @@ public:
const bool enableDTX = true,
const bool enableVAD = false,
const ACMVADMode mode = VADNormal);
///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReplaceInternalDTX()
@ -451,9 +451,9 @@ public:
// -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM.
//
void SetNetEqDecodeLock(
RWLockWrapper* netEqDecodeLock)
{
_netEqDecodeLock = netEqDecodeLock;
RWLockWrapper* netEqDecodeLock)
{
_netEqDecodeLock = netEqDecodeLock;
}
@ -465,7 +465,7 @@ public:
// true if the codec has an internal DTX, e.g. G729,
// false otherwise.
//
bool HasInternalDTX() const
bool HasInternalDTX() const
{
return _hasInternalDTX;
}
@ -481,7 +481,7 @@ public:
// >0 estimated bandwidth in bits/sec.
//
WebRtc_Word32 GetEstimatedBandwidth();
///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetEstimatedBandwidth()
@ -514,7 +514,7 @@ public:
WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes);
///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 ResetEncoder()
// By calling this function you would re-initialize the encoder with the
@ -540,7 +540,7 @@ public:
WebRtc_Word16 ResetDecoder(
WebRtc_Word16 payloadType);
///////////////////////////////////////////////////////////////////////////
// void DestructEncoder()
// This function is called to delete the encoder instance, if possible, to
@ -581,7 +581,7 @@ public:
//
WebRtc_UWord32 LastEncodedTimestamp() const;
///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 UnregisterFromNetEq()
// To remove the codec from NetEQ. If the codec (or the decoder instance)
@ -654,7 +654,7 @@ public:
return 0;
}
///////////////////////////////////////////////////////////////////////////
// UpdateEncoderSampFreq()
// Call this function to update the encoder sampling frequency. This
@ -757,7 +757,7 @@ public:
//
virtual WebRtc_Word32 SetISACMaxRate(
const WebRtc_UWord32 maxRateBitPerSec);
///////////////////////////////////////////////////////////////////////////
// SaveDecoderParamS()
@ -779,7 +779,7 @@ public:
void SetIsMaster(bool isMaster);
///////////////////////////////////////////////////////////////////////////
// REDPayloadISAC()
@ -810,7 +810,7 @@ public:
const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenBytes);
protected:
///////////////////////////////////////////////////////////////////////////
// All the functions with FunctionNameSafe(...) contain the actual
@ -840,7 +840,7 @@ protected:
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType) = 0;
///////////////////////////////////////////////////////////////////////////
// See Add10MsSafe() for the description of function, input(s)/output(s)
// and return value.
@ -850,22 +850,22 @@ protected:
const WebRtc_Word16* data,
const WebRtc_UWord16 length,
const WebRtc_UWord8 audioChannel);
///////////////////////////////////////////////////////////////////////////
// See RegisterInNetEq() for the description of function,
// input(s)/output(s) and return value.
//
virtual WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) = 0;
///////////////////////////////////////////////////////////////////////////
// See EncoderParam() for the description of function, input(s)/output(s)
// and return value.
//
WebRtc_Word16 EncoderParamsSafe(
WebRtcACMCodecParams *encParams);
///////////////////////////////////////////////////////////////////////////
// See DecoderParam for the description of function, input(s)/output(s)
// and return value.
@ -883,13 +883,13 @@ protected:
virtual bool DecoderParamsSafe(
WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType);
///////////////////////////////////////////////////////////////////////////
// See ResetEncoder() for the description of function, input(s)/output(s)
// and return value.
//
WebRtc_Word16 ResetEncoderSafe();
///////////////////////////////////////////////////////////////////////////
// See InitEncoder() for the description of function, input(s)/output(s)
// and return value.
@ -905,14 +905,14 @@ protected:
WebRtc_Word16 InitDecoderSafe(
WebRtcACMCodecParams *codecParams,
bool forceInitialization);
///////////////////////////////////////////////////////////////////////////
// See ResetDecoder() for the description of function, input(s)/output(s)
// and return value.
//
WebRtc_Word16 ResetDecoderSafe(
WebRtc_Word16 payloadType);
///////////////////////////////////////////////////////////////////////////
// See DestructEncoder() for the description of function,
// input(s)/output(s) and return value.
@ -924,7 +924,7 @@ protected:
// input(s)/output(s) and return value.
//
virtual void DestructDecoderSafe() = 0;
///////////////////////////////////////////////////////////////////////////
// See SetBitRate() for the description of function, input(s)/output(s)
// and return value.
@ -933,19 +933,19 @@ protected:
//
virtual WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 bitRateBPS);
///////////////////////////////////////////////////////////////////////////
// See GetEstimatedBandwidth() for the description of function, input(s)/output(s)
// and return value.
//
virtual WebRtc_Word32 GetEstimatedBandwidthSafe();
///////////////////////////////////////////////////////////////////////////
// See SetEstimatedBandwidth() for the description of function, input(s)/output(s)
// and return value.
//
virtual WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
///////////////////////////////////////////////////////////////////////////
// See GetRedPayload() for the description of function, input(s)/output(s)
// and return value.
@ -1145,7 +1145,7 @@ protected:
//
virtual WebRtc_Word16 InternalCreateEncoder() = 0;
///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalCreateDecoder()
// This is a codec-specific method called in CreateDecoderSafe() it is
@ -1175,7 +1175,7 @@ protected:
// 0 if succeeded.
//
virtual void InternalDestructEncoderInst(
void* ptrInst) = 0;
void* ptrInst) = 0;
///////////////////////////////////////////////////////////////////////////
@ -1230,7 +1230,7 @@ protected:
WebRtc_Word16* bitStreamLenByte,
WebRtc_Word16* samplesProcessed);
///////////////////////////////////////////////////////////////////////////
// CanChangeEncodingParam()
// Check if the codec parameters can be changed. In conferencing normally
@ -1242,7 +1242,7 @@ protected:
//
virtual bool CanChangeEncodingParam(CodecInst& codecInst);
///////////////////////////////////////////////////////////////////////////
// CurrentRate()
// Call to get the current encoding rate of the encoder. This function
@ -1256,24 +1256,23 @@ protected:
virtual void CurrentRate(
WebRtc_Word32& /* rateBitPerSec */)
{
return;
}
virtual void SaveDecoderParamSafe(
const WebRtcACMCodecParams* codecParams);
// &_inAudio[_inAudioIxWrite] always point to where new audio can be
// written to
// &_inAudio[_inAudioIxWrite] always point to where new audio can be
// written to
WebRtc_Word16 _inAudioIxWrite;
// &_inAudio[_inAudioIxRead] points to where audio has to be read from
WebRtc_Word16 _inAudioIxRead;
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
// dynamically for 80ms depending on the sampling frequency
// of the codec.
@ -1285,12 +1284,12 @@ protected:
// This will point to a static database of the supported codecs
WebRtc_Word16 _codecID;
// This will account for the No of samples were not encoded
// the case is rare, either samples are missed due to overwite
// at input buffer or due to encoding error
WebRtc_UWord32 _noMissedSamples;
// True if the encoder instance created
bool _encoderExist;
bool _decoderExist;
@ -1330,4 +1329,4 @@ protected:
} // 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(
WebRtc_UWord8* /* bitStream */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::EnableDTX()
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::DisableDTX()
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -98,7 +98,7 @@ ACMGSMFR::InternalInitEncoder(
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -106,51 +106,51 @@ ACMGSMFR::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMGSMFR::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
}
ACMGenericCodec*
ACMGenericCodec*
ACMGSMFR::CreateInstance(void)
{
return NULL;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalCreateEncoder()
{
return -1;
}
void
void
ACMGSMFR::DestructEncoderSafe()
{
return;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalCreateDecoder()
{
return -1;
}
void
void
ACMGSMFR::DestructDecoderSafe()
{
return;
}
void
void
ACMGSMFR::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -158,7 +158,7 @@ ACMGSMFR::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
@ -196,33 +196,33 @@ ACMGSMFR::~ACMGSMFR()
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
&_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
_inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
return 0;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::EnableDTX()
{
if(_dtxEnabled)
@ -233,8 +233,8 @@ ACMGSMFR::EnableDTX()
{
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableDTX: cannot init encoder for GSMFR");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableDTX: cannot init encoder for GSMFR");
return -1;
}
_dtxEnabled = true;
@ -247,7 +247,7 @@ ACMGSMFR::EnableDTX()
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::DisableDTX()
{
if(!_dtxEnabled)
@ -258,8 +258,8 @@ ACMGSMFR::DisableDTX()
{
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"DisableDTX: cannot init encoder for GSMFR");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"DisableDTX: cannot init encoder for GSMFR");
return -1;
}
_dtxEnabled = false;
@ -273,45 +273,45 @@ ACMGSMFR::DisableDTX()
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: cannot init encoder for GSMFR");
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: cannot init encoder for GSMFR");
}
return 0;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: cannot init decoder for GSMFR");
return -1;
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: cannot init decoder for GSMFR");
return -1;
}
return 0;
}
WebRtc_Word32
WebRtc_Word32
ACMGSMFR::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodecDef: decoder is not initialized for GSMFR");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodecDef: decoder is not initialized for GSMFR");
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -322,27 +322,27 @@ ACMGSMFR::CodecDef(
}
ACMGenericCodec*
ACMGenericCodec*
ACMGSMFR::CreateInstance(void)
{
return NULL;
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalCreateEncoder()
{
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
return -1;
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
return -1;
}
return 0;
}
void
void
ACMGSMFR::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
@ -355,20 +355,20 @@ ACMGSMFR::DestructEncoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::InternalCreateDecoder()
{
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
return -1;
}
return 0;
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
return -1;
}
return 0;
}
void
void
ACMGSMFR::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
@ -381,7 +381,7 @@ ACMGSMFR::DestructDecoderSafe()
}
void
void
ACMGSMFR::InternalDestructEncoderInst(
void* ptrInst)
{
@ -393,18 +393,18 @@ ACMGSMFR::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMGSMFR::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
if(payloadType != _decoderParams.codecInstant.pltype)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: payload-type does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot unregister codec: payload-type does not match \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_GSMFR_H
#define ACM_GSMFR_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
#include "acm_generic_codec.h"
@ -28,7 +28,7 @@ public:
ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
@ -39,29 +39,29 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
WebRtc_Word16 UnregisterFromNetEqSafe(
@ -74,5 +74,4 @@ protected:
} // 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
ACMILBC::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
@ -97,7 +97,7 @@ ACMILBC::InternalCreateEncoder()
}
void
void
ACMILBC::DestructEncoderSafe()
{
return;
@ -111,14 +111,14 @@ ACMILBC::InternalCreateDecoder()
}
void
void
ACMILBC::DestructDecoderSafe()
{
return;
}
void
void
ACMILBC::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -175,15 +175,15 @@ ACMILBC::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
if (*bitStreamLenByte < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: error in encode for ILBC");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: error in encode for ILBC");
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
_inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte;
@ -207,7 +207,7 @@ ACMILBC::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// initialize with a correct processing block length
if((160 == (codecParams->codecInstant).pacsize) ||
if((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize))
{
// processing block of 20ms
@ -221,8 +221,8 @@ ACMILBC::InternalInitEncoder(
}
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: invalid processing block");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: invalid processing block");
return -1;
}
}
@ -233,13 +233,13 @@ ACMILBC::InternalInitDecoder(
WebRtcACMCodecParams* codecParams)
{
// initialize with a correct processing block length
if((160 == (codecParams->codecInstant).pacsize) ||
if((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize))
{
// processing block of 20ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
}
else if((240 == (codecParams->codecInstant).pacsize) ||
else if((240 == (codecParams->codecInstant).pacsize) ||
(480 == (codecParams->codecInstant).pacsize))
{
// processing block of 30ms
@ -247,8 +247,8 @@ ACMILBC::InternalInitDecoder(
}
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: invalid processing block");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: invalid processing block");
return -1;
}
}
@ -261,15 +261,15 @@ ACMILBC::CodecDef(
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: decoder not initialized for ILBC");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: decoder not initialized for ILBC");
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's
// database.
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype,
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype,
_decoderInstPtr, 8000);
SET_ILBC_FUNCTIONS((codecDef));
return 0;
@ -288,15 +288,15 @@ ACMILBC::InternalCreateEncoder()
{
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for ILBC encoder");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for ILBC encoder");
return -1;
}
return 0;
}
void
void
ACMILBC::DestructEncoderSafe()
{
_encoderInitialized = false;
@ -314,15 +314,15 @@ ACMILBC::InternalCreateDecoder()
{
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for ILBC decoder");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for ILBC decoder");
return -1;
}
return 0;
}
void
void
ACMILBC::DestructDecoderSafe()
{
_decoderInitialized = false;
@ -335,7 +335,7 @@ ACMILBC::DestructDecoderSafe()
}
void
void
ACMILBC::InternalDestructEncoderInst(
void* ptrInst)
{
@ -350,10 +350,10 @@ WebRtc_Word16
ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate)
{
// Check that rate is valid. No need to store the value
if (rate == 13300)
if (rate == 13300)
{
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
}
}
else if (rate == 15200)
{
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
@ -374,11 +374,11 @@ ACMILBC::UnregisterFromNetEqSafe(
{
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}

View File

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

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_ISAC_H
#define ACM_ISAC_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
#include "acm_generic_codec.h"
@ -32,7 +32,7 @@ public:
WebRtc_Word16 InternalEncode(
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams);
@ -52,7 +52,7 @@ public:
WebRtc_Word16* /* bitStreamLenByte */,
WebRtc_UWord32* /* timestamp */,
WebRtcACMEncodingType* /* encodingType */)
{
{
return -1;
}
@ -91,13 +91,13 @@ protected:
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 bitRate);
@ -110,9 +110,9 @@ protected:
WebRtc_Word16* payloadBytes);
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
@ -130,7 +130,7 @@ protected:
void CurrentRate(WebRtc_Word32& rateBitPerSec);
void UpdateFrameLen();
bool DecoderParamsSafe(
WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType);
@ -150,4 +150,4 @@ protected:
} //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.
*/
#ifndef ACM_ISAC_MACROS_H
#define ACM_ISAC_MACROS_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
#include "engine_configurations.h"
@ -72,5 +72,5 @@ namespace webrtc
} //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
if(EnableVADByIdxSafe(idx) < 0)
{
// Failed to enable VAD.
// Failed to enable VAD.
// Delete VAD instance, if it is created
if(_ptrVADInst[idx] != NULL)
{
@ -164,7 +164,7 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = malloc(memorySizeBytes);
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");
_isInitialized[idx] = false;
return -1;
@ -176,8 +176,8 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = NULL;
}
LogError("Assign", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not Assign");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not Assign");
_isInitialized[idx] = false;
return -1;
}
@ -188,8 +188,8 @@ ACMNetEQ::InitByIdxSafe(
_instMem[idx] = NULL;
}
LogError("Init", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not initialize NetEq");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"InitByIdxSafe: NetEq Initialization error: could not initialize NetEq");
_isInitialized[idx] = false;
return -1;
}
@ -206,28 +206,28 @@ ACMNetEQ::EnableVADByIdxSafe(
if(WebRtcVad_Create(&_ptrVADInst[idx]) < 0)
{
_ptrVADInst[idx] = NULL;
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not create VAD");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not create VAD");
return -1;
}
}
if(WebRtcNetEQ_SetVADInstance(_inst[idx], _ptrVADInst[idx],
(WebRtcNetEQ_VADInitFunction) WebRtcVad_Init,
(WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode,
(WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0)
{
LogError("setVADinstance", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD instance");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD instance");
return -1;
}
if(WebRtcNetEQ_SetVADMode(_inst[idx], _vadMode) < 0)
{
LogError("setVADmode", idx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD mode");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"EnableVADByIdxSafe: NetEq Initialization error: could not set VAD mode");
return -1;
}
return 0;
@ -238,18 +238,18 @@ ACMNetEQ::EnableVADByIdxSafe(
WebRtc_Word32
ACMNetEQ::AllocatePacketBuffer(
WebRtcNetEQDecoder* usedCodecs,
WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs)
{
// Due to WebRtcNetEQ_GetRecommendedBufferSize
// the following has to be int otherwise we will have compiler error
// if not casted
// if not casted
CriticalSectionScoped lock(*_netEqCritSect);
for(WebRtc_Word16 idx = 0; idx < _numSlaves + 1; idx++)
{
if(AllocatePacketBufferByIdxSafe(usedCodecs, noOfCodecs, idx) < 0)
{
{
return -1;
}
}
@ -258,7 +258,7 @@ ACMNetEQ::AllocatePacketBuffer(
WebRtc_Word16
ACMNetEQ::AllocatePacketBufferByIdxSafe(
WebRtcNetEQDecoder* usedCodecs,
WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs,
const WebRtc_Word16 idx)
{
@ -267,11 +267,11 @@ ACMNetEQ::AllocatePacketBufferByIdxSafe(
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AllocatePacketBufferByIdxSafe: NetEq is not initialized.");
return -1;
}
if (WebRtcNetEQ_GetRecommendedBufferSize(_inst[idx], usedCodecs, noOfCodecs,
if (WebRtcNetEQ_GetRecommendedBufferSize(_inst[idx], usedCodecs, noOfCodecs,
kTCPLargeJitter , &maxNoPackets, &bufferSizeInBytes)
!= 0)
{
@ -286,8 +286,8 @@ ACMNetEQ::AllocatePacketBufferByIdxSafe(
_netEqPacketBuffer[idx] = (WebRtc_Word16 *)malloc(bufferSizeInBytes);
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 "
"memory for NetEq Packet Buffer");
return -1;
@ -319,7 +319,7 @@ ACMNetEQ::SetExtraDelay(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetExtraDelay: NetEq is not initialized.");
return -1;
}
@ -329,7 +329,7 @@ ACMNetEQ::SetExtraDelay(
return -1;
}
}
return 0;
return 0;
}
@ -344,7 +344,7 @@ ACMNetEQ::SetAVTPlayout(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetAVTPlayout: NetEq is not initialized.");
return -1;
}
@ -373,7 +373,7 @@ ACMNetEQ::CurrentSampFreqHz() const
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"CurrentSampFreqHz: NetEq is not initialized.");
return -1;
}
@ -392,7 +392,7 @@ ACMNetEQ::SetPlayoutMode(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq is not initialized.");
return -1;
}
@ -410,10 +410,9 @@ ACMNetEQ::SetPlayoutMode(
playoutMode = kPlayoutStreaming;
break;
default:
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq Error playout mode not recognized");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetPlayoutMode: NetEq Error playout mode not recognized");
return -1;
break;
}
if(WebRtcNetEQ_SetPlayoutMode(_inst[idx], playoutMode) < 0)
{
@ -443,7 +442,7 @@ ACMNetEQ::NetworkStatistics(
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"NetworkStatistics: NetEq is not initialized.");
return -1;
}
@ -474,7 +473,7 @@ ACMNetEQ::JitterStatistics(
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"JitterStatistics: NetEq is not initialized.");
return -1;
}
@ -555,7 +554,7 @@ ACMNetEQ::RecIn(
netEqRTPInfo.markerBit = rtpInfo.header.markerBit;
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.
// we masked 6 most significant bits of 32-bit so we don't loose resolution
// when do the following multiplication.
@ -565,23 +564,23 @@ ACMNetEQ::RecIn(
(_currentSampFreqKHz * nowInMs);
int status;
if(rtpInfo.type.Audio.channel == 1)
{
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq is not initialized.");
return -1;
}
// PUSH into Master
status = WebRtcNetEQ_RecInRTPStruct(_inst[0], &netEqRTPInfo,
status = WebRtcNetEQ_RecInRTPStruct(_inst[0], &netEqRTPInfo,
(WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength,
recvTimestamp);
if(status < 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");
return -1;
}
@ -590,27 +589,27 @@ ACMNetEQ::RecIn(
{
if(!_isInitialized[1])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq is not initialized.");
return -1;
}
// PUSH into Slave
status = WebRtcNetEQ_RecInRTPStruct(_inst[1], &netEqRTPInfo,
status = WebRtcNetEQ_RecInRTPStruct(_inst[1], &netEqRTPInfo,
(WebRtc_UWord8 *)incomingPayload, (WebRtc_Word16)payloadLength,
recvTimestamp);
if(status < 0)
{
LogError("RecInRTPStruct", 1);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecIn: NetEq, error in pushing in Slave");
return -1;
}
}
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"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);
return -1;
}
@ -635,13 +634,13 @@ ACMNetEQ::RecOut(
{
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq is not initialized.");
return -1;
}
{
WriteLockScoped lockCodec(*_decodeLock);
if(WebRtcNetEQ_RecOut(_inst[0], &(audioFrame._payloadData[0]),
if(WebRtcNetEQ_RecOut(_inst[0], &(audioFrame._payloadData[0]),
&payloadLenSample) != 0)
{
LogError("RecOut", 0);
@ -665,7 +664,7 @@ ACMNetEQ::RecOut(
{
if(!_isInitialized[0] || !_isInitialized[1])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RecOut: NetEq is not initialized.");
return -1;
}
@ -673,11 +672,11 @@ ACMNetEQ::RecOut(
WebRtc_Word16 payloadSlave[480];
{
WriteLockScoped lockCodec(*_decodeLock);
if(WebRtcNetEQ_RecOutMasterSlave(_inst[0], payloadMaster,
if(WebRtcNetEQ_RecOutMasterSlave(_inst[0], payloadMaster,
&payloadLenSample, _masterSlaveInfo, 1) != 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");
// Check for errors that can be recovered from:
@ -689,11 +688,11 @@ ACMNetEQ::RecOut(
return -1;
}
}
if(WebRtcNetEQ_RecOutMasterSlave(_inst[1], payloadSlave,
if(WebRtcNetEQ_RecOutMasterSlave(_inst[1], payloadSlave,
&payloadLenSampleSlave, _masterSlaveInfo, 0) != 0)
{
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");
// Check for errors that can be recovered from:
@ -708,15 +707,15 @@ ACMNetEQ::RecOut(
}
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 \
audio by Master (%d samples) and Slave (%d samples).",
audio by Master (%d samples) and Slave (%d samples).",
payloadLenSample, payloadLenSampleSlave);
if(payloadLenSample > payloadLenSampleSlave)
{
memset(&payloadSlave[payloadLenSampleSlave], 0,
memset(&payloadSlave[payloadLenSampleSlave], 0,
(payloadLenSample - payloadLenSampleSlave) * sizeof(WebRtc_Word16));
}
}
}
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[1], &typeSlave);
if((typeMaster == kOutputNormal) ||
if((typeMaster == kOutputNormal) ||
(typeSlave == kOutputNormal))
{
type = kOutputNormal;
}
else
else
{
type = typeMaster;
}
@ -741,7 +740,7 @@ audio by Master (%d samples) and Slave (%d samples).",
audioFrame._payloadDataLengthInSamples = static_cast<WebRtc_UWord16>(payloadLenSample);
// 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;
if(_vadStatus)
{
@ -796,7 +795,7 @@ audio by Master (%d samples) and Slave (%d samples).",
{
// type is kOutputVADPassive which
// 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.");
audioFrame._vadActivity = AudioFrame::kVadUnknown;
audioFrame._speechType = AudioFrame::kNormalSpeech;
@ -816,7 +815,7 @@ ACMNetEQ::AddCodec(
{
if (codecDef == NULL)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"ACMNetEQ::AddCodec: error, codecDef is NULL");
return -1;
}
@ -834,14 +833,14 @@ ACMNetEQ::AddCodec(
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"ACMNetEQ::AddCodec: NetEq is not initialized.");
return -1;
}
if(WebRtcNetEQ_CodecDbAdd(_inst[idx], codecDef) < 0)
{
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");
return -1;
}
@ -863,50 +862,50 @@ ACMNetEQ::RTPPack(
WebRtc_Word32 idx = 0;
WEBRTC_SPL_SET_BYTE(rtpPacket, (WebRtc_Word8)0x80, idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, rtpInfo.header.payloadType, idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.sequenceNumber), 1), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.sequenceNumber), 0), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 3), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 2), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 1), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.timestamp), 0), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 3), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 2), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 1), idx);
idx++;
WEBRTC_SPL_SET_BYTE(rtpPacket, WEBRTC_SPL_GET_BYTE(
&(rtpInfo.header.ssrc), 0), idx);
idx++;
for (WebRtc_Word16 i=0; i < payloadLengthW8; i++)
{
WEBRTC_SPL_SET_BYTE(rtpPacket, payload[i], idx);
@ -921,7 +920,7 @@ ACMNetEQ::RTPPack(
}
bool
bool
ACMNetEQ::VADStatus() const
{
CriticalSectionScoped lock(*_netEqCritSect);
@ -938,16 +937,16 @@ ACMNetEQ::SetVADStatus(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetVADStatus: NetEq is not initialized.");
return -1;
}
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
// post-decode VAD
if(WebRtcNetEQ_SetVADInstance(_inst[idx], NULL,
if(WebRtcNetEQ_SetVADInstance(_inst[idx], NULL,
(WebRtcNetEQ_VADInitFunction) WebRtcVad_Init,
(WebRtcNetEQ_VADSetmodeFunction) WebRtcVad_set_mode,
(WebRtcNetEQ_VADFunction) WebRtcVad_Process) < 0)
@ -972,7 +971,7 @@ ACMNetEQ::SetVADStatus(
{
return -1;
}
// Set previous VAD status to PASSIVE
_previousAudioActivity = AudioFrame::kVadPassive;
}
@ -997,7 +996,7 @@ ACMNetEQ::SetVADMode(
CriticalSectionScoped lock(*_netEqCritSect);
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");
return -1;
}
@ -1007,7 +1006,7 @@ ACMNetEQ::SetVADMode(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetVADMode: NetEq is not initialized.");
return -1;
}
@ -1031,7 +1030,7 @@ ACMNetEQ::FlushBuffers()
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"FlushBuffers: NetEq is not initialized.");
return -1;
}
@ -1081,22 +1080,22 @@ ACMNetEQ::RemoveCodec(
WebRtcNetEQDecoder codecIdx,
bool isStereo)
{
// sanity check
// sanity check
if((codecIdx <= kDecoderReservedStart) ||
(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");
return -1;
}
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"RemoveCodec: NetEq is not initialized.");
return -1;
}
if(WebRtcNetEQ_CodecDbRemove(_inst[0], codecIdx) < 0)
{
LogError("CodecDB_Remove", 0);
@ -1122,7 +1121,7 @@ ACMNetEQ::Delay(
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Delay: NetEq is not initialized.");
return -1;
}
@ -1147,7 +1146,7 @@ ACMNetEQ::SetBackgroundNoiseMode(
{
if(!_isInitialized[idx])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"SetBackgroundNoiseMode: NetEq is not initialized.");
return -1;
}
@ -1168,7 +1167,7 @@ ACMNetEQ::BackgroundNoiseMode(
CriticalSectionScoped lock(*_netEqCritSect);
if(!_isInitialized[0])
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"BackgroundNoiseMode: NetEq is not initialized.");
return -1;
}
@ -1193,7 +1192,7 @@ ACMNetEQ::SetUniqueId(
}
void
void
ACMNetEQ::LogError(
const WebRtc_Word8* neteqFuncName,
const WebRtc_Word16 idx) const
@ -1205,8 +1204,8 @@ ACMNetEQ::LogError(
strncpy(myFuncName, neteqFuncName, 49);
errorName[NETEQ_ERR_MSG_LEN_BYTE - 1] = '\0';
myFuncName[49] = '\0';
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"NetEq-%d Error in function %s, error-code: %d, error-string: %s",
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"NetEq-%d Error in function %s, error-code: %d, error-string: %s",
idx,
myFuncName,
neteqErrorCode,
@ -1242,19 +1241,19 @@ ACMNetEQ::AddSlave(
// initialize the receiver, this also sets up VAD.
if(InitByIdxSafe(slaveIdx) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not Initialize");
return -1;
}
// Allocate buffer.
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");
return -1;
}
if(_masterSlaveInfo != NULL)
{
free(_masterSlaveInfo);
@ -1262,15 +1261,15 @@ ACMNetEQ::AddSlave(
}
int msInfoSize = WebRtcNetEQ_GetMasterSlaveInfoSize();
_masterSlaveInfo = malloc(msInfoSize);
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");
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.
_numSlaves = 1;
_isInitialized[slaveIdx] = true;
@ -1280,14 +1279,14 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_GetCurrentDelay(_inst[0], &currentDelayMs) < 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.");
return -1;
}
if(WebRtcNetEQ_SetExtraDelay(_inst[slaveIdx], currentDelayMs) < 0)
{
LogError("SetExtraDelay", slaveIdx);
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: AddSlave Failed, Could not set delay");
return -1;
}
@ -1296,7 +1295,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_SetAVTPlayout(_inst[slaveIdx], (_avtPlayout) ? 1 : 0) < 0)
{
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.");
return -1;
}
@ -1306,7 +1305,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_GetBGNMode(_inst[0], &currentMode) < 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.");
return -1;
}
@ -1314,7 +1313,7 @@ ACMNetEQ::AddSlave(
if(WebRtcNetEQ_SetBGNMode(_inst[slaveIdx], (WebRtcNetEQBGNMode)currentMode) < 0)
{
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.");
return -1;
}
@ -1332,15 +1331,14 @@ ACMNetEQ::AddSlave(
playoutMode = kPlayoutStreaming;
break;
default:
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: NetEq Error, playout mode not recognized");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"AddSlave: NetEq Error, playout mode not recognized");
return -1;
break;
}
if(WebRtcNetEQ_SetPlayoutMode(_inst[slaveIdx], playoutMode) < 0)
{
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.");
return -1;
}
@ -1365,4 +1363,3 @@ ACMNetEQ::NumSlaves()
}
} // namespace webrtc

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_NETEQ_H
#define ACM_NETEQ_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
#include "audio_coding_module.h"
#include "audio_coding_module_typedefs.h"
@ -69,7 +69,7 @@ public:
// if out of memory.
//
WebRtc_Word32 Init();
//
// RecIn()
// Gives the payload to NetEQ.
@ -132,7 +132,7 @@ public:
// <0 if NetEQ returned an error.
//
WebRtc_Word32 AllocatePacketBuffer(
WebRtcNetEQDecoder* usedCodecs,
WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs);
//
@ -298,9 +298,9 @@ public:
//
// Return value : Pointer to the decode lock.
//
RWLockWrapper* DecodeLock() const
{
return _decodeLock;
RWLockWrapper* DecodeLock() const
{
return _decodeLock;
}
//
@ -372,13 +372,13 @@ public:
void SetReceivedStereo(
bool receivedStereo);
WebRtc_UWord8 NumSlaves();
enum JB {masterJB = 0, slaveJB = 1};
WebRtc_Word16 AddSlave(
WebRtcNetEQDecoder* usedCodecs,
WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs);
private:
@ -426,7 +426,7 @@ private:
bool _avtPlayout;
AudioPlayoutMode _playoutMode;
CriticalSectionWrapper* _netEqCritSect;
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1];
bool _vadStatus;
@ -443,4 +443,4 @@ private:
} //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(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
@ -48,11 +48,11 @@ ACMOPUS::InternalEncode(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
@ -60,7 +60,7 @@ ACMOPUS::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -68,7 +68,7 @@ ACMOPUS::InternalInitEncoder(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -76,9 +76,9 @@ ACMOPUS::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMOPUS::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
@ -92,35 +92,35 @@ ACMOPUS::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalCreateEncoder()
{
return -1;
}
void
void
ACMOPUS::DestructEncoderSafe()
{
return;
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalCreateDecoder()
{
return -1;
}
void
void
ACMOPUS::DestructDecoderSafe()
{
return;
}
void
void
ACMOPUS::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -128,7 +128,7 @@ ACMOPUS::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
@ -136,7 +136,7 @@ ACMOPUS::UnregisterFromNetEqSafe(
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::SetBitRateSafe(
const WebRtc_Word32 /*rate*/ )
{
@ -172,14 +172,14 @@ _opusMode(1), // default mode is the hybrid mode
_flagVBR(0) // default VBR off
{
_codecID = codecID;
// Current implementation doesn't have DTX. That might change.
_hasInternalDTX = false;
// Default sampling frequency
_mySampFreq = 48000;
// default rate
// default rate
_myRate = 50000;
return;
@ -201,7 +201,7 @@ ACMOPUS::~ACMOPUS()
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
@ -212,14 +212,14 @@ ACMOPUS::InternalEncode(
WebRtc_Word16 byteLengthFrame = 0;
// Derive what byte-length is requested
// Derive what byte-length is requested
byteLengthFrame = _myRate*_frameLenSmpl/(8*_mySampFreq);
// Call Encoder
*bitStreamLenByte = WebRtcOpus_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
(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
_inAudioIxRead += _frameLenSmpl;
@ -227,8 +227,8 @@ ACMOPUS::InternalEncode(
if(*bitStreamLenByte < 0)
{
// error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for Opus");
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for Opus");
*bitStreamLenByte = 0;
return -1;
}
@ -238,11 +238,11 @@ ACMOPUS::InternalEncode(
WebRtc_Word16
WebRtc_Word16
ACMOPUS::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
{
@ -250,7 +250,7 @@ ACMOPUS::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
@ -260,7 +260,7 @@ ACMOPUS::InternalInitEncoder(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -274,7 +274,7 @@ ACMOPUS::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMOPUS::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
@ -286,7 +286,7 @@ ACMOPUS::CodecDef(
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -304,7 +304,7 @@ ACMOPUS::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalCreateEncoder()
{
if (WebRtcOpus_CreateEnc(&_encoderInstPtr, _mySampFreq) < 0)
@ -317,7 +317,7 @@ ACMOPUS::InternalCreateEncoder()
}
void
void
ACMOPUS::DestructEncoderSafe()
{
_encoderExist = false;
@ -330,12 +330,12 @@ ACMOPUS::DestructEncoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::InternalCreateDecoder()
{
{
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");
return -1;
}
@ -343,7 +343,7 @@ ACMOPUS::InternalCreateDecoder()
}
void
void
ACMOPUS::DestructDecoderSafe()
{
_decoderExist = false;
@ -356,10 +356,10 @@ ACMOPUS::DestructDecoderSafe()
}
void
void
ACMOPUS::InternalDestructEncoderInst(
void* ptrInst)
{
{
if(ptrInst != NULL)
{
WebRtcOpus_FreeEnc((OPUS_inst_t*)ptrInst);
@ -368,25 +368,25 @@ ACMOPUS::InternalDestructEncoderInst(
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderOpus);
}
WebRtc_Word16
WebRtc_Word16
ACMOPUS::SetBitRateSafe(
const WebRtc_Word32 rate)
{
@ -459,17 +459,16 @@ ACMOPUS::SetBitRateSafe(
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate Opus");
return -1;
break;
}
}
// Re-init with new rate
if (WebRtcOpus_EncoderInit(_encoderInstPtr, _mySampFreq, _opusMode, _flagVBR) >= 0)
{
_encoderParams.codecInstant.rate = _myRate;
return 0;
}
else
}
else
{
return -1;
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_OPUS_H
#define ACM_OPUS_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_OPUS_H_
#include "acm_generic_codec.h"
@ -41,23 +41,23 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
@ -80,5 +80,4 @@ protected:
} // 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(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
@ -47,10 +47,10 @@ ACMPCM16B::InternalEncode(
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
@ -59,15 +59,15 @@ ACMPCM16B::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1;
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -75,9 +75,9 @@ ACMPCM16B::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMPCM16B::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1;
@ -91,21 +91,21 @@ ACMPCM16B::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalCreateEncoder()
{
return -1;
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalCreateDecoder()
{
return -1;
}
void
void
ACMPCM16B::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -113,20 +113,20 @@ ACMPCM16B::InternalDestructEncoderInst(
}
void
void
ACMPCM16B::DestructEncoderSafe()
{
return;
}
void
void
ACMPCM16B::DestructDecoderSafe()
{
return;
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::UnregisterFromNetEqSafe(
ACMNetEQ* /* netEq */,
WebRtc_Word16 /* payloadType */)
@ -153,7 +153,7 @@ ACMPCM16B::~ACMPCM16B()
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
@ -168,10 +168,10 @@ ACMPCM16B::InternalEncode(
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
@ -180,17 +180,17 @@ ACMPCM16B::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization,
// PCM has no instance
return 0;
return 0;
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -200,12 +200,12 @@ ACMPCM16B::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMPCM16B::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -248,7 +248,7 @@ ACMPCM16B::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalCreateEncoder()
{
// PCM has no instance
@ -256,7 +256,7 @@ ACMPCM16B::InternalCreateEncoder()
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::InternalCreateDecoder()
{
// PCM has no instance
@ -264,7 +264,7 @@ ACMPCM16B::InternalCreateDecoder()
}
void
void
ACMPCM16B::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -273,7 +273,7 @@ ACMPCM16B::InternalDestructEncoderInst(
}
void
void
ACMPCM16B::DestructEncoderSafe()
{
// PCM has no instance
@ -282,7 +282,7 @@ ACMPCM16B::DestructEncoderSafe()
return;
}
void
void
ACMPCM16B::DestructDecoderSafe()
{
// PCM has no instance
@ -292,18 +292,18 @@ ACMPCM16B::DestructDecoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMPCM16B::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
@ -313,17 +313,14 @@ the stored payload type",
case 8000:
{
return netEq->RemoveCodec(kDecoderPCM16B);
break;
}
case 16000:
{
return netEq->RemoveCodec(kDecoderPCM16Bwb);
break;
}
case 32000:
{
return netEq->RemoveCodec(kDecoderPCM16Bswb32kHz);
break;
}
default:
{

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_PCM16B_H
#define ACM_PCM16B_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
#include "acm_generic_codec.h"
@ -37,23 +37,23 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
@ -66,5 +66,4 @@ protected:
} // 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.
*/
#ifndef ACM_PCMA_H
#define ACM_PCMA_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
#include "acm_generic_codec.h"
@ -37,13 +37,13 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
@ -51,9 +51,9 @@ protected:
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
@ -64,5 +64,4 @@ protected:
} // 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(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
*bitStreamLenByte = WebRtcG711_EncodeU(NULL, &_inAudio[_inAudioIxRead],
_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
_inAudioIxRead += _frameLenSmpl*_noChannels;
return *bitStreamLenByte;
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
@ -59,17 +59,17 @@ ACMPCMU::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization,
// PCM has no instance
return 0;
return 0;
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -79,12 +79,12 @@ ACMPCMU::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMPCMU::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -101,7 +101,7 @@ ACMPCMU::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::InternalCreateEncoder()
{
// PCM has no instance
@ -109,7 +109,7 @@ ACMPCMU::InternalCreateEncoder()
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::InternalCreateDecoder()
{
// PCM has no instance
@ -117,7 +117,7 @@ ACMPCMU::InternalCreateDecoder()
}
void
void
ACMPCMU::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -126,7 +126,7 @@ ACMPCMU::InternalDestructEncoderInst(
}
void
void
ACMPCMU::DestructEncoderSafe()
{
// PCM has no instance
@ -144,7 +144,7 @@ void ACMPCMU::DestructDecoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMPCMU::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
@ -152,15 +152,15 @@ ACMPCMU::UnregisterFromNetEqSafe(
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
return netEq->RemoveCodec(kDecoderPCMu);
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_PCMU_H
#define ACM_PCMU_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
#include "acm_generic_codec.h"
@ -37,23 +37,23 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
@ -64,5 +64,4 @@ protected:
} // 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(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
@ -41,10 +41,10 @@ ACMRED::InternalEncode(
}
WebRtc_Word16
WebRtc_Word16
ACMRED::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */)
@ -53,17 +53,17 @@ ACMRED::DecodeSafe(
}
WebRtc_Word16
WebRtc_Word16
ACMRED::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization,
// RED has no instance
return 0;
return 0;
}
WebRtc_Word16
WebRtc_Word16
ACMRED::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
@ -73,7 +73,7 @@ ACMRED::InternalInitDecoder(
}
WebRtc_Word32
WebRtc_Word32
ACMRED::CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
@ -85,7 +85,7 @@ ACMRED::CodecDef(
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -102,7 +102,7 @@ ACMRED::CreateInstance(void)
}
WebRtc_Word16
WebRtc_Word16
ACMRED::InternalCreateEncoder()
{
// RED has no instance
@ -110,7 +110,7 @@ ACMRED::InternalCreateEncoder()
}
WebRtc_Word16
WebRtc_Word16
ACMRED::InternalCreateDecoder()
{
// RED has no instance
@ -118,7 +118,7 @@ ACMRED::InternalCreateDecoder()
}
void
void
ACMRED::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -127,7 +127,7 @@ ACMRED::InternalDestructEncoderInst(
}
void
void
ACMRED::DestructEncoderSafe()
{
// RED has no instance
@ -141,18 +141,18 @@ void ACMRED::DestructDecoderSafe()
}
WebRtc_Word16
WebRtc_Word16
ACMRED::UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType)
{
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_RED_H
#define ACM_RED_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
#include "acm_generic_codec.h"
@ -37,23 +37,23 @@ public:
protected:
WebRtc_Word16 DecodeSafe(
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef(
WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst);
void DestructEncoderSafe();
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
@ -64,5 +64,4 @@ protected:
} // 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(
const WebRtc_Word16* inAudio,
WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio,
const WebRtc_Word16* inAudio,
WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio,
WebRtc_Word32 outFreqHz,
WebRtc_UWord8 numAudioChannels)
{
CriticalSectionScoped cs(_resamplerCritSect);
if(inFreqHz == outFreqHz)
@ -55,20 +55,20 @@ ACMResampler::Resample10Msec(
WebRtc_Word32 ret;
ResamplerType type;
type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo;
ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type);
type = (numAudioChannels == 1)? kResamplerSynchronous:kResamplerSynchronousStereo;
ret = _resampler.ResetIfNeeded(inFreqHz,outFreqHz,type);
if (ret < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in reset of resampler");
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in reset of resampler");
return -1;
}
ret = _resampler.Push(inAudio, lengthIn, outAudio, maxLen, outLen);
if (ret < 0 )
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _id,
"Error in resampler: resampler.Push");
return -1;
}
@ -79,11 +79,11 @@ ACMResampler::Resample10Msec(
}
void
void
ACMResampler::SetUniqueId(
WebRtc_Word32 id)
{
CriticalSectionScoped lock(_resamplerCritSect);
CriticalSectionScoped lock(_resamplerCritSect);
_id = id;
}

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_RESAMPLER_H
#define ACM_RESAMPLER_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RESAMPLER_H_
#include "resampler.h"
#include "typedefs.h"
@ -23,14 +23,14 @@ class ACMResampler
public:
ACMResampler();
~ACMResampler();
WebRtc_Word16 Resample10Msec(
const WebRtc_Word16* inAudio,
const WebRtc_Word32 inFreqHz,
WebRtc_Word16* outAudio,
const WebRtc_Word32 outFreqHz,
WebRtc_UWord8 numAudioChannels);
void SetUniqueId(
WebRtc_Word32 id);
@ -44,4 +44,4 @@ private:
} // 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;
}
void
void
ACMSPEEX::DestructEncoderSafe()
{
return;
@ -140,7 +140,7 @@ ACMSPEEX::InternalCreateDecoder()
return -1;
}
void
void
ACMSPEEX::DestructDecoderSafe()
{
return;
@ -153,7 +153,7 @@ ACMSPEEX::SetBitRateSafe(
return -1;
}
void
void
ACMSPEEX::InternalDestructEncoderInst(
void* /* ptrInst */)
{
@ -196,7 +196,7 @@ _encoderInstPtr(NULL),
_decoderInstPtr(NULL)
{
_codecID = codecID;
// Set sampling frequency, frame size and rate Speex
if(_codecID == ACMCodecDB::kSPEEX8)
{
@ -212,7 +212,7 @@ _decoderInstPtr(NULL)
}
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Wrong codec id for Speex.");
_samplingFrequency = -1;
@ -257,14 +257,14 @@ ACMSPEEX::InternalEncode(
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
_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
_inAudioIxRead += _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");
return status;
}
@ -315,7 +315,7 @@ ACMSPEEX::EnableDTX()
// enable DTX
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");
return -1;
}
@ -342,7 +342,7 @@ ACMSPEEX::DisableDTX()
// disable DTX
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");
return -1;
}
@ -365,7 +365,7 @@ ACMSPEEX::InternalInitEncoder(
// sanity check
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");
return -1;
}
@ -376,7 +376,7 @@ ACMSPEEX::InternalInitEncoder(
if (status >= 0) {
return 0;
} else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in initialization of Speex encoder");
return -1;
}
@ -387,20 +387,20 @@ ACMSPEEX::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
WebRtc_Word16 status;
// sanity check
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");
return -1;
}
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0)? -1:0);
if (status >= 0) {
return 0;
} else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in initialization of Speex decoder");
return -1;
}
@ -413,12 +413,12 @@ ACMSPEEX::CodecDef(
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error, Speex decoder is not initialized");
return -1;
}
// Fill up the structure by calling
// Fill up the structure by calling
// "SET_CODEC_PAR" & "SET_SPEEX_FUNCTION."
// Then call NetEQ to add the codec to it's
// database.
@ -439,14 +439,13 @@ ACMSPEEX::CodecDef(
}
default:
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Unsupported sampling frequency for Speex");
return -1;
break;
}
}
SET_SPEEX_FUNCTIONS((codecDef));
return 0;
}
@ -463,7 +462,7 @@ ACMSPEEX::InternalCreateEncoder()
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
}
void
void
ACMSPEEX::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
@ -484,7 +483,7 @@ ACMSPEEX::InternalCreateDecoder()
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
}
void
void
ACMSPEEX::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
@ -508,17 +507,17 @@ ACMSPEEX::SetBitRateSafe(
_encodingRate = rate;
_encoderParams.codecInstant.rate = rate;
} else {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Unsupported encoding rate for Speex");
return -1;
}
return 0;
}
void
void
ACMSPEEX::InternalDestructEncoderInst(
void* ptrInst)
{
@ -537,11 +536,11 @@ ACMSPEEX::UnregisterFromNetEqSafe(
{
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 \
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
the stored payload type",
_decoderParams.codecInstant.plname,
payloadType,
_decoderParams.codecInstant.pltype);
return -1;
}
@ -559,7 +558,7 @@ the stored payload type",
}
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");
return -1;
}
@ -583,9 +582,9 @@ ACMSPEEX::EnableVBR()
// enable Variable Bit Rate (VBR)
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");
return -1;
}
_vbrEnabled = true;
@ -612,7 +611,7 @@ ACMSPEEX::DisableVBR()
// disable DTX
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");
return -1;
@ -643,7 +642,7 @@ ACMSPEEX::SetComplMode(
// Set new mode
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");
return -1;
}
@ -662,4 +661,3 @@ ACMSPEEX::SetComplMode(
#endif
} // namespace webrtc

View File

@ -8,8 +8,8 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef ACM_SPEEX_H
#define ACM_SPEEX_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
#include "acm_generic_codec.h"
@ -54,28 +54,28 @@ protected:
void DestructDecoderSafe();
WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst(
void* ptrInst);
WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX();
#ifdef UNUSEDSPEEX
#ifdef UNUSEDSPEEX
WebRtc_Word16 EnableVBR();
WebRtc_Word16 DisableVBR();
WebRtc_Word16 SetComplMode(
WebRtc_Word16 mode);
#endif
WebRtc_Word16 UnregisterFromNetEqSafe(
ACMNetEQ* netEq,
WebRtc_Word16 payloadType);
@ -91,4 +91,4 @@ protected:
} // 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
AudioCodingModule*
AudioCodingModule*
AudioCodingModule::Create(
const WebRtc_Word32 id)
{
@ -26,7 +26,7 @@ AudioCodingModule::Create(
}
// Destroy module
void
void
AudioCodingModule::Destroy(
AudioCodingModule* module)
{
@ -34,10 +34,10 @@ AudioCodingModule::Destroy(
}
// Returns version of the module and its components.
WebRtc_Word32
WebRtc_Word32
AudioCodingModule::GetVersion(
WebRtc_Word8* version,
WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& remainingBufferInBytes,
WebRtc_UWord32& position)
{
WebRtc_Word32 len = position;
@ -45,7 +45,7 @@ AudioCodingModule::GetVersion(
position = static_cast<WebRtc_UWord32>(strlen(version));
remainingBufferInBytes -= (position - len);
// Get NetEQ version.
if(ACMNetEQ::GetVersion(version,
remainingBufferInBytes, position) < 0)
@ -72,32 +72,32 @@ AudioCodingModule::GetVersion(
// Get number of supported codecs
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs()
{
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"NumberOfCodecs()");
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
}
// Get supported codec param with id
WebRtc_Word32
// Get supported codec param with id
WebRtc_Word32
AudioCodingModule::Codec(
const WebRtc_UWord8 listId,
CodecInst& codec)
{
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"Codec(const WebRtc_UWord8 listId, CodecInst& codec)");
// Get the codec settings for the codec with the given list ID
return ACMCodecDB::Codec(listId, &codec);
}
// Get supported codec Param with name
WebRtc_Word32
// Get supported codec Param with name
WebRtc_Word32
AudioCodingModule::Codec(
const WebRtc_Word8* payloadName,
CodecInst& codec,
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)");
// Search through codec list for a matching name
@ -108,7 +108,7 @@ AudioCodingModule::Codec(
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))
{
// We found a match, return OK
@ -118,7 +118,7 @@ AudioCodingModule::Codec(
}
// 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.pltype = -1;
codec.pacsize = 0;
@ -133,7 +133,7 @@ AudioCodingModule::Codec(
const WebRtc_Word8* payloadName,
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;
@ -145,10 +145,10 @@ AudioCodingModule::Codec(
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))
{
// We found a match, return codec list number (index)
// We found a match, return codec list number (index)
return codecCntr;
}
}
@ -159,17 +159,17 @@ AudioCodingModule::Codec(
}
// Checks the validity of the parameters of the given codec
bool
bool
AudioCodingModule::IsCodecValid(
const CodecInst& codec)
{
int mirrorID;
char errMsg[500];
WEBRTC_TRACE(webrtc::kTraceModuleCall, webrtc::kTraceAudioCoding, -1,
"IsCodecValid(const CodecInst& codec)");
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
if(codecNumber < 0)
{
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.
*/
#ifndef AUDIO_CODING_MODULE_IMPL_H
#define AUDIO_CODING_MODULE_IMPL_H
#ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#define WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_
#include "acm_codec_database.h"
#include "acm_neteq.h"
@ -59,9 +59,9 @@ public:
WebRtc_Word32 TimeUntilNextProcess();
// 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
WebRtc_Word32 SetMode(
const bool passive);
@ -94,7 +94,7 @@ public:
// return there longterm avarage or their fixed rate.
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
virtual WebRtc_Word32 SetReceivedEstimatedBandwidth(
const WebRtc_Word32 bw);
@ -123,7 +123,7 @@ public:
ACMBackgroundNoiseMode& mode);
/////////////////////////////////////////
// (FEC) Forward Error Correction
// (FEC) Forward Error Correction
//
// configure FEC status i.e on/off
@ -193,7 +193,7 @@ public:
CodecInst& currentReceiveCodec) const;
// incoming packet from network parsed and ready for decode
WebRtc_Word32 IncomingPacket(
WebRtc_Word32 IncomingPacket(
const WebRtc_Word8* incomingPayload,
const WebRtc_Word32 payloadLength,
const WebRtcRTPHeader& rtpInfo);
@ -222,7 +222,7 @@ public:
// Estimate the Bandwidth based on the incoming stream
// 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;
// Set playout mode voice, fax
@ -261,21 +261,21 @@ public:
void DestructEncoderInst(void* ptrInst);
WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff);
// GET RED payload for iSAC. The method id called
// when 'this' ACM is default ACM.
WebRtc_Word32 REDPayloadISAC(
const WebRtc_Word32 isacRate,
const WebRtc_Word32 isacRate,
const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenByte);
WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff);
WebRtc_UWord32 EarliestTimestamp() const;
WebRtc_Word32 LastEncodedTimestamp(WebRtc_UWord32& timestamp) const;
WebRtc_Word32 ReplaceInternalDTXWithWebRtc(
const bool useWebRtcDTX);
@ -361,15 +361,15 @@ private:
WebRtc_UWord32 _lastFECTimestamp;
WebRtc_UWord8 _redPayloadType;
// if no RED is registered as receive codec this
// will have an invalid value.
// will have an invalid value.
WebRtc_UWord8 _receiveREDPayloadType;
// This is to keep track of CN instances where we can send DTMFs
WebRtc_UWord8 _previousPayloadType;
// This keeps track of payload types associated with _codecs[].
// We define it as signed variable and initialize with -1 to indicate
// unused elements.
// We define it as signed variable and initialize with -1 to indicate
// unused elements.
WebRtc_Word16 _registeredPlTypes[ACMCodecDB::kMaxNumCodecs];
// Used when payloads are pushed into ACM without any RTP info
@ -380,7 +380,7 @@ private:
bool _receiverInitialized;
ACMDTMFDetection* _dtmfDetector;
AudioCodingFeedback* _dtmfCallback;
WebRtc_Word16 _lastDetectedTone;
CriticalSectionWrapper* _callbackCritSect;
@ -397,4 +397,4 @@ private:
} // namespace webrtc
#endif
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_AUDIO_CODING_MODULE_IMPL_H_