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:
parent
a56d759723
commit
f7fa6276e2
@ -16,24 +16,9 @@
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G729
|
||||
// NOTE! G.729 is not included in the open-source package. The following
|
||||
// interface file is needed:
|
||||
//
|
||||
// /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);
|
||||
// NOTE! G.729 is not included in the open-source package. Modify this file
|
||||
// or your codec API to match the function calls and names of used G.729 API
|
||||
// file.
|
||||
#include "g729_interface.h"
|
||||
#endif
|
||||
|
||||
@ -47,152 +32,96 @@ ACMG729::ACMG729(WebRtc_Word16 /* codecID */)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMG729::~ACMG729()
|
||||
{
|
||||
ACMG729::~ACMG729() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::EnableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::EnableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::DisableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::DisableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::ReplaceInternalDTXSafe(
|
||||
const bool /*replaceInternalDTX*/)
|
||||
{
|
||||
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(
|
||||
const bool /*replaceInternalDTX*/) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::IsInternalDTXReplacedSafe(
|
||||
bool* /* internalDTXReplaced */)
|
||||
{
|
||||
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(
|
||||
bool* /* internalDTXReplaced */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */)
|
||||
{
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMG729::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMG729::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::DestructEncoderSafe()
|
||||
{
|
||||
void ACMG729::DestructEncoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::DestructDecoderSafe()
|
||||
{
|
||||
void ACMG729::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMG729::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMG729::ACMG729(
|
||||
WebRtc_Word16 codecID):
|
||||
_encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL)
|
||||
{
|
||||
ACMG729::ACMG729(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMG729::~ACMG729()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
ACMG729::~ACMG729() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
// Delete encoder memory
|
||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
// Delete decoder memory
|
||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
@ -200,23 +129,18 @@ ACMG729::~ACMG729()
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
// Initialize before entering the loop
|
||||
WebRtc_Word16 noEncodedSamples = 0;
|
||||
WebRtc_Word16 tmpLenByte = 0;
|
||||
WebRtc_Word16 vadDecision = 0;
|
||||
*bitStreamLenByte = 0;
|
||||
while(noEncodedSamples < _frameLenSmpl)
|
||||
{
|
||||
while (noEncodedSamples < _frameLenSmpl) {
|
||||
// Call G.729 encoder with pointer to encoder memory, input
|
||||
// audio, number of samples and bitsream
|
||||
tmpLenByte = WebRtcG729_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead], 80,
|
||||
tmpLenByte = WebRtcG729_Encode(
|
||||
_encoderInstPtr, &_inAudio[_inAudioIxRead], 80,
|
||||
(WebRtc_Word16*) (&(bitStream[*bitStreamLenByte])));
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
@ -224,8 +148,7 @@ ACMG729::InternalEncode(
|
||||
_inAudioIxRead += 80;
|
||||
|
||||
// sanity check
|
||||
if(tmpLenByte < 0)
|
||||
{
|
||||
if (tmpLenByte < 0) {
|
||||
// error has happened
|
||||
*bitStreamLenByte = 0;
|
||||
return -1;
|
||||
@ -233,12 +156,9 @@ ACMG729::InternalEncode(
|
||||
|
||||
// increment number of written bytes
|
||||
*bitStreamLenByte += tmpLenByte;
|
||||
switch(tmpLenByte)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if(0 == noEncodedSamples)
|
||||
{
|
||||
switch (tmpLenByte) {
|
||||
case 0: {
|
||||
if (0 == noEncodedSamples) {
|
||||
// this is the first 10 ms in this packet and there is
|
||||
// no data generated, perhaps DTX is enabled and the
|
||||
// codec is not generating any bit-stream for this 10 ms.
|
||||
@ -247,14 +167,11 @@ ACMG729::InternalEncode(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
case 2: {
|
||||
// check if G.729 internal DTX is enabled
|
||||
if(_hasInternalDTX && _dtxEnabled)
|
||||
{
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -262,14 +179,12 @@ ACMG729::InternalEncode(
|
||||
// how much audio we have encoded
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
case 10:
|
||||
{
|
||||
case 10: {
|
||||
vadDecision = 1;
|
||||
// this is a valid length just continue encoding
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -279,10 +194,8 @@ ACMG729::InternalEncode(
|
||||
}
|
||||
|
||||
// update VAD decision vector
|
||||
if(_hasInternalDTX && !vadDecision && _dtxEnabled)
|
||||
{
|
||||
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
|
||||
{
|
||||
if (_hasInternalDTX && !vadDecision && _dtxEnabled) {
|
||||
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||
_vadLabel[n] = vadDecision;
|
||||
}
|
||||
}
|
||||
@ -291,78 +204,52 @@ ACMG729::InternalEncode(
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::EnableDTX()
|
||||
{
|
||||
if(_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
// DTX already enabled, do nothing
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist)
|
||||
{
|
||||
} else if (_encoderExist) {
|
||||
// Re-init the G.729 encoder to turn on DTX
|
||||
if(WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0)
|
||||
{
|
||||
if (WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::DisableDTX()
|
||||
{
|
||||
if(!_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
// DTX already dissabled, do nothing
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist)
|
||||
{
|
||||
} else if (_encoderExist) {
|
||||
// Re-init the G.729 decoder to turn off DTX
|
||||
if(WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0)
|
||||
{
|
||||
if (WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::ReplaceInternalDTXSafe(
|
||||
const bool replaceInternalDTX)
|
||||
{
|
||||
// This function is used to dissable the G.729 built in DTX and use an
|
||||
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replaceInternalDTX) {
|
||||
// This function is used to disable the G.729 built in DTX and use an
|
||||
// external instead.
|
||||
|
||||
if(replaceInternalDTX == _hasInternalDTX)
|
||||
{
|
||||
if (replaceInternalDTX == _hasInternalDTX) {
|
||||
// Make sure we keep the DTX/VAD setting if possible
|
||||
bool oldEnableDTX = _dtxEnabled;
|
||||
bool oldEnableVAD = _vadEnabled;
|
||||
ACMVADMode oldMode = _vadMode;
|
||||
if (replaceInternalDTX)
|
||||
{
|
||||
if (replaceInternalDTX) {
|
||||
// Disable internal DTX before enabling external DTX
|
||||
DisableDTX();
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Disable external DTX before enabling internal
|
||||
ACMGenericCodec::DisableDTX();
|
||||
}
|
||||
@ -381,56 +268,36 @@ ACMG729::ReplaceInternalDTXSafe(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::IsInternalDTXReplacedSafe(
|
||||
bool* internalDTXReplaced)
|
||||
{
|
||||
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internalDTXReplaced) {
|
||||
// Get status of wether DTX is replaced or not
|
||||
*internalDTXReplaced = !_hasInternalDTX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
// This function is not used. G.729 decoder is called from inside NetEQ
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
// Init G.729 encoder
|
||||
return WebRtcG729_EncoderInit(_encoderInstPtr,
|
||||
((codecParams->enableDTX) ? 1 : 0));
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
// Init G.729 decoder
|
||||
return WebRtcG729_DecoderInit(_decoderInstPtr);
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -440,71 +307,49 @@ ACMG729::CodecDef(
|
||||
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype,
|
||||
_decoderInstPtr, 8000);
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729, codecInst.pltype, _decoderInstPtr,
|
||||
8000);
|
||||
SET_G729_FUNCTIONS((codecDef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMG729::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMG729::CreateInstance(void) {
|
||||
// Function not used
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
|
||||
// Create encoder memory
|
||||
return WebRtcG729_CreateEnc(&_encoderInstPtr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::DestructEncoderSafe()
|
||||
{
|
||||
void ACMG729::DestructEncoderSafe() {
|
||||
// Free encoder memory
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
|
||||
// Create decoder memory
|
||||
return WebRtcG729_CreateDec(&_decoderInstPtr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::DestructDecoderSafe()
|
||||
{
|
||||
void ACMG729::DestructDecoderSafe() {
|
||||
// Free decoder memory
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729::InternalDestructEncoderInst(
|
||||
void* ptrInst)
|
||||
{
|
||||
if(ptrInst != NULL)
|
||||
{
|
||||
void ACMG729::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst);
|
||||
}
|
||||
return;
|
||||
|
@ -19,34 +19,28 @@ struct G729_decinst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMG729 : public ACMGenericCodec
|
||||
{
|
||||
class ACMG729 : public ACMGenericCodec {
|
||||
public:
|
||||
ACMG729(WebRtc_Word16 codecID);
|
||||
~ACMG729();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -57,18 +51,15 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
WebRtc_Word16 EnableDTX();
|
||||
|
||||
WebRtc_Word16 DisableDTX();
|
||||
|
||||
WebRtc_Word32 ReplaceInternalDTXSafe(
|
||||
const bool replaceInternalDTX);
|
||||
WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
|
||||
|
||||
WebRtc_Word32 IsInternalDTXReplacedSafe(
|
||||
bool* internalDTXReplaced);
|
||||
WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
|
||||
|
||||
G729_encinst_t_* _encoderInstPtr;
|
||||
G729_decinst_t_* _decoderInstPtr;
|
||||
|
@ -16,24 +16,9 @@
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_G729_1
|
||||
// NOTE! G.729.1 is not included in the open-source package. The following
|
||||
// interface file is needed:
|
||||
//
|
||||
// /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);
|
||||
// NOTE! G.729.1 is not included in the open-source package. Modify this file
|
||||
// or your codec API to match the function calls and names of used G.729.1 API
|
||||
// file.
|
||||
#include "g7291_interface.h"
|
||||
#endif
|
||||
|
||||
@ -50,105 +35,63 @@ ACMG729_1::ACMG729_1( WebRtc_Word16 /* codecID */)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMG729_1::~ACMG729_1()
|
||||
{
|
||||
ACMG729_1::~ACMG729_1() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729_1::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */)
|
||||
{
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMG729_1::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::DestructEncoderSafe()
|
||||
{
|
||||
void ACMG729_1::DestructEncoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::DestructDecoderSafe()
|
||||
{
|
||||
void ACMG729_1::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::SetBitRateSafe(
|
||||
const WebRtc_Word32 /*rate*/ )
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 /*rate*/) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -168,27 +111,20 @@ ACMG729_1::ACMG729_1(WebRtc_Word16 codecID)
|
||||
return;
|
||||
}
|
||||
|
||||
ACMG729_1::~ACMG729_1()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
ACMG729_1::~ACMG729_1() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
|
||||
// Initialize before entering the loop
|
||||
WebRtc_Word16 noEncodedSamples = 0;
|
||||
@ -203,18 +139,18 @@ ACMG729_1::InternalEncode(
|
||||
byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode);
|
||||
|
||||
// The following might be revised if we have G729.1 Annex C (support for DTX);
|
||||
do
|
||||
{
|
||||
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
||||
(WebRtc_Word16*)bitStream, _myRate, n20msFrames);
|
||||
do {
|
||||
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead],
|
||||
(WebRtc_Word16*) bitStream, _myRate,
|
||||
n20msFrames);
|
||||
|
||||
// increment the read index this tell the caller that how far
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += 160;
|
||||
|
||||
// sanity check
|
||||
if(*bitStreamLenByte < 0)
|
||||
{
|
||||
if (*bitStreamLenByte < 0) {
|
||||
// error has happened
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalEncode: Encode error for G729_1");
|
||||
@ -225,19 +161,15 @@ ACMG729_1::InternalEncode(
|
||||
noEncodedSamples += 160;
|
||||
} while (*bitStreamLenByte == 0);
|
||||
|
||||
|
||||
// This criteria will change if we have Annex C.
|
||||
if(*bitStreamLenByte != byteLengthFrame)
|
||||
{
|
||||
if (*bitStreamLenByte != byteLengthFrame) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalEncode: Encode error for G729_1");
|
||||
*bitStreamLenByte = 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if(noEncodedSamples != _frameLenSmpl)
|
||||
{
|
||||
if (noEncodedSamples != _frameLenSmpl) {
|
||||
*bitStreamLenByte = 0;
|
||||
return -1;
|
||||
}
|
||||
@ -245,35 +177,24 @@ ACMG729_1::InternalEncode(
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams) {
|
||||
//set the bit rate and initialize
|
||||
_myRate = codecParams->codecInstant.rate;
|
||||
return SetBitRateSafe((WebRtc_UWord32) _myRate);
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
if (WebRtcG7291_DecoderInit(_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalInitDecoder: init decoder failed for G729_1");
|
||||
return -1;
|
||||
@ -281,14 +202,9 @@ ACMG729_1::InternalInitDecoder(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMG729_1::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"CodeDef: Decoder uninitialized for G729_1");
|
||||
return -1;
|
||||
@ -298,25 +214,18 @@ ACMG729_1::CodecDef(
|
||||
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype,
|
||||
_decoderInstPtr, 16000);
|
||||
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, _decoderInstPtr,
|
||||
16000);
|
||||
SET_G729_1_FUNCTIONS((codecDef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMG729_1::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalCreateEncoder()
|
||||
{
|
||||
if (WebRtcG7291_Create(&_encoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||
if (WebRtcG7291_Create(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateEncoder: create encoder failed for G729_1");
|
||||
return -1;
|
||||
@ -324,25 +233,17 @@ ACMG729_1::InternalCreateEncoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::DestructEncoderSafe()
|
||||
{
|
||||
void ACMG729_1::DestructEncoderSafe() {
|
||||
_encoderExist = false;
|
||||
_encoderInitialized = false;
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::InternalCreateDecoder()
|
||||
{
|
||||
if (WebRtcG7291_Create(&_decoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
|
||||
if (WebRtcG7291_Create(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateDecoder: create decoder failed for G729_1");
|
||||
return -1;
|
||||
@ -350,103 +251,77 @@ ACMG729_1::InternalCreateDecoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::DestructDecoderSafe()
|
||||
{
|
||||
void ACMG729_1::DestructDecoderSafe() {
|
||||
_decoderExist = false;
|
||||
_decoderInitialized = false;
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcG7291_Free(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMG729_1::InternalDestructEncoderInst(
|
||||
void* ptrInst)
|
||||
{
|
||||
if(ptrInst != NULL)
|
||||
{
|
||||
void ACMG729_1::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
//WebRtcG7291_Free((G729_1_inst_t*)ptrInst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMG729_1::SetBitRateSafe(
|
||||
const WebRtc_Word32 rate)
|
||||
{
|
||||
WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
//allowed rates: { 8000, 12000, 14000, 16000, 18000, 20000,
|
||||
// 22000, 24000, 26000, 28000, 30000, 32000};
|
||||
// TODO(tlegrand): This check exists in one other place two. Should be
|
||||
// possible to reuse code.
|
||||
switch(rate)
|
||||
{
|
||||
case 8000:
|
||||
{
|
||||
switch (rate) {
|
||||
case 8000: {
|
||||
_myRate = 8000;
|
||||
break;
|
||||
}
|
||||
case 12000:
|
||||
{
|
||||
case 12000: {
|
||||
_myRate = 12000;
|
||||
break;
|
||||
}
|
||||
case 14000:
|
||||
{
|
||||
case 14000: {
|
||||
_myRate = 14000;
|
||||
break;
|
||||
}
|
||||
case 16000:
|
||||
{
|
||||
case 16000: {
|
||||
_myRate = 16000;
|
||||
break;
|
||||
}
|
||||
case 18000:
|
||||
{
|
||||
case 18000: {
|
||||
_myRate = 18000;
|
||||
break;
|
||||
}
|
||||
case 20000:
|
||||
{
|
||||
case 20000: {
|
||||
_myRate = 20000;
|
||||
break;
|
||||
}
|
||||
case 22000:
|
||||
{
|
||||
case 22000: {
|
||||
_myRate = 22000;
|
||||
break;
|
||||
}
|
||||
case 24000:
|
||||
{
|
||||
case 24000: {
|
||||
_myRate = 24000;
|
||||
break;
|
||||
}
|
||||
case 26000:
|
||||
{
|
||||
case 26000: {
|
||||
_myRate = 26000;
|
||||
break;
|
||||
}
|
||||
case 28000:
|
||||
{
|
||||
case 28000: {
|
||||
_myRate = 28000;
|
||||
break;
|
||||
}
|
||||
case 30000:
|
||||
{
|
||||
case 30000: {
|
||||
_myRate = 30000;
|
||||
break;
|
||||
}
|
||||
case 32000:
|
||||
{
|
||||
case 32000: {
|
||||
_myRate = 32000;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"SetBitRateSafe: Invalid rate G729_1");
|
||||
return -1;
|
||||
@ -454,18 +329,15 @@ ACMG729_1::SetBitRateSafe(
|
||||
}
|
||||
|
||||
// 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;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -19,34 +19,28 @@ struct G729_1_inst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMG729_1: public ACMGenericCodec
|
||||
{
|
||||
class ACMG729_1 : public ACMGenericCodec {
|
||||
public:
|
||||
ACMG729_1(WebRtc_Word16 codecID);
|
||||
~ACMG729_1();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -57,11 +51,9 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(
|
||||
const WebRtc_Word32 rate);
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
G729_1_inst_t_* _encoderInstPtr;
|
||||
G729_1_inst_t_* _decoderInstPtr;
|
||||
@ -69,7 +61,6 @@ protected:
|
||||
WebRtc_UWord16 _myRate;
|
||||
WebRtc_Word16 _flag8kHz;
|
||||
WebRtc_Word16 _flagG729mode;
|
||||
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,35 +23,30 @@
|
||||
struct WebRtcVadInst;
|
||||
struct WebRtcCngEncInst;
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
// forward declaration
|
||||
struct CodecInst;
|
||||
class ACMNetEQ;
|
||||
|
||||
class ACMGenericCodec
|
||||
{
|
||||
class ACMGenericCodec {
|
||||
public:
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Constructor of the class
|
||||
//
|
||||
ACMGenericCodec();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Destructor of the class.
|
||||
//
|
||||
virtual ~ACMGenericCodec();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// ACMGenericCodec* CreateInstance();
|
||||
// The function will be used for FEC. It is not implemented yet.
|
||||
//
|
||||
virtual ACMGenericCodec* CreateInstance() = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 Encode()
|
||||
// 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
|
||||
// bytes.
|
||||
//
|
||||
WebRtc_Word16 Encode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 Encode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_UWord32* timeStamp,
|
||||
WebRtcACMEncodingType* encodingType);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 Decode()
|
||||
// This function is used to decode a given bit-stream, without engaging
|
||||
@ -134,11 +127,8 @@ public:
|
||||
// -1 if failed to decode,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word16 Decode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word16 Decode(WebRtc_UWord8* bitStream, WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio, WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -157,7 +147,8 @@ public:
|
||||
// we simply copy the data and return it both for
|
||||
// left channel and right channel decoding.
|
||||
virtual void SplitStereoPacket(WebRtc_UWord8* /* payload */,
|
||||
WebRtc_Word32* /* payload_length */) {}
|
||||
WebRtc_Word32* /* payload_length */) {
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// bool EncoderInitialized();
|
||||
@ -168,7 +159,6 @@ public:
|
||||
//
|
||||
bool EncoderInitialized();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// bool DecoderInitialized();
|
||||
//
|
||||
@ -178,7 +168,6 @@ public:
|
||||
//
|
||||
bool DecoderInitialized();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 EncoderParams()
|
||||
// It is called to get encoder parameters. It will call
|
||||
@ -194,9 +183,7 @@ public:
|
||||
// 0 otherwise.
|
||||
//
|
||||
//
|
||||
WebRtc_Word16 EncoderParams(
|
||||
WebRtcACMCodecParams *encParams);
|
||||
|
||||
WebRtc_Word16 EncoderParams(WebRtcACMCodecParams *encParams);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 DecoderParams(...)
|
||||
@ -213,11 +200,9 @@ public:
|
||||
// 0 otherwise.
|
||||
//
|
||||
//
|
||||
bool DecoderParams(
|
||||
WebRtcACMCodecParams *decParams,
|
||||
bool DecoderParams(WebRtcACMCodecParams *decParams,
|
||||
const WebRtc_UWord8 payloadType);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InitEncoder(...)
|
||||
// This function is called to initialize the encoder with the given
|
||||
@ -234,11 +219,9 @@ public:
|
||||
// -1 if failed to initialize.
|
||||
//
|
||||
//
|
||||
WebRtc_Word16 InitEncoder(
|
||||
WebRtcACMCodecParams* codecParams,
|
||||
WebRtc_Word16 InitEncoder(WebRtcACMCodecParams* codecParams,
|
||||
bool forceInitialization);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InitDecoder()
|
||||
// This function is called to initialize the decoder with the given
|
||||
@ -256,11 +239,9 @@ public:
|
||||
// -1 if failed to initialize.
|
||||
//
|
||||
//
|
||||
WebRtc_Word16 InitDecoder(
|
||||
WebRtcACMCodecParams* codecParams,
|
||||
WebRtc_Word16 InitDecoder(WebRtcACMCodecParams* codecParams,
|
||||
bool forceInitialization);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 RegisterInNetEq(...)
|
||||
// This function is called to register the decoder in NetEq, with the given
|
||||
@ -274,10 +255,7 @@ public:
|
||||
// -1 if failed to register,
|
||||
// 0 if successfully initialized.
|
||||
//
|
||||
WebRtc_Word32 RegisterInNetEq(
|
||||
ACMNetEQ* netEq,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
WebRtc_Word32 RegisterInNetEq(ACMNetEQ* netEq, const CodecInst& codecInst);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 Add10MsData(...)
|
||||
@ -298,13 +276,11 @@ public:
|
||||
// -1 if failed
|
||||
// 0 otherwise.
|
||||
//
|
||||
WebRtc_Word32 Add10MsData(
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
WebRtc_Word32 Add10MsData(const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_Word16* data,
|
||||
const WebRtc_UWord16 length,
|
||||
const WebRtc_UWord8 audioChannel);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_UWord32 NoMissedSamples()
|
||||
// This function returns the number of samples which are overwritten in
|
||||
@ -317,7 +293,6 @@ public:
|
||||
//
|
||||
WebRtc_UWord32 NoMissedSamples() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void ResetNoMissedSamples()
|
||||
// This function resets the number of overwritten samples to zero.
|
||||
@ -325,7 +300,6 @@ public:
|
||||
//
|
||||
void ResetNoMissedSamples();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 SetBitRate()
|
||||
// The function is called to set the encoding rate.
|
||||
@ -340,7 +314,6 @@ public:
|
||||
//
|
||||
WebRtc_Word16 SetBitRate(const WebRtc_Word32 bitRateBPS);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DestructEncoderInst()
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
void DestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void DestructEncoderInst(void* ptrInst);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 AudioBuffer()
|
||||
@ -369,9 +341,7 @@ public:
|
||||
// -1 if fails to copy the audio buffer,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word16 AudioBuffer(
|
||||
WebRtcACMAudioBuff& audioBuff);
|
||||
|
||||
WebRtc_Word16 AudioBuffer(WebRtcACMAudioBuff& audioBuff);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_UWord32 EarliestTimestamp()
|
||||
@ -383,7 +353,6 @@ public:
|
||||
//
|
||||
WebRtc_UWord32 EarliestTimestamp() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 SetAudioBuffer()
|
||||
// This function is called to set the audio buffer and the associated
|
||||
@ -395,8 +364,6 @@ public:
|
||||
//
|
||||
WebRtc_Word16 SetAudioBuffer(WebRtcACMAudioBuff& audioBuff);
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 SetVAD()
|
||||
// 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,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word16 SetVAD(
|
||||
const bool enableDTX = true,
|
||||
const bool enableVAD = false,
|
||||
const ACMVADMode mode = VADNormal);
|
||||
|
||||
WebRtc_Word16 SetVAD(const bool enableDTX = true,
|
||||
const bool enableVAD = false, const ACMVADMode mode =
|
||||
VADNormal);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 ReplaceInternalDTX()
|
||||
@ -447,15 +412,15 @@ public:
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 IsInternalDTXReplaced()
|
||||
// This is called to check if the codec internal DTX is replaced by WebRtc DTX.
|
||||
// This is only valid for G729 where the user has possibility to replace
|
||||
// This is called to check if the codec internal DTX is replaced by WebRtc
|
||||
// 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.
|
||||
//
|
||||
// Output:
|
||||
// -internalDTXReplaced : if true the internal DTX is replaced with WebRtc.
|
||||
//
|
||||
// Return value
|
||||
// -1 if failed to check if replace internal DTX or replacement not feasible,
|
||||
// -1 if failed to check
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word32 IsInternalDTXReplaced(bool* internalDTXReplaced);
|
||||
@ -467,13 +432,10 @@ public:
|
||||
// Input:
|
||||
// -netEqDecodeLock : pointer to the lock associated with NetEQ of ACM.
|
||||
//
|
||||
void SetNetEqDecodeLock(
|
||||
RWLockWrapper* netEqDecodeLock)
|
||||
{
|
||||
void SetNetEqDecodeLock(RWLockWrapper* netEqDecodeLock) {
|
||||
_netEqDecodeLock = netEqDecodeLock;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// bool HasInternalDTX()
|
||||
// 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,
|
||||
// false otherwise.
|
||||
//
|
||||
bool HasInternalDTX() const
|
||||
{
|
||||
bool HasInternalDTX() const {
|
||||
return _hasInternalDTX;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 GetEstimatedBandwidth()
|
||||
// Used to get decoder estimated bandwidth. Only iSAC will provide a value.
|
||||
@ -499,7 +459,6 @@ public:
|
||||
//
|
||||
WebRtc_Word32 GetEstimatedBandwidth();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 SetEstimatedBandwidth()
|
||||
// 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,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word32 GetRedPayload(
|
||||
WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word32 GetRedPayload(WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word16* payloadBytes);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 ResetEncoder()
|
||||
// By calling this function you would re-initialize the encoder with the
|
||||
@ -544,7 +501,6 @@ public:
|
||||
//
|
||||
WebRtc_Word16 ResetEncoder();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 ResetEncoder()
|
||||
// By calling this function you would re-initialize the decoder with the
|
||||
@ -554,9 +510,7 @@ public:
|
||||
// -1 if failed,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word16 ResetDecoder(
|
||||
WebRtc_Word16 payloadType);
|
||||
|
||||
WebRtc_Word16 ResetDecoder(WebRtc_Word16 payloadType);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void DestructEncoder()
|
||||
@ -567,7 +521,6 @@ public:
|
||||
//
|
||||
void DestructEncoder();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void DestructDecoder()
|
||||
// This function is called to delete the decoder instance, if possible, to
|
||||
@ -578,7 +531,6 @@ public:
|
||||
//
|
||||
void DestructDecoder();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 SamplesLeftToEncode()
|
||||
// Returns the number of samples required to be able to do encoding.
|
||||
@ -588,7 +540,6 @@ public:
|
||||
//
|
||||
WebRtc_Word16 SamplesLeftToEncode();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_UWord32 LastEncodedTimestamp()
|
||||
// Returns the timestamp of the last frame it encoded.
|
||||
@ -598,7 +549,6 @@ public:
|
||||
//
|
||||
WebRtc_UWord32 LastEncodedTimestamp() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SetUniqueID()
|
||||
// Set a unique ID for the codec to be used for tracing and debuging
|
||||
@ -606,9 +556,7 @@ public:
|
||||
// Input
|
||||
// -id : A number to identify the codec.
|
||||
//
|
||||
void SetUniqueID(
|
||||
const WebRtc_UWord32 id);
|
||||
|
||||
void SetUniqueID(const WebRtc_UWord32 id);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IsAudioBufferFresh()
|
||||
@ -620,7 +568,6 @@ public:
|
||||
//
|
||||
bool IsAudioBufferFresh() const;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// UpdateDecoderSampFreq()
|
||||
// For most of the codecs this function does nothing. It must be
|
||||
@ -646,13 +593,10 @@ public:
|
||||
// 0 if succeeded in updating the decoder.
|
||||
// -1 if failed to update.
|
||||
//
|
||||
virtual WebRtc_Word16 UpdateDecoderSampFreq(
|
||||
WebRtc_Word16 /* codecId */)
|
||||
{
|
||||
virtual WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 /* codecId */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// UpdateEncoderSampFreq()
|
||||
// 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.
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual WebRtc_Word16 UpdateEncoderSampFreq(
|
||||
WebRtc_UWord16 encoderSampFreqHz);
|
||||
|
||||
virtual WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 encoderSampFreqHz);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// EncoderSampFreq()
|
||||
@ -685,9 +627,7 @@ public:
|
||||
// -1 if failed to output sampling rate.
|
||||
// 0 if the sample rate is returned successfully.
|
||||
//
|
||||
virtual WebRtc_Word16 EncoderSampFreq(
|
||||
WebRtc_UWord16& sampFreqHz);
|
||||
|
||||
virtual WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word32 ConfigISACBandwidthEstimator()
|
||||
@ -715,9 +655,7 @@ public:
|
||||
//
|
||||
virtual WebRtc_Word32 ConfigISACBandwidthEstimator(
|
||||
const WebRtc_UWord8 initFrameSizeMsec,
|
||||
const WebRtc_UWord16 initRateBitPerSec,
|
||||
const bool enforceFrameSize);
|
||||
|
||||
const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SetISACMaxPayloadSize()
|
||||
@ -737,7 +675,6 @@ public:
|
||||
virtual WebRtc_Word32 SetISACMaxPayloadSize(
|
||||
const WebRtc_UWord16 maxPayloadLenBytes);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SetISACMaxRate()
|
||||
// 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.
|
||||
// 0 if the maximum rate is set successfully.
|
||||
//
|
||||
virtual WebRtc_Word32 SetISACMaxRate(
|
||||
const WebRtc_UWord32 maxRateBitPerSec);
|
||||
|
||||
virtual WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// SaveDecoderParamS()
|
||||
@ -765,20 +700,14 @@ public:
|
||||
// -codecParams : pointer to a struct where the parameters of
|
||||
// decoder is stored in.
|
||||
//
|
||||
void SaveDecoderParam(
|
||||
const WebRtcACMCodecParams* codecParams);
|
||||
void SaveDecoderParam(const WebRtcACMCodecParams* codecParams);
|
||||
|
||||
|
||||
WebRtc_Word32 FrameSize()
|
||||
{
|
||||
WebRtc_Word32 FrameSize() {
|
||||
return _frameLenSmpl;
|
||||
}
|
||||
|
||||
void SetIsMaster(bool isMaster);
|
||||
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// REDPayloadISAC()
|
||||
// This is an iSAC-specific function. The function is called to get RED
|
||||
@ -803,8 +732,7 @@ public:
|
||||
// is returned.
|
||||
//
|
||||
//
|
||||
virtual WebRtc_Word16 REDPayloadISAC(
|
||||
const WebRtc_Word32 isacRate,
|
||||
virtual WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate,
|
||||
const WebRtc_Word16 isacBwEstimate,
|
||||
WebRtc_UWord8* payload,
|
||||
WebRtc_Word16* payloadLenBytes);
|
||||
@ -834,8 +762,7 @@ protected:
|
||||
// See Encode() for the description of function, input(s)/output(s) and
|
||||
// return value.
|
||||
//
|
||||
WebRtc_Word16 EncodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 EncodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_UWord32* timeStamp,
|
||||
WebRtcACMEncodingType* encodingType);
|
||||
@ -844,8 +771,7 @@ protected:
|
||||
// See Decode() for the description of function, input(s)/output(s) and
|
||||
// return value.
|
||||
//
|
||||
virtual WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
virtual WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
@ -855,8 +781,7 @@ protected:
|
||||
// See Add10MsSafe() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
//
|
||||
virtual WebRtc_Word32 Add10MsDataSafe(
|
||||
const WebRtc_UWord32 timeStamp,
|
||||
virtual WebRtc_Word32 Add10MsDataSafe(const WebRtc_UWord32 timeStamp,
|
||||
const WebRtc_Word16* data,
|
||||
const WebRtc_UWord16 length,
|
||||
const WebRtc_UWord8 audioChannel);
|
||||
@ -865,16 +790,14 @@ protected:
|
||||
// See RegisterInNetEq() for the description of function,
|
||||
// input(s)/output(s) and return value.
|
||||
//
|
||||
virtual WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
virtual WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See EncoderParam() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
//
|
||||
WebRtc_Word16 EncoderParamsSafe(
|
||||
WebRtcACMCodecParams *encParams);
|
||||
WebRtc_Word16 EncoderParamsSafe(WebRtcACMCodecParams *encParams);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
// with a single codec instance.
|
||||
//
|
||||
virtual bool DecoderParamsSafe(
|
||||
WebRtcACMCodecParams *decParams,
|
||||
virtual bool DecoderParamsSafe(WebRtcACMCodecParams *decParams,
|
||||
const WebRtc_UWord8 payloadType);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -904,24 +826,21 @@ protected:
|
||||
// See InitEncoder() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
//
|
||||
WebRtc_Word16 InitEncoderSafe(
|
||||
WebRtcACMCodecParams *codecParams,
|
||||
WebRtc_Word16 InitEncoderSafe(WebRtcACMCodecParams *codecParams,
|
||||
bool forceInitialization);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See InitDecoder() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
//
|
||||
WebRtc_Word16 InitDecoderSafe(
|
||||
WebRtcACMCodecParams *codecParams,
|
||||
WebRtc_Word16 InitDecoderSafe(WebRtcACMCodecParams *codecParams,
|
||||
bool forceInitialization);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See ResetDecoder() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
//
|
||||
WebRtc_Word16 ResetDecoderSafe(
|
||||
WebRtc_Word16 payloadType);
|
||||
WebRtc_Word16 ResetDecoderSafe(WebRtc_Word16 payloadType);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See DestructEncoder() for the description of function,
|
||||
@ -941,51 +860,47 @@ protected:
|
||||
//
|
||||
// Any codec that can change the bit-rate has to implement this.
|
||||
//
|
||||
virtual WebRtc_Word16 SetBitRateSafe(
|
||||
const WebRtc_Word32 bitRateBPS);
|
||||
virtual WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRateBPS);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See GetEstimatedBandwidth() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
// See GetEstimatedBandwidth() for the description of function,
|
||||
// input(s)/output(s) and return value.
|
||||
//
|
||||
virtual WebRtc_Word32 GetEstimatedBandwidthSafe();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See SetEstimatedBandwidth() for the description of function, input(s)/output(s)
|
||||
// and return value.
|
||||
// See SetEstimatedBandwidth() for the description of function,
|
||||
// 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)
|
||||
// and return value.
|
||||
//
|
||||
virtual WebRtc_Word32 GetRedPayloadSafe(
|
||||
WebRtc_UWord8* redPayload,
|
||||
virtual WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word16* payloadBytes);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See SetVAD() for the description of function, input(s)/output(s) and
|
||||
// return value.
|
||||
//
|
||||
WebRtc_Word16 SetVADSafe(
|
||||
const bool enableDTX = true,
|
||||
const bool enableVAD = false,
|
||||
WebRtc_Word16 SetVADSafe(const bool enableDTX = true, const bool enableVAD =
|
||||
false,
|
||||
const ACMVADMode mode = VADNormal);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See ReplaceInternalDTX() for the description of function, input and
|
||||
// return value.
|
||||
//
|
||||
virtual WebRtc_Word32 ReplaceInternalDTXSafe(
|
||||
const bool replaceInternalDTX);
|
||||
virtual WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// See IsInternalDTXReplaced() for the description of function, input and
|
||||
// return value.
|
||||
//
|
||||
virtual WebRtc_Word32 IsInternalDTXReplacedSafe(
|
||||
bool* internalDTXReplaced);
|
||||
virtual WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 CreateEncoder()
|
||||
@ -997,7 +912,6 @@ protected:
|
||||
//
|
||||
WebRtc_Word16 CreateEncoder();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 CreateDecoder()
|
||||
// Creates the decoder instance.
|
||||
@ -1008,7 +922,6 @@ protected:
|
||||
//
|
||||
WebRtc_Word16 CreateDecoder();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 EnableVAD();
|
||||
// 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 DisableVAD()
|
||||
// Disables VAD.
|
||||
@ -1035,7 +947,6 @@ protected:
|
||||
//
|
||||
WebRtc_Word16 DisableVAD();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 EnableDTX()
|
||||
// Enables DTX. This method should be overwritten for codecs which have
|
||||
@ -1047,7 +958,6 @@ protected:
|
||||
//
|
||||
virtual WebRtc_Word16 EnableDTX();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 DisableDTX()
|
||||
// Disables usage of DTX. This method should be overwritten for codecs which
|
||||
@ -1059,7 +969,6 @@ protected:
|
||||
//
|
||||
virtual WebRtc_Word16 DisableDTX();
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalEncode()
|
||||
// This is a codec-specific function called in EncodeSafe() to actually
|
||||
@ -1075,11 +984,9 @@ protected:
|
||||
// -1 if failed,
|
||||
// otherwise the length of the bit-stream is returned.
|
||||
//
|
||||
virtual WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
virtual WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalInitEncoder()
|
||||
// This is a codec-specific function called in InitEncoderSafe(), it has to
|
||||
@ -1102,7 +1009,6 @@ protected:
|
||||
virtual WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams) = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalInitDecoder()
|
||||
// This is a codec-specific function called in InitDecoderSafe(), it has to
|
||||
@ -1120,7 +1026,6 @@ protected:
|
||||
virtual WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams) = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void IncreaseNoMissedSamples()
|
||||
// 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
|
||||
// by this value.
|
||||
//
|
||||
void IncreaseNoMissedSamples(
|
||||
const WebRtc_Word16 noSamples);
|
||||
|
||||
void IncreaseNoMissedSamples(const WebRtc_Word16 noSamples);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalCreateEncoder()
|
||||
@ -1146,7 +1049,6 @@ protected:
|
||||
//
|
||||
virtual WebRtc_Word16 InternalCreateEncoder() = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalCreateDecoder()
|
||||
// This is a codec-specific method called in CreateDecoderSafe() it is
|
||||
@ -1159,7 +1061,6 @@ protected:
|
||||
//
|
||||
virtual WebRtc_Word16 InternalCreateDecoder() = 0;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// void InternalDestructEncoderInst()
|
||||
// This is a codec-specific method, used in conferencing, called from
|
||||
@ -1175,9 +1076,7 @@ protected:
|
||||
// -1 if failed,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
virtual void InternalDestructEncoderInst(
|
||||
void* ptrInst) = 0;
|
||||
|
||||
virtual void InternalDestructEncoderInst(void* ptrInst) = 0;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 InternalResetEncoder()
|
||||
@ -1194,8 +1093,6 @@ protected:
|
||||
//
|
||||
virtual WebRtc_Word16 InternalResetEncoder();
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// WebRtc_Word16 ProcessFrameVADDTX()
|
||||
// This function is called when a full frame of audio is available. It will
|
||||
@ -1226,12 +1123,10 @@ protected:
|
||||
// -1 if failed,
|
||||
// 0 if succeeded.
|
||||
//
|
||||
WebRtc_Word16 ProcessFrameVADDTX(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 ProcessFrameVADDTX(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_Word16* samplesProcessed);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CanChangeEncodingParam()
|
||||
// Check if the codec parameters can be changed. In conferencing normally
|
||||
@ -1243,7 +1138,6 @@ protected:
|
||||
//
|
||||
virtual bool CanChangeEncodingParam(CodecInst& codecInst);
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// CurrentRate()
|
||||
// Call to get the current encoding rate of the encoder. This function
|
||||
@ -1254,14 +1148,11 @@ protected:
|
||||
// Output:
|
||||
// -rateBitPerSec : the current target rate of the codec.
|
||||
//
|
||||
virtual void CurrentRate(
|
||||
WebRtc_Word32& /* rateBitPerSec */)
|
||||
{
|
||||
virtual void CurrentRate(WebRtc_Word32& /* rateBitPerSec */) {
|
||||
return;
|
||||
}
|
||||
|
||||
virtual void SaveDecoderParamSafe(
|
||||
const WebRtcACMCodecParams* codecParams);
|
||||
virtual void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
|
||||
|
||||
// &_inAudio[_inAudioIxWrite] always point to where new audio can be
|
||||
// written to
|
||||
|
@ -16,24 +16,9 @@
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_GSMFR
|
||||
// NOTE! GSM-FR is not included in the open-source package. The following
|
||||
// interface file is needed:
|
||||
//
|
||||
// /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);
|
||||
// NOTE! GSM-FR is not included in the open-source package. Modify this file
|
||||
// or your codec API to match the function calls and names of used GSM-FR API
|
||||
// file.
|
||||
#include "gsmfr_interface.h"
|
||||
#endif
|
||||
|
||||
@ -47,240 +32,157 @@ ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codecID */)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMGSMFR::~ACMGSMFR()
|
||||
{
|
||||
ACMGSMFR::~ACMGSMFR() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::EnableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::DisableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMGSMFR::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */)
|
||||
{
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMGSMFR::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::DestructEncoderSafe()
|
||||
{
|
||||
void ACMGSMFR::DestructEncoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::DestructDecoderSafe()
|
||||
{
|
||||
void ACMGSMFR::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMGSMFR::ACMGSMFR(
|
||||
WebRtc_Word16 codecID):
|
||||
_encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL)
|
||||
{
|
||||
ACMGSMFR::ACMGSMFR(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
_hasInternalDTX = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMGSMFR::~ACMGSMFR()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
ACMGSMFR::~ACMGSMFR() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*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
|
||||
// we have gone forward in reading the audio buffer
|
||||
_inAudioIxRead += _frameLenSmpl;
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::EnableDTX()
|
||||
{
|
||||
if(_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist)
|
||||
{
|
||||
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0)
|
||||
{
|
||||
} else if (_encoderExist) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"EnableDTX: cannot init encoder for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::DisableDTX()
|
||||
{
|
||||
if(!_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist)
|
||||
{
|
||||
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0)
|
||||
{
|
||||
} else if (_encoderExist) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"DisableDTX: cannot init encoder for GSMFR");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, ((codecParams->enableDTX)? 1:0)) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr,
|
||||
((codecParams->enableDTX) ? 1 : 0)) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalInitEncoder: cannot init encoder for GSMFR");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
if (WebRtcGSMFR_DecoderInit(_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalInitDecoder: cannot init decoder for GSMFR");
|
||||
return -1;
|
||||
@ -288,14 +190,9 @@ ACMGSMFR::InternalInitDecoder(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMGSMFR::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"CodecDef: decoder is not initialized for GSMFR");
|
||||
return -1;
|
||||
@ -304,25 +201,18 @@ ACMGSMFR::CodecDef(
|
||||
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
|
||||
// Then call NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype,
|
||||
_decoderInstPtr, 8000);
|
||||
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, _decoderInstPtr,
|
||||
8000);
|
||||
SET_GSMFR_FUNCTIONS((codecDef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMGSMFR::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalCreateEncoder()
|
||||
{
|
||||
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
|
||||
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
|
||||
return -1;
|
||||
@ -330,12 +220,8 @@ ACMGSMFR::InternalCreateEncoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::DestructEncoderSafe()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
void ACMGSMFR::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
@ -343,12 +229,8 @@ ACMGSMFR::DestructEncoderSafe()
|
||||
_encoderInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMGSMFR::InternalCreateDecoder()
|
||||
{
|
||||
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
|
||||
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
|
||||
return -1;
|
||||
@ -356,12 +238,8 @@ ACMGSMFR::InternalCreateDecoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::DestructDecoderSafe()
|
||||
{
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
void ACMGSMFR::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
@ -369,13 +247,8 @@ ACMGSMFR::DestructDecoderSafe()
|
||||
_decoderInitialized = false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMGSMFR::InternalDestructEncoderInst(
|
||||
void* ptrInst)
|
||||
{
|
||||
if(ptrInst != NULL)
|
||||
{
|
||||
void ACMGSMFR::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst);
|
||||
}
|
||||
return;
|
||||
|
@ -19,34 +19,28 @@ struct GSMFR_decinst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMGSMFR : public ACMGenericCodec
|
||||
{
|
||||
class ACMGSMFR : public ACMGenericCodec {
|
||||
public:
|
||||
ACMGSMFR(WebRtc_Word16 codecID);
|
||||
~ACMGSMFR();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -57,8 +51,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
WebRtc_Word16 EnableDTX();
|
||||
|
||||
|
@ -19,8 +19,7 @@
|
||||
#include "ilbc.h"
|
||||
#endif
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
#ifndef WEBRTC_CODEC_ILBC
|
||||
|
||||
@ -30,145 +29,94 @@ ACMILBC::ACMILBC(WebRtc_Word16 /* codecID */)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMILBC::~ACMILBC()
|
||||
{
|
||||
ACMILBC::~ACMILBC() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMILBC::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */)
|
||||
{
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMILBC::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMILBC::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::DestructEncoderSafe()
|
||||
{
|
||||
void ACMILBC::DestructEncoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::DestructDecoderSafe()
|
||||
{
|
||||
void ACMILBC::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMILBC::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
|
||||
ACMILBC::ACMILBC(
|
||||
WebRtc_Word16 codecID):
|
||||
_encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL)
|
||||
{
|
||||
ACMILBC::ACMILBC(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ACMILBC::~ACMILBC()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
ACMILBC::~ACMILBC() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
|
||||
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
|
||||
if (*bitStreamLenByte < 0)
|
||||
{
|
||||
&_inAudio[_inAudioIxRead],
|
||||
_frameLenSmpl,
|
||||
(WebRtc_Word16*) bitStream);
|
||||
if (*bitStreamLenByte < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalEncode: error in encode for ILBC");
|
||||
return -1;
|
||||
@ -179,78 +127,51 @@ ACMILBC::InternalEncode(
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
// initialize with a correct processing block length
|
||||
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||
(320 == (codecParams->codecInstant).pacsize))
|
||||
{
|
||||
(320 == (codecParams->codecInstant).pacsize)) {
|
||||
// processing block of 20ms
|
||||
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||
}
|
||||
else if((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize))
|
||||
{
|
||||
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize)) {
|
||||
// processing block of 30ms
|
||||
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalInitEncoder: invalid processing block");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||
// initialize with a correct processing block length
|
||||
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||
(320 == (codecParams->codecInstant).pacsize))
|
||||
{
|
||||
(320 == (codecParams->codecInstant).pacsize)) {
|
||||
// processing block of 20ms
|
||||
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
|
||||
}
|
||||
else if((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize))
|
||||
{
|
||||
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||
(480 == (codecParams->codecInstant).pacsize)) {
|
||||
// processing block of 30ms
|
||||
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalInitDecoder: invalid processing block");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMILBC::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"CodeDef: decoder not initialized for ILBC");
|
||||
return -1;
|
||||
@ -259,25 +180,18 @@ ACMILBC::CodecDef(
|
||||
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
|
||||
// Then return the structure back to NetEQ to add the codec to it's
|
||||
// database.
|
||||
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype,
|
||||
_decoderInstPtr, 8000);
|
||||
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, _decoderInstPtr,
|
||||
8000);
|
||||
SET_ILBC_FUNCTIONS((codecDef));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMILBC::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMILBC::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalCreateEncoder()
|
||||
{
|
||||
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
|
||||
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateEncoder: cannot create instance for ILBC encoder");
|
||||
return -1;
|
||||
@ -285,25 +199,17 @@ ACMILBC::InternalCreateEncoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::DestructEncoderSafe()
|
||||
{
|
||||
void ACMILBC::DestructEncoderSafe() {
|
||||
_encoderInitialized = false;
|
||||
_encoderExist = false;
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::InternalCreateDecoder()
|
||||
{
|
||||
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
|
||||
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"InternalCreateDecoder: cannot create instance for ILBC decoder");
|
||||
return -1;
|
||||
@ -311,45 +217,29 @@ ACMILBC::InternalCreateDecoder()
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::DestructDecoderSafe()
|
||||
{
|
||||
void ACMILBC::DestructDecoderSafe() {
|
||||
_decoderInitialized = false;
|
||||
_decoderExist = false;
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMILBC::InternalDestructEncoderInst(
|
||||
void* ptrInst)
|
||||
{
|
||||
if(ptrInst != NULL)
|
||||
{
|
||||
void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate)
|
||||
{
|
||||
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
// Check that rate is valid. No need to store the value
|
||||
if (rate == 13300)
|
||||
{
|
||||
if (rate == 13300) {
|
||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||
}
|
||||
else if (rate == 15200)
|
||||
{
|
||||
} else if (rate == 15200) {
|
||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
_encoderParams.codecInstant.rate = rate;
|
||||
|
@ -17,42 +17,33 @@
|
||||
struct iLBC_encinst_t_;
|
||||
struct iLBC_decinst_t_;
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
class ACMILBC : public ACMGenericCodec
|
||||
{
|
||||
class ACMILBC : public ACMGenericCodec {
|
||||
public:
|
||||
ACMILBC(WebRtc_Word16 codecID);
|
||||
~ACMILBC();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(
|
||||
const WebRtc_Word32 rate);
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
@ -62,8 +53,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
iLBC_encinst_t_* _encoderInstPtr;
|
||||
iLBC_decinst_t_* _decoderInstPtr;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13,129 +13,104 @@
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
struct ACMISACInst;
|
||||
|
||||
enum iSACCodingMode {ADAPTIVE, CHANNEL_INDEPENDENT};
|
||||
enum iSACCodingMode {
|
||||
ADAPTIVE,
|
||||
CHANNEL_INDEPENDENT
|
||||
};
|
||||
|
||||
|
||||
class ACMISAC : public ACMGenericCodec
|
||||
{
|
||||
class ACMISAC : public ACMGenericCodec {
|
||||
public:
|
||||
ACMISAC(WebRtc_Word16 codecID);
|
||||
~ACMISAC();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 DeliverCachedIsacData(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DeliverCachedIsacData(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_UWord32* timestamp,
|
||||
WebRtcACMEncodingType* encodingType,
|
||||
const WebRtc_UWord16 isacRate,
|
||||
const WebRtc_UWord8 isacBWestimate);
|
||||
|
||||
WebRtc_Word16 DeliverCachedData(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 DeliverCachedData(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */,
|
||||
WebRtc_UWord32* /* timestamp */,
|
||||
WebRtcACMEncodingType* /* encodingType */)
|
||||
{
|
||||
WebRtcACMEncodingType* /* encodingType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16 UpdateDecoderSampFreq(
|
||||
WebRtc_Word16 codecId);
|
||||
WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codecId);
|
||||
|
||||
WebRtc_Word16 UpdateEncoderSampFreq(
|
||||
WebRtc_UWord16 sampFreqHz);
|
||||
WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 sampFreqHz);
|
||||
|
||||
WebRtc_Word16 EncoderSampFreq(
|
||||
WebRtc_UWord16& sampFreqHz);
|
||||
WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
|
||||
|
||||
WebRtc_Word32 ConfigISACBandwidthEstimator(
|
||||
const WebRtc_UWord8 initFrameSizeMsec,
|
||||
const WebRtc_UWord16 initRateBitPerSec,
|
||||
const bool enforceFrameSize);
|
||||
const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
|
||||
|
||||
WebRtc_Word32 SetISACMaxPayloadSize(
|
||||
const WebRtc_UWord16 maxPayloadLenBytes);
|
||||
WebRtc_Word32 SetISACMaxPayloadSize(const WebRtc_UWord16 maxPayloadLenBytes);
|
||||
|
||||
WebRtc_Word32 SetISACMaxRate(
|
||||
const WebRtc_UWord32 maxRateBitPerSec);
|
||||
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
|
||||
|
||||
WebRtc_Word16 REDPayloadISAC(
|
||||
const WebRtc_Word32 isacRate,
|
||||
WebRtc_Word16 REDPayloadISAC(const WebRtc_Word32 isacRate,
|
||||
const WebRtc_Word16 isacBwEstimate,
|
||||
WebRtc_UWord8* payload,
|
||||
WebRtc_Word16* payloadLenBytes);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte, WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
|
||||
void DestructDecoderSafe();
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(
|
||||
const WebRtc_Word32 bitRate);
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRate);
|
||||
|
||||
WebRtc_Word32 GetEstimatedBandwidthSafe();
|
||||
|
||||
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
|
||||
|
||||
WebRtc_Word32 GetRedPayloadSafe(
|
||||
WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
|
||||
WebRtc_Word16* payloadBytes);
|
||||
|
||||
WebRtc_Word16 InternalCreateEncoder();
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
WebRtc_Word16 Transcode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte,
|
||||
WebRtc_Word16 qBWE,
|
||||
WebRtc_Word32 rate,
|
||||
bool isRED);
|
||||
WebRtc_Word16 Transcode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte, WebRtc_Word16 qBWE,
|
||||
WebRtc_Word32 rate, bool isRED);
|
||||
|
||||
void CurrentRate(WebRtc_Word32& rateBitPerSec);
|
||||
|
||||
void UpdateFrameLen();
|
||||
|
||||
bool DecoderParamsSafe(
|
||||
WebRtcACMCodecParams *decParams,
|
||||
bool DecoderParamsSafe(WebRtcACMCodecParams *decParams,
|
||||
const WebRtc_UWord8 payloadType);
|
||||
|
||||
void SaveDecoderParamSafe(
|
||||
const WebRtcACMCodecParams* codecParams);
|
||||
void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
|
||||
|
||||
ACMISACInst* _codecInstPtr;
|
||||
|
||||
bool _isEncInitialized;
|
||||
iSACCodingMode _isacCodingMode;
|
||||
bool _enforceFrameSize;
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
#include "engine_configurations.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
#ifdef WEBRTC_CODEC_ISAC
|
||||
#define ACM_ISAC_CREATE WebRtcIsac_Create
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -29,8 +29,7 @@ enum ACMSpeechType;
|
||||
|
||||
#define MAX_NUM_SLAVE_NETEQ 1
|
||||
|
||||
class ACMNetEQ
|
||||
{
|
||||
class ACMNetEQ {
|
||||
public:
|
||||
// Constructor of the class
|
||||
ACMNetEQ();
|
||||
@ -62,8 +61,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 RecIn(
|
||||
const WebRtc_UWord8* incomingPayload,
|
||||
WebRtc_Word32 RecIn(const WebRtc_UWord8* incomingPayload,
|
||||
const WebRtc_Word32 payloadLength,
|
||||
const WebRtcRTPHeader& rtpInfo);
|
||||
|
||||
@ -78,8 +76,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// -1 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 RecOut(
|
||||
AudioFrame& audioFrame);
|
||||
WebRtc_Word32 RecOut(AudioFrame& audioFrame);
|
||||
|
||||
//
|
||||
// AddCodec()
|
||||
@ -94,9 +91,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 AddCodec(
|
||||
WebRtcNetEQ_CodecDef *codecDef,
|
||||
bool toMaster = true);
|
||||
WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codecDef, bool toMaster = true);
|
||||
|
||||
//
|
||||
// AllocatePacketBuffer()
|
||||
@ -109,8 +104,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 AllocatePacketBuffer(
|
||||
const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs);
|
||||
|
||||
//
|
||||
@ -123,8 +117,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 SetExtraDelay(
|
||||
const WebRtc_Word32 delayInMS);
|
||||
WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delayInMS);
|
||||
|
||||
//
|
||||
// SetAVTPlayout()
|
||||
@ -136,8 +129,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 SetAVTPlayout(
|
||||
const bool enable);
|
||||
WebRtc_Word32 SetAVTPlayout(const bool enable);
|
||||
|
||||
//
|
||||
// AVTPlayout()
|
||||
@ -167,8 +159,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 SetPlayoutMode(
|
||||
const AudioPlayoutMode mode);
|
||||
WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode);
|
||||
|
||||
//
|
||||
// PlayoutMode()
|
||||
@ -188,8 +179,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// <0 if NetEQ returned an error.
|
||||
//
|
||||
WebRtc_Word32 NetworkStatistics(
|
||||
ACMNetworkStatistics* statistics) const;
|
||||
WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const;
|
||||
|
||||
//
|
||||
// VADMode()
|
||||
@ -209,8 +199,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// -1 if an error occurred.
|
||||
//
|
||||
WebRtc_Word16 SetVADMode(
|
||||
const ACMVADMode mode);
|
||||
WebRtc_Word16 SetVADMode(const ACMVADMode mode);
|
||||
|
||||
//
|
||||
// DecodeLock()
|
||||
@ -218,8 +207,7 @@ public:
|
||||
//
|
||||
// Return value : Pointer to the decode lock.
|
||||
//
|
||||
RWLockWrapper* DecodeLock() const
|
||||
{
|
||||
RWLockWrapper* DecodeLock() const {
|
||||
return _decodeLock;
|
||||
}
|
||||
|
||||
@ -242,10 +230,7 @@ public:
|
||||
// Return value : 0 if ok.
|
||||
// -1 if an error occurred.
|
||||
//
|
||||
WebRtc_Word16 RemoveCodec(
|
||||
WebRtcNetEQDecoder codecIdx,
|
||||
bool isStereo = false);
|
||||
|
||||
WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codecIdx, bool isStereo = false);
|
||||
|
||||
//
|
||||
// SetBackgroundNoiseMode()
|
||||
@ -258,8 +243,7 @@ public:
|
||||
// Return value : 0 if succeeded,
|
||||
// -1 if failed to set the mode.
|
||||
//
|
||||
WebRtc_Word16 SetBackgroundNoiseMode(
|
||||
const ACMBackgroundNoiseMode mode);
|
||||
WebRtc_Word16 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
|
||||
|
||||
//
|
||||
// BackgroundNoiseMode()
|
||||
@ -267,27 +251,25 @@ public:
|
||||
//
|
||||
// Return value : The mode of background noise.
|
||||
//
|
||||
WebRtc_Word16 BackgroundNoiseMode(
|
||||
ACMBackgroundNoiseMode& mode);
|
||||
WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
|
||||
|
||||
void SetUniqueId(
|
||||
WebRtc_Word32 id);
|
||||
void SetUniqueId(WebRtc_Word32 id);
|
||||
|
||||
WebRtc_Word32 PlayoutTimestamp(
|
||||
WebRtc_UWord32& timestamp);
|
||||
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
|
||||
|
||||
void SetReceivedStereo(
|
||||
bool receivedStereo);
|
||||
void SetReceivedStereo(bool receivedStereo);
|
||||
|
||||
WebRtc_UWord8 NumSlaves();
|
||||
|
||||
enum JB {masterJB = 0, slaveJB = 1};
|
||||
enum JB {
|
||||
masterJB = 0,
|
||||
slaveJB = 1
|
||||
};
|
||||
|
||||
// Delete all slaves.
|
||||
void RemoveSlaves();
|
||||
|
||||
WebRtc_Word16 AddSlave(
|
||||
const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* usedCodecs,
|
||||
WebRtc_Word16 noOfCodecs);
|
||||
|
||||
private:
|
||||
@ -304,18 +286,13 @@ private:
|
||||
// Output:
|
||||
// - rtpPacket : The RTP packet.
|
||||
//
|
||||
static void RTPPack(
|
||||
WebRtc_Word16* rtpPacket,
|
||||
const WebRtc_Word8* payload,
|
||||
static void RTPPack(WebRtc_Word16* rtpPacket, const WebRtc_Word8* payload,
|
||||
const WebRtc_Word32 payloadLengthW8,
|
||||
const WebRtcRTPHeader& rtpInfo);
|
||||
|
||||
void LogError(
|
||||
const char* neteqFuncName,
|
||||
const WebRtc_Word16 idx) const;
|
||||
void LogError(const char* neteqFuncName, const WebRtc_Word16 idx) const;
|
||||
|
||||
WebRtc_Word16 InitByIdxSafe(
|
||||
const WebRtc_Word16 idx);
|
||||
WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx);
|
||||
|
||||
// EnableVAD()
|
||||
// Enable VAD.
|
||||
@ -325,8 +302,7 @@ private:
|
||||
//
|
||||
WebRtc_Word16 EnableVAD();
|
||||
|
||||
WebRtc_Word16 EnableVADByIdxSafe(
|
||||
const WebRtc_Word16 idx);
|
||||
WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx);
|
||||
|
||||
WebRtc_Word16 AllocatePacketBufferByIdxSafe(
|
||||
const WebRtcNetEQDecoder* usedCodecs,
|
||||
|
@ -90,7 +90,6 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
|
||||
}
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
||||
|
@ -13,37 +13,30 @@
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCM16B : public ACMGenericCodec
|
||||
{
|
||||
class ACMPCM16B : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCM16B(WebRtc_Word16 codecID);
|
||||
~ACMPCM16B();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -54,8 +47,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
|
||||
|
@ -13,37 +13,30 @@
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCMA : public ACMGenericCodec
|
||||
{
|
||||
class ACMPCMA : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCMA(WebRtc_Word16 codecID);
|
||||
~ACMPCMA();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -54,8 +47,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
};
|
||||
|
@ -13,37 +13,30 @@
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
class ACMPCMU : public ACMGenericCodec
|
||||
{
|
||||
class ACMPCMU : public ACMGenericCodec {
|
||||
public:
|
||||
ACMPCMU(WebRtc_Word16 codecID);
|
||||
~ACMPCMU();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -54,8 +47,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||
};
|
||||
|
@ -15,71 +15,48 @@
|
||||
#include "webrtc_neteq.h"
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
ACMRED::ACMRED(WebRtc_Word16 codecID)
|
||||
{
|
||||
ACMRED::ACMRED(WebRtc_Word16 codecID) {
|
||||
_codecID = codecID;
|
||||
}
|
||||
|
||||
|
||||
ACMRED::~ACMRED()
|
||||
{
|
||||
ACMRED::~ACMRED() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
// RED is never used as an encoder
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMRED::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
// This codec does not need initialization,
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMRED::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
// This codec does not need initialization,
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word32
|
||||
ACMRED::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
// Todo:
|
||||
// log error
|
||||
return -1;
|
||||
@ -94,48 +71,31 @@ ACMRED::CodecDef(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMRED::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMRED::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMRED::InternalCreateEncoder() {
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMRED::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMRED::InternalCreateDecoder() {
|
||||
// RED has no instance
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMRED::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMRED::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
// RED has no instance
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMRED::DestructEncoderSafe()
|
||||
{
|
||||
void ACMRED::DestructEncoderSafe() {
|
||||
// RED has no instance
|
||||
return;
|
||||
}
|
||||
|
||||
void ACMRED::DestructDecoderSafe()
|
||||
{
|
||||
void ACMRED::DestructDecoderSafe() {
|
||||
// RED has no instance
|
||||
return;
|
||||
}
|
||||
|
@ -13,37 +13,30 @@
|
||||
|
||||
#include "acm_generic_codec.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
class ACMRED : public ACMGenericCodec
|
||||
{
|
||||
class ACMRED : public ACMGenericCodec {
|
||||
public:
|
||||
ACMRED(WebRtc_Word16 codecID);
|
||||
~ACMRED();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -54,8 +47,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
@ -17,34 +17,8 @@
|
||||
#include "webrtc_neteq_help_macros.h"
|
||||
|
||||
#ifdef WEBRTC_CODEC_SPEEX
|
||||
// NOTE! Speex is not included in the open-source package. The following
|
||||
// interface file is needed:
|
||||
//
|
||||
// /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);
|
||||
// NOTE! Speex is not included in the open-source package. Modify this file or
|
||||
// your codec API to match the function calls and names of used Speex API file.
|
||||
#include "speex_interface.h"
|
||||
#endif
|
||||
|
||||
@ -62,153 +36,105 @@ ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codecID */)
|
||||
return;
|
||||
}
|
||||
|
||||
ACMSPEEX::~ACMSPEEX()
|
||||
{
|
||||
ACMSPEEX::~ACMSPEEX() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalEncode(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::EnableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DisableDTX()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
ACMSPEEX::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */)
|
||||
{
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||
const CodecInst& /* codecInst */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMSPEEX::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
ACMSPEEX::DestructEncoderSafe()
|
||||
{
|
||||
void ACMSPEEX::DestructEncoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
ACMSPEEX::DestructDecoderSafe()
|
||||
{
|
||||
void ACMSPEEX::DestructDecoderSafe() {
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::SetBitRateSafe(
|
||||
const WebRtc_Word32 /* rate */)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
ACMSPEEX::InternalDestructEncoderInst(
|
||||
void* /* ptrInst */)
|
||||
{
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef UNUSEDSPEEX
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::EnableVBR()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DisableVBR()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::SetComplMode(
|
||||
WebRtc_Word16 mode)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else //===================== Actual Implementation =======================
|
||||
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID):
|
||||
_encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL)
|
||||
{
|
||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID)
|
||||
: _encoderInstPtr(NULL),
|
||||
_decoderInstPtr(NULL) {
|
||||
_codecID = codecID;
|
||||
|
||||
// Set sampling frequency, frame size and rate Speex
|
||||
if(_codecID == ACMCodecDB::kSPEEX8)
|
||||
{
|
||||
if (_codecID == ACMCodecDB::kSPEEX8) {
|
||||
_samplingFrequency = 8000;
|
||||
_samplesIn20MsAudio = 160;
|
||||
_encodingRate = 11000;
|
||||
}
|
||||
else if(_codecID == ACMCodecDB::kSPEEX16)
|
||||
{
|
||||
} else if (_codecID == ACMCodecDB::kSPEEX16) {
|
||||
_samplingFrequency = 16000;
|
||||
_samplesIn20MsAudio = 320;
|
||||
_encodingRate = 22000;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Wrong codec id for Speex.");
|
||||
|
||||
@ -225,32 +151,25 @@ _decoderInstPtr(NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
ACMSPEEX::~ACMSPEEX()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
ACMSPEEX::~ACMSPEEX() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalEncode(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16* bitStreamLenByte) {
|
||||
WebRtc_Word16 status;
|
||||
WebRtc_Word16 numEncodedSamples = 0;
|
||||
WebRtc_Word16 n = 0;
|
||||
|
||||
while( numEncodedSamples < _frameLenSmpl)
|
||||
{
|
||||
while (numEncodedSamples < _frameLenSmpl) {
|
||||
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
||||
_encodingRate);
|
||||
|
||||
@ -259,22 +178,19 @@ ACMSPEEX::InternalEncode(
|
||||
_inAudioIxRead += _samplesIn20MsAudio;
|
||||
numEncodedSamples += _samplesIn20MsAudio;
|
||||
|
||||
if(status < 0)
|
||||
{
|
||||
if (status < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Error in Speex encoder");
|
||||
return status;
|
||||
}
|
||||
|
||||
// Update VAD, if internal DTX is used
|
||||
if(_hasInternalDTX && _dtxEnabled)
|
||||
{
|
||||
if (_hasInternalDTX && _dtxEnabled) {
|
||||
_vadLabel[n++] = status;
|
||||
_vadLabel[n++] = status;
|
||||
}
|
||||
|
||||
if(status == 0)
|
||||
{
|
||||
if (status == 0) {
|
||||
// This frame is detected as inactive. We need send whatever
|
||||
// encoded so far.
|
||||
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
||||
@ -289,65 +205,48 @@ ACMSPEEX::InternalEncode(
|
||||
return *bitStreamLenByte;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DecodeSafe(
|
||||
WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||
WebRtc_Word16 /* bitStreamLenByte */,
|
||||
WebRtc_Word16* /* audio */,
|
||||
WebRtc_Word16* /* audioSamples */,
|
||||
WebRtc_Word8* /* speechType */)
|
||||
{
|
||||
WebRtc_Word8* /* speechType */) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::EnableDTX()
|
||||
{
|
||||
if(_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||
if (_dtxEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist) // check if encoder exist
|
||||
{
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
// 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,
|
||||
"Cannot enable DTX for Speex");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DisableDTX()
|
||||
{
|
||||
if(!_dtxEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||
if (!_dtxEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist) // check if encoder exist
|
||||
{
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
// 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,
|
||||
"Cannot disable DTX for Speex");
|
||||
return -1;
|
||||
}
|
||||
_dtxEnabled = false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
return 0;
|
||||
}
|
||||
@ -355,20 +254,19 @@ ACMSPEEX::DisableDTX()
|
||||
return 0;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalInitEncoder(
|
||||
WebRtcACMCodecParams* codecParams)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||
// sanity check
|
||||
if (_encoderInstPtr == NULL)
|
||||
{
|
||||
if (_encoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Cannot initialize Speex encoder, instance does not exist");
|
||||
return -1;
|
||||
}
|
||||
|
||||
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) {
|
||||
return 0;
|
||||
@ -379,15 +277,12 @@ ACMSPEEX::InternalInitEncoder(
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||
WebRtcACMCodecParams* /* codecParams */) {
|
||||
WebRtc_Word16 status;
|
||||
|
||||
// sanity check
|
||||
if (_decoderInstPtr == NULL)
|
||||
{
|
||||
if (_decoderInstPtr == NULL) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Cannot initialize Speex decoder, instance does not exist");
|
||||
return -1;
|
||||
@ -403,13 +298,9 @@ ACMSPEEX::InternalInitDecoder(
|
||||
}
|
||||
}
|
||||
|
||||
WebRtc_Word32
|
||||
ACMSPEEX::CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst)
|
||||
{
|
||||
if (!_decoderInitialized)
|
||||
{
|
||||
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst) {
|
||||
if (!_decoderInitialized) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Error, Speex decoder is not initialized");
|
||||
return -1;
|
||||
@ -420,22 +311,18 @@ ACMSPEEX::CodecDef(
|
||||
// Then call NetEQ to add the codec to its
|
||||
// database.
|
||||
|
||||
switch(_samplingFrequency)
|
||||
{
|
||||
case 8000:
|
||||
{
|
||||
switch (_samplingFrequency) {
|
||||
case 8000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype,
|
||||
_decoderInstPtr, 8000);
|
||||
break;
|
||||
}
|
||||
case 16000:
|
||||
{
|
||||
case 16000: {
|
||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype,
|
||||
_decoderInstPtr, 16000);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||
"Unsupported sampling frequency for Speex");
|
||||
|
||||
@ -447,23 +334,16 @@ ACMSPEEX::CodecDef(
|
||||
return 0;
|
||||
}
|
||||
|
||||
ACMGenericCodec*
|
||||
ACMSPEEX::CreateInstance(void)
|
||||
{
|
||||
ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalCreateEncoder()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
|
||||
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
|
||||
}
|
||||
|
||||
void
|
||||
ACMSPEEX::DestructEncoderSafe()
|
||||
{
|
||||
if(_encoderInstPtr != NULL)
|
||||
{
|
||||
void ACMSPEEX::DestructEncoderSafe() {
|
||||
if (_encoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||
_encoderInstPtr = NULL;
|
||||
}
|
||||
@ -473,18 +353,12 @@ ACMSPEEX::DestructEncoderSafe()
|
||||
_encodingRate = 0;
|
||||
}
|
||||
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::InternalCreateDecoder()
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
|
||||
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
|
||||
}
|
||||
|
||||
void
|
||||
ACMSPEEX::DestructDecoderSafe()
|
||||
{
|
||||
if(_decoderInstPtr != NULL)
|
||||
{
|
||||
void ACMSPEEX::DestructDecoderSafe() {
|
||||
if (_decoderInstPtr != NULL) {
|
||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||
_decoderInstPtr = NULL;
|
||||
}
|
||||
@ -493,10 +367,7 @@ ACMSPEEX::DestructDecoderSafe()
|
||||
_decoderInitialized = false;
|
||||
}
|
||||
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::SetBitRateSafe(
|
||||
const WebRtc_Word32 rate)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||
// Check if changed rate
|
||||
if (rate == _encodingRate) {
|
||||
return 0;
|
||||
@ -513,13 +384,8 @@ ACMSPEEX::SetBitRateSafe(
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ACMSPEEX::InternalDestructEncoderInst(
|
||||
void* ptrInst)
|
||||
{
|
||||
if(ptrInst != NULL)
|
||||
{
|
||||
void ACMSPEEX::InternalDestructEncoderInst(void* ptrInst) {
|
||||
if (ptrInst != NULL) {
|
||||
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst);
|
||||
}
|
||||
return;
|
||||
@ -529,18 +395,14 @@ ACMSPEEX::InternalDestructEncoderInst(
|
||||
|
||||
// This API is currently not in use. If requested to be able to enable/disable VBR
|
||||
// an ACM API need to be added.
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::EnableVBR()
|
||||
{
|
||||
if(_vbrEnabled)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||
if (_vbrEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist) // check if encoder exist
|
||||
} else if (_encoderExist) // check if encoder exist
|
||||
{
|
||||
// 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,
|
||||
"Cannot enable VBR mode for Speex");
|
||||
|
||||
@ -548,28 +410,20 @@ ACMSPEEX::EnableVBR()
|
||||
}
|
||||
_vbrEnabled = true;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This API is currently not in use. If requested to be able to enable/disable VBR
|
||||
// an ACM API need to be added.
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::DisableVBR()
|
||||
{
|
||||
if(!_vbrEnabled)
|
||||
{
|
||||
// This API is currently not in use. If requested to be able to enable/disable
|
||||
// VBR an ACM API need to be added.
|
||||
WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||
if (!_vbrEnabled) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist) // check if encoder exist
|
||||
{
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
// 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,
|
||||
"Cannot disable DTX for Speex");
|
||||
|
||||
@ -577,9 +431,7 @@ ACMSPEEX::DisableVBR()
|
||||
}
|
||||
_vbrEnabled = false;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
return 0;
|
||||
}
|
||||
@ -587,29 +439,21 @@ ACMSPEEX::DisableVBR()
|
||||
|
||||
// This API is currently not in use. If requested to be able to set complexity
|
||||
// an ACM API need to be added.
|
||||
WebRtc_Word16
|
||||
ACMSPEEX::SetComplMode(
|
||||
WebRtc_Word16 mode)
|
||||
{
|
||||
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||
// Check if new mode
|
||||
if(mode == _complMode)
|
||||
{
|
||||
if (mode == _complMode) {
|
||||
return 0;
|
||||
}
|
||||
else if(_encoderExist) // check if encoder exist
|
||||
{
|
||||
} else if (_encoderExist) { // check if encoder exist
|
||||
// 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,
|
||||
"Error in complexity mode for Speex");
|
||||
return -1;
|
||||
}
|
||||
_complMode = mode;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// encoder doesn't exists, therefore disabling is harmless
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,34 +19,28 @@ struct SPEEX_decinst_t_;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class ACMSPEEX : public ACMGenericCodec
|
||||
{
|
||||
class ACMSPEEX : public ACMGenericCodec {
|
||||
public:
|
||||
ACMSPEEX(WebRtc_Word16 codecID);
|
||||
~ACMSPEEX();
|
||||
// for FEC
|
||||
ACMGenericCodec* CreateInstance(void);
|
||||
|
||||
WebRtc_Word16 InternalEncode(
|
||||
WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||
WebRtc_Word16* bitStreamLenByte);
|
||||
|
||||
WebRtc_Word16 InternalInitEncoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
WebRtc_Word16 InternalInitDecoder(
|
||||
WebRtcACMCodecParams *codecParams);
|
||||
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||
|
||||
protected:
|
||||
WebRtc_Word16 DecodeSafe(
|
||||
WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||
WebRtc_Word16 bitStreamLenByte,
|
||||
WebRtc_Word16* audio,
|
||||
WebRtc_Word16* audioSamples,
|
||||
WebRtc_Word8* speechType);
|
||||
|
||||
WebRtc_Word32 CodecDef(
|
||||
WebRtcNetEQ_CodecDef& codecDef,
|
||||
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||
const CodecInst& codecInst);
|
||||
|
||||
void DestructEncoderSafe();
|
||||
@ -57,11 +51,9 @@ protected:
|
||||
|
||||
WebRtc_Word16 InternalCreateDecoder();
|
||||
|
||||
void InternalDestructEncoderInst(
|
||||
void* ptrInst);
|
||||
void InternalDestructEncoderInst(void* ptrInst);
|
||||
|
||||
WebRtc_Word16 SetBitRateSafe(
|
||||
const WebRtc_Word32 rate);
|
||||
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||
|
||||
WebRtc_Word16 EnableDTX();
|
||||
|
||||
@ -72,8 +64,7 @@ protected:
|
||||
|
||||
WebRtc_Word16 DisableVBR();
|
||||
|
||||
WebRtc_Word16 SetComplMode(
|
||||
WebRtc_Word16 mode);
|
||||
WebRtc_Word16 SetComplMode(WebRtc_Word16 mode);
|
||||
#endif
|
||||
|
||||
SPEEX_encinst_t_* _encoderInstPtr;
|
||||
|
@ -8,51 +8,38 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
|
||||
#include "acm_dtmf_detection.h"
|
||||
#include "audio_coding_module.h"
|
||||
#include "audio_coding_module_impl.h"
|
||||
#include "trace.h"
|
||||
|
||||
namespace webrtc
|
||||
{
|
||||
namespace webrtc {
|
||||
|
||||
// Create module
|
||||
AudioCodingModule*
|
||||
AudioCodingModule::Create(
|
||||
const WebRtc_Word32 id)
|
||||
{
|
||||
AudioCodingModule* AudioCodingModule::Create(const WebRtc_Word32 id) {
|
||||
return new AudioCodingModuleImpl(id);
|
||||
}
|
||||
|
||||
// Destroy module
|
||||
void
|
||||
AudioCodingModule::Destroy(
|
||||
AudioCodingModule* module)
|
||||
{
|
||||
void AudioCodingModule::Destroy(AudioCodingModule* module) {
|
||||
delete static_cast<AudioCodingModuleImpl*>(module);
|
||||
}
|
||||
|
||||
// Get number of supported codecs
|
||||
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs()
|
||||
{
|
||||
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
|
||||
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
|
||||
}
|
||||
|
||||
// Get supported codec param with id
|
||||
WebRtc_Word32
|
||||
AudioCodingModule::Codec(
|
||||
const WebRtc_UWord8 listId,
|
||||
CodecInst& codec)
|
||||
{
|
||||
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 listId,
|
||||
CodecInst& codec) {
|
||||
// Get the codec settings for the codec with the given list ID
|
||||
return ACMCodecDB::Codec(listId, &codec);
|
||||
}
|
||||
|
||||
// Get supported codec Param with name, frequency and number of channels.
|
||||
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
||||
CodecInst& codec,
|
||||
int sampling_freq_hz,
|
||||
CodecInst& codec, int sampling_freq_hz,
|
||||
int channels) {
|
||||
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.
|
||||
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
||||
int sampling_freq_hz,
|
||||
int channels) {
|
||||
int sampling_freq_hz, int channels) {
|
||||
return ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
|
||||
}
|
||||
|
||||
// Checks the validity of the parameters of the given codec
|
||||
bool
|
||||
AudioCodingModule::IsCodecValid(
|
||||
const CodecInst& codec)
|
||||
{
|
||||
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
|
||||
int mirrorID;
|
||||
char errMsg[500];
|
||||
|
||||
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
|
||||
|
||||
if(codecNumber < 0)
|
||||
{
|
||||
if (codecNumber < 0) {
|
||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user