Reformating files in audio coding module.

This CL format the ramaining files on the audio coding module. No other changes are done, except for fixing a few long lines and TODOs without owner.

BUG=issue1024

Review URL: https://webrtc-codereview.appspot.com/928012

git-svn-id: http://webrtc.googlecode.com/svn/trunk@3042 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
tina.legrand@webrtc.org 2012-11-05 09:35:51 +00:00
parent a56d759723
commit f7fa6276e2
26 changed files with 5715 additions and 7532 deletions

View File

@ -16,24 +16,9 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_G729 #ifdef WEBRTC_CODEC_G729
// NOTE! G.729 is not included in the open-source package. The following // NOTE! G.729 is not included in the open-source package. Modify this file
// interface file is needed: // or your codec API to match the function calls and names of used G.729 API
// // file.
// /modules/audio_coding/codecs/g729/main/interface/g729_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcG729_CreateEnc(G729_encinst_t_** inst);
// int16_t WebRtcG729_CreateDec(G729_decinst_t_** inst);
// int16_t WebRtcG729_FreeEnc(G729_encinst_t_* inst);
// int16_t WebRtcG729_FreeDec(G729_decinst_t_* inst);
// int16_t WebRtcG729_Encode(G729_encinst_t_* encInst, int16_t* input,
// int16_t len, int16_t* output);
// int16_t WebRtcG729_EncoderInit(G729_encinst_t_* encInst, int16_t mode);
// int16_t WebRtcG729_Decode(G729_decinst_t_* decInst);
// int16_t WebRtcG729_DecodeBwe(G729_decinst_t_* decInst, int16_t* input);
// int16_t WebRtcG729_DecodePlc(G729_decinst_t_* decInst);
// int16_t WebRtcG729_DecoderInit(G729_decinst_t_* decInst);
#include "g729_interface.h" #include "g729_interface.h"
#endif #endif
@ -47,152 +32,96 @@ ACMG729::ACMG729(WebRtc_Word16 /* codecID */)
return; return;
} }
ACMG729::~ACMG729() {
ACMG729::~ACMG729()
{
return; return;
} }
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMG729::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729::EnableDTX() {
WebRtc_Word16
ACMG729::EnableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729::DisableDTX() {
WebRtc_Word16
ACMG729::DisableDTX()
{
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(
ACMG729::ReplaceInternalDTXSafe( const bool /*replaceInternalDTX*/) {
const bool /*replaceInternalDTX*/)
{
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(
ACMG729::IsInternalDTXReplacedSafe( bool* /* internalDTXReplaced */) {
bool* /* internalDTXReplaced */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG729::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG729::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMG729::CreateInstance(void) {
ACMGenericCodec*
ACMG729::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
WebRtc_Word16
ACMG729::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMG729::DestructEncoderSafe() {
void
ACMG729::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
WebRtc_Word16
ACMG729::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMG729::DestructDecoderSafe() {
void
ACMG729::DestructDecoderSafe()
{
return; return;
} }
void ACMG729::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMG729::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMG729::ACMG729(WebRtc_Word16 codecID)
ACMG729::ACMG729( : _encoderInstPtr(NULL),
WebRtc_Word16 codecID): _decoderInstPtr(NULL) {
_encoderInstPtr(NULL),
_decoderInstPtr(NULL)
{
_codecID = codecID; _codecID = codecID;
_hasInternalDTX = true; _hasInternalDTX = true;
return; return;
} }
ACMG729::~ACMG729() {
ACMG729::~ACMG729() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
// Delete encoder memory // Delete encoder memory
WebRtcG729_FreeEnc(_encoderInstPtr); WebRtcG729_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
// Delete decoder memory // Delete decoder memory
WebRtcG729_FreeDec(_decoderInstPtr); WebRtcG729_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
@ -200,23 +129,18 @@ ACMG729::~ACMG729()
return; return;
} }
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMG729::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
// Initialize before entering the loop // Initialize before entering the loop
WebRtc_Word16 noEncodedSamples = 0; WebRtc_Word16 noEncodedSamples = 0;
WebRtc_Word16 tmpLenByte = 0; WebRtc_Word16 tmpLenByte = 0;
WebRtc_Word16 vadDecision = 0; WebRtc_Word16 vadDecision = 0;
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
while(noEncodedSamples < _frameLenSmpl) while (noEncodedSamples < _frameLenSmpl) {
{
// Call G.729 encoder with pointer to encoder memory, input // Call G.729 encoder with pointer to encoder memory, input
// audio, number of samples and bitsream // audio, number of samples and bitsream
tmpLenByte = WebRtcG729_Encode(_encoderInstPtr, tmpLenByte = WebRtcG729_Encode(
&_inAudio[_inAudioIxRead], 80, _encoderInstPtr, &_inAudio[_inAudioIxRead], 80,
(WebRtc_Word16*) (&(bitStream[*bitStreamLenByte]))); (WebRtc_Word16*) (&(bitStream[*bitStreamLenByte])));
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
@ -224,8 +148,7 @@ ACMG729::InternalEncode(
_inAudioIxRead += 80; _inAudioIxRead += 80;
// sanity check // sanity check
if(tmpLenByte < 0) if (tmpLenByte < 0) {
{
// error has happened // error has happened
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
@ -233,12 +156,9 @@ ACMG729::InternalEncode(
// increment number of written bytes // increment number of written bytes
*bitStreamLenByte += tmpLenByte; *bitStreamLenByte += tmpLenByte;
switch(tmpLenByte) switch (tmpLenByte) {
{ case 0: {
case 0: if (0 == noEncodedSamples) {
{
if(0 == noEncodedSamples)
{
// this is the first 10 ms in this packet and there is // this is the first 10 ms in this packet and there is
// no data generated, perhaps DTX is enabled and the // no data generated, perhaps DTX is enabled and the
// codec is not generating any bit-stream for this 10 ms. // codec is not generating any bit-stream for this 10 ms.
@ -247,14 +167,11 @@ ACMG729::InternalEncode(
} }
break; break;
} }
case 2: case 2: {
{
// check if G.729 internal DTX is enabled // check if G.729 internal DTX is enabled
if(_hasInternalDTX && _dtxEnabled) if (_hasInternalDTX && _dtxEnabled) {
{
vadDecision = 0; vadDecision = 0;
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
{
_vadLabel[n] = vadDecision; _vadLabel[n] = vadDecision;
} }
} }
@ -262,14 +179,12 @@ ACMG729::InternalEncode(
// how much audio we have encoded // how much audio we have encoded
return *bitStreamLenByte; return *bitStreamLenByte;
} }
case 10: case 10: {
{
vadDecision = 1; vadDecision = 1;
// this is a valid length just continue encoding // this is a valid length just continue encoding
break; break;
} }
default: default: {
{
return -1; return -1;
} }
} }
@ -279,10 +194,8 @@ ACMG729::InternalEncode(
} }
// update VAD decision vector // update VAD decision vector
if(_hasInternalDTX && !vadDecision && _dtxEnabled) if (_hasInternalDTX && !vadDecision && _dtxEnabled) {
{ for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
{
_vadLabel[n] = vadDecision; _vadLabel[n] = vadDecision;
} }
} }
@ -291,78 +204,52 @@ ACMG729::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG729::EnableDTX() {
WebRtc_Word16 if (_dtxEnabled) {
ACMG729::EnableDTX()
{
if(_dtxEnabled)
{
// DTX already enabled, do nothing // DTX already enabled, do nothing
return 0; return 0;
} } else if (_encoderExist) {
else if(_encoderExist)
{
// Re-init the G.729 encoder to turn on DTX // Re-init the G.729 encoder to turn on DTX
if(WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) if (WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
WebRtc_Word16 ACMG729::DisableDTX() {
WebRtc_Word16 if (!_dtxEnabled) {
ACMG729::DisableDTX()
{
if(!_dtxEnabled)
{
// DTX already dissabled, do nothing // DTX already dissabled, do nothing
return 0; return 0;
} } else if (_encoderExist) {
else if(_encoderExist)
{
// Re-init the G.729 decoder to turn off DTX // Re-init the G.729 decoder to turn off DTX
if(WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) if (WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) {
{
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
} }
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replaceInternalDTX) {
WebRtc_Word32 // This function is used to disable the G.729 built in DTX and use an
ACMG729::ReplaceInternalDTXSafe(
const bool replaceInternalDTX)
{
// This function is used to dissable the G.729 built in DTX and use an
// external instead. // external instead.
if(replaceInternalDTX == _hasInternalDTX) if (replaceInternalDTX == _hasInternalDTX) {
{
// Make sure we keep the DTX/VAD setting if possible // Make sure we keep the DTX/VAD setting if possible
bool oldEnableDTX = _dtxEnabled; bool oldEnableDTX = _dtxEnabled;
bool oldEnableVAD = _vadEnabled; bool oldEnableVAD = _vadEnabled;
ACMVADMode oldMode = _vadMode; ACMVADMode oldMode = _vadMode;
if (replaceInternalDTX) if (replaceInternalDTX) {
{
// Disable internal DTX before enabling external DTX // Disable internal DTX before enabling external DTX
DisableDTX(); DisableDTX();
} } else {
else
{
// Disable external DTX before enabling internal // Disable external DTX before enabling internal
ACMGenericCodec::DisableDTX(); ACMGenericCodec::DisableDTX();
} }
@ -381,56 +268,36 @@ ACMG729::ReplaceInternalDTXSafe(
return 0; return 0;
} }
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internalDTXReplaced) {
WebRtc_Word32
ACMG729::IsInternalDTXReplacedSafe(
bool* internalDTXReplaced)
{
// Get status of wether DTX is replaced or not // Get status of wether DTX is replaced or not
*internalDTXReplaced = !_hasInternalDTX; *internalDTXReplaced = !_hasInternalDTX;
return 0; return 0;
} }
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG729::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
// This function is not used. G.729 decoder is called from inside NetEQ // This function is not used. G.729 decoder is called from inside NetEQ
return 0; return 0;
} }
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16
ACMG729::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// Init G.729 encoder // Init G.729 encoder
return WebRtcG729_EncoderInit(_encoderInstPtr, return WebRtcG729_EncoderInit(_encoderInstPtr,
((codecParams->enableDTX) ? 1 : 0)); ((codecParams->enableDTX) ? 1 : 0));
} }
WebRtc_Word16 ACMG729::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
// Init G.729 decoder // Init G.729 decoder
return WebRtcG729_DecoderInit(_decoderInstPtr); return WebRtcG729_DecoderInit(_decoderInstPtr);
} }
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMG729::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -440,71 +307,49 @@ ACMG729::CodecDef(
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 8000); 8000);
SET_G729_FUNCTIONS((codecDef)); SET_G729_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMG729::CreateInstance(void) {
ACMGenericCodec*
ACMG729::CreateInstance(void)
{
// Function not used // Function not used
return NULL; return NULL;
} }
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
WebRtc_Word16
ACMG729::InternalCreateEncoder()
{
// Create encoder memory // Create encoder memory
return WebRtcG729_CreateEnc(&_encoderInstPtr); return WebRtcG729_CreateEnc(&_encoderInstPtr);
} }
void ACMG729::DestructEncoderSafe() {
void
ACMG729::DestructEncoderSafe()
{
// Free encoder memory // Free encoder memory
_encoderExist = false; _encoderExist = false;
_encoderInitialized = false; _encoderInitialized = false;
if(_encoderInstPtr != NULL) if (_encoderInstPtr != NULL) {
{
WebRtcG729_FreeEnc(_encoderInstPtr); WebRtcG729_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
} }
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
WebRtc_Word16
ACMG729::InternalCreateDecoder()
{
// Create decoder memory // Create decoder memory
return WebRtcG729_CreateDec(&_decoderInstPtr); return WebRtcG729_CreateDec(&_decoderInstPtr);
} }
void ACMG729::DestructDecoderSafe() {
void
ACMG729::DestructDecoderSafe()
{
// Free decoder memory // Free decoder memory
_decoderExist = false; _decoderExist = false;
_decoderInitialized = false; _decoderInitialized = false;
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcG729_FreeDec(_decoderInstPtr); WebRtcG729_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
} }
void ACMG729::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMG729::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst); WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst);
} }
return; return;

View File

@ -19,34 +19,28 @@ struct G729_decinst_t_;
namespace webrtc { namespace webrtc {
class ACMG729 : public ACMGenericCodec class ACMG729 : public ACMGenericCodec {
{
public: public:
ACMG729(WebRtc_Word16 codecID); ACMG729(WebRtc_Word16 codecID);
~ACMG729(); ~ACMG729();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -57,18 +51,15 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
WebRtc_Word16 DisableDTX(); WebRtc_Word16 DisableDTX();
WebRtc_Word32 ReplaceInternalDTXSafe( WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
const bool replaceInternalDTX);
WebRtc_Word32 IsInternalDTXReplacedSafe( WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
bool* internalDTXReplaced);
G729_encinst_t_* _encoderInstPtr; G729_encinst_t_* _encoderInstPtr;
G729_decinst_t_* _decoderInstPtr; G729_decinst_t_* _decoderInstPtr;

View File

@ -16,24 +16,9 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_G729_1 #ifdef WEBRTC_CODEC_G729_1
// NOTE! G.729.1 is not included in the open-source package. The following // NOTE! G.729.1 is not included in the open-source package. Modify this file
// interface file is needed: // or your codec API to match the function calls and names of used G.729.1 API
// // file.
// /modules/audio_coding/codecs/g7291/main/interface/g7291_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcG7291_Create(G729_1_inst_t_** inst);
// int16_t WebRtcG7291_Free(G729_1_inst_t_* inst);
// int16_t WebRtcG7291_Encode(G729_1_inst_t_* encInst, int16_t* input,
// int16_t* output, int16_t myRate,
// int16_t nrFrames);
// int16_t WebRtcG7291_EncoderInit(G729_1_inst_t_* encInst, int16_t myRate,
// int16_t flag8kHz, int16_t flagG729mode);
// int16_t WebRtcG7291_Decode(G729_1_inst_t_* decInst);
// int16_t WebRtcG7291_DecodeBwe(G729_1_inst_t_* decInst, int16_t* input);
// int16_t WebRtcG7291_DecodePlc(G729_1_inst_t_* decInst);
// int16_t WebRtcG7291_DecoderInit(G729_1_inst_t_* decInst);
#include "g7291_interface.h" #include "g7291_interface.h"
#endif #endif
@ -50,105 +35,63 @@ ACMG729_1::ACMG729_1( WebRtc_Word16 /* codecID */)
return; return;
} }
ACMG729_1::~ACMG729_1() {
ACMG729_1::~ACMG729_1()
{
return; return;
} }
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMG729_1::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729_1::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMG729_1::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
ACMGenericCodec*
ACMG729_1::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
WebRtc_Word16
ACMG729_1::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMG729_1::DestructEncoderSafe() {
void
ACMG729_1::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
WebRtc_Word16
ACMG729_1::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMG729_1::DestructDecoderSafe() {
void
ACMG729_1::DestructDecoderSafe()
{
return; return;
} }
void ACMG729_1::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMG729_1::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 /*rate*/) {
ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 /*rate*/ )
{
return -1; return -1;
} }
@ -168,27 +111,20 @@ ACMG729_1::ACMG729_1(WebRtc_Word16 codecID)
return; return;
} }
ACMG729_1::~ACMG729_1() ACMG729_1::~ACMG729_1() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL)
{
WebRtcG7291_Free(_encoderInstPtr); WebRtcG7291_Free(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcG7291_Free(_decoderInstPtr); WebRtcG7291_Free(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMG729_1::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
// Initialize before entering the loop // Initialize before entering the loop
WebRtc_Word16 noEncodedSamples = 0; WebRtc_Word16 noEncodedSamples = 0;
@ -203,18 +139,18 @@ ACMG729_1::InternalEncode(
byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode); byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode);
// The following might be revised if we have G729.1 Annex C (support for DTX); // The following might be revised if we have G729.1 Annex C (support for DTX);
do do {
{ *bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr,
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], &_inAudio[_inAudioIxRead],
(WebRtc_Word16*)bitStream, _myRate, n20msFrames); (WebRtc_Word16*) bitStream, _myRate,
n20msFrames);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += 160; _inAudioIxRead += 160;
// sanity check // sanity check
if(*bitStreamLenByte < 0) if (*bitStreamLenByte < 0) {
{
// error has happened // error has happened
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
@ -225,19 +161,15 @@ ACMG729_1::InternalEncode(
noEncodedSamples += 160; noEncodedSamples += 160;
} while (*bitStreamLenByte == 0); } while (*bitStreamLenByte == 0);
// This criteria will change if we have Annex C. // This criteria will change if we have Annex C.
if(*bitStreamLenByte != byteLengthFrame) if (*bitStreamLenByte != byteLengthFrame) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: Encode error for G729_1"); "InternalEncode: Encode error for G729_1");
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
if (noEncodedSamples != _frameLenSmpl) {
if(noEncodedSamples != _frameLenSmpl)
{
*bitStreamLenByte = 0; *bitStreamLenByte = 0;
return -1; return -1;
} }
@ -245,35 +177,24 @@ ACMG729_1::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMG729_1::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* codecParams) {
ACMG729_1::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
//set the bit rate and initialize //set the bit rate and initialize
_myRate = codecParams->codecInstant.rate; _myRate = codecParams->codecInstant.rate;
return SetBitRateSafe((WebRtc_UWord32) _myRate); return SetBitRateSafe((WebRtc_UWord32) _myRate);
} }
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMG729_1::InternalInitDecoder( if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0) {
WebRtcACMCodecParams* /* codecParams */)
{
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: init decoder failed for G729_1"); "InternalInitDecoder: init decoder failed for G729_1");
return -1; return -1;
@ -281,14 +202,9 @@ ACMG729_1::InternalInitDecoder(
return 0; return 0;
} }
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMG729_1::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: Decoder uninitialized for G729_1"); "CodeDef: Decoder uninitialized for G729_1");
return -1; return -1;
@ -298,25 +214,18 @@ ACMG729_1::CodecDef(
// "SET_CODEC_PAR" & "SET_G729_FUNCTION." // "SET_CODEC_PAR" & "SET_G729_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 16000); 16000);
SET_G729_1_FUNCTIONS((codecDef)); SET_G729_1_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
ACMGenericCodec*
ACMG729_1::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
WebRtc_Word16 if (WebRtcG7291_Create(&_encoderInstPtr) < 0) {
ACMG729_1::InternalCreateEncoder()
{
if (WebRtcG7291_Create(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: create encoder failed for G729_1"); "InternalCreateEncoder: create encoder failed for G729_1");
return -1; return -1;
@ -324,25 +233,17 @@ ACMG729_1::InternalCreateEncoder()
return 0; return 0;
} }
void ACMG729_1::DestructEncoderSafe() {
void
ACMG729_1::DestructEncoderSafe()
{
_encoderExist = false; _encoderExist = false;
_encoderInitialized = false; _encoderInitialized = false;
if(_encoderInstPtr != NULL) if (_encoderInstPtr != NULL) {
{
WebRtcG7291_Free(_encoderInstPtr); WebRtcG7291_Free(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
} }
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
WebRtc_Word16 if (WebRtcG7291_Create(&_decoderInstPtr) < 0) {
ACMG729_1::InternalCreateDecoder()
{
if (WebRtcG7291_Create(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: create decoder failed for G729_1"); "InternalCreateDecoder: create decoder failed for G729_1");
return -1; return -1;
@ -350,103 +251,77 @@ ACMG729_1::InternalCreateDecoder()
return 0; return 0;
} }
void ACMG729_1::DestructDecoderSafe() {
void
ACMG729_1::DestructDecoderSafe()
{
_decoderExist = false; _decoderExist = false;
_decoderInitialized = false; _decoderInitialized = false;
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcG7291_Free(_decoderInstPtr); WebRtcG7291_Free(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
} }
void ACMG729_1::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMG729_1::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
//WebRtcG7291_Free((G729_1_inst_t*)ptrInst); //WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 rate) {
ACMG729_1::SetBitRateSafe(
const WebRtc_Word32 rate)
{
//allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000, //allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000,
// 22000, 24000, 26000, 28000, 30000, 32000}; // 22000, 24000, 26000, 28000, 30000, 32000};
// TODO(tlegrand): This check exists in one other place two. Should be // TODO(tlegrand): This check exists in one other place two. Should be
// possible to reuse code. // possible to reuse code.
switch(rate) switch (rate) {
{ case 8000: {
case 8000:
{
_myRate = 8000; _myRate = 8000;
break; break;
} }
case 12000: case 12000: {
{
_myRate = 12000; _myRate = 12000;
break; break;
} }
case 14000: case 14000: {
{
_myRate = 14000; _myRate = 14000;
break; break;
} }
case 16000: case 16000: {
{
_myRate = 16000; _myRate = 16000;
break; break;
} }
case 18000: case 18000: {
{
_myRate = 18000; _myRate = 18000;
break; break;
} }
case 20000: case 20000: {
{
_myRate = 20000; _myRate = 20000;
break; break;
} }
case 22000: case 22000: {
{
_myRate = 22000; _myRate = 22000;
break; break;
} }
case 24000: case 24000: {
{
_myRate = 24000; _myRate = 24000;
break; break;
} }
case 26000: case 26000: {
{
_myRate = 26000; _myRate = 26000;
break; break;
} }
case 28000: case 28000: {
{
_myRate = 28000; _myRate = 28000;
break; break;
} }
case 30000: case 30000: {
{
_myRate = 30000; _myRate = 30000;
break; break;
} }
case 32000: case 32000: {
{
_myRate = 32000; _myRate = 32000;
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"SetBitRateSafe: Invalid rate G729_1"); "SetBitRateSafe: Invalid rate G729_1");
return -1; return -1;
@ -454,18 +329,15 @@ ACMG729_1::SetBitRateSafe(
} }
// Re-init with new rate // Re-init with new rate
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, _flagG729mode) >= 0) if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz,
{ _flagG729mode) >= 0) {
_encoderParams.codecInstant.rate = _myRate; _encoderParams.codecInstant.rate = _myRate;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
#endif #endif
} // namespace webrtc } // namespace webrtc

View File

@ -19,34 +19,28 @@ struct G729_1_inst_t_;
namespace webrtc { namespace webrtc {
class ACMG729_1: public ACMGenericCodec class ACMG729_1 : public ACMGenericCodec {
{
public: public:
ACMG729_1(WebRtc_Word16 codecID); ACMG729_1(WebRtc_Word16 codecID);
~ACMG729_1(); ~ACMG729_1();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -57,11 +51,9 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
const WebRtc_Word32 rate);
G729_1_inst_t_* _encoderInstPtr; G729_1_inst_t_* _encoderInstPtr;
G729_1_inst_t_* _decoderInstPtr; G729_1_inst_t_* _decoderInstPtr;
@ -69,7 +61,6 @@ protected:
WebRtc_UWord16 _myRate; WebRtc_UWord16 _myRate;
WebRtc_Word16 _flag8kHz; WebRtc_Word16 _flag8kHz;
WebRtc_Word16 _flagG729mode; WebRtc_Word16 _flagG729mode;
}; };
} // namespace webrtc } // namespace webrtc

File diff suppressed because it is too large Load Diff

View File

@ -23,35 +23,30 @@
struct WebRtcVadInst; struct WebRtcVadInst;
struct WebRtcCngEncInst; struct WebRtcCngEncInst;
namespace webrtc namespace webrtc {
{
// forward declaration // forward declaration
struct CodecInst; struct CodecInst;
class ACMNetEQ; class ACMNetEQ;
class ACMGenericCodec class ACMGenericCodec {
{
public: public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Constructor of the class // Constructor of the class
// //
ACMGenericCodec(); ACMGenericCodec();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Destructor of the class. // Destructor of the class.
// //
virtual ~ACMGenericCodec(); virtual ~ACMGenericCodec();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// ACMGenericCodec* CreateInstance(); // ACMGenericCodec* CreateInstance();
// The function will be used for FEC. It is not implemented yet. // The function will be used for FEC. It is not implemented yet.
// //
virtual ACMGenericCodec* CreateInstance() = 0; virtual ACMGenericCodec* CreateInstance() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 Encode() // WebRtc_Word16 Encode()
// The function is called to perform an encoding of the audio stored in // The function is called to perform an encoding of the audio stored in
@ -105,13 +100,11 @@ public:
// -1 if error is occurred, otherwise the length of the bit-stream in // -1 if error is occurred, otherwise the length of the bit-stream in
// bytes. // bytes.
// //
WebRtc_Word16 Encode( WebRtc_Word16 Encode(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitStreamLenByte,
WebRtc_UWord32* timeStamp, WebRtc_UWord32* timeStamp,
WebRtcACMEncodingType* encodingType); WebRtcACMEncodingType* encodingType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 Decode() // WebRtc_Word16 Decode()
// This function is used to decode a given bit-stream, without engaging // This function is used to decode a given bit-stream, without engaging
@ -134,11 +127,8 @@ public:
// -1 if failed to decode, // -1 if failed to decode,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word16 Decode( WebRtc_Word16 Decode(WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
WebRtc_UWord8* bitStream, WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -157,7 +147,8 @@ public:
// we simply copy the data and return it both for // we simply copy the data and return it both for
// left channel and right channel decoding. // left channel and right channel decoding.
virtual void SplitStereoPacket(WebRtc_UWord8* /* payload */, virtual void SplitStereoPacket(WebRtc_UWord8* /* payload */,
WebRtc_Word32* /* payload_length */) {} WebRtc_Word32* /* payload_length */) {
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool EncoderInitialized(); // bool EncoderInitialized();
@ -168,7 +159,6 @@ public:
// //
bool EncoderInitialized(); bool EncoderInitialized();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool DecoderInitialized(); // bool DecoderInitialized();
// //
@ -178,7 +168,6 @@ public:
// //
bool DecoderInitialized(); bool DecoderInitialized();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 EncoderParams() // WebRtc_Word16 EncoderParams()
// It is called to get encoder parameters. It will call // It is called to get encoder parameters. It will call
@ -194,9 +183,7 @@ public:
// 0 otherwise. // 0 otherwise.
// //
// //
WebRtc_Word16 EncoderParams( WebRtc_Word16 EncoderParams(WebRtcACMCodecParams *encParams);
WebRtcACMCodecParams *encParams);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 DecoderParams(...) // WebRtc_Word16 DecoderParams(...)
@ -213,11 +200,9 @@ public:
// 0 otherwise. // 0 otherwise.
// //
// //
bool DecoderParams( bool DecoderParams(WebRtcACMCodecParams *decParams,
WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InitEncoder(...) // WebRtc_Word16 InitEncoder(...)
// This function is called to initialize the encoder with the given // This function is called to initialize the encoder with the given
@ -234,11 +219,9 @@ public:
// -1 if failed to initialize. // -1 if failed to initialize.
// //
// //
WebRtc_Word16 InitEncoder( WebRtc_Word16 InitEncoder(WebRtcACMCodecParams* codecParams,
WebRtcACMCodecParams* codecParams,
bool forceInitialization); bool forceInitialization);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InitDecoder() // WebRtc_Word16 InitDecoder()
// This function is called to initialize the decoder with the given // This function is called to initialize the decoder with the given
@ -256,11 +239,9 @@ public:
// -1 if failed to initialize. // -1 if failed to initialize.
// //
// //
WebRtc_Word16 InitDecoder( WebRtc_Word16 InitDecoder(WebRtcACMCodecParams* codecParams,
WebRtcACMCodecParams* codecParams,
bool forceInitialization); bool forceInitialization);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 RegisterInNetEq(...) // WebRtc_Word32 RegisterInNetEq(...)
// This function is called to register the decoder in NetEq, with the given // This function is called to register the decoder in NetEq, with the given
@ -274,10 +255,7 @@ public:
// -1 if failed to register, // -1 if failed to register,
// 0 if successfully initialized. // 0 if successfully initialized.
// //
WebRtc_Word32 RegisterInNetEq( WebRtc_Word32 RegisterInNetEq(ACMNetEQ* netEq, const CodecInst& codecInst);
ACMNetEQ* netEq,
const CodecInst& codecInst);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 Add10MsData(...) // WebRtc_Word32 Add10MsData(...)
@ -298,13 +276,11 @@ public:
// -1 if failed // -1 if failed
// 0 otherwise. // 0 otherwise.
// //
WebRtc_Word32 Add10MsData( WebRtc_Word32 Add10MsData(const WebRtc_UWord32 timeStamp,
const WebRtc_UWord32 timeStamp,
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 length, const WebRtc_UWord16 length,
const WebRtc_UWord8 audioChannel); const WebRtc_UWord8 audioChannel);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_UWord32 NoMissedSamples() // WebRtc_UWord32 NoMissedSamples()
// This function returns the number of samples which are overwritten in // This function returns the number of samples which are overwritten in
@ -317,7 +293,6 @@ public:
// //
WebRtc_UWord32 NoMissedSamples() const; WebRtc_UWord32 NoMissedSamples() const;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void ResetNoMissedSamples() // void ResetNoMissedSamples()
// This function resets the number of overwritten samples to zero. // This function resets the number of overwritten samples to zero.
@ -325,7 +300,6 @@ public:
// //
void ResetNoMissedSamples(); void ResetNoMissedSamples();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 SetBitRate() // WebRtc_Word16 SetBitRate()
// The function is called to set the encoding rate. // The function is called to set the encoding rate.
@ -340,7 +314,6 @@ public:
// //
WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS); WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// DestructEncoderInst() // DestructEncoderInst()
// This API is used in conferencing. It will free the memory that is pointed // This API is used in conferencing. It will free the memory that is pointed
@ -351,8 +324,7 @@ public:
// -ptrInst : pointer to an encoder instance to be deleted. // -ptrInst : pointer to an encoder instance to be deleted.
// //
// //
void DestructEncoderInst( void DestructEncoderInst(void* ptrInst);
void* ptrInst);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 AudioBuffer() // WebRtc_Word16 AudioBuffer()
@ -369,9 +341,7 @@ public:
// -1 if fails to copy the audio buffer, // -1 if fails to copy the audio buffer,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word16 AudioBuffer( WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff);
WebRtcACMAudioBuff& audioBuff);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_UWord32 EarliestTimestamp() // WebRtc_UWord32 EarliestTimestamp()
@ -383,7 +353,6 @@ public:
// //
WebRtc_UWord32 EarliestTimestamp() const; WebRtc_UWord32 EarliestTimestamp() const;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 SetAudioBuffer() // WebRtc_Word16 SetAudioBuffer()
// This function is called to set the audio buffer and the associated // This function is called to set the audio buffer and the associated
@ -395,8 +364,6 @@ public:
// //
WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff); WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 SetVAD() // WebRtc_Word16 SetVAD()
// This is called to set VAD & DTX. If the codec has internal DTX that will // This is called to set VAD & DTX. If the codec has internal DTX that will
@ -424,11 +391,9 @@ public:
// -1 if failed to set DTX & VAD as specified, // -1 if failed to set DTX & VAD as specified,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word16 SetVAD( WebRtc_Word16 SetVAD(const bool enableDTX = true,
const bool enableDTX = true, const bool enableVAD = false, const ACMVADMode mode =
const bool enableVAD = false, VADNormal);
const ACMVADMode mode = VADNormal);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ReplaceInternalDTX() // WebRtc_Word32 ReplaceInternalDTX()
@ -447,15 +412,15 @@ public:
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 IsInternalDTXReplaced() // WebRtc_Word32 IsInternalDTXReplaced()
// This is called to check if the codec internal DTX is replaced by WebRtc DTX. // This is called to check if the codec internal DTX is replaced by WebRtc
// This is only valid for G729 where the user has possibility to replace // DTX. This is only valid for G729 where the user has possibility to replace
// AnnexB with WebRtc DTX. For other codecs this function has no effect. // AnnexB with WebRtc DTX. For other codecs this function has no effect.
// //
// Output: // Output:
// -internalDTXReplaced : if true the internal DTX is replaced with WebRtc. // -internalDTXReplaced : if true the internal DTX is replaced with WebRtc.
// //
// Return value // Return value
// -1 if failed to check if replace internal DTX or replacement not feasible, // -1 if failed to check
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word32 IsInternalDTXReplaced(bool* internalDTXReplaced); WebRtc_Word32 IsInternalDTXReplaced(bool* internalDTXReplaced);
@ -467,13 +432,10 @@ public:
// Input: // Input:
// -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM. // -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM.
// //
void SetNetEqDecodeLock( void SetNetEqDecodeLock(RWLockWrapper* netEqDecodeLock) {
RWLockWrapper* netEqDecodeLock)
{
_netEqDecodeLock = netEqDecodeLock; _netEqDecodeLock = netEqDecodeLock;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// bool HasInternalDTX() // bool HasInternalDTX()
// Used to check if the codec has internal DTX. // Used to check if the codec has internal DTX.
@ -482,12 +444,10 @@ public:
// true if the codec has an internal DTX, e.g. G729, // true if the codec has an internal DTX, e.g. G729,
// false otherwise. // false otherwise.
// //
bool HasInternalDTX() const bool HasInternalDTX() const {
{
return _hasInternalDTX; return _hasInternalDTX;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 GetEstimatedBandwidth() // WebRtc_Word32 GetEstimatedBandwidth()
// Used to get decoder estimated bandwidth. Only iSAC will provide a value. // Used to get decoder estimated bandwidth. Only iSAC will provide a value.
@ -499,7 +459,6 @@ public:
// //
WebRtc_Word32 GetEstimatedBandwidth(); WebRtc_Word32 GetEstimatedBandwidth();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 SetEstimatedBandwidth() // WebRtc_Word32 SetEstimatedBandwidth()
// Used to set estiamted bandwidth sent out of band from other side. Only // Used to set estiamted bandwidth sent out of band from other side. Only
@ -527,11 +486,9 @@ public:
// -1 if fails to get codec specific RED, // -1 if fails to get codec specific RED,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word32 GetRedPayload( WebRtc_Word32 GetRedPayload(WebRtc_UWord8* redPayload,
WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes); WebRtc_Word16* payloadBytes);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 ResetEncoder() // WebRtc_Word16 ResetEncoder()
// By calling this function you would re-initialize the encoder with the // By calling this function you would re-initialize the encoder with the
@ -544,7 +501,6 @@ public:
// //
WebRtc_Word16 ResetEncoder(); WebRtc_Word16 ResetEncoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 ResetEncoder() // WebRtc_Word16 ResetEncoder()
// By calling this function you would re-initialize the decoder with the // By calling this function you would re-initialize the decoder with the
@ -554,9 +510,7 @@ public:
// -1 if failed, // -1 if failed,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word16 ResetDecoder( WebRtc_Word16 ResetDecoder(WebRtc_Word16 payloadType);
WebRtc_Word16 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void DestructEncoder() // void DestructEncoder()
@ -567,7 +521,6 @@ public:
// //
void DestructEncoder(); void DestructEncoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void DestructDecoder() // void DestructDecoder()
// This function is called to delete the decoder instance, if possible, to // This function is called to delete the decoder instance, if possible, to
@ -578,7 +531,6 @@ public:
// //
void DestructDecoder(); void DestructDecoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 SamplesLeftToEncode() // WebRtc_Word16 SamplesLeftToEncode()
// Returns the number of samples required to be able to do encoding. // Returns the number of samples required to be able to do encoding.
@ -588,7 +540,6 @@ public:
// //
WebRtc_Word16 SamplesLeftToEncode(); WebRtc_Word16 SamplesLeftToEncode();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_UWord32 LastEncodedTimestamp() // WebRtc_UWord32 LastEncodedTimestamp()
// Returns the timestamp of the last frame it encoded. // Returns the timestamp of the last frame it encoded.
@ -598,7 +549,6 @@ public:
// //
WebRtc_UWord32 LastEncodedTimestamp() const; WebRtc_UWord32 LastEncodedTimestamp() const;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SetUniqueID() // SetUniqueID()
// Set a unique ID for the codec to be used for tracing and debuging // Set a unique ID for the codec to be used for tracing and debuging
@ -606,9 +556,7 @@ public:
// Input // Input
// -id : A number to identify the codec. // -id : A number to identify the codec.
// //
void SetUniqueID( void SetUniqueID(const WebRtc_UWord32 id);
const WebRtc_UWord32 id);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// IsAudioBufferFresh() // IsAudioBufferFresh()
@ -620,7 +568,6 @@ public:
// //
bool IsAudioBufferFresh() const; bool IsAudioBufferFresh() const;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// UpdateDecoderSampFreq() // UpdateDecoderSampFreq()
// For most of the codecs this function does nothing. It must be // For most of the codecs this function does nothing. It must be
@ -646,13 +593,10 @@ public:
// 0 if succeeded in updating the decoder. // 0 if succeeded in updating the decoder.
// -1 if failed to update. // -1 if failed to update.
// //
virtual WebRtc_Word16 UpdateDecoderSampFreq( virtual WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 /* codecId */) {
WebRtc_Word16 /* codecId */)
{
return 0; return 0;
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// UpdateEncoderSampFreq() // UpdateEncoderSampFreq()
// Call this function to update the encoder sampling frequency. This // Call this function to update the encoder sampling frequency. This
@ -669,9 +613,7 @@ public:
// -1 if failed, or if this is meaningless for the given codec. // -1 if failed, or if this is meaningless for the given codec.
// 0 if succeeded. // 0 if succeeded.
// //
virtual WebRtc_Word16 UpdateEncoderSampFreq( virtual WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 encoderSampFreqHz);
WebRtc_UWord16 encoderSampFreqHz);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// EncoderSampFreq() // EncoderSampFreq()
@ -685,9 +627,7 @@ public:
// -1 if failed to output sampling rate. // -1 if failed to output sampling rate.
// 0 if the sample rate is returned successfully. // 0 if the sample rate is returned successfully.
// //
virtual WebRtc_Word16 EncoderSampFreq( virtual WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
WebRtc_UWord16& sampFreqHz);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word32 ConfigISACBandwidthEstimator() // WebRtc_Word32 ConfigISACBandwidthEstimator()
@ -715,9 +655,7 @@ public:
// //
virtual WebRtc_Word32 ConfigISACBandwidthEstimator( virtual WebRtc_Word32 ConfigISACBandwidthEstimator(
const WebRtc_UWord8 initFrameSizeMsec, const WebRtc_UWord8 initFrameSizeMsec,
const WebRtc_UWord16 initRateBitPerSec, const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
const bool enforceFrameSize);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SetISACMaxPayloadSize() // SetISACMaxPayloadSize()
@ -737,7 +675,6 @@ public:
virtual WebRtc_Word32 SetISACMaxPayloadSize( virtual WebRtc_Word32 SetISACMaxPayloadSize(
const WebRtc_UWord16 maxPayloadLenBytes); const WebRtc_UWord16 maxPayloadLenBytes);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SetISACMaxRate() // SetISACMaxRate()
// Set the maximum instantaneous rate of iSAC. For a payload of B bits // Set the maximum instantaneous rate of iSAC. For a payload of B bits
@ -753,9 +690,7 @@ public:
// -1 if failed to set the maximum rate. // -1 if failed to set the maximum rate.
// 0 if the maximum rate is set successfully. // 0 if the maximum rate is set successfully.
// //
virtual WebRtc_Word32 SetISACMaxRate( virtual WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
const WebRtc_UWord32 maxRateBitPerSec);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// SaveDecoderParamS() // SaveDecoderParamS()
@ -765,20 +700,14 @@ public:
// -codecParams : pointer to a struct where the parameters of // -codecParams : pointer to a struct where the parameters of
// decoder is stored in. // decoder is stored in.
// //
void SaveDecoderParam( void SaveDecoderParam(const WebRtcACMCodecParams* codecParams);
const WebRtcACMCodecParams* codecParams);
WebRtc_Word32 FrameSize() {
WebRtc_Word32 FrameSize()
{
return _frameLenSmpl; return _frameLenSmpl;
} }
void SetIsMaster(bool isMaster); void SetIsMaster(bool isMaster);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// REDPayloadISAC() // REDPayloadISAC()
// This is an iSAC-specific function. The function is called to get RED // This is an iSAC-specific function. The function is called to get RED
@ -803,8 +732,7 @@ public:
// is returned. // is returned.
// //
// //
virtual WebRtc_Word16 REDPayloadISAC( virtual WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate,
const WebRtc_Word32 isacRate,
const WebRtc_Word16 isacBwEstimate, const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload, WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenBytes); WebRtc_Word16* payloadLenBytes);
@ -834,8 +762,7 @@ protected:
// See Encode() for the description of function, input(s)/output(s) and // See Encode() for the description of function, input(s)/output(s) and
// return value. // return value.
// //
WebRtc_Word16 EncodeSafe( WebRtc_Word16 EncodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitStreamLenByte,
WebRtc_UWord32* timeStamp, WebRtc_UWord32* timeStamp,
WebRtcACMEncodingType* encodingType); WebRtcACMEncodingType* encodingType);
@ -844,8 +771,7 @@ protected:
// See Decode() for the description of function, input(s)/output(s) and // See Decode() for the description of function, input(s)/output(s) and
// return value. // return value.
// //
virtual WebRtc_Word16 DecodeSafe( virtual WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
@ -855,8 +781,7 @@ protected:
// See Add10MsSafe() for the description of function, input(s)/output(s) // See Add10MsSafe() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
virtual WebRtc_Word32 Add10MsDataSafe( virtual WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timeStamp,
const WebRtc_UWord32 timeStamp,
const WebRtc_Word16* data, const WebRtc_Word16* data,
const WebRtc_UWord16 length, const WebRtc_UWord16 length,
const WebRtc_UWord8 audioChannel); const WebRtc_UWord8 audioChannel);
@ -865,16 +790,14 @@ protected:
// See RegisterInNetEq() for the description of function, // See RegisterInNetEq() for the description of function,
// input(s)/output(s) and return value. // input(s)/output(s) and return value.
// //
virtual WebRtc_Word32 CodecDef( virtual WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst) = 0; const CodecInst& codecInst) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See EncoderParam() for the description of function, input(s)/output(s) // See EncoderParam() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 EncoderParamsSafe( WebRtc_Word16 EncoderParamsSafe(WebRtcACMCodecParams *encParams);
WebRtcACMCodecParams *encParams);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See DecoderParam for the description of function, input(s)/output(s) // See DecoderParam for the description of function, input(s)/output(s)
@ -890,8 +813,7 @@ protected:
// can be registered as receive codec. Hence two payloads are associated // can be registered as receive codec. Hence two payloads are associated
// with a single codec instance. // with a single codec instance.
// //
virtual bool DecoderParamsSafe( virtual bool DecoderParamsSafe(WebRtcACMCodecParams *decParams,
WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
@ -904,24 +826,21 @@ protected:
// See InitEncoder() for the description of function, input(s)/output(s) // See InitEncoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 InitEncoderSafe( WebRtc_Word16 InitEncoderSafe(WebRtcACMCodecParams *codecParams,
WebRtcACMCodecParams *codecParams,
bool forceInitialization); bool forceInitialization);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See InitDecoder() for the description of function, input(s)/output(s) // See InitDecoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 InitDecoderSafe( WebRtc_Word16 InitDecoderSafe(WebRtcACMCodecParams *codecParams,
WebRtcACMCodecParams *codecParams,
bool forceInitialization); bool forceInitialization);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See ResetDecoder() for the description of function, input(s)/output(s) // See ResetDecoder() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
WebRtc_Word16 ResetDecoderSafe( WebRtc_Word16 ResetDecoderSafe(WebRtc_Word16 payloadType);
WebRtc_Word16 payloadType);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See DestructEncoder() for the description of function, // See DestructEncoder() for the description of function,
@ -941,51 +860,47 @@ protected:
// //
// Any codec that can change the bit-rate has to implement this. // Any codec that can change the bit-rate has to implement this.
// //
virtual WebRtc_Word16 SetBitRateSafe( virtual WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRateBPS);
const WebRtc_Word32 bitRateBPS);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See GetEstimatedBandwidth() for the description of function, input(s)/output(s) // See GetEstimatedBandwidth() for the description of function,
// and return value. // input(s)/output(s) and return value.
// //
virtual WebRtc_Word32 GetEstimatedBandwidthSafe(); virtual WebRtc_Word32 GetEstimatedBandwidthSafe();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See SetEstimatedBandwidth() for the description of function, input(s)/output(s) // See SetEstimatedBandwidth() for the description of function,
// and return value. // input(s)/output(s) and return value.
// //
virtual WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth); virtual WebRtc_Word32 SetEstimatedBandwidthSafe(
WebRtc_Word32 estimatedBandwidth);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See GetRedPayload() for the description of function, input(s)/output(s) // See GetRedPayload() for the description of function, input(s)/output(s)
// and return value. // and return value.
// //
virtual WebRtc_Word32 GetRedPayloadSafe( virtual WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes); WebRtc_Word16* payloadBytes);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See SetVAD() for the description of function, input(s)/output(s) and // See SetVAD() for the description of function, input(s)/output(s) and
// return value. // return value.
// //
WebRtc_Word16 SetVADSafe( WebRtc_Word16 SetVADSafe(const bool enableDTX = true, const bool enableVAD =
const bool enableDTX = true, false,
const bool enableVAD = false,
const ACMVADMode mode = VADNormal); const ACMVADMode mode = VADNormal);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See ReplaceInternalDTX() for the description of function, input and // See ReplaceInternalDTX() for the description of function, input and
// return value. // return value.
// //
virtual WebRtc_Word32 ReplaceInternalDTXSafe( virtual WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
const bool replaceInternalDTX);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// See IsInternalDTXReplaced() for the description of function, input and // See IsInternalDTXReplaced() for the description of function, input and
// return value. // return value.
// //
virtual WebRtc_Word32 IsInternalDTXReplacedSafe( virtual WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
bool* internalDTXReplaced);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 CreateEncoder() // WebRtc_Word16 CreateEncoder()
@ -997,7 +912,6 @@ protected:
// //
WebRtc_Word16 CreateEncoder(); WebRtc_Word16 CreateEncoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 CreateDecoder() // WebRtc_Word16 CreateDecoder()
// Creates the decoder instance. // Creates the decoder instance.
@ -1008,7 +922,6 @@ protected:
// //
WebRtc_Word16 CreateDecoder(); WebRtc_Word16 CreateDecoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 EnableVAD(); // WebRtc_Word16 EnableVAD();
// Enables VAD with the given mode. The VAD instance will be created if // Enables VAD with the given mode. The VAD instance will be created if
@ -1024,7 +937,6 @@ protected:
// //
WebRtc_Word16 EnableVAD(ACMVADMode mode); WebRtc_Word16 EnableVAD(ACMVADMode mode);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 DisableVAD() // WebRtc_Word16 DisableVAD()
// Disables VAD. // Disables VAD.
@ -1035,7 +947,6 @@ protected:
// //
WebRtc_Word16 DisableVAD(); WebRtc_Word16 DisableVAD();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 EnableDTX() // WebRtc_Word16 EnableDTX()
// Enables DTX. This method should be overwritten for codecs which have // Enables DTX. This method should be overwritten for codecs which have
@ -1047,7 +958,6 @@ protected:
// //
virtual WebRtc_Word16 EnableDTX(); virtual WebRtc_Word16 EnableDTX();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 DisableDTX() // WebRtc_Word16 DisableDTX()
// Disables usage of DTX. This method should be overwritten for codecs which // Disables usage of DTX. This method should be overwritten for codecs which
@ -1059,7 +969,6 @@ protected:
// //
virtual WebRtc_Word16 DisableDTX(); virtual WebRtc_Word16 DisableDTX();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalEncode() // WebRtc_Word16 InternalEncode()
// This is a codec-specific function called in EncodeSafe() to actually // This is a codec-specific function called in EncodeSafe() to actually
@ -1075,11 +984,9 @@ protected:
// -1 if failed, // -1 if failed,
// otherwise the length of the bit-stream is returned. // otherwise the length of the bit-stream is returned.
// //
virtual WebRtc_Word16 InternalEncode( virtual WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte) = 0; WebRtc_Word16* bitStreamLenByte) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalInitEncoder() // WebRtc_Word16 InternalInitEncoder()
// This is a codec-specific function called in InitEncoderSafe(), it has to // This is a codec-specific function called in InitEncoderSafe(), it has to
@ -1102,7 +1009,6 @@ protected:
virtual WebRtc_Word16 InternalInitEncoder( virtual WebRtc_Word16 InternalInitEncoder(
WebRtcACMCodecParams *codecParams) = 0; WebRtcACMCodecParams *codecParams) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalInitDecoder() // WebRtc_Word16 InternalInitDecoder()
// This is a codec-specific function called in InitDecoderSafe(), it has to // This is a codec-specific function called in InitDecoderSafe(), it has to
@ -1120,7 +1026,6 @@ protected:
virtual WebRtc_Word16 InternalInitDecoder( virtual WebRtc_Word16 InternalInitDecoder(
WebRtcACMCodecParams *codecParams) = 0; WebRtcACMCodecParams *codecParams) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void IncreaseNoMissedSamples() // void IncreaseNoMissedSamples()
// This method is called to increase the number of samples that are // This method is called to increase the number of samples that are
@ -1130,9 +1035,7 @@ protected:
// -noSamples : the number of overwritten samples is incremented // -noSamples : the number of overwritten samples is incremented
// by this value. // by this value.
// //
void IncreaseNoMissedSamples( void IncreaseNoMissedSamples(const WebRtc_Word16 noSamples);
const WebRtc_Word16 noSamples);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalCreateEncoder() // WebRtc_Word16 InternalCreateEncoder()
@ -1146,7 +1049,6 @@ protected:
// //
virtual WebRtc_Word16 InternalCreateEncoder() = 0; virtual WebRtc_Word16 InternalCreateEncoder() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalCreateDecoder() // WebRtc_Word16 InternalCreateDecoder()
// This is a codec-specific method called in CreateDecoderSafe() it is // This is a codec-specific method called in CreateDecoderSafe() it is
@ -1159,7 +1061,6 @@ protected:
// //
virtual WebRtc_Word16 InternalCreateDecoder() = 0; virtual WebRtc_Word16 InternalCreateDecoder() = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// void InternalDestructEncoderInst() // void InternalDestructEncoderInst()
// This is a codec-specific method, used in conferencing, called from // This is a codec-specific method, used in conferencing, called from
@ -1175,9 +1076,7 @@ protected:
// -1 if failed, // -1 if failed,
// 0 if succeeded. // 0 if succeeded.
// //
virtual void InternalDestructEncoderInst( virtual void InternalDestructEncoderInst(void* ptrInst) = 0;
void* ptrInst) = 0;
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 InternalResetEncoder() // WebRtc_Word16 InternalResetEncoder()
@ -1194,8 +1093,6 @@ protected:
// //
virtual WebRtc_Word16 InternalResetEncoder(); virtual WebRtc_Word16 InternalResetEncoder();
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// WebRtc_Word16 ProcessFrameVADDTX() // WebRtc_Word16 ProcessFrameVADDTX()
// This function is called when a full frame of audio is available. It will // This function is called when a full frame of audio is available. It will
@ -1226,12 +1123,10 @@ protected:
// -1 if failed, // -1 if failed,
// 0 if succeeded. // 0 if succeeded.
// //
WebRtc_Word16 ProcessFrameVADDTX( WebRtc_Word16 ProcessFrameVADDTX(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitStreamLenByte,
WebRtc_Word16* samplesProcessed); WebRtc_Word16* samplesProcessed);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// CanChangeEncodingParam() // CanChangeEncodingParam()
// Check if the codec parameters can be changed. In conferencing normally // Check if the codec parameters can be changed. In conferencing normally
@ -1243,7 +1138,6 @@ protected:
// //
virtual bool CanChangeEncodingParam(CodecInst& codecInst); virtual bool CanChangeEncodingParam(CodecInst& codecInst);
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// CurrentRate() // CurrentRate()
// Call to get the current encoding rate of the encoder. This function // Call to get the current encoding rate of the encoder. This function
@ -1254,14 +1148,11 @@ protected:
// Output: // Output:
// -rateBitPerSec : the current target rate of the codec. // -rateBitPerSec : the current target rate of the codec.
// //
virtual void CurrentRate( virtual void CurrentRate(WebRtc_Word32& /* rateBitPerSec */) {
WebRtc_Word32& /* rateBitPerSec */)
{
return; return;
} }
virtual void SaveDecoderParamSafe( virtual void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
const WebRtcACMCodecParams* codecParams);
// &_inAudio[_inAudioIxWrite] always point to where new audio can be // &_inAudio[_inAudioIxWrite] always point to where new audio can be
// written to // written to

View File

@ -16,24 +16,9 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_GSMFR #ifdef WEBRTC_CODEC_GSMFR
// NOTE! GSM-FR is not included in the open-source package. The following // NOTE! GSM-FR is not included in the open-source package. Modify this file
// interface file is needed: // or your codec API to match the function calls and names of used GSM-FR API
// // file.
// /modules/audio_coding/codecs/gsmfr/main/interface/gsmfr_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcGSMFR_CreateEnc(GSMFR_encinst_t_** inst);
// int16_t WebRtcGSMFR_CreateDec(GSMFR_decinst_t_** inst);
// int16_t WebRtcGSMFR_FreeEnc(GSMFR_encinst_t_* inst);
// int16_t WebRtcGSMFR_FreeDec(GSMFR_decinst_t_* inst);
// int16_t WebRtcGSMFR_Encode(GSMFR_encinst_t_* encInst, int16_t* input,
// int16_t len, int16_t* output);
// int16_t WebRtcGSMFR_EncoderInit(GSMFR_encinst_t_* encInst, int16_t mode);
// int16_t WebRtcGSMFR_Decode(GSMFR_decinst_t_* decInst);
// int16_t WebRtcGSMFR_DecodeBwe(GSMFR_decinst_t_* decInst, int16_t* input);
// int16_t WebRtcGSMFR_DecodePlc(GSMFR_decinst_t_* decInst);
// int16_t WebRtcGSMFR_DecoderInit(GSMFR_decinst_t_* decInst);
#include "gsmfr_interface.h" #include "gsmfr_interface.h"
#endif #endif
@ -47,240 +32,157 @@ ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codecID */)
return; return;
} }
ACMGSMFR::~ACMGSMFR() {
ACMGSMFR::~ACMGSMFR()
{
return; return;
} }
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMGSMFR::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::EnableDTX() {
WebRtc_Word16
ACMGSMFR::EnableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::DisableDTX() {
WebRtc_Word16
ACMGSMFR::DisableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMGSMFR::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMGSMFR::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMGSMFR::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
ACMGenericCodec*
ACMGSMFR::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
WebRtc_Word16
ACMGSMFR::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMGSMFR::DestructEncoderSafe() {
void
ACMGSMFR::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
WebRtc_Word16
ACMGSMFR::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMGSMFR::DestructDecoderSafe() {
void
ACMGSMFR::DestructDecoderSafe()
{
return; return;
} }
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMGSMFR::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMGSMFR::ACMGSMFR( ACMGSMFR::ACMGSMFR(WebRtc_Word16 codecID)
WebRtc_Word16 codecID): : _encoderInstPtr(NULL),
_encoderInstPtr(NULL), _decoderInstPtr(NULL) {
_decoderInstPtr(NULL)
{
_codecID = codecID; _codecID = codecID;
_hasInternalDTX = true; _hasInternalDTX = true;
return; return;
} }
ACMGSMFR::~ACMGSMFR() {
ACMGSMFR::~ACMGSMFR() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcGSMFR_FreeEnc(_encoderInstPtr); WebRtcGSMFR_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcGSMFR_FreeDec(_decoderInstPtr); WebRtcGSMFR_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMGSMFR::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream); &_inAudio[_inAudioIxRead],
_frameLenSmpl,
(WebRtc_Word16*) bitStream);
// increment the read index this tell the caller that how far // increment the read index this tell the caller that how far
// we have gone forward in reading the audio buffer // we have gone forward in reading the audio buffer
_inAudioIxRead += _frameLenSmpl; _inAudioIxRead += _frameLenSmpl;
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMGSMFR::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMGSMFR::EnableDTX() {
WebRtc_Word16 if (_dtxEnabled) {
ACMGSMFR::EnableDTX()
{
if(_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) {
else if(_encoderExist) if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) {
{
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"EnableDTX: cannot init encoder for GSMFR"); "EnableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
WebRtc_Word16 ACMGSMFR::DisableDTX() {
WebRtc_Word16 if (!_dtxEnabled) {
ACMGSMFR::DisableDTX()
{
if(!_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) {
else if(_encoderExist) if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) {
{
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"DisableDTX: cannot init encoder for GSMFR"); "DisableDTX: cannot init encoder for GSMFR");
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
} }
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16 if (WebRtcGSMFR_EncoderInit(_encoderInstPtr,
ACMGSMFR::InternalInitEncoder( ((codecParams->enableDTX) ? 1 : 0)) < 0) {
WebRtcACMCodecParams* codecParams)
{
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: cannot init encoder for GSMFR"); "InternalInitEncoder: cannot init encoder for GSMFR");
} }
return 0; return 0;
} }
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMGSMFR::InternalInitDecoder( if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0) {
WebRtcACMCodecParams* /* codecParams */)
{
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: cannot init decoder for GSMFR"); "InternalInitDecoder: cannot init decoder for GSMFR");
return -1; return -1;
@ -288,14 +190,9 @@ ACMGSMFR::InternalInitDecoder(
return 0; return 0;
} }
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMGSMFR::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodecDef: decoder is not initialized for GSMFR"); "CodecDef: decoder is not initialized for GSMFR");
return -1; return -1;
@ -304,25 +201,18 @@ ACMGSMFR::CodecDef(
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION." // "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
// Then call NetEQ to add the codec to it's // Then call NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 8000); 8000);
SET_GSMFR_FUNCTIONS((codecDef)); SET_GSMFR_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
ACMGenericCodec*
ACMGSMFR::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
WebRtc_Word16 if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) {
ACMGSMFR::InternalCreateEncoder()
{
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for GSMFR encoder"); "InternalCreateEncoder: cannot create instance for GSMFR encoder");
return -1; return -1;
@ -330,12 +220,8 @@ ACMGSMFR::InternalCreateEncoder()
return 0; return 0;
} }
void ACMGSMFR::DestructEncoderSafe() {
void if (_encoderInstPtr != NULL) {
ACMGSMFR::DestructEncoderSafe()
{
if(_encoderInstPtr != NULL)
{
WebRtcGSMFR_FreeEnc(_encoderInstPtr); WebRtcGSMFR_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
@ -343,12 +229,8 @@ ACMGSMFR::DestructEncoderSafe()
_encoderInitialized = false; _encoderInitialized = false;
} }
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
WebRtc_Word16 if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) {
ACMGSMFR::InternalCreateDecoder()
{
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for GSMFR decoder"); "InternalCreateDecoder: cannot create instance for GSMFR decoder");
return -1; return -1;
@ -356,12 +238,8 @@ ACMGSMFR::InternalCreateDecoder()
return 0; return 0;
} }
void ACMGSMFR::DestructDecoderSafe() {
void if (_decoderInstPtr != NULL) {
ACMGSMFR::DestructDecoderSafe()
{
if(_decoderInstPtr != NULL)
{
WebRtcGSMFR_FreeDec(_decoderInstPtr); WebRtcGSMFR_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@ -369,13 +247,8 @@ ACMGSMFR::DestructDecoderSafe()
_decoderInitialized = false; _decoderInitialized = false;
} }
void ACMGSMFR::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMGSMFR::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst); WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst);
} }
return; return;

View File

@ -19,34 +19,28 @@ struct GSMFR_decinst_t_;
namespace webrtc { namespace webrtc {
class ACMGSMFR : public ACMGenericCodec class ACMGSMFR : public ACMGenericCodec {
{
public: public:
ACMGSMFR(WebRtc_Word16 codecID); ACMGSMFR(WebRtc_Word16 codecID);
~ACMGSMFR(); ~ACMGSMFR();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -57,8 +51,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();

View File

@ -19,8 +19,7 @@
#include "ilbc.h" #include "ilbc.h"
#endif #endif
namespace webrtc namespace webrtc {
{
#ifndef WEBRTC_CODEC_ILBC #ifndef WEBRTC_CODEC_ILBC
@ -30,145 +29,94 @@ ACMILBC::ACMILBC(WebRtc_Word16 /* codecID */)
return; return;
} }
ACMILBC::~ACMILBC() {
ACMILBC::~ACMILBC()
{
return; return;
} }
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMILBC::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMILBC::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMILBC::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 ACMILBC::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMILBC::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
WebRtc_Word32 const CodecInst& /* codecInst */) {
ACMILBC::CodecDef(
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMILBC::CreateInstance(void) {
ACMGenericCodec*
ACMILBC::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
WebRtc_Word16
ACMILBC::InternalCreateEncoder()
{
return -1; return -1;
} }
void ACMILBC::DestructEncoderSafe() {
void
ACMILBC::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
WebRtc_Word16
ACMILBC::InternalCreateDecoder()
{
return -1; return -1;
} }
void ACMILBC::DestructDecoderSafe() {
void
ACMILBC::DestructDecoderSafe()
{
return; return;
} }
void ACMILBC::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMILBC::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */)
{
return -1; return -1;
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMILBC::ACMILBC(WebRtc_Word16 codecID)
ACMILBC::ACMILBC( : _encoderInstPtr(NULL),
WebRtc_Word16 codecID): _decoderInstPtr(NULL) {
_encoderInstPtr(NULL),
_decoderInstPtr(NULL)
{
_codecID = codecID; _codecID = codecID;
return; return;
} }
ACMILBC::~ACMILBC() {
ACMILBC::~ACMILBC() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcIlbcfix_EncoderFree(_encoderInstPtr); WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcIlbcfix_DecoderFree(_decoderInstPtr); WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitStream,
WebRtc_Word16 WebRtc_Word16* bitStreamLenByte) {
ACMILBC::InternalEncode(
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr, *bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream); &_inAudio[_inAudioIxRead],
if (*bitStreamLenByte < 0) _frameLenSmpl,
{ (WebRtc_Word16*) bitStream);
if (*bitStreamLenByte < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalEncode: error in encode for ILBC"); "InternalEncode: error in encode for ILBC");
return -1; return -1;
@ -179,78 +127,51 @@ ACMILBC::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMILBC::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16
ACMILBC::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// initialize with a correct processing block length // initialize with a correct processing block length
if ((160 == (codecParams->codecInstant).pacsize) || if ((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) (320 == (codecParams->codecInstant).pacsize)) {
{
// processing block of 20ms // processing block of 20ms
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20); return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
} } else if ((240 == (codecParams->codecInstant).pacsize) ||
else if((240 == (codecParams->codecInstant).pacsize) || (480 == (codecParams->codecInstant).pacsize)) {
(480 == (codecParams->codecInstant).pacsize))
{
// processing block of 30ms // processing block of 30ms
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30); return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
} } else {
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitEncoder: invalid processing block"); "InternalInitEncoder: invalid processing block");
return -1; return -1;
} }
} }
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
WebRtc_Word16
ACMILBC::InternalInitDecoder(
WebRtcACMCodecParams* codecParams)
{
// initialize with a correct processing block length // initialize with a correct processing block length
if ((160 == (codecParams->codecInstant).pacsize) || if ((160 == (codecParams->codecInstant).pacsize) ||
(320 == (codecParams->codecInstant).pacsize)) (320 == (codecParams->codecInstant).pacsize)) {
{
// processing block of 20ms // processing block of 20ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20); return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
} } else if ((240 == (codecParams->codecInstant).pacsize) ||
else if((240 == (codecParams->codecInstant).pacsize) || (480 == (codecParams->codecInstant).pacsize)) {
(480 == (codecParams->codecInstant).pacsize))
{
// processing block of 30ms // processing block of 30ms
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30); return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30);
} } else {
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalInitDecoder: invalid processing block"); "InternalInitDecoder: invalid processing block");
return -1; return -1;
} }
} }
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMILBC::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"CodeDef: decoder not initialized for ILBC"); "CodeDef: decoder not initialized for ILBC");
return -1; return -1;
@ -259,25 +180,18 @@ ACMILBC::CodecDef(
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION." // "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
// Then return the structure back to NetEQ to add the codec to it's // Then return the structure back to NetEQ to add the codec to it's
// database. // database.
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, _decoderInstPtr,
_decoderInstPtr, 8000); 8000);
SET_ILBC_FUNCTIONS((codecDef)); SET_ILBC_FUNCTIONS((codecDef));
return 0; return 0;
} }
ACMGenericCodec* ACMILBC::CreateInstance(void) {
ACMGenericCodec*
ACMILBC::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
WebRtc_Word16 if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) {
ACMILBC::InternalCreateEncoder()
{
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateEncoder: cannot create instance for ILBC encoder"); "InternalCreateEncoder: cannot create instance for ILBC encoder");
return -1; return -1;
@ -285,25 +199,17 @@ ACMILBC::InternalCreateEncoder()
return 0; return 0;
} }
void ACMILBC::DestructEncoderSafe() {
void
ACMILBC::DestructEncoderSafe()
{
_encoderInitialized = false; _encoderInitialized = false;
_encoderExist = false; _encoderExist = false;
if(_encoderInstPtr != NULL) if (_encoderInstPtr != NULL) {
{
WebRtcIlbcfix_EncoderFree(_encoderInstPtr); WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
} }
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
WebRtc_Word16 if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) {
ACMILBC::InternalCreateDecoder()
{
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"InternalCreateDecoder: cannot create instance for ILBC decoder"); "InternalCreateDecoder: cannot create instance for ILBC decoder");
return -1; return -1;
@ -311,45 +217,29 @@ ACMILBC::InternalCreateDecoder()
return 0; return 0;
} }
void ACMILBC::DestructDecoderSafe() {
void
ACMILBC::DestructDecoderSafe()
{
_decoderInitialized = false; _decoderInitialized = false;
_decoderExist = false; _decoderExist = false;
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcIlbcfix_DecoderFree(_decoderInstPtr); WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
} }
void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMILBC::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst); WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst);
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) {
ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate)
{
// Check that rate is valid. No need to store the value // Check that rate is valid. No need to store the value
if (rate == 13300) if (rate == 13300) {
{
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30); WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
} } else if (rate == 15200) {
else if (rate == 15200)
{
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20); WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
} } else {
else
{
return -1; return -1;
} }
_encoderParams.codecInstant.rate = rate; _encoderParams.codecInstant.rate = rate;

View File

@ -17,42 +17,33 @@
struct iLBC_encinst_t_; struct iLBC_encinst_t_;
struct iLBC_decinst_t_; struct iLBC_decinst_t_;
namespace webrtc namespace webrtc {
{
class ACMILBC : public ACMGenericCodec class ACMILBC : public ACMGenericCodec {
{
public: public:
ACMILBC(WebRtc_Word16 codecID); ACMILBC(WebRtc_Word16 codecID);
~ACMILBC(); ~ACMILBC();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
WebRtc_Word16 SetBitRateSafe(
const WebRtc_Word32 rate);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -62,8 +53,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
iLBC_encinst_t_* _encoderInstPtr; iLBC_encinst_t_* _encoderInstPtr;
iLBC_decinst_t_* _decoderInstPtr; iLBC_decinst_t_* _decoderInstPtr;

File diff suppressed because it is too large Load Diff

View File

@ -13,129 +13,104 @@
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
struct ACMISACInst; struct ACMISACInst;
enum iSACCodingMode {ADAPTIVE, CHANNEL_INDEPENDENT}; enum iSACCodingMode {
ADAPTIVE,
CHANNEL_INDEPENDENT
};
class ACMISAC : public ACMGenericCodec {
class ACMISAC : public ACMGenericCodec
{
public: public:
ACMISAC(WebRtc_Word16 codecID); ACMISAC(WebRtc_Word16 codecID);
~ACMISAC(); ~ACMISAC();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 DeliverCachedIsacData( WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16* bitStreamLenByte,
WebRtc_UWord32* timestamp, WebRtc_UWord32* timestamp,
WebRtcACMEncodingType* encodingType, WebRtcACMEncodingType* encodingType,
const WebRtc_UWord16 isacRate, const WebRtc_UWord16 isacRate,
const WebRtc_UWord8 isacBWestimate); const WebRtc_UWord8 isacBWestimate);
WebRtc_Word16 DeliverCachedData( WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitStream */,
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */, WebRtc_Word16* /* bitStreamLenByte */,
WebRtc_UWord32* /* timestamp */, WebRtc_UWord32* /* timestamp */,
WebRtcACMEncodingType* /* encodingType */) WebRtcACMEncodingType* /* encodingType */) {
{
return -1; return -1;
} }
WebRtc_Word16 UpdateDecoderSampFreq( WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codecId);
WebRtc_Word16 codecId);
WebRtc_Word16 UpdateEncoderSampFreq( WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 sampFreqHz);
WebRtc_UWord16 sampFreqHz);
WebRtc_Word16 EncoderSampFreq( WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
WebRtc_UWord16& sampFreqHz);
WebRtc_Word32 ConfigISACBandwidthEstimator( WebRtc_Word32 ConfigISACBandwidthEstimator(
const WebRtc_UWord8 initFrameSizeMsec, const WebRtc_UWord8 initFrameSizeMsec,
const WebRtc_UWord16 initRateBitPerSec, const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
const bool enforceFrameSize);
WebRtc_Word32 SetISACMaxPayloadSize( WebRtc_Word32 SetISACMaxPayloadSize(const WebRtc_UWord16 maxPayloadLenBytes);
const WebRtc_UWord16 maxPayloadLenBytes);
WebRtc_Word32 SetISACMaxRate( WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
const WebRtc_UWord32 maxRateBitPerSec);
WebRtc_Word16 REDPayloadISAC( WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate,
const WebRtc_Word32 isacRate,
const WebRtc_Word16 isacBwEstimate, const WebRtc_Word16 isacBwEstimate,
WebRtc_UWord8* payload, WebRtc_UWord8* payload,
WebRtc_Word16* payloadLenBytes); WebRtc_Word16* payloadLenBytes);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio,
WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
void DestructDecoderSafe(); void DestructDecoderSafe();
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRate);
const WebRtc_Word32 bitRate);
WebRtc_Word32 GetEstimatedBandwidthSafe(); WebRtc_Word32 GetEstimatedBandwidthSafe();
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth); WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
WebRtc_Word32 GetRedPayloadSafe( WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
WebRtc_UWord8* redPayload,
WebRtc_Word16* payloadBytes); WebRtc_Word16* payloadBytes);
WebRtc_Word16 InternalCreateEncoder(); WebRtc_Word16 InternalCreateEncoder();
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 Transcode( WebRtc_Word16 Transcode(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream, WebRtc_Word16* bitStreamLenByte, WebRtc_Word16 qBWE,
WebRtc_Word16* bitStreamLenByte, WebRtc_Word32 rate, bool isRED);
WebRtc_Word16 qBWE,
WebRtc_Word32 rate,
bool isRED);
void CurrentRate(WebRtc_Word32& rateBitPerSec); void CurrentRate(WebRtc_Word32& rateBitPerSec);
void UpdateFrameLen(); void UpdateFrameLen();
bool DecoderParamsSafe( bool DecoderParamsSafe(WebRtcACMCodecParams *decParams,
WebRtcACMCodecParams *decParams,
const WebRtc_UWord8 payloadType); const WebRtc_UWord8 payloadType);
void SaveDecoderParamSafe( void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
const WebRtcACMCodecParams* codecParams);
ACMISACInst* _codecInstPtr; ACMISACInst* _codecInstPtr;
bool _isEncInitialized; bool _isEncInitialized;
iSACCodingMode _isacCodingMode; iSACCodingMode _isacCodingMode;
bool _enforceFrameSize; bool _enforceFrameSize;

View File

@ -13,8 +13,7 @@
#include "engine_configurations.h" #include "engine_configurations.h"
namespace webrtc namespace webrtc {
{
#ifdef WEBRTC_CODEC_ISAC #ifdef WEBRTC_CODEC_ISAC
#define ACM_ISAC_CREATE WebRtcIsac_Create #define ACM_ISAC_CREATE WebRtcIsac_Create

File diff suppressed because it is too large Load Diff

View File

@ -29,8 +29,7 @@ enum ACMSpeechType;
#define MAX_NUM_SLAVE_NETEQ 1 #define MAX_NUM_SLAVE_NETEQ 1
class ACMNetEQ class ACMNetEQ {
{
public: public:
// Constructor of the class // Constructor of the class
ACMNetEQ(); ACMNetEQ();
@ -62,8 +61,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 RecIn( WebRtc_Word32 RecIn(const WebRtc_UWord8* incomingPayload,
const WebRtc_UWord8* incomingPayload,
const WebRtc_Word32 payloadLength, const WebRtc_Word32 payloadLength,
const WebRtcRTPHeader& rtpInfo); const WebRtcRTPHeader& rtpInfo);
@ -78,8 +76,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if NetEQ returned an error. // -1 if NetEQ returned an error.
// //
WebRtc_Word32 RecOut( WebRtc_Word32 RecOut(AudioFrame& audioFrame);
AudioFrame& audioFrame);
// //
// AddCodec() // AddCodec()
@ -94,9 +91,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 AddCodec( WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codecDef, bool toMaster = true);
WebRtcNetEQ_CodecDef *codecDef,
bool toMaster = true);
// //
// AllocatePacketBuffer() // AllocatePacketBuffer()
@ -109,8 +104,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 AllocatePacketBuffer( WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* usedCodecs,
const WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 noOfCodecs);
// //
@ -123,8 +117,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetExtraDelay( WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delayInMS);
const WebRtc_Word32 delayInMS);
// //
// SetAVTPlayout() // SetAVTPlayout()
@ -136,8 +129,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetAVTPlayout( WebRtc_Word32 SetAVTPlayout(const bool enable);
const bool enable);
// //
// AVTPlayout() // AVTPlayout()
@ -167,8 +159,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 SetPlayoutMode( WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode);
const AudioPlayoutMode mode);
// //
// PlayoutMode() // PlayoutMode()
@ -188,8 +179,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// <0 if NetEQ returned an error. // <0 if NetEQ returned an error.
// //
WebRtc_Word32 NetworkStatistics( WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const;
ACMNetworkStatistics* statistics) const;
// //
// VADMode() // VADMode()
@ -209,8 +199,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if an error occurred. // -1 if an error occurred.
// //
WebRtc_Word16 SetVADMode( WebRtc_Word16 SetVADMode(const ACMVADMode mode);
const ACMVADMode mode);
// //
// DecodeLock() // DecodeLock()
@ -218,8 +207,7 @@ public:
// //
// Return value : Pointer to the decode lock. // Return value : Pointer to the decode lock.
// //
RWLockWrapper* DecodeLock() const RWLockWrapper* DecodeLock() const {
{
return _decodeLock; return _decodeLock;
} }
@ -242,10 +230,7 @@ public:
// Return value : 0 if ok. // Return value : 0 if ok.
// -1 if an error occurred. // -1 if an error occurred.
// //
WebRtc_Word16 RemoveCodec( WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codecIdx, bool isStereo = false);
WebRtcNetEQDecoder codecIdx,
bool isStereo = false);
// //
// SetBackgroundNoiseMode() // SetBackgroundNoiseMode()
@ -258,8 +243,7 @@ public:
// Return value : 0 if succeeded, // Return value : 0 if succeeded,
// -1 if failed to set the mode. // -1 if failed to set the mode.
// //
WebRtc_Word16 SetBackgroundNoiseMode( WebRtc_Word16 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
const ACMBackgroundNoiseMode mode);
// //
// BackgroundNoiseMode() // BackgroundNoiseMode()
@ -267,27 +251,25 @@ public:
// //
// Return value : The mode of background noise. // Return value : The mode of background noise.
// //
WebRtc_Word16 BackgroundNoiseMode( WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
ACMBackgroundNoiseMode& mode);
void SetUniqueId( void SetUniqueId(WebRtc_Word32 id);
WebRtc_Word32 id);
WebRtc_Word32 PlayoutTimestamp( WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
WebRtc_UWord32& timestamp);
void SetReceivedStereo( void SetReceivedStereo(bool receivedStereo);
bool receivedStereo);
WebRtc_UWord8 NumSlaves(); WebRtc_UWord8 NumSlaves();
enum JB {masterJB = 0, slaveJB = 1}; enum JB {
masterJB = 0,
slaveJB = 1
};
// Delete all slaves. // Delete all slaves.
void RemoveSlaves(); void RemoveSlaves();
WebRtc_Word16 AddSlave( WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* usedCodecs,
const WebRtcNetEQDecoder* usedCodecs,
WebRtc_Word16 noOfCodecs); WebRtc_Word16 noOfCodecs);
private: private:
@ -304,18 +286,13 @@ private:
// Output: // Output:
// - rtpPacket : The RTP packet. // - rtpPacket : The RTP packet.
// //
static void RTPPack( static void RTPPack(WebRtc_Word16* rtpPacket, const WebRtc_Word8* payload,
WebRtc_Word16* rtpPacket,
const WebRtc_Word8* payload,
const WebRtc_Word32 payloadLengthW8, const WebRtc_Word32 payloadLengthW8,
const WebRtcRTPHeader& rtpInfo); const WebRtcRTPHeader& rtpInfo);
void LogError( void LogError(const char* neteqFuncName, const WebRtc_Word16 idx) const;
const char* neteqFuncName,
const WebRtc_Word16 idx) const;
WebRtc_Word16 InitByIdxSafe( WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx);
const WebRtc_Word16 idx);
// EnableVAD() // EnableVAD()
// Enable VAD. // Enable VAD.
@ -325,8 +302,7 @@ private:
// //
WebRtc_Word16 EnableVAD(); WebRtc_Word16 EnableVAD();
WebRtc_Word16 EnableVADByIdxSafe( WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx);
const WebRtc_Word16 idx);
WebRtc_Word16 AllocatePacketBufferByIdxSafe( WebRtc_Word16 AllocatePacketBufferByIdxSafe(
const WebRtcNetEQDecoder* usedCodecs, const WebRtcNetEQDecoder* usedCodecs,

View File

@ -90,7 +90,6 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
} }
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) { ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
_codecID = codecID; _codecID = codecID;
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID); _samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);

View File

@ -13,37 +13,30 @@
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMPCM16B : public ACMGenericCodec class ACMPCM16B : public ACMGenericCodec {
{
public: public:
ACMPCM16B(WebRtc_Word16 codecID); ACMPCM16B(WebRtc_Word16 codecID);
~ACMPCM16B(); ~ACMPCM16B();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -54,8 +47,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);

View File

@ -13,37 +13,30 @@
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMPCMA : public ACMGenericCodec class ACMPCMA : public ACMGenericCodec {
{
public: public:
ACMPCMA(WebRtc_Word16 codecID); ACMPCMA(WebRtc_Word16 codecID);
~ACMPCMA(); ~ACMPCMA();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -54,8 +47,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
}; };

View File

@ -13,37 +13,30 @@
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMPCMU : public ACMGenericCodec class ACMPCMU : public ACMGenericCodec {
{
public: public:
ACMPCMU(WebRtc_Word16 codecID); ACMPCMU(WebRtc_Word16 codecID);
~ACMPCMU(); ~ACMPCMU();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -54,8 +47,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length); void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
}; };

View File

@ -15,71 +15,48 @@
#include "webrtc_neteq.h" #include "webrtc_neteq.h"
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
namespace webrtc namespace webrtc {
{
ACMRED::ACMRED(WebRtc_Word16 codecID) ACMRED::ACMRED(WebRtc_Word16 codecID) {
{
_codecID = codecID; _codecID = codecID;
} }
ACMRED::~ACMRED() {
ACMRED::~ACMRED()
{
return; return;
} }
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 WebRtc_Word16* /* bitStreamLenByte */) {
ACMRED::InternalEncode(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
// RED is never used as an encoder // RED is never used as an encoder
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitStream */,
WebRtc_Word16
ACMRED::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 ACMRED::InternalInitEncoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMRED::InternalInitEncoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization, // This codec does not need initialization,
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMRED::InternalInitDecoder(
WebRtc_Word16 WebRtcACMCodecParams* /* codecParams */) {
ACMRED::InternalInitDecoder(
WebRtcACMCodecParams* /* codecParams */)
{
// This codec does not need initialization, // This codec does not need initialization,
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtc_Word32 const CodecInst& codecInst) {
ACMRED::CodecDef( if (!_decoderInitialized) {
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
// Todo: // Todo:
// log error // log error
return -1; return -1;
@ -94,48 +71,31 @@ ACMRED::CodecDef(
return 0; return 0;
} }
ACMGenericCodec* ACMRED::CreateInstance(void) {
ACMGenericCodec*
ACMRED::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 ACMRED::InternalCreateEncoder() {
WebRtc_Word16
ACMRED::InternalCreateEncoder()
{
// RED has no instance // RED has no instance
return 0; return 0;
} }
WebRtc_Word16 ACMRED::InternalCreateDecoder() {
WebRtc_Word16
ACMRED::InternalCreateDecoder()
{
// RED has no instance // RED has no instance
return 0; return 0;
} }
void ACMRED::InternalDestructEncoderInst(void* /* ptrInst */) {
void
ACMRED::InternalDestructEncoderInst(
void* /* ptrInst */)
{
// RED has no instance // RED has no instance
return; return;
} }
void ACMRED::DestructEncoderSafe() {
void
ACMRED::DestructEncoderSafe()
{
// RED has no instance // RED has no instance
return; return;
} }
void ACMRED::DestructDecoderSafe() void ACMRED::DestructDecoderSafe() {
{
// RED has no instance // RED has no instance
return; return;
} }

View File

@ -13,37 +13,30 @@
#include "acm_generic_codec.h" #include "acm_generic_codec.h"
namespace webrtc namespace webrtc {
{
class ACMRED : public ACMGenericCodec class ACMRED : public ACMGenericCodec {
{
public: public:
ACMRED(WebRtc_Word16 codecID); ACMRED(WebRtc_Word16 codecID);
~ACMRED(); ~ACMRED();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -54,8 +47,7 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
}; };
} // namespace webrtc } // namespace webrtc

View File

@ -17,34 +17,8 @@
#include "webrtc_neteq_help_macros.h" #include "webrtc_neteq_help_macros.h"
#ifdef WEBRTC_CODEC_SPEEX #ifdef WEBRTC_CODEC_SPEEX
// NOTE! Speex is not included in the open-source package. The following // NOTE! Speex is not included in the open-source package. Modify this file or
// interface file is needed: // your codec API to match the function calls and names of used Speex API file.
//
// /modules/audio_coding/codecs/speex/main/interface/speex_interface.h
//
// The API in the header file should match the one below.
//
// int16_t WebRtcSpeex_CreateEnc(SPEEX_encinst_t **SPEEXenc_inst,
// int32_t fs);
// int16_t WebRtcSpeex_FreeEnc(SPEEX_encinst_t *SPEEXenc_inst);
// int16_t WebRtcSpeex_CreateDec(SPEEX_decinst_t **SPEEXdec_inst,
// int32_t fs,
// int16_t enh_enabled);
// int16_t WebRtcSpeex_FreeDec(SPEEX_decinst_t *SPEEXdec_inst);
// int16_t WebRtcSpeex_Encode(SPEEX_encinst_t *SPEEXenc_inst,
// int16_t *speechIn,
// int32_t rate);
// int16_t WebRtcSpeex_EncoderInit(SPEEX_encinst_t *SPEEXenc_inst,
// int16_t vbr, int16_t complexity,
// int16_t vad_enable);
// int16_t WebRtcSpeex_GetBitstream(SPEEX_encinst_t *SPEEXenc_inst,
// int16_t *encoded);
// int16_t WebRtcSpeex_DecodePlc(SPEEX_decinst_t *SPEEXdec_inst,
// int16_t *decoded, int16_t noOfLostFrames);
// int16_t WebRtcSpeex_Decode(SPEEX_decinst_t *SPEEXdec_inst,
// int16_t *encoded, int16_t len,
// int16_t *decoded, int16_t *speechType);
// int16_t WebRtcSpeex_DecoderInit(SPEEX_decinst_t *SPEEXdec_inst);
#include "speex_interface.h" #include "speex_interface.h"
#endif #endif
@ -62,153 +36,105 @@ ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codecID */)
return; return;
} }
ACMSPEEX::~ACMSPEEX() ACMSPEEX::~ACMSPEEX() {
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* /* bitStream */,
ACMSPEEX::InternalEncode( WebRtc_Word16* /* bitStreamLenByte */) {
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16* /* bitStreamLenByte */)
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMSPEEX::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::EnableDTX() {
ACMSPEEX::EnableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::DisableDTX() {
ACMSPEEX::DisableDTX()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
ACMSPEEX::InternalInitEncoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
ACMSPEEX::InternalInitDecoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
return -1; return -1;
} }
WebRtc_Word32 WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
ACMSPEEX::CodecDef( const CodecInst& /* codecInst */) {
WebRtcNetEQ_CodecDef& /* codecDef */,
const CodecInst& /* codecInst */)
{
return -1; return -1;
} }
ACMGenericCodec* ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
ACMSPEEX::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
ACMSPEEX::InternalCreateEncoder()
{
return -1; return -1;
} }
void void ACMSPEEX::DestructEncoderSafe() {
ACMSPEEX::DestructEncoderSafe()
{
return; return;
} }
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
WebRtc_Word16
ACMSPEEX::InternalCreateDecoder()
{
return -1; return -1;
} }
void void ACMSPEEX::DestructDecoderSafe() {
ACMSPEEX::DestructDecoderSafe()
{
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
ACMSPEEX::SetBitRateSafe(
const WebRtc_Word32 /* rate */)
{
return -1; return -1;
} }
void void ACMSPEEX::InternalDestructEncoderInst(void* /* ptrInst */) {
ACMSPEEX::InternalDestructEncoderInst(
void* /* ptrInst */)
{
return; return;
} }
#ifdef UNUSEDSPEEX #ifdef UNUSEDSPEEX
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::EnableVBR() {
ACMSPEEX::EnableVBR()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::DisableVBR() {
ACMSPEEX::DisableVBR()
{
return -1; return -1;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
ACMSPEEX::SetComplMode(
WebRtc_Word16 mode)
{
return -1; return -1;
} }
#endif #endif
#else //===================== Actual Implementation ======================= #else //===================== Actual Implementation =======================
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID): ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID)
_encoderInstPtr(NULL), : _encoderInstPtr(NULL),
_decoderInstPtr(NULL) _decoderInstPtr(NULL) {
{
_codecID = codecID; _codecID = codecID;
// Set sampling frequency, frame size and rate Speex // Set sampling frequency, frame size and rate Speex
if(_codecID == ACMCodecDB::kSPEEX8) if (_codecID == ACMCodecDB::kSPEEX8) {
{
_samplingFrequency = 8000; _samplingFrequency = 8000;
_samplesIn20MsAudio = 160; _samplesIn20MsAudio = 160;
_encodingRate = 11000; _encodingRate = 11000;
} } else if (_codecID == ACMCodecDB::kSPEEX16) {
else if(_codecID == ACMCodecDB::kSPEEX16)
{
_samplingFrequency = 16000; _samplingFrequency = 16000;
_samplesIn20MsAudio = 320; _samplesIn20MsAudio = 320;
_encodingRate = 22000; _encodingRate = 22000;
} } else {
else
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Wrong codec id for Speex."); "Wrong codec id for Speex.");
@ -225,32 +151,25 @@ _decoderInstPtr(NULL)
return; return;
} }
ACMSPEEX::~ACMSPEEX() ACMSPEEX::~ACMSPEEX() {
{ if (_encoderInstPtr != NULL) {
if(_encoderInstPtr != NULL)
{
WebRtcSpeex_FreeEnc(_encoderInstPtr); WebRtcSpeex_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
if(_decoderInstPtr != NULL) if (_decoderInstPtr != NULL) {
{
WebRtcSpeex_FreeDec(_decoderInstPtr); WebRtcSpeex_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
return; return;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitStream,
ACMSPEEX::InternalEncode( WebRtc_Word16* bitStreamLenByte) {
WebRtc_UWord8* bitStream,
WebRtc_Word16* bitStreamLenByte)
{
WebRtc_Word16 status; WebRtc_Word16 status;
WebRtc_Word16 numEncodedSamples = 0; WebRtc_Word16 numEncodedSamples = 0;
WebRtc_Word16 n = 0; WebRtc_Word16 n = 0;
while( numEncodedSamples < _frameLenSmpl) while (numEncodedSamples < _frameLenSmpl) {
{
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead], status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
_encodingRate); _encodingRate);
@ -259,22 +178,19 @@ ACMSPEEX::InternalEncode(
_inAudioIxRead += _samplesIn20MsAudio; _inAudioIxRead += _samplesIn20MsAudio;
numEncodedSamples += _samplesIn20MsAudio; numEncodedSamples += _samplesIn20MsAudio;
if(status < 0) if (status < 0) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in Speex encoder"); "Error in Speex encoder");
return status; return status;
} }
// Update VAD, if internal DTX is used // Update VAD, if internal DTX is used
if(_hasInternalDTX && _dtxEnabled) if (_hasInternalDTX && _dtxEnabled) {
{
_vadLabel[n++] = status; _vadLabel[n++] = status;
_vadLabel[n++] = status; _vadLabel[n++] = status;
} }
if(status == 0) if (status == 0) {
{
// This frame is detected as inactive. We need send whatever // This frame is detected as inactive. We need send whatever
// encoded so far. // encoded so far.
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr, *bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
@ -289,65 +205,48 @@ ACMSPEEX::InternalEncode(
return *bitStreamLenByte; return *bitStreamLenByte;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
ACMSPEEX::DecodeSafe(
WebRtc_UWord8* /* bitStream */,
WebRtc_Word16 /* bitStreamLenByte */, WebRtc_Word16 /* bitStreamLenByte */,
WebRtc_Word16* /* audio */, WebRtc_Word16* /* audio */,
WebRtc_Word16* /* audioSamples */, WebRtc_Word16* /* audioSamples */,
WebRtc_Word8* /* speechType */) WebRtc_Word8* /* speechType */) {
{
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::EnableDTX() {
ACMSPEEX::EnableDTX() if (_dtxEnabled) {
{
if(_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// enable DTX // enable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 1) < 0) if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0),
{ _complMode, 1) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot enable DTX for Speex"); "Cannot enable DTX for Speex");
return -1; return -1;
} }
_dtxEnabled = true; _dtxEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::DisableDTX() {
ACMSPEEX::DisableDTX() if (!_dtxEnabled) {
{
if(!_dtxEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// disable DTX // disable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1:0), _complMode, 0) < 0) if (WebRtcSpeex_EncoderInit(_encoderInstPtr, (_vbrEnabled ? 1 : 0),
{ _complMode, 0) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
return -1; return -1;
} }
_dtxEnabled = false; _dtxEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
@ -355,20 +254,19 @@ ACMSPEEX::DisableDTX()
return 0; return 0;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
ACMSPEEX::InternalInitEncoder(
WebRtcACMCodecParams* codecParams)
{
// sanity check // sanity check
if (_encoderInstPtr == NULL) if (_encoderInstPtr == NULL) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot initialize Speex encoder, instance does not exist"); "Cannot initialize Speex encoder, instance does not exist");
return -1; return -1;
} }
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate); WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
status += (WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode, ((codecParams->enableDTX)? 1:0)) < 0)? -1:0; status +=
(WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode,
((codecParams->enableDTX) ? 1 : 0)) < 0) ?
-1 : 0;
if (status >= 0) { if (status >= 0) {
return 0; return 0;
@ -379,15 +277,12 @@ ACMSPEEX::InternalInitEncoder(
} }
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
ACMSPEEX::InternalInitDecoder( WebRtcACMCodecParams* /* codecParams */) {
WebRtcACMCodecParams* /* codecParams */)
{
WebRtc_Word16 status; WebRtc_Word16 status;
// sanity check // sanity check
if (_decoderInstPtr == NULL) if (_decoderInstPtr == NULL) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot initialize Speex decoder, instance does not exist"); "Cannot initialize Speex decoder, instance does not exist");
return -1; return -1;
@ -403,13 +298,9 @@ ACMSPEEX::InternalInitDecoder(
} }
} }
WebRtc_Word32 WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
ACMSPEEX::CodecDef( const CodecInst& codecInst) {
WebRtcNetEQ_CodecDef& codecDef, if (!_decoderInitialized) {
const CodecInst& codecInst)
{
if (!_decoderInitialized)
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error, Speex decoder is not initialized"); "Error, Speex decoder is not initialized");
return -1; return -1;
@ -420,22 +311,18 @@ ACMSPEEX::CodecDef(
// Then call NetEQ to add the codec to its // Then call NetEQ to add the codec to its
// database. // database.
switch(_samplingFrequency) switch (_samplingFrequency) {
{ case 8000: {
case 8000:
{
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype,
_decoderInstPtr, 8000); _decoderInstPtr, 8000);
break; break;
} }
case 16000: case 16000: {
{
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype, SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype,
_decoderInstPtr, 16000); _decoderInstPtr, 16000);
break; break;
} }
default: default: {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Unsupported sampling frequency for Speex"); "Unsupported sampling frequency for Speex");
@ -447,23 +334,16 @@ ACMSPEEX::CodecDef(
return 0; return 0;
} }
ACMGenericCodec* ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
ACMSPEEX::CreateInstance(void)
{
return NULL; return NULL;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
ACMSPEEX::InternalCreateEncoder()
{
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency); return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
} }
void void ACMSPEEX::DestructEncoderSafe() {
ACMSPEEX::DestructEncoderSafe() if (_encoderInstPtr != NULL) {
{
if(_encoderInstPtr != NULL)
{
WebRtcSpeex_FreeEnc(_encoderInstPtr); WebRtcSpeex_FreeEnc(_encoderInstPtr);
_encoderInstPtr = NULL; _encoderInstPtr = NULL;
} }
@ -473,18 +353,12 @@ ACMSPEEX::DestructEncoderSafe()
_encodingRate = 0; _encodingRate = 0;
} }
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
WebRtc_Word16
ACMSPEEX::InternalCreateDecoder()
{
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1); return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
} }
void void ACMSPEEX::DestructDecoderSafe() {
ACMSPEEX::DestructDecoderSafe() if (_decoderInstPtr != NULL) {
{
if(_decoderInstPtr != NULL)
{
WebRtcSpeex_FreeDec(_decoderInstPtr); WebRtcSpeex_FreeDec(_decoderInstPtr);
_decoderInstPtr = NULL; _decoderInstPtr = NULL;
} }
@ -493,10 +367,7 @@ ACMSPEEX::DestructDecoderSafe()
_decoderInitialized = false; _decoderInitialized = false;
} }
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
ACMSPEEX::SetBitRateSafe(
const WebRtc_Word32 rate)
{
// Check if changed rate // Check if changed rate
if (rate == _encodingRate) { if (rate == _encodingRate) {
return 0; return 0;
@ -513,13 +384,8 @@ ACMSPEEX::SetBitRateSafe(
return 0; return 0;
} }
void ACMSPEEX::InternalDestructEncoderInst(void* ptrInst) {
void if (ptrInst != NULL) {
ACMSPEEX::InternalDestructEncoderInst(
void* ptrInst)
{
if(ptrInst != NULL)
{
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst); WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst);
} }
return; return;
@ -529,18 +395,14 @@ ACMSPEEX::InternalDestructEncoderInst(
// This API is currently not in use. If requested to be able to enable/disable VBR // This API is currently not in use. If requested to be able to enable/disable VBR
// an ACM API need to be added. // an ACM API need to be added.
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::EnableVBR() {
ACMSPEEX::EnableVBR() if (_vbrEnabled) {
{
if(_vbrEnabled)
{
return 0; return 0;
} } else if (_encoderExist) // check if encoder exist
else if(_encoderExist) // check if encoder exist
{ {
// enable Variable Bit Rate (VBR) // enable Variable Bit Rate (VBR)
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode, (_dtxEnabled? 1:0)) < 0) if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode,
{ (_dtxEnabled ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot enable VBR mode for Speex"); "Cannot enable VBR mode for Speex");
@ -548,28 +410,20 @@ ACMSPEEX::EnableVBR()
} }
_vbrEnabled = true; _vbrEnabled = true;
return 0; return 0;
} } else {
else
{
return -1; return -1;
} }
} }
// This API is currently not in use. If requested to be able to enable/disable
// This API is currently not in use. If requested to be able to enable/disable VBR // VBR an ACM API need to be added.
// an ACM API need to be added. WebRtc_Word16 ACMSPEEX::DisableVBR() {
WebRtc_Word16 if (!_vbrEnabled) {
ACMSPEEX::DisableVBR()
{
if(!_vbrEnabled)
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// disable DTX // disable DTX
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode, (_dtxEnabled? 1:0)) < 0) if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode,
{ (_dtxEnabled ? 1 : 0)) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Cannot disable DTX for Speex"); "Cannot disable DTX for Speex");
@ -577,9 +431,7 @@ ACMSPEEX::DisableVBR()
} }
_vbrEnabled = false; _vbrEnabled = false;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }
@ -587,29 +439,21 @@ ACMSPEEX::DisableVBR()
// This API is currently not in use. If requested to be able to set complexity // This API is currently not in use. If requested to be able to set complexity
// an ACM API need to be added. // an ACM API need to be added.
WebRtc_Word16 WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
ACMSPEEX::SetComplMode(
WebRtc_Word16 mode)
{
// Check if new mode // Check if new mode
if(mode == _complMode) if (mode == _complMode) {
{
return 0; return 0;
} } else if (_encoderExist) { // check if encoder exist
else if(_encoderExist) // check if encoder exist
{
// Set new mode // Set new mode
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled? 1:0)) < 0) if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled ? 1 : 0))
{ < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID, WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
"Error in complexity mode for Speex"); "Error in complexity mode for Speex");
return -1; return -1;
} }
_complMode = mode; _complMode = mode;
return 0; return 0;
} } else {
else
{
// encoder doesn't exists, therefore disabling is harmless // encoder doesn't exists, therefore disabling is harmless
return 0; return 0;
} }

View File

@ -19,34 +19,28 @@ struct SPEEX_decinst_t_;
namespace webrtc { namespace webrtc {
class ACMSPEEX : public ACMGenericCodec class ACMSPEEX : public ACMGenericCodec {
{
public: public:
ACMSPEEX(WebRtc_Word16 codecID); ACMSPEEX(WebRtc_Word16 codecID);
~ACMSPEEX(); ~ACMSPEEX();
// for FEC // for FEC
ACMGenericCodec* CreateInstance(void); ACMGenericCodec* CreateInstance(void);
WebRtc_Word16 InternalEncode( WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
WebRtc_UWord8* bitstream,
WebRtc_Word16* bitStreamLenByte); WebRtc_Word16* bitStreamLenByte);
WebRtc_Word16 InternalInitEncoder( WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
WebRtc_Word16 InternalInitDecoder( WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
WebRtcACMCodecParams *codecParams);
protected: protected:
WebRtc_Word16 DecodeSafe( WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
WebRtc_UWord8* bitStream,
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16 bitStreamLenByte,
WebRtc_Word16* audio, WebRtc_Word16* audio,
WebRtc_Word16* audioSamples, WebRtc_Word16* audioSamples,
WebRtc_Word8* speechType); WebRtc_Word8* speechType);
WebRtc_Word32 CodecDef( WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
WebRtcNetEQ_CodecDef& codecDef,
const CodecInst& codecInst); const CodecInst& codecInst);
void DestructEncoderSafe(); void DestructEncoderSafe();
@ -57,11 +51,9 @@ protected:
WebRtc_Word16 InternalCreateDecoder(); WebRtc_Word16 InternalCreateDecoder();
void InternalDestructEncoderInst( void InternalDestructEncoderInst(void* ptrInst);
void* ptrInst);
WebRtc_Word16 SetBitRateSafe( WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
const WebRtc_Word32 rate);
WebRtc_Word16 EnableDTX(); WebRtc_Word16 EnableDTX();
@ -72,8 +64,7 @@ protected:
WebRtc_Word16 DisableVBR(); WebRtc_Word16 DisableVBR();
WebRtc_Word16 SetComplMode( WebRtc_Word16 SetComplMode(WebRtc_Word16 mode);
WebRtc_Word16 mode);
#endif #endif
SPEEX_encinst_t_* _encoderInstPtr; SPEEX_encinst_t_* _encoderInstPtr;

View File

@ -8,51 +8,38 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "acm_dtmf_detection.h" #include "acm_dtmf_detection.h"
#include "audio_coding_module.h" #include "audio_coding_module.h"
#include "audio_coding_module_impl.h" #include "audio_coding_module_impl.h"
#include "trace.h" #include "trace.h"
namespace webrtc namespace webrtc {
{
// Create module // Create module
AudioCodingModule* AudioCodingModule* AudioCodingModule::Create(const WebRtc_Word32 id) {
AudioCodingModule::Create(
const WebRtc_Word32 id)
{
return new AudioCodingModuleImpl(id); return new AudioCodingModuleImpl(id);
} }
// Destroy module // Destroy module
void void AudioCodingModule::Destroy(AudioCodingModule* module) {
AudioCodingModule::Destroy(
AudioCodingModule* module)
{
delete static_cast<AudioCodingModuleImpl*>(module); delete static_cast<AudioCodingModuleImpl*>(module);
} }
// Get number of supported codecs // Get number of supported codecs
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
{
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs); return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
} }
// Get supported codec param with id // Get supported codec param with id
WebRtc_Word32 WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 listId,
AudioCodingModule::Codec( CodecInst& codec) {
const WebRtc_UWord8 listId,
CodecInst& codec)
{
// Get the codec settings for the codec with the given list ID // Get the codec settings for the codec with the given list ID
return ACMCodecDB::Codec(listId, &codec); return ACMCodecDB::Codec(listId, &codec);
} }
// Get supported codec Param with name, frequency and number of channels. // Get supported codec Param with name, frequency and number of channels.
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name, WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
CodecInst& codec, CodecInst& codec, int sampling_freq_hz,
int sampling_freq_hz,
int channels) { int channels) {
int codec_id; int codec_id;
@ -77,28 +64,21 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
// Get supported codec Index with name, frequency and number of channels. // Get supported codec Index with name, frequency and number of channels.
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name, WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
int sampling_freq_hz, int sampling_freq_hz, int channels) {
int channels) {
return ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels); return ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
} }
// Checks the validity of the parameters of the given codec // Checks the validity of the parameters of the given codec
bool bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
AudioCodingModule::IsCodecValid(
const CodecInst& codec)
{
int mirrorID; int mirrorID;
char errMsg[500]; char errMsg[500];
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500); int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
if(codecNumber < 0) if (codecNumber < 0) {
{
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg); WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);
return false; return false;
} } else {
else
{
return true; return true;
} }
} }