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,25 +16,10 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_G729
|
#ifdef WEBRTC_CODEC_G729
|
||||||
// NOTE! G.729 is not included in the open-source package. The following
|
// NOTE! G.729 is not included in the open-source package. Modify this file
|
||||||
// interface file is needed:
|
// or your codec API to match the function calls and names of used G.729 API
|
||||||
//
|
// file.
|
||||||
// /modules/audio_coding/codecs/g729/main/interface/g729_interface.h
|
#include "g729_interface.h"
|
||||||
//
|
|
||||||
// The API in the header file should match the one below.
|
|
||||||
//
|
|
||||||
// int16_t WebRtcG729_CreateEnc(G729_encinst_t_** inst);
|
|
||||||
// int16_t WebRtcG729_CreateDec(G729_decinst_t_** inst);
|
|
||||||
// int16_t WebRtcG729_FreeEnc(G729_encinst_t_* inst);
|
|
||||||
// int16_t WebRtcG729_FreeDec(G729_decinst_t_* inst);
|
|
||||||
// int16_t WebRtcG729_Encode(G729_encinst_t_* encInst, int16_t* input,
|
|
||||||
// int16_t len, int16_t* output);
|
|
||||||
// int16_t WebRtcG729_EncoderInit(G729_encinst_t_* encInst, int16_t mode);
|
|
||||||
// int16_t WebRtcG729_Decode(G729_decinst_t_* decInst);
|
|
||||||
// int16_t WebRtcG729_DecodeBwe(G729_decinst_t_* decInst, int16_t* input);
|
|
||||||
// int16_t WebRtcG729_DecodePlc(G729_decinst_t_* decInst);
|
|
||||||
// int16_t WebRtcG729_DecoderInit(G729_decinst_t_* decInst);
|
|
||||||
#include "g729_interface.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -47,469 +32,329 @@ ACMG729::ACMG729(WebRtc_Word16 /* codecID */)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMG729::~ACMG729() {
|
||||||
ACMG729::~ACMG729()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
ACMG729::InternalEncode(
|
return -1;
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::EnableDTX() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729::EnableDTX()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::DisableDTX() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729::DisableDTX()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(
|
||||||
ACMG729::ReplaceInternalDTXSafe(
|
const bool /*replaceInternalDTX*/) {
|
||||||
const bool /*replaceInternalDTX*/)
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(
|
||||||
ACMG729::IsInternalDTXReplacedSafe(
|
bool* /* internalDTXReplaced */) {
|
||||||
bool* /* internalDTXReplaced */)
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
ACMG729::DecodeSafe(
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audioSamples */,
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
WebRtc_Word8* /* speechType */) {
|
||||||
WebRtc_Word16* /* audio */,
|
return -1;
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalInitEncoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMG729::InternalInitEncoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalInitDecoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMG729::InternalInitDecoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMG729::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||||
WebRtc_Word32
|
const CodecInst& /* codecInst */) {
|
||||||
ACMG729::CodecDef(
|
return -1;
|
||||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
|
||||||
const CodecInst& /* codecInst */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMG729::CreateInstance(void) {
|
||||||
ACMGenericCodec*
|
return NULL;
|
||||||
ACMG729::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729::InternalCreateEncoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729::DestructEncoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMG729::DestructEncoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729::InternalCreateDecoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729::DestructDecoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMG729::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
void
|
return;
|
||||||
ACMG729::InternalDestructEncoderInst(
|
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //===================== Actual Implementation =======================
|
#else //===================== Actual Implementation =======================
|
||||||
|
ACMG729::ACMG729(WebRtc_Word16 codecID)
|
||||||
ACMG729::ACMG729(
|
: _encoderInstPtr(NULL),
|
||||||
WebRtc_Word16 codecID):
|
_decoderInstPtr(NULL) {
|
||||||
_encoderInstPtr(NULL),
|
_codecID = codecID;
|
||||||
_decoderInstPtr(NULL)
|
_hasInternalDTX = true;
|
||||||
{
|
return;
|
||||||
_codecID = codecID;
|
|
||||||
_hasInternalDTX = true;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMG729::~ACMG729() {
|
||||||
ACMG729::~ACMG729()
|
if (_encoderInstPtr != NULL) {
|
||||||
{
|
// Delete encoder memory
|
||||||
if(_encoderInstPtr != NULL)
|
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||||
{
|
_encoderInstPtr = NULL;
|
||||||
// Delete encoder memory
|
}
|
||||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
if (_decoderInstPtr != NULL) {
|
||||||
_encoderInstPtr = NULL;
|
// Delete decoder memory
|
||||||
}
|
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||||
if(_decoderInstPtr != NULL)
|
_decoderInstPtr = NULL;
|
||||||
{
|
}
|
||||||
// Delete decoder memory
|
return;
|
||||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// Call G.729 encoder with pointer to encoder memory, input
|
||||||
|
// audio, number of samples and bitsream
|
||||||
|
tmpLenByte = WebRtcG729_Encode(
|
||||||
|
_encoderInstPtr, &_inAudio[_inAudioIxRead], 80,
|
||||||
|
(WebRtc_Word16*) (&(bitStream[*bitStreamLenByte])));
|
||||||
|
|
||||||
WebRtc_Word16
|
// increment the read index this tell the caller that how far
|
||||||
ACMG729::InternalEncode(
|
// we have gone forward in reading the audio buffer
|
||||||
WebRtc_UWord8* bitStream,
|
_inAudioIxRead += 80;
|
||||||
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)
|
|
||||||
{
|
|
||||||
// Call G.729 encoder with pointer to encoder memory, input
|
|
||||||
// audio, number of samples and bitsream
|
|
||||||
tmpLenByte = WebRtcG729_Encode(_encoderInstPtr,
|
|
||||||
&_inAudio[_inAudioIxRead], 80,
|
|
||||||
(WebRtc_Word16*)(&(bitStream[*bitStreamLenByte])));
|
|
||||||
|
|
||||||
// increment the read index this tell the caller that how far
|
// sanity check
|
||||||
// we have gone forward in reading the audio buffer
|
if (tmpLenByte < 0) {
|
||||||
_inAudioIxRead += 80;
|
// error has happened
|
||||||
|
*bitStreamLenByte = 0;
|
||||||
// sanity check
|
return -1;
|
||||||
if(tmpLenByte < 0)
|
|
||||||
{
|
|
||||||
// error has happened
|
|
||||||
*bitStreamLenByte = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// increment number of written bytes
|
|
||||||
*bitStreamLenByte += tmpLenByte;
|
|
||||||
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.
|
|
||||||
// we do not continue encoding this frame.
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
// check if G.729 internal DTX is enabled
|
|
||||||
if(_hasInternalDTX && _dtxEnabled)
|
|
||||||
{
|
|
||||||
vadDecision = 0;
|
|
||||||
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
|
|
||||||
{
|
|
||||||
_vadLabel[n] = vadDecision;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// we got a SID and have to send out this packet no matter
|
|
||||||
// how much audio we have encoded
|
|
||||||
return *bitStreamLenByte;
|
|
||||||
}
|
|
||||||
case 10:
|
|
||||||
{
|
|
||||||
vadDecision = 1;
|
|
||||||
// this is a valid length just continue encoding
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update number of encoded samples
|
|
||||||
noEncodedSamples += 80;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update VAD decision vector
|
// increment number of written bytes
|
||||||
if(_hasInternalDTX && !vadDecision && _dtxEnabled)
|
*bitStreamLenByte += tmpLenByte;
|
||||||
{
|
switch (tmpLenByte) {
|
||||||
for(WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++)
|
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.
|
||||||
|
// we do not continue encoding this frame.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
// check if G.729 internal DTX is enabled
|
||||||
|
if (_hasInternalDTX && _dtxEnabled) {
|
||||||
|
vadDecision = 0;
|
||||||
|
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||||
_vadLabel[n] = vadDecision;
|
_vadLabel[n] = vadDecision;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// we got a SID and have to send out this packet no matter
|
||||||
|
// how much audio we have encoded
|
||||||
// done encoding, return number of encoded bytes
|
return *bitStreamLenByte;
|
||||||
return *bitStreamLenByte;
|
}
|
||||||
}
|
case 10: {
|
||||||
|
vadDecision = 1;
|
||||||
|
// this is a valid length just continue encoding
|
||||||
WebRtc_Word16
|
break;
|
||||||
ACMG729::EnableDTX()
|
}
|
||||||
{
|
default: {
|
||||||
if(_dtxEnabled)
|
|
||||||
{
|
|
||||||
// DTX already enabled, do nothing
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(_encoderExist)
|
|
||||||
{
|
|
||||||
// Re-init the G.729 encoder to turn on DTX
|
|
||||||
if(WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
_dtxEnabled = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// update number of encoded samples
|
||||||
|
noEncodedSamples += 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update VAD decision vector
|
||||||
|
if (_hasInternalDTX && !vadDecision && _dtxEnabled) {
|
||||||
|
for (WebRtc_Word16 n = 0; n < MAX_FRAME_SIZE_10MSEC; n++) {
|
||||||
|
_vadLabel[n] = vadDecision;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// done encoding, return number of encoded bytes
|
||||||
|
return *bitStreamLenByte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::EnableDTX() {
|
||||||
WebRtc_Word16
|
if (_dtxEnabled) {
|
||||||
ACMG729::DisableDTX()
|
// DTX already enabled, do nothing
|
||||||
{
|
|
||||||
if(!_dtxEnabled)
|
|
||||||
{
|
|
||||||
// DTX already dissabled, do nothing
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(_encoderExist)
|
|
||||||
{
|
|
||||||
// Re-init the G.729 decoder to turn off DTX
|
|
||||||
if(WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
_dtxEnabled = false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
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
|
|
||||||
// external instead.
|
|
||||||
|
|
||||||
if(replaceInternalDTX == _hasInternalDTX)
|
|
||||||
{
|
|
||||||
// Make sure we keep the DTX/VAD setting if possible
|
|
||||||
bool oldEnableDTX = _dtxEnabled;
|
|
||||||
bool oldEnableVAD = _vadEnabled;
|
|
||||||
ACMVADMode oldMode = _vadMode;
|
|
||||||
if (replaceInternalDTX)
|
|
||||||
{
|
|
||||||
// Disable internal DTX before enabling external DTX
|
|
||||||
DisableDTX();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Disable external DTX before enabling internal
|
|
||||||
ACMGenericCodec::DisableDTX();
|
|
||||||
}
|
|
||||||
_hasInternalDTX = !replaceInternalDTX;
|
|
||||||
WebRtc_Word16 status = SetVADSafe(oldEnableDTX, oldEnableVAD, oldMode);
|
|
||||||
// Check if VAD status has changed from inactive to active, or if error was
|
|
||||||
// reported
|
|
||||||
if (status == 1) {
|
|
||||||
_vadEnabled = true;
|
|
||||||
return status;
|
|
||||||
} else if (status < 0) {
|
|
||||||
_hasInternalDTX = replaceInternalDTX;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (_encoderExist) {
|
||||||
|
// Re-init the G.729 encoder to turn on DTX
|
||||||
|
if (WebRtcG729_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||||
WebRtc_Word32
|
return -1;
|
||||||
ACMG729::IsInternalDTXReplacedSafe(
|
}
|
||||||
bool* internalDTXReplaced)
|
_dtxEnabled = true;
|
||||||
{
|
|
||||||
// Get status of wether DTX is replaced or not
|
|
||||||
*internalDTXReplaced = !_hasInternalDTX;
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::DisableDTX() {
|
||||||
WebRtc_Word16
|
if (!_dtxEnabled) {
|
||||||
ACMG729::DecodeSafe(
|
// DTX already dissabled, do nothing
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
|
||||||
WebRtc_Word16* /* audio */,
|
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
// This function is not used. G.729 decoder is called from inside NetEQ
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (_encoderExist) {
|
||||||
|
// Re-init the G.729 decoder to turn off DTX
|
||||||
|
if (WebRtcG729_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729::InternalInitEncoder(
|
|
||||||
WebRtcACMCodecParams* codecParams)
|
|
||||||
{
|
|
||||||
// Init G.729 encoder
|
|
||||||
return WebRtcG729_EncoderInit(_encoderInstPtr,
|
|
||||||
((codecParams->enableDTX)? 1:0));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
// Todo:
|
|
||||||
// log error
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
_dtxEnabled = false;
|
||||||
// Fill up the structure by calling
|
|
||||||
// "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_G729_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
// encoder doesn't exists, therefore disabling is harmless
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMG729::ReplaceInternalDTXSafe(const bool replaceInternalDTX) {
|
||||||
|
// This function is used to disable the G.729 built in DTX and use an
|
||||||
|
// external instead.
|
||||||
|
|
||||||
ACMGenericCodec*
|
if (replaceInternalDTX == _hasInternalDTX) {
|
||||||
ACMG729::CreateInstance(void)
|
// Make sure we keep the DTX/VAD setting if possible
|
||||||
{
|
bool oldEnableDTX = _dtxEnabled;
|
||||||
// Function not used
|
bool oldEnableVAD = _vadEnabled;
|
||||||
return NULL;
|
ACMVADMode oldMode = _vadMode;
|
||||||
}
|
if (replaceInternalDTX) {
|
||||||
|
// Disable internal DTX before enabling external DTX
|
||||||
|
DisableDTX();
|
||||||
WebRtc_Word16
|
} else {
|
||||||
ACMG729::InternalCreateEncoder()
|
// Disable external DTX before enabling internal
|
||||||
{
|
ACMGenericCodec::DisableDTX();
|
||||||
// Create encoder memory
|
|
||||||
return WebRtcG729_CreateEnc(&_encoderInstPtr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMG729::DestructEncoderSafe()
|
|
||||||
{
|
|
||||||
// Free encoder memory
|
|
||||||
_encoderExist = false;
|
|
||||||
_encoderInitialized = false;
|
|
||||||
if(_encoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcG729_FreeEnc(_encoderInstPtr);
|
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
_hasInternalDTX = !replaceInternalDTX;
|
||||||
|
WebRtc_Word16 status = SetVADSafe(oldEnableDTX, oldEnableVAD, oldMode);
|
||||||
|
// Check if VAD status has changed from inactive to active, or if error was
|
||||||
WebRtc_Word16
|
// reported
|
||||||
ACMG729::InternalCreateDecoder()
|
if (status == 1) {
|
||||||
{
|
_vadEnabled = true;
|
||||||
// Create decoder memory
|
return status;
|
||||||
return WebRtcG729_CreateDec(&_decoderInstPtr);
|
} else if (status < 0) {
|
||||||
}
|
_hasInternalDTX = replaceInternalDTX;
|
||||||
|
return -1;
|
||||||
|
|
||||||
void
|
|
||||||
ACMG729::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
// Free decoder memory
|
|
||||||
_decoderExist = false;
|
|
||||||
_decoderInitialized = false;
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcG729_FreeDec(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMG729::IsInternalDTXReplacedSafe(bool* internalDTXReplaced) {
|
||||||
|
// Get status of wether DTX is replaced or not
|
||||||
|
*internalDTXReplaced = !_hasInternalDTX;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
WebRtc_Word16 ACMG729::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
ACMG729::InternalDestructEncoderInst(
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
void* ptrInst)
|
WebRtc_Word16* /* audio */,
|
||||||
{
|
WebRtc_Word16* /* audioSamples */,
|
||||||
if(ptrInst != NULL)
|
WebRtc_Word8* /* speechType */) {
|
||||||
{
|
// This function is not used. G.729 decoder is called from inside NetEQ
|
||||||
WebRtcG729_FreeEnc((G729_encinst_t_*)ptrInst);
|
return 0;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||||
|
// Init G.729 encoder
|
||||||
|
return WebRtcG729_EncoderInit(_encoderInstPtr,
|
||||||
|
((codecParams->enableDTX) ? 1 : 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
||||||
|
// Todo:
|
||||||
|
// log error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill up the structure by calling
|
||||||
|
// "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_G729_FUNCTIONS((codecDef));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMG729::CreateInstance(void) {
|
||||||
|
// Function not used
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalCreateEncoder() {
|
||||||
|
// Create encoder memory
|
||||||
|
return WebRtcG729_CreateEnc(&_encoderInstPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMG729::DestructEncoderSafe() {
|
||||||
|
// Free encoder memory
|
||||||
|
_encoderExist = false;
|
||||||
|
_encoderInitialized = false;
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcG729_FreeEnc(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729::InternalCreateDecoder() {
|
||||||
|
// Create decoder memory
|
||||||
|
return WebRtcG729_CreateDec(&_decoderInstPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMG729::DestructDecoderSafe() {
|
||||||
|
// Free decoder memory
|
||||||
|
_decoderExist = false;
|
||||||
|
_decoderInitialized = false;
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcG729_FreeDec(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMG729::InternalDestructEncoderInst(void* ptrInst) {
|
||||||
|
if (ptrInst != NULL) {
|
||||||
|
WebRtcG729_FreeEnc((G729_encinst_t_*) ptrInst);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -19,62 +19,53 @@ struct G729_decinst_t_;
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ACMG729 : public ACMGenericCodec
|
class ACMG729 : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMG729(WebRtc_Word16 codecID);
|
||||||
ACMG729(WebRtc_Word16 codecID);
|
~ACMG729();
|
||||||
~ACMG729();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
WebRtc_Word16 EnableDTX();
|
WebRtc_Word16 EnableDTX();
|
||||||
|
|
||||||
WebRtc_Word16 DisableDTX();
|
WebRtc_Word16 DisableDTX();
|
||||||
|
|
||||||
WebRtc_Word32 ReplaceInternalDTXSafe(
|
WebRtc_Word32 ReplaceInternalDTXSafe(const bool replaceInternalDTX);
|
||||||
const bool replaceInternalDTX);
|
|
||||||
|
|
||||||
WebRtc_Word32 IsInternalDTXReplacedSafe(
|
WebRtc_Word32 IsInternalDTXReplacedSafe(bool* internalDTXReplaced);
|
||||||
bool* internalDTXReplaced);
|
|
||||||
|
|
||||||
G729_encinst_t_* _encoderInstPtr;
|
G729_encinst_t_* _encoderInstPtr;
|
||||||
G729_decinst_t_* _decoderInstPtr;
|
G729_decinst_t_* _decoderInstPtr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_H_
|
||||||
|
@ -16,24 +16,9 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_G729_1
|
#ifdef WEBRTC_CODEC_G729_1
|
||||||
// NOTE! G.729.1 is not included in the open-source package. The following
|
// NOTE! G.729.1 is not included in the open-source package. Modify this file
|
||||||
// interface file is needed:
|
// or your codec API to match the function calls and names of used G.729.1 API
|
||||||
//
|
// file.
|
||||||
// /modules/audio_coding/codecs/g7291/main/interface/g7291_interface.h
|
|
||||||
//
|
|
||||||
// The API in the header file should match the one below.
|
|
||||||
//
|
|
||||||
// int16_t WebRtcG7291_Create(G729_1_inst_t_** inst);
|
|
||||||
// int16_t WebRtcG7291_Free(G729_1_inst_t_* inst);
|
|
||||||
// int16_t WebRtcG7291_Encode(G729_1_inst_t_* encInst, int16_t* input,
|
|
||||||
// int16_t* output, int16_t myRate,
|
|
||||||
// int16_t nrFrames);
|
|
||||||
// int16_t WebRtcG7291_EncoderInit(G729_1_inst_t_* encInst, int16_t myRate,
|
|
||||||
// int16_t flag8kHz, int16_t flagG729mode);
|
|
||||||
// int16_t WebRtcG7291_Decode(G729_1_inst_t_* decInst);
|
|
||||||
// int16_t WebRtcG7291_DecodeBwe(G729_1_inst_t_* decInst, int16_t* input);
|
|
||||||
// int16_t WebRtcG7291_DecodePlc(G729_1_inst_t_* decInst);
|
|
||||||
// int16_t WebRtcG7291_DecoderInit(G729_1_inst_t_* decInst);
|
|
||||||
#include "g7291_interface.h"
|
#include "g7291_interface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -41,7 +26,7 @@ namespace webrtc {
|
|||||||
|
|
||||||
#ifndef WEBRTC_CODEC_G729_1
|
#ifndef WEBRTC_CODEC_G729_1
|
||||||
|
|
||||||
ACMG729_1::ACMG729_1( WebRtc_Word16 /* codecID */)
|
ACMG729_1::ACMG729_1(WebRtc_Word16 /* codecID */)
|
||||||
: _encoderInstPtr(NULL),
|
: _encoderInstPtr(NULL),
|
||||||
_decoderInstPtr(NULL),
|
_decoderInstPtr(NULL),
|
||||||
_myRate(32000),
|
_myRate(32000),
|
||||||
@ -50,105 +35,63 @@ ACMG729_1::ACMG729_1( WebRtc_Word16 /* codecID */)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMG729_1::~ACMG729_1() {
|
||||||
ACMG729_1::~ACMG729_1()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
ACMG729_1::InternalEncode(
|
return -1;
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
ACMG729_1::DecodeSafe(
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audioSamples */,
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
WebRtc_Word8* /* speechType */) {
|
||||||
WebRtc_Word16* /* audio */,
|
return -1;
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalInitEncoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMG729_1::InternalInitEncoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalInitDecoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMG729_1::InternalInitDecoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMG729_1::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||||
WebRtc_Word32
|
const CodecInst& /* codecInst */) {
|
||||||
ACMG729_1::CodecDef(
|
return -1;
|
||||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
|
||||||
const CodecInst& /* codecInst */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
|
||||||
ACMGenericCodec*
|
return NULL;
|
||||||
ACMG729_1::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729_1::InternalCreateEncoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729_1::DestructEncoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMG729_1::DestructEncoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMG729_1::InternalCreateDecoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729_1::DestructDecoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMG729_1::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMG729_1::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
void
|
return;
|
||||||
ACMG729_1::InternalDestructEncoderInst(
|
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMG729_1::SetBitRateSafe(const WebRtc_Word32 /*rate*/) {
|
||||||
ACMG729_1::SetBitRateSafe(
|
|
||||||
const WebRtc_Word32 /*rate*/ )
|
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,304 +111,233 @@ ACMG729_1::ACMG729_1(WebRtc_Word16 codecID)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ACMG729_1::~ACMG729_1()
|
ACMG729_1::~ACMG729_1() {
|
||||||
{
|
if (_encoderInstPtr != NULL) {
|
||||||
if(_encoderInstPtr != NULL)
|
WebRtcG7291_Free(_encoderInstPtr);
|
||||||
{
|
_encoderInstPtr = NULL;
|
||||||
WebRtcG7291_Free(_encoderInstPtr);
|
}
|
||||||
_encoderInstPtr = NULL;
|
if (_decoderInstPtr != NULL) {
|
||||||
}
|
WebRtcG7291_Free(_decoderInstPtr);
|
||||||
if(_decoderInstPtr != NULL)
|
_decoderInstPtr = NULL;
|
||||||
{
|
}
|
||||||
WebRtcG7291_Free(_decoderInstPtr);
|
return;
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::InternalEncode(WebRtc_UWord8* bitStream,
|
||||||
|
WebRtc_Word16* bitStreamLenByte) {
|
||||||
|
|
||||||
WebRtc_Word16
|
// Initialize before entering the loop
|
||||||
ACMG729_1::InternalEncode(
|
WebRtc_Word16 noEncodedSamples = 0;
|
||||||
WebRtc_UWord8* bitStream,
|
*bitStreamLenByte = 0;
|
||||||
WebRtc_Word16* bitStreamLenByte)
|
|
||||||
{
|
|
||||||
|
|
||||||
// Initialize before entering the loop
|
|
||||||
WebRtc_Word16 noEncodedSamples = 0;
|
|
||||||
*bitStreamLenByte = 0;
|
|
||||||
|
|
||||||
WebRtc_Word16 byteLengthFrame = 0;
|
WebRtc_Word16 byteLengthFrame = 0;
|
||||||
|
|
||||||
// Derive number of 20ms frames per encoded packet.
|
// Derive number of 20ms frames per encoded packet.
|
||||||
// [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples
|
// [1,2,3] <=> [20,40,60]ms <=> [320,640,960] samples
|
||||||
WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320);
|
WebRtc_Word16 n20msFrames = (_frameLenSmpl / 320);
|
||||||
// Byte length for the frame. +1 is for rate information.
|
// Byte length for the frame. +1 is for rate information.
|
||||||
byteLengthFrame = _myRate/(8*50) * n20msFrames + (1 - _flagG729mode);
|
byteLengthFrame = _myRate / (8 * 50) * n20msFrames + (1 - _flagG729mode);
|
||||||
|
|
||||||
// The following might be revised if we have G729.1 Annex C (support for DTX);
|
// The following might be revised if we have G729.1 Annex C (support for DTX);
|
||||||
do
|
do {
|
||||||
{
|
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr,
|
||||||
*bitStreamLenByte = WebRtcG7291_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
&_inAudio[_inAudioIxRead],
|
||||||
(WebRtc_Word16*)bitStream, _myRate, n20msFrames);
|
(WebRtc_Word16*) bitStream, _myRate,
|
||||||
|
n20msFrames);
|
||||||
|
|
||||||
// increment the read index this tell the caller that how far
|
// increment the read index this tell the caller that how far
|
||||||
// we have gone forward in reading the audio buffer
|
// we have gone forward in reading the audio buffer
|
||||||
_inAudioIxRead += 160;
|
_inAudioIxRead += 160;
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if(*bitStreamLenByte < 0)
|
if (*bitStreamLenByte < 0) {
|
||||||
{
|
|
||||||
// error has happened
|
// error has happened
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
"InternalEncode: Encode error for G729_1");
|
"InternalEncode: Encode error for G729_1");
|
||||||
*bitStreamLenByte = 0;
|
*bitStreamLenByte = 0;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
noEncodedSamples += 160;
|
|
||||||
} while(*bitStreamLenByte == 0);
|
|
||||||
|
|
||||||
|
|
||||||
// This criteria will change if we have Annex C.
|
|
||||||
if(*bitStreamLenByte != byteLengthFrame)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalEncode: Encode error for G729_1");
|
|
||||||
*bitStreamLenByte = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if(noEncodedSamples != _frameLenSmpl)
|
|
||||||
{
|
|
||||||
*bitStreamLenByte = 0;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *bitStreamLenByte;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMG729_1::DecodeSafe(
|
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
|
||||||
WebRtc_Word16* /* audio */,
|
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalInitDecoder: init decoder failed for G729_1");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fill up the structure by calling
|
noEncodedSamples += 160;
|
||||||
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
} while (*bitStreamLenByte == 0);
|
||||||
// Then call NetEQ to add the codec to it's
|
|
||||||
// database.
|
|
||||||
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype,
|
|
||||||
_decoderInstPtr, 16000);
|
|
||||||
SET_G729_1_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// This criteria will change if we have Annex C.
|
||||||
ACMGenericCodec*
|
if (*bitStreamLenByte != byteLengthFrame) {
|
||||||
ACMG729_1::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMG729_1::InternalCreateEncoder()
|
|
||||||
{
|
|
||||||
if (WebRtcG7291_Create(&_encoderInstPtr) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
"InternalCreateEncoder: create encoder failed for G729_1");
|
"InternalEncode: Encode error for G729_1");
|
||||||
|
*bitStreamLenByte = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noEncodedSamples != _frameLenSmpl) {
|
||||||
|
*bitStreamLenByte = 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return *bitStreamLenByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMG729_1::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
|
WebRtc_Word16* /* audio */,
|
||||||
|
WebRtc_Word16* /* audioSamples */,
|
||||||
|
WebRtc_Word8* /* speechType */) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"InternalInitDecoder: init decoder failed for G729_1");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
// Fill up the structure by calling
|
||||||
ACMG729_1::DestructEncoderSafe()
|
// "SET_CODEC_PAR" & "SET_G729_FUNCTION."
|
||||||
{
|
// Then call NetEQ to add the codec to it's
|
||||||
_encoderExist = false;
|
// database.
|
||||||
_encoderInitialized = false;
|
SET_CODEC_PAR((codecDef), kDecoderG729_1, codecInst.pltype, _decoderInstPtr,
|
||||||
if(_encoderInstPtr != NULL)
|
16000);
|
||||||
{
|
SET_G729_1_FUNCTIONS((codecDef));
|
||||||
WebRtcG7291_Free(_encoderInstPtr);
|
return 0;
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMG729_1::CreateInstance(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMG729_1::InternalCreateEncoder() {
|
||||||
ACMG729_1::InternalCreateDecoder()
|
if (WebRtcG7291_Create(&_encoderInstPtr) < 0) {
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
if (WebRtcG7291_Create(&_decoderInstPtr) < 0)
|
"InternalCreateEncoder: create encoder failed for G729_1");
|
||||||
{
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMG729_1::DestructEncoderSafe() {
|
||||||
|
_encoderExist = false;
|
||||||
|
_encoderInitialized = false;
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcG7291_Free(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMG729_1::DestructDecoderSafe() {
|
||||||
|
_decoderExist = false;
|
||||||
|
_decoderInitialized = false;
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcG7291_Free(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = 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) {
|
||||||
|
//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: {
|
||||||
|
_myRate = 8000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 12000: {
|
||||||
|
_myRate = 12000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 14000: {
|
||||||
|
_myRate = 14000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 16000: {
|
||||||
|
_myRate = 16000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 18000: {
|
||||||
|
_myRate = 18000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 20000: {
|
||||||
|
_myRate = 20000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 22000: {
|
||||||
|
_myRate = 22000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 24000: {
|
||||||
|
_myRate = 24000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 26000: {
|
||||||
|
_myRate = 26000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 28000: {
|
||||||
|
_myRate = 28000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 30000: {
|
||||||
|
_myRate = 30000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 32000: {
|
||||||
|
_myRate = 32000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
"InternalCreateDecoder: create decoder failed for G729_1");
|
"SetBitRateSafe: Invalid rate G729_1");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
|
||||||
|
// Re-init with new rate
|
||||||
|
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz,
|
||||||
|
_flagG729mode) >= 0) {
|
||||||
|
_encoderParams.codecInstant.rate = _myRate;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMG729_1::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
_decoderExist = false;
|
|
||||||
_decoderInitialized = false;
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcG7291_Free(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = 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)
|
|
||||||
{
|
|
||||||
//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:
|
|
||||||
{
|
|
||||||
_myRate = 8000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 12000:
|
|
||||||
{
|
|
||||||
_myRate = 12000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 14000:
|
|
||||||
{
|
|
||||||
_myRate = 14000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16000:
|
|
||||||
{
|
|
||||||
_myRate = 16000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 18000:
|
|
||||||
{
|
|
||||||
_myRate = 18000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 20000:
|
|
||||||
{
|
|
||||||
_myRate = 20000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 22000:
|
|
||||||
{
|
|
||||||
_myRate = 22000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 24000:
|
|
||||||
{
|
|
||||||
_myRate = 24000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 26000:
|
|
||||||
{
|
|
||||||
_myRate = 26000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 28000:
|
|
||||||
{
|
|
||||||
_myRate = 28000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 30000:
|
|
||||||
{
|
|
||||||
_myRate = 30000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 32000:
|
|
||||||
{
|
|
||||||
_myRate = 32000;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"SetBitRateSafe: Invalid rate G729_1");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Re-init with new rate
|
|
||||||
if (WebRtcG7291_EncoderInit(_encoderInstPtr, _myRate, _flag8kHz, _flagG729mode) >= 0)
|
|
||||||
{
|
|
||||||
_encoderParams.codecInstant.rate = _myRate;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -19,59 +19,50 @@ struct G729_1_inst_t_;
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ACMG729_1: public ACMGenericCodec
|
class ACMG729_1 : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMG729_1(WebRtc_Word16 codecID);
|
||||||
ACMG729_1(WebRtc_Word16 codecID);
|
~ACMG729_1();
|
||||||
~ACMG729_1();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
WebRtc_Word16 SetBitRateSafe(
|
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||||
const WebRtc_Word32 rate);
|
|
||||||
|
|
||||||
G729_1_inst_t_* _encoderInstPtr;
|
G729_1_inst_t_* _encoderInstPtr;
|
||||||
G729_1_inst_t_* _decoderInstPtr;
|
G729_1_inst_t_* _decoderInstPtr;
|
||||||
|
|
||||||
WebRtc_UWord16 _myRate;
|
|
||||||
WebRtc_Word16 _flag8kHz;
|
|
||||||
WebRtc_Word16 _flagG729mode;
|
|
||||||
|
|
||||||
|
WebRtc_UWord16 _myRate;
|
||||||
|
WebRtc_Word16 _flag8kHz;
|
||||||
|
WebRtc_Word16 _flagG729mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_G729_1_H_
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -16,25 +16,10 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_GSMFR
|
#ifdef WEBRTC_CODEC_GSMFR
|
||||||
// NOTE! GSM-FR is not included in the open-source package. The following
|
// NOTE! GSM-FR is not included in the open-source package. Modify this file
|
||||||
// interface file is needed:
|
// or your codec API to match the function calls and names of used GSM-FR API
|
||||||
//
|
// file.
|
||||||
// /modules/audio_coding/codecs/gsmfr/main/interface/gsmfr_interface.h
|
#include "gsmfr_interface.h"
|
||||||
//
|
|
||||||
// The API in the header file should match the one below.
|
|
||||||
//
|
|
||||||
// int16_t WebRtcGSMFR_CreateEnc(GSMFR_encinst_t_** inst);
|
|
||||||
// int16_t WebRtcGSMFR_CreateDec(GSMFR_decinst_t_** inst);
|
|
||||||
// int16_t WebRtcGSMFR_FreeEnc(GSMFR_encinst_t_* inst);
|
|
||||||
// int16_t WebRtcGSMFR_FreeDec(GSMFR_decinst_t_* inst);
|
|
||||||
// int16_t WebRtcGSMFR_Encode(GSMFR_encinst_t_* encInst, int16_t* input,
|
|
||||||
// int16_t len, int16_t* output);
|
|
||||||
// int16_t WebRtcGSMFR_EncoderInit(GSMFR_encinst_t_* encInst, int16_t mode);
|
|
||||||
// int16_t WebRtcGSMFR_Decode(GSMFR_decinst_t_* decInst);
|
|
||||||
// int16_t WebRtcGSMFR_DecodeBwe(GSMFR_decinst_t_* decInst, int16_t* input);
|
|
||||||
// int16_t WebRtcGSMFR_DecodePlc(GSMFR_decinst_t_* decInst);
|
|
||||||
// int16_t WebRtcGSMFR_DecoderInit(GSMFR_decinst_t_* decInst);
|
|
||||||
#include "gsmfr_interface.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -47,340 +32,228 @@ ACMGSMFR::ACMGSMFR(WebRtc_Word16 /* codecID */)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGSMFR::~ACMGSMFR() {
|
||||||
ACMGSMFR::~ACMGSMFR()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
ACMGSMFR::InternalEncode(
|
return -1;
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
ACMGSMFR::DecodeSafe(
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audioSamples */,
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
WebRtc_Word8* /* speechType */) {
|
||||||
WebRtc_Word16* /* audio */,
|
return -1;
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMGSMFR::EnableDTX()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMGSMFR::DisableDTX()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMGSMFR::InternalInitEncoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalInitDecoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMGSMFR::InternalInitDecoder(
|
return -1;
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||||
WebRtc_Word32
|
const CodecInst& /* codecInst */) {
|
||||||
ACMGSMFR::CodecDef(
|
return -1;
|
||||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
|
||||||
const CodecInst& /* codecInst */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
|
||||||
ACMGenericCodec*
|
return NULL;
|
||||||
ACMGSMFR::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMGSMFR::InternalCreateEncoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMGSMFR::DestructEncoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMGSMFR::DestructEncoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMGSMFR::InternalCreateDecoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMGSMFR::DestructDecoderSafe() {
|
||||||
void
|
return;
|
||||||
ACMGSMFR::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMGSMFR::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
void
|
return;
|
||||||
ACMGSMFR::InternalDestructEncoderInst(
|
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //===================== Actual Implementation =======================
|
#else //===================== Actual Implementation =======================
|
||||||
|
|
||||||
ACMGSMFR::ACMGSMFR(
|
ACMGSMFR::ACMGSMFR(WebRtc_Word16 codecID)
|
||||||
WebRtc_Word16 codecID):
|
: _encoderInstPtr(NULL),
|
||||||
_encoderInstPtr(NULL),
|
_decoderInstPtr(NULL) {
|
||||||
_decoderInstPtr(NULL)
|
_codecID = codecID;
|
||||||
{
|
_hasInternalDTX = true;
|
||||||
_codecID = codecID;
|
return;
|
||||||
_hasInternalDTX = true;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGSMFR::~ACMGSMFR() {
|
||||||
ACMGSMFR::~ACMGSMFR()
|
if (_encoderInstPtr != NULL) {
|
||||||
{
|
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||||
if(_encoderInstPtr != NULL)
|
_encoderInstPtr = NULL;
|
||||||
{
|
}
|
||||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
if (_decoderInstPtr != NULL) {
|
||||||
_encoderInstPtr = NULL;
|
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||||
}
|
_decoderInstPtr = NULL;
|
||||||
if(_decoderInstPtr != NULL)
|
}
|
||||||
{
|
return;
|
||||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalEncode(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_Word16
|
WebRtc_Word16* bitStreamLenByte) {
|
||||||
ACMGSMFR::InternalEncode(
|
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
|
||||||
WebRtc_UWord8* bitStream,
|
&_inAudio[_inAudioIxRead],
|
||||||
WebRtc_Word16* bitStreamLenByte)
|
_frameLenSmpl,
|
||||||
{
|
(WebRtc_Word16*) bitStream);
|
||||||
*bitStreamLenByte = WebRtcGSMFR_Encode(_encoderInstPtr,
|
// increment the read index this tell the caller that how far
|
||||||
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
|
// we have gone forward in reading the audio buffer
|
||||||
// increment the read index this tell the caller that how far
|
_inAudioIxRead += _frameLenSmpl;
|
||||||
// we have gone forward in reading the audio buffer
|
return *bitStreamLenByte;
|
||||||
_inAudioIxRead += _frameLenSmpl;
|
|
||||||
return *bitStreamLenByte;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
|
WebRtc_Word16* /* audio */,
|
||||||
|
WebRtc_Word16* /* audioSamples */,
|
||||||
|
WebRtc_Word8* /* speechType */) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMGSMFR::EnableDTX() {
|
||||||
ACMGSMFR::DecodeSafe(
|
if (_dtxEnabled) {
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
|
||||||
WebRtc_Word16* /* audio */,
|
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (_encoderExist) {
|
||||||
|
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 1) < 0) {
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMGSMFR::EnableDTX()
|
|
||||||
{
|
|
||||||
if(_dtxEnabled)
|
|
||||||
{
|
|
||||||
return 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
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMGSMFR::DisableDTX()
|
|
||||||
{
|
|
||||||
if(!_dtxEnabled)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(_encoderExist)
|
|
||||||
{
|
|
||||||
if(WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
"DisableDTX: cannot init encoder for GSMFR");
|
"EnableDTX: cannot init encoder for GSMFR");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
_dtxEnabled = false;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else
|
_dtxEnabled = true;
|
||||||
{
|
|
||||||
// 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_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_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalInitDecoder: cannot init decoder for GSMFR");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
// Fill up the structure by calling
|
|
||||||
// "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_GSMFR_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
|
||||||
|
|
||||||
ACMGenericCodec*
|
|
||||||
ACMGSMFR::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMGSMFR::InternalCreateEncoder()
|
|
||||||
{
|
|
||||||
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::DisableDTX() {
|
||||||
void
|
if (!_dtxEnabled) {
|
||||||
ACMGSMFR::DestructEncoderSafe()
|
return 0;
|
||||||
{
|
} else if (_encoderExist) {
|
||||||
if(_encoderInstPtr != NULL)
|
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr, 0) < 0) {
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
"DisableDTX: cannot init encoder for GSMFR");
|
||||||
_encoderInstPtr = NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
_encoderExist = false;
|
_dtxEnabled = false;
|
||||||
_encoderInitialized = false;
|
return 0;
|
||||||
|
} else {
|
||||||
|
// encoder doesn't exists, therefore disabling is harmless
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||||
WebRtc_Word16
|
if (WebRtcGSMFR_EncoderInit(_encoderInstPtr,
|
||||||
ACMGSMFR::InternalCreateDecoder()
|
((codecParams->enableDTX) ? 1 : 0)) < 0) {
|
||||||
{
|
|
||||||
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
|
"InternalInitEncoder: cannot init encoder for GSMFR");
|
||||||
|
}
|
||||||
|
return 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;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMGSMFR::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
void
|
const CodecInst& codecInst) {
|
||||||
ACMGSMFR::DestructDecoderSafe()
|
if (!_decoderInitialized) {
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
if(_decoderInstPtr != NULL)
|
"CodecDef: decoder is not initialized for GSMFR");
|
||||||
{
|
return -1;
|
||||||
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
}
|
||||||
_decoderInstPtr = NULL;
|
// Fill up the structure by calling
|
||||||
}
|
// "SET_CODEC_PAR" & "SET_GSMFR_FUNCTION."
|
||||||
_decoderExist = false;
|
// Then call NetEQ to add the codec to it's
|
||||||
_decoderInitialized = false;
|
// database.
|
||||||
|
SET_CODEC_PAR((codecDef), kDecoderGSMFR, codecInst.pltype, _decoderInstPtr,
|
||||||
|
8000);
|
||||||
|
SET_GSMFR_FUNCTIONS((codecDef));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMGSMFR::CreateInstance(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
WebRtc_Word16 ACMGSMFR::InternalCreateEncoder() {
|
||||||
ACMGSMFR::InternalDestructEncoderInst(
|
if (WebRtcGSMFR_CreateEnc(&_encoderInstPtr) < 0) {
|
||||||
void* ptrInst)
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
{
|
"InternalCreateEncoder: cannot create instance for GSMFR encoder");
|
||||||
if(ptrInst != NULL)
|
return -1;
|
||||||
{
|
}
|
||||||
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*)ptrInst);
|
return 0;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
void ACMGSMFR::DestructEncoderSafe() {
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcGSMFR_FreeEnc(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
_encoderExist = false;
|
||||||
|
_encoderInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMGSMFR::InternalCreateDecoder() {
|
||||||
|
if (WebRtcGSMFR_CreateDec(&_decoderInstPtr) < 0) {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"InternalCreateDecoder: cannot create instance for GSMFR decoder");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMGSMFR::DestructDecoderSafe() {
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcGSMFR_FreeDec(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
_decoderExist = false;
|
||||||
|
_decoderInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMGSMFR::InternalDestructEncoderInst(void* ptrInst) {
|
||||||
|
if (ptrInst != NULL) {
|
||||||
|
WebRtcGSMFR_FreeEnc((GSMFR_encinst_t_*) ptrInst);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -19,55 +19,48 @@ struct GSMFR_decinst_t_;
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ACMGSMFR : public ACMGenericCodec
|
class ACMGSMFR : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMGSMFR(WebRtc_Word16 codecID);
|
||||||
ACMGSMFR(WebRtc_Word16 codecID);
|
~ACMGSMFR();
|
||||||
~ACMGSMFR();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
WebRtc_Word16 EnableDTX();
|
WebRtc_Word16 EnableDTX();
|
||||||
|
|
||||||
WebRtc_Word16 DisableDTX();
|
WebRtc_Word16 DisableDTX();
|
||||||
|
|
||||||
GSMFR_encinst_t_* _encoderInstPtr;
|
GSMFR_encinst_t_* _encoderInstPtr;
|
||||||
GSMFR_decinst_t_* _decoderInstPtr;
|
GSMFR_decinst_t_* _decoderInstPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_GSMFR_H_
|
||||||
|
@ -16,11 +16,10 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_ILBC
|
#ifdef WEBRTC_CODEC_ILBC
|
||||||
#include "ilbc.h"
|
#include "ilbc.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
#ifndef WEBRTC_CODEC_ILBC
|
#ifndef WEBRTC_CODEC_ILBC
|
||||||
|
|
||||||
@ -30,333 +29,224 @@ ACMILBC::ACMILBC(WebRtc_Word16 /* codecID */)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMILBC::~ACMILBC() {
|
||||||
ACMILBC::~ACMILBC()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
ACMILBC::InternalEncode(
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
WebRtc_Word16* /* audioSamples */,
|
||||||
{
|
WebRtc_Word8* /* speechType */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalInitEncoder(
|
||||||
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalInitDecoder(
|
||||||
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||||
|
const CodecInst& /* codecInst */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMILBC::CreateInstance(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMILBC::DestructEncoderSafe() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMILBC::DestructDecoderSafe() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMILBC::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else //===================== Actual Implementation =======================
|
||||||
|
|
||||||
|
ACMILBC::ACMILBC(WebRtc_Word16 codecID)
|
||||||
|
: _encoderInstPtr(NULL),
|
||||||
|
_decoderInstPtr(NULL) {
|
||||||
|
_codecID = codecID;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACMILBC::~ACMILBC() {
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalEncode(WebRtc_UWord8* bitStream,
|
||||||
|
WebRtc_Word16* bitStreamLenByte) {
|
||||||
|
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
|
||||||
|
&_inAudio[_inAudioIxRead],
|
||||||
|
_frameLenSmpl,
|
||||||
|
(WebRtc_Word16*) bitStream);
|
||||||
|
if (*bitStreamLenByte < 0) {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"InternalEncode: error in encode for ILBC");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
// 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 ACMILBC::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
|
WebRtc_Word16* /* audio */,
|
||||||
|
WebRtc_Word16* /* audioSamples */,
|
||||||
|
WebRtc_Word8* /* speechType */) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMILBC::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||||
ACMILBC::DecodeSafe(
|
// initialize with a correct processing block length
|
||||||
WebRtc_UWord8* /* bitStream */,
|
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
(320 == (codecParams->codecInstant).pacsize)) {
|
||||||
WebRtc_Word16* /* audio */,
|
// processing block of 20ms
|
||||||
WebRtc_Word16* /* audioSamples */,
|
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||||
WebRtc_Word8* /* speechType */)
|
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||||
{
|
(480 == (codecParams->codecInstant).pacsize)) {
|
||||||
|
// processing block of 30ms
|
||||||
|
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||||
|
} else {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"InternalInitEncoder: invalid processing block");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalInitDecoder(WebRtcACMCodecParams* codecParams) {
|
||||||
WebRtc_Word16
|
// initialize with a correct processing block length
|
||||||
ACMILBC::InternalInitEncoder(
|
if ((160 == (codecParams->codecInstant).pacsize) ||
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
(320 == (codecParams->codecInstant).pacsize)) {
|
||||||
{
|
// processing block of 20ms
|
||||||
|
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 20);
|
||||||
|
} else if ((240 == (codecParams->codecInstant).pacsize) ||
|
||||||
|
(480 == (codecParams->codecInstant).pacsize)) {
|
||||||
|
// processing block of 30ms
|
||||||
|
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30);
|
||||||
|
} else {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"InternalInitDecoder: invalid processing block");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMILBC::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtc_Word16
|
const CodecInst& codecInst) {
|
||||||
ACMILBC::InternalInitDecoder(
|
if (!_decoderInitialized) {
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
{
|
"CodeDef: decoder not initialized for ILBC");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
// Fill up the structure by calling
|
||||||
|
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
|
||||||
|
// Then return the structure back to NetEQ to add the codec to it's
|
||||||
|
// database.
|
||||||
|
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype, _decoderInstPtr,
|
||||||
|
8000);
|
||||||
|
SET_ILBC_FUNCTIONS((codecDef));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMILBC::CreateInstance(void) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word16 ACMILBC::InternalCreateEncoder() {
|
||||||
ACMILBC::CodecDef(
|
if (WebRtcIlbcfix_EncoderCreate(&_encoderInstPtr) < 0) {
|
||||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
const CodecInst& /* codecInst */)
|
"InternalCreateEncoder: cannot create instance for ILBC encoder");
|
||||||
{
|
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMILBC::DestructEncoderSafe() {
|
||||||
ACMGenericCodec*
|
_encoderInitialized = false;
|
||||||
ACMILBC::CreateInstance(void)
|
_encoderExist = false;
|
||||||
{
|
if (_encoderInstPtr != NULL) {
|
||||||
return NULL;
|
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMILBC::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
if (WebRtcIlbcfix_DecoderCreate(&_decoderInstPtr) < 0) {
|
||||||
ACMILBC::InternalCreateEncoder()
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
{
|
"InternalCreateDecoder: cannot create instance for ILBC decoder");
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMILBC::DestructDecoderSafe() {
|
||||||
void
|
_decoderInitialized = false;
|
||||||
ACMILBC::DestructEncoderSafe()
|
_decoderExist = false;
|
||||||
{
|
if (_decoderInstPtr != NULL) {
|
||||||
return;
|
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMILBC::InternalDestructEncoderInst(void* ptrInst) {
|
||||||
|
if (ptrInst != NULL) {
|
||||||
|
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*) ptrInst);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||||
ACMILBC::InternalCreateDecoder()
|
// Check that rate is valid. No need to store the value
|
||||||
{
|
if (rate == 13300) {
|
||||||
|
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
||||||
|
} else if (rate == 15200) {
|
||||||
|
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
||||||
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
_encoderParams.codecInstant.rate = rate;
|
||||||
|
|
||||||
|
return 0;
|
||||||
void
|
|
||||||
ACMILBC::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMILBC::InternalDestructEncoderInst(
|
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMILBC::SetBitRateSafe(const WebRtc_Word32 /* rate */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else //===================== Actual Implementation =======================
|
|
||||||
|
|
||||||
|
|
||||||
ACMILBC::ACMILBC(
|
|
||||||
WebRtc_Word16 codecID):
|
|
||||||
_encoderInstPtr(NULL),
|
|
||||||
_decoderInstPtr(NULL)
|
|
||||||
{
|
|
||||||
_codecID = codecID;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ACMILBC::~ACMILBC()
|
|
||||||
{
|
|
||||||
if(_encoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMILBC::InternalEncode(
|
|
||||||
WebRtc_UWord8* bitStream,
|
|
||||||
WebRtc_Word16* bitStreamLenByte)
|
|
||||||
{
|
|
||||||
*bitStreamLenByte = WebRtcIlbcfix_Encode(_encoderInstPtr,
|
|
||||||
&_inAudio[_inAudioIxRead], _frameLenSmpl, (WebRtc_Word16*)bitStream);
|
|
||||||
if (*bitStreamLenByte < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalEncode: error in encode for ILBC");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// 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
|
|
||||||
ACMILBC::DecodeSafe(
|
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
|
||||||
WebRtc_Word16* /* audio */,
|
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMILBC::InternalInitEncoder(
|
|
||||||
WebRtcACMCodecParams* codecParams)
|
|
||||||
{
|
|
||||||
// initialize with a correct processing block length
|
|
||||||
if((160 == (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))
|
|
||||||
{
|
|
||||||
// processing block of 30ms
|
|
||||||
return WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"InternalInitEncoder: invalid processing block");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMILBC::InternalInitDecoder(
|
|
||||||
WebRtcACMCodecParams* codecParams)
|
|
||||||
{
|
|
||||||
// initialize with a correct processing block length
|
|
||||||
if((160 == (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))
|
|
||||||
{
|
|
||||||
// processing block of 30ms
|
|
||||||
return WebRtcIlbcfix_DecoderInit(_decoderInstPtr, 30);
|
|
||||||
}
|
|
||||||
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_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"CodeDef: decoder not initialized for ILBC");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
// Fill up the structure by calling
|
|
||||||
// "SET_CODEC_PAR" & "SET_ILBC_FUNCTION."
|
|
||||||
// Then return the structure back to NetEQ to add the codec to it's
|
|
||||||
// database.
|
|
||||||
SET_CODEC_PAR((codecDef), kDecoderILBC, codecInst.pltype,
|
|
||||||
_decoderInstPtr, 8000);
|
|
||||||
SET_ILBC_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ACMGenericCodec*
|
|
||||||
ACMILBC::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMILBC::DestructEncoderSafe()
|
|
||||||
{
|
|
||||||
_encoderInitialized = false;
|
|
||||||
_encoderExist = false;
|
|
||||||
if(_encoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_EncoderFree(_encoderInstPtr);
|
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMILBC::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
_decoderInitialized = false;
|
|
||||||
_decoderExist = false;
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_DecoderFree(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMILBC::InternalDestructEncoderInst(
|
|
||||||
void* ptrInst)
|
|
||||||
{
|
|
||||||
if(ptrInst != NULL)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_EncoderFree((iLBC_encinst_t_*)ptrInst);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMILBC::SetBitRateSafe(const WebRtc_Word32 rate)
|
|
||||||
{
|
|
||||||
// Check that rate is valid. No need to store the value
|
|
||||||
if (rate == 13300)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 30);
|
|
||||||
}
|
|
||||||
else if (rate == 15200)
|
|
||||||
{
|
|
||||||
WebRtcIlbcfix_EncoderInit(_encoderInstPtr, 20);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
_encoderParams.codecInstant.rate = rate;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -17,58 +17,48 @@
|
|||||||
struct iLBC_encinst_t_;
|
struct iLBC_encinst_t_;
|
||||||
struct iLBC_decinst_t_;
|
struct iLBC_decinst_t_;
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
class ACMILBC : public ACMGenericCodec
|
class ACMILBC : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMILBC(WebRtc_Word16 codecID);
|
||||||
ACMILBC(WebRtc_Word16 codecID);
|
~ACMILBC();
|
||||||
~ACMILBC();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
|
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||||
|
|
||||||
WebRtc_Word16 SetBitRateSafe(
|
void DestructEncoderSafe();
|
||||||
const WebRtc_Word32 rate);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
iLBC_encinst_t_* _encoderInstPtr;
|
||||||
void* ptrInst);
|
iLBC_decinst_t_* _decoderInstPtr;
|
||||||
|
|
||||||
iLBC_encinst_t_* _encoderInstPtr;
|
|
||||||
iLBC_decinst_t_* _decoderInstPtr;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ILBC_H_
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -13,137 +13,112 @@
|
|||||||
|
|
||||||
#include "acm_generic_codec.h"
|
#include "acm_generic_codec.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
struct ACMISACInst;
|
struct ACMISACInst;
|
||||||
|
|
||||||
enum iSACCodingMode {ADAPTIVE, CHANNEL_INDEPENDENT};
|
enum iSACCodingMode {
|
||||||
|
ADAPTIVE,
|
||||||
|
CHANNEL_INDEPENDENT
|
||||||
class ACMISAC : public ACMGenericCodec
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ACMISAC(WebRtc_Word16 codecID);
|
|
||||||
~ACMISAC();
|
|
||||||
// for FEC
|
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
|
||||||
WebRtc_UWord8* bitstream,
|
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 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* /* bitStreamLenByte */,
|
|
||||||
WebRtc_UWord32* /* timestamp */,
|
|
||||||
WebRtcACMEncodingType* /* encodingType */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16 UpdateDecoderSampFreq(
|
|
||||||
WebRtc_Word16 codecId);
|
|
||||||
|
|
||||||
WebRtc_Word16 UpdateEncoderSampFreq(
|
|
||||||
WebRtc_UWord16 sampFreqHz);
|
|
||||||
|
|
||||||
WebRtc_Word16 EncoderSampFreq(
|
|
||||||
WebRtc_UWord16& sampFreqHz);
|
|
||||||
|
|
||||||
WebRtc_Word32 ConfigISACBandwidthEstimator(
|
|
||||||
const WebRtc_UWord8 initFrameSizeMsec,
|
|
||||||
const WebRtc_UWord16 initRateBitPerSec,
|
|
||||||
const bool enforceFrameSize);
|
|
||||||
|
|
||||||
WebRtc_Word32 SetISACMaxPayloadSize(
|
|
||||||
const WebRtc_UWord16 maxPayloadLenBytes);
|
|
||||||
|
|
||||||
WebRtc_Word32 SetISACMaxRate(
|
|
||||||
const WebRtc_UWord32 maxRateBitPerSec);
|
|
||||||
|
|
||||||
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* audioSamples,
|
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
|
||||||
|
|
||||||
WebRtc_Word16 SetBitRateSafe(
|
|
||||||
const WebRtc_Word32 bitRate);
|
|
||||||
|
|
||||||
WebRtc_Word32 GetEstimatedBandwidthSafe();
|
|
||||||
|
|
||||||
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
|
|
||||||
|
|
||||||
WebRtc_Word32 GetRedPayloadSafe(
|
|
||||||
WebRtc_UWord8* redPayload,
|
|
||||||
WebRtc_Word16* payloadBytes);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
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,
|
|
||||||
const WebRtc_UWord8 payloadType);
|
|
||||||
|
|
||||||
void SaveDecoderParamSafe(
|
|
||||||
const WebRtcACMCodecParams* codecParams);
|
|
||||||
|
|
||||||
ACMISACInst* _codecInstPtr;
|
|
||||||
|
|
||||||
bool _isEncInitialized;
|
|
||||||
iSACCodingMode _isacCodingMode;
|
|
||||||
bool _enforceFrameSize;
|
|
||||||
WebRtc_Word32 _isacCurrentBN;
|
|
||||||
WebRtc_UWord16 _samplesIn10MsAudio;
|
|
||||||
WebRtcACMCodecParams _decoderParams32kHz;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace
|
class ACMISAC : public ACMGenericCodec {
|
||||||
|
public:
|
||||||
|
ACMISAC(WebRtc_Word16 codecID);
|
||||||
|
~ACMISAC();
|
||||||
|
// for FEC
|
||||||
|
ACMGenericCodec* CreateInstance(void);
|
||||||
|
|
||||||
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
|
|
||||||
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
|
|
||||||
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
|
|
||||||
|
WebRtc_Word16 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* /* bitStreamLenByte */,
|
||||||
|
WebRtc_UWord32* /* timestamp */,
|
||||||
|
WebRtcACMEncodingType* /* encodingType */) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 UpdateDecoderSampFreq(WebRtc_Word16 codecId);
|
||||||
|
|
||||||
|
WebRtc_Word16 UpdateEncoderSampFreq(WebRtc_UWord16 sampFreqHz);
|
||||||
|
|
||||||
|
WebRtc_Word16 EncoderSampFreq(WebRtc_UWord16& sampFreqHz);
|
||||||
|
|
||||||
|
WebRtc_Word32 ConfigISACBandwidthEstimator(
|
||||||
|
const WebRtc_UWord8 initFrameSizeMsec,
|
||||||
|
const WebRtc_UWord16 initRateBitPerSec, const bool enforceFrameSize);
|
||||||
|
|
||||||
|
WebRtc_Word32 SetISACMaxPayloadSize(const WebRtc_UWord16 maxPayloadLenBytes);
|
||||||
|
|
||||||
|
WebRtc_Word32 SetISACMaxRate(const WebRtc_UWord32 maxRateBitPerSec);
|
||||||
|
|
||||||
|
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* audioSamples,
|
||||||
|
WebRtc_Word8* speechType);
|
||||||
|
|
||||||
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
|
const CodecInst& codecInst);
|
||||||
|
|
||||||
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
|
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 bitRate);
|
||||||
|
|
||||||
|
WebRtc_Word32 GetEstimatedBandwidthSafe();
|
||||||
|
|
||||||
|
WebRtc_Word32 SetEstimatedBandwidthSafe(WebRtc_Word32 estimatedBandwidth);
|
||||||
|
|
||||||
|
WebRtc_Word32 GetRedPayloadSafe(WebRtc_UWord8* redPayload,
|
||||||
|
WebRtc_Word16* payloadBytes);
|
||||||
|
|
||||||
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
|
|
||||||
|
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,
|
||||||
|
const WebRtc_UWord8 payloadType);
|
||||||
|
|
||||||
|
void SaveDecoderParamSafe(const WebRtcACMCodecParams* codecParams);
|
||||||
|
|
||||||
|
ACMISACInst* _codecInstPtr;
|
||||||
|
bool _isEncInitialized;
|
||||||
|
iSACCodingMode _isacCodingMode;
|
||||||
|
bool _enforceFrameSize;
|
||||||
|
WebRtc_Word32 _isacCurrentBN;
|
||||||
|
WebRtc_UWord16 _samplesIn10MsAudio;
|
||||||
|
WebRtcACMCodecParams _decoderParams32kHz;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_H_
|
||||||
|
@ -13,62 +13,61 @@
|
|||||||
|
|
||||||
#include "engine_configurations.h"
|
#include "engine_configurations.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_ISAC
|
#ifdef WEBRTC_CODEC_ISAC
|
||||||
# define ACM_ISAC_CREATE WebRtcIsac_Create
|
#define ACM_ISAC_CREATE WebRtcIsac_Create
|
||||||
# define ACM_ISAC_FREE WebRtcIsac_Free
|
#define ACM_ISAC_FREE WebRtcIsac_Free
|
||||||
# define ACM_ISAC_ENCODERINIT WebRtcIsac_EncoderInit
|
#define ACM_ISAC_ENCODERINIT WebRtcIsac_EncoderInit
|
||||||
# define ACM_ISAC_ENCODE WebRtcIsac_Encode
|
#define ACM_ISAC_ENCODE WebRtcIsac_Encode
|
||||||
# define ACM_ISAC_DECODERINIT WebRtcIsac_DecoderInit
|
#define ACM_ISAC_DECODERINIT WebRtcIsac_DecoderInit
|
||||||
# define ACM_ISAC_DECODE_BWE WebRtcIsac_UpdateBwEstimate
|
#define ACM_ISAC_DECODE_BWE WebRtcIsac_UpdateBwEstimate
|
||||||
# define ACM_ISAC_DECODE_B WebRtcIsac_Decode
|
#define ACM_ISAC_DECODE_B WebRtcIsac_Decode
|
||||||
# define ACM_ISAC_DECODEPLC WebRtcIsac_DecodePlc
|
#define ACM_ISAC_DECODEPLC WebRtcIsac_DecodePlc
|
||||||
# define ACM_ISAC_CONTROL WebRtcIsac_Control
|
#define ACM_ISAC_CONTROL WebRtcIsac_Control
|
||||||
# define ACM_ISAC_CONTROL_BWE WebRtcIsac_ControlBwe
|
#define ACM_ISAC_CONTROL_BWE WebRtcIsac_ControlBwe
|
||||||
# define ACM_ISAC_GETFRAMELEN WebRtcIsac_ReadFrameLen
|
#define ACM_ISAC_GETFRAMELEN WebRtcIsac_ReadFrameLen
|
||||||
# define ACM_ISAC_GETERRORCODE WebRtcIsac_GetErrorCode
|
#define ACM_ISAC_GETERRORCODE WebRtcIsac_GetErrorCode
|
||||||
# define ACM_ISAC_GETSENDBITRATE WebRtcIsac_GetUplinkBw
|
#define ACM_ISAC_GETSENDBITRATE WebRtcIsac_GetUplinkBw
|
||||||
# define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsac_SetMaxPayloadSize
|
#define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsac_SetMaxPayloadSize
|
||||||
# define ACM_ISAC_SETMAXRATE WebRtcIsac_SetMaxRate
|
#define ACM_ISAC_SETMAXRATE WebRtcIsac_SetMaxRate
|
||||||
# define ACM_ISAC_GETNEWBITSTREAM WebRtcIsac_GetNewBitStream
|
#define ACM_ISAC_GETNEWBITSTREAM WebRtcIsac_GetNewBitStream
|
||||||
# define ACM_ISAC_GETSENDBWE WebRtcIsac_GetDownLinkBwIndex
|
#define ACM_ISAC_GETSENDBWE WebRtcIsac_GetDownLinkBwIndex
|
||||||
# define ACM_ISAC_SETBWE WebRtcIsac_UpdateUplinkBw
|
#define ACM_ISAC_SETBWE WebRtcIsac_UpdateUplinkBw
|
||||||
# define ACM_ISAC_GETBWE WebRtcIsac_ReadBwIndex
|
#define ACM_ISAC_GETBWE WebRtcIsac_ReadBwIndex
|
||||||
# define ACM_ISAC_GETNEWFRAMELEN WebRtcIsac_GetNewFrameLen
|
#define ACM_ISAC_GETNEWFRAMELEN WebRtcIsac_GetNewFrameLen
|
||||||
# define ACM_ISAC_STRUCT ISACStruct
|
#define ACM_ISAC_STRUCT ISACStruct
|
||||||
# define ACM_ISAC_GETENCSAMPRATE WebRtcIsac_EncSampRate
|
#define ACM_ISAC_GETENCSAMPRATE WebRtcIsac_EncSampRate
|
||||||
# define ACM_ISAC_GETDECSAMPRATE WebRtcIsac_DecSampRate
|
#define ACM_ISAC_GETDECSAMPRATE WebRtcIsac_DecSampRate
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_ISACFX
|
#ifdef WEBRTC_CODEC_ISACFX
|
||||||
# define ACM_ISAC_CREATE WebRtcIsacfix_Create
|
#define ACM_ISAC_CREATE WebRtcIsacfix_Create
|
||||||
# define ACM_ISAC_FREE WebRtcIsacfix_Free
|
#define ACM_ISAC_FREE WebRtcIsacfix_Free
|
||||||
# define ACM_ISAC_ENCODERINIT WebRtcIsacfix_EncoderInit
|
#define ACM_ISAC_ENCODERINIT WebRtcIsacfix_EncoderInit
|
||||||
# define ACM_ISAC_ENCODE WebRtcIsacfix_Encode
|
#define ACM_ISAC_ENCODE WebRtcIsacfix_Encode
|
||||||
# define ACM_ISAC_DECODERINIT WebRtcIsacfix_DecoderInit
|
#define ACM_ISAC_DECODERINIT WebRtcIsacfix_DecoderInit
|
||||||
# define ACM_ISAC_DECODE_BWE WebRtcIsacfix_UpdateBwEstimate
|
#define ACM_ISAC_DECODE_BWE WebRtcIsacfix_UpdateBwEstimate
|
||||||
# define ACM_ISAC_DECODE_B WebRtcIsacfix_Decode
|
#define ACM_ISAC_DECODE_B WebRtcIsacfix_Decode
|
||||||
# define ACM_ISAC_DECODEPLC WebRtcIsacfix_DecodePlc
|
#define ACM_ISAC_DECODEPLC WebRtcIsacfix_DecodePlc
|
||||||
# define ACM_ISAC_CONTROL ACMISACFixControl // local Impl
|
#define ACM_ISAC_CONTROL ACMISACFixControl // local Impl
|
||||||
# define ACM_ISAC_CONTROL_BWE ACMISACFixControlBWE // local Impl
|
#define ACM_ISAC_CONTROL_BWE ACMISACFixControlBWE // local Impl
|
||||||
# define ACM_ISAC_GETFRAMELEN WebRtcIsacfix_ReadFrameLen
|
#define ACM_ISAC_GETFRAMELEN WebRtcIsacfix_ReadFrameLen
|
||||||
# define ACM_ISAC_GETERRORCODE WebRtcIsacfix_GetErrorCode
|
#define ACM_ISAC_GETERRORCODE WebRtcIsacfix_GetErrorCode
|
||||||
# define ACM_ISAC_GETSENDBITRATE ACMISACFixGetSendBitrate // local Impl
|
#define ACM_ISAC_GETSENDBITRATE ACMISACFixGetSendBitrate // local Impl
|
||||||
# define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsacfix_SetMaxPayloadSize
|
#define ACM_ISAC_SETMAXPAYLOADSIZE WebRtcIsacfix_SetMaxPayloadSize
|
||||||
# define ACM_ISAC_SETMAXRATE WebRtcIsacfix_SetMaxRate
|
#define ACM_ISAC_SETMAXRATE WebRtcIsacfix_SetMaxRate
|
||||||
# define ACM_ISAC_GETNEWBITSTREAM ACMISACFixGetNewBitstream // local Impl
|
#define ACM_ISAC_GETNEWBITSTREAM ACMISACFixGetNewBitstream // local Impl
|
||||||
# define ACM_ISAC_GETSENDBWE ACMISACFixGetSendBWE // local Impl
|
#define ACM_ISAC_GETSENDBWE ACMISACFixGetSendBWE // local Impl
|
||||||
# define ACM_ISAC_SETBWE WebRtcIsacfix_UpdateUplinkBw
|
#define ACM_ISAC_SETBWE WebRtcIsacfix_UpdateUplinkBw
|
||||||
# define ACM_ISAC_GETBWE WebRtcIsacfix_ReadBwIndex
|
#define ACM_ISAC_GETBWE WebRtcIsacfix_ReadBwIndex
|
||||||
# define ACM_ISAC_GETNEWFRAMELEN WebRtcIsacfix_GetNewFrameLen
|
#define ACM_ISAC_GETNEWFRAMELEN WebRtcIsacfix_GetNewFrameLen
|
||||||
# define ACM_ISAC_STRUCT ISACFIX_MainStruct
|
#define ACM_ISAC_STRUCT ISACFIX_MainStruct
|
||||||
# define ACM_ISAC_GETENCSAMPRATE ACMISACFixGetEncSampRate // local Impl
|
#define ACM_ISAC_GETENCSAMPRATE ACMISACFixGetEncSampRate // local Impl
|
||||||
# define ACM_ISAC_GETDECSAMPRATE ACMISACFixGetDecSampRate // local Impl
|
#define ACM_ISAC_GETDECSAMPRATE ACMISACFixGetDecSampRate // local Impl
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} //namespace
|
} //namespace
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_ISAC_MACROS_H_
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -29,341 +29,317 @@ enum ACMSpeechType;
|
|||||||
|
|
||||||
#define MAX_NUM_SLAVE_NETEQ 1
|
#define MAX_NUM_SLAVE_NETEQ 1
|
||||||
|
|
||||||
class ACMNetEQ
|
class ACMNetEQ {
|
||||||
{
|
public:
|
||||||
public:
|
// Constructor of the class
|
||||||
// Constructor of the class
|
ACMNetEQ();
|
||||||
ACMNetEQ();
|
|
||||||
|
|
||||||
// Destructor of the class.
|
// Destructor of the class.
|
||||||
~ACMNetEQ();
|
~ACMNetEQ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init()
|
// Init()
|
||||||
// Allocates memory for NetEQ and VAD and initializes them.
|
// Allocates memory for NetEQ and VAD and initializes them.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// -1 if NetEQ or VAD returned an error or
|
// -1 if NetEQ or VAD returned an error or
|
||||||
// if out of memory.
|
// if out of memory.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 Init();
|
WebRtc_Word32 Init();
|
||||||
|
|
||||||
//
|
//
|
||||||
// RecIn()
|
// RecIn()
|
||||||
// Gives the payload to NetEQ.
|
// Gives the payload to NetEQ.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - incomingPayload : Incoming audio payload.
|
// - incomingPayload : Incoming audio payload.
|
||||||
// - payloadLength : Length of incoming audio payload.
|
// - payloadLength : Length of incoming audio payload.
|
||||||
// - rtpInfo : RTP header for the incoming payload containing
|
// - rtpInfo : RTP header for the incoming payload containing
|
||||||
// information about payload type, sequence number,
|
// information about payload type, sequence number,
|
||||||
// timestamp, ssrc and marker bit.
|
// timestamp, ssrc and marker bit.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 RecIn(
|
WebRtc_Word32 RecIn(const WebRtc_UWord8* incomingPayload,
|
||||||
const WebRtc_UWord8* incomingPayload,
|
const WebRtc_Word32 payloadLength,
|
||||||
const WebRtc_Word32 payloadLength,
|
const WebRtcRTPHeader& rtpInfo);
|
||||||
const WebRtcRTPHeader& rtpInfo);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// RecOut()
|
// RecOut()
|
||||||
// Asks NetEQ for 10 ms of decoded audio.
|
// Asks NetEQ for 10 ms of decoded audio.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// -audioFrame : an audio frame were output data and
|
// -audioFrame : an audio frame were output data and
|
||||||
// associated parameters are written to.
|
// associated parameters are written to.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// -1 if NetEQ returned an error.
|
// -1 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 RecOut(
|
WebRtc_Word32 RecOut(AudioFrame& audioFrame);
|
||||||
AudioFrame& audioFrame);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// AddCodec()
|
// AddCodec()
|
||||||
// Adds a new codec to the NetEQ codec database.
|
// Adds a new codec to the NetEQ codec database.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - codecDef : The codec to be added.
|
// - codecDef : The codec to be added.
|
||||||
// - toMaster : true if the codec has to be added to Master
|
// - toMaster : true if the codec has to be added to Master
|
||||||
// NetEq, otherwise will be added to the Slave
|
// NetEq, otherwise will be added to the Slave
|
||||||
// NetEQ.
|
// NetEQ.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 AddCodec(
|
WebRtc_Word32 AddCodec(WebRtcNetEQ_CodecDef *codecDef, bool toMaster = true);
|
||||||
WebRtcNetEQ_CodecDef *codecDef,
|
|
||||||
bool toMaster = true);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// AllocatePacketBuffer()
|
// AllocatePacketBuffer()
|
||||||
// Allocates the NetEQ packet buffer.
|
// Allocates the NetEQ packet buffer.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - usedCodecs : An array of the codecs to be used by NetEQ.
|
// - usedCodecs : An array of the codecs to be used by NetEQ.
|
||||||
// - noOfCodecs : Number of codecs in usedCodecs.
|
// - noOfCodecs : Number of codecs in usedCodecs.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 AllocatePacketBuffer(
|
WebRtc_Word32 AllocatePacketBuffer(const WebRtcNetEQDecoder* usedCodecs,
|
||||||
const WebRtcNetEQDecoder* usedCodecs,
|
WebRtc_Word16 noOfCodecs);
|
||||||
WebRtc_Word16 noOfCodecs);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetExtraDelay()
|
// SetExtraDelay()
|
||||||
// Sets an delayInMS milliseconds extra delay in NetEQ.
|
// Sets an delayInMS milliseconds extra delay in NetEQ.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - delayInMS : Extra delay in milliseconds.
|
// - delayInMS : Extra delay in milliseconds.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 SetExtraDelay(
|
WebRtc_Word32 SetExtraDelay(const WebRtc_Word32 delayInMS);
|
||||||
const WebRtc_Word32 delayInMS);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetAVTPlayout()
|
// SetAVTPlayout()
|
||||||
// Enable/disable playout of AVT payloads.
|
// Enable/disable playout of AVT payloads.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - enable : Enable if true, disable if false.
|
// - enable : Enable if true, disable if false.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 SetAVTPlayout(
|
WebRtc_Word32 SetAVTPlayout(const bool enable);
|
||||||
const bool enable);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// AVTPlayout()
|
// AVTPlayout()
|
||||||
// Get the current AVT playout state.
|
// Get the current AVT playout state.
|
||||||
//
|
//
|
||||||
// Return value : True if AVT playout is enabled.
|
// Return value : True if AVT playout is enabled.
|
||||||
// False if AVT playout is disabled.
|
// False if AVT playout is disabled.
|
||||||
//
|
//
|
||||||
bool AVTPlayout() const;
|
bool AVTPlayout() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// CurrentSampFreqHz()
|
// CurrentSampFreqHz()
|
||||||
// Get the current sampling frequency in Hz.
|
// Get the current sampling frequency in Hz.
|
||||||
//
|
//
|
||||||
// Return value : Sampling frequency in Hz.
|
// Return value : Sampling frequency in Hz.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 CurrentSampFreqHz() const;
|
WebRtc_Word32 CurrentSampFreqHz() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetPlayoutMode()
|
// SetPlayoutMode()
|
||||||
// Sets the playout mode to voice or fax.
|
// Sets the playout mode to voice or fax.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - mode : The playout mode to be used, voice,
|
// - mode : The playout mode to be used, voice,
|
||||||
// fax, or streaming.
|
// fax, or streaming.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 SetPlayoutMode(
|
WebRtc_Word32 SetPlayoutMode(const AudioPlayoutMode mode);
|
||||||
const AudioPlayoutMode mode);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// PlayoutMode()
|
// PlayoutMode()
|
||||||
// Get the current playout mode.
|
// Get the current playout mode.
|
||||||
//
|
//
|
||||||
// Return value : The current playout mode.
|
// Return value : The current playout mode.
|
||||||
//
|
//
|
||||||
AudioPlayoutMode PlayoutMode() const;
|
AudioPlayoutMode PlayoutMode() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// NetworkStatistics()
|
// NetworkStatistics()
|
||||||
// Get the current network statistics from NetEQ.
|
// Get the current network statistics from NetEQ.
|
||||||
//
|
//
|
||||||
// Output:
|
// Output:
|
||||||
// - statistics : The current network statistics.
|
// - statistics : The current network statistics.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// <0 if NetEQ returned an error.
|
// <0 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 NetworkStatistics(
|
WebRtc_Word32 NetworkStatistics(ACMNetworkStatistics* statistics) const;
|
||||||
ACMNetworkStatistics* statistics) const;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// VADMode()
|
// VADMode()
|
||||||
// Get the current VAD Mode.
|
// Get the current VAD Mode.
|
||||||
//
|
//
|
||||||
// Return value : The current VAD mode.
|
// Return value : The current VAD mode.
|
||||||
//
|
//
|
||||||
ACMVADMode VADMode() const;
|
ACMVADMode VADMode() const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetVADMode()
|
// SetVADMode()
|
||||||
// Set the VAD mode.
|
// Set the VAD mode.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - mode : The new VAD mode.
|
// - mode : The new VAD mode.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// -1 if an error occurred.
|
// -1 if an error occurred.
|
||||||
//
|
//
|
||||||
WebRtc_Word16 SetVADMode(
|
WebRtc_Word16 SetVADMode(const ACMVADMode mode);
|
||||||
const ACMVADMode mode);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// DecodeLock()
|
// DecodeLock()
|
||||||
// Get the decode lock used to protect decoder instances while decoding.
|
// Get the decode lock used to protect decoder instances while decoding.
|
||||||
//
|
//
|
||||||
// Return value : Pointer to the decode lock.
|
// Return value : Pointer to the decode lock.
|
||||||
//
|
//
|
||||||
RWLockWrapper* DecodeLock() const
|
RWLockWrapper* DecodeLock() const {
|
||||||
{
|
return _decodeLock;
|
||||||
return _decodeLock;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// FlushBuffers()
|
// FlushBuffers()
|
||||||
// Flushes the NetEQ packet and speech buffers.
|
// Flushes the NetEQ packet and speech buffers.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// -1 if NetEQ returned an error.
|
// -1 if NetEQ returned an error.
|
||||||
//
|
//
|
||||||
WebRtc_Word32 FlushBuffers();
|
WebRtc_Word32 FlushBuffers();
|
||||||
|
|
||||||
//
|
//
|
||||||
// RemoveCodec()
|
// RemoveCodec()
|
||||||
// Removes a codec from the NetEQ codec database.
|
// Removes a codec from the NetEQ codec database.
|
||||||
//
|
//
|
||||||
// Input:
|
// Input:
|
||||||
// - codecIdx : Codec to be removed.
|
// - codecIdx : Codec to be removed.
|
||||||
//
|
//
|
||||||
// Return value : 0 if ok.
|
// Return value : 0 if ok.
|
||||||
// -1 if an error occurred.
|
// -1 if an error occurred.
|
||||||
//
|
//
|
||||||
WebRtc_Word16 RemoveCodec(
|
WebRtc_Word16 RemoveCodec(WebRtcNetEQDecoder codecIdx, bool isStereo = false);
|
||||||
WebRtcNetEQDecoder codecIdx,
|
|
||||||
bool isStereo = false);
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// SetBackgroundNoiseMode()
|
||||||
|
// Set the mode of the background noise.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - mode : an enumerator specifying the mode of the
|
||||||
|
// background noise.
|
||||||
|
//
|
||||||
|
// Return value : 0 if succeeded,
|
||||||
|
// -1 if failed to set the mode.
|
||||||
|
//
|
||||||
|
WebRtc_Word16 SetBackgroundNoiseMode(const ACMBackgroundNoiseMode mode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// SetBackgroundNoiseMode()
|
// BackgroundNoiseMode()
|
||||||
// Set the mode of the background noise.
|
// return the mode of the background noise.
|
||||||
//
|
//
|
||||||
// Input:
|
// Return value : The mode of background noise.
|
||||||
// - mode : an enumerator specifying the mode of the
|
//
|
||||||
// background noise.
|
WebRtc_Word16 BackgroundNoiseMode(ACMBackgroundNoiseMode& mode);
|
||||||
//
|
|
||||||
// Return value : 0 if succeeded,
|
|
||||||
// -1 if failed to set the mode.
|
|
||||||
//
|
|
||||||
WebRtc_Word16 SetBackgroundNoiseMode(
|
|
||||||
const ACMBackgroundNoiseMode mode);
|
|
||||||
|
|
||||||
//
|
void SetUniqueId(WebRtc_Word32 id);
|
||||||
// BackgroundNoiseMode()
|
|
||||||
// return the mode of the background noise.
|
|
||||||
//
|
|
||||||
// Return value : The mode of background noise.
|
|
||||||
//
|
|
||||||
WebRtc_Word16 BackgroundNoiseMode(
|
|
||||||
ACMBackgroundNoiseMode& mode);
|
|
||||||
|
|
||||||
void SetUniqueId(
|
WebRtc_Word32 PlayoutTimestamp(WebRtc_UWord32& timestamp);
|
||||||
WebRtc_Word32 id);
|
|
||||||
|
|
||||||
WebRtc_Word32 PlayoutTimestamp(
|
void SetReceivedStereo(bool receivedStereo);
|
||||||
WebRtc_UWord32& timestamp);
|
|
||||||
|
|
||||||
void SetReceivedStereo(
|
WebRtc_UWord8 NumSlaves();
|
||||||
bool receivedStereo);
|
|
||||||
|
|
||||||
WebRtc_UWord8 NumSlaves();
|
enum JB {
|
||||||
|
masterJB = 0,
|
||||||
|
slaveJB = 1
|
||||||
|
};
|
||||||
|
|
||||||
enum JB {masterJB = 0, slaveJB = 1};
|
// Delete all slaves.
|
||||||
|
void RemoveSlaves();
|
||||||
|
|
||||||
// Delete all slaves.
|
WebRtc_Word16 AddSlave(const WebRtcNetEQDecoder* usedCodecs,
|
||||||
void RemoveSlaves();
|
WebRtc_Word16 noOfCodecs);
|
||||||
|
|
||||||
WebRtc_Word16 AddSlave(
|
private:
|
||||||
const WebRtcNetEQDecoder* usedCodecs,
|
//
|
||||||
WebRtc_Word16 noOfCodecs);
|
// RTPPack()
|
||||||
|
// Creates a Word16 RTP packet out of the payload data in Word16 and
|
||||||
|
// a WebRtcRTPHeader.
|
||||||
|
//
|
||||||
|
// Input:
|
||||||
|
// - payload : Payload to be packetized.
|
||||||
|
// - payloadLengthW8 : Length of the payload in bytes.
|
||||||
|
// - rtpInfo : RTP header struct.
|
||||||
|
//
|
||||||
|
// Output:
|
||||||
|
// - rtpPacket : The RTP packet.
|
||||||
|
//
|
||||||
|
static void RTPPack(WebRtc_Word16* rtpPacket, const WebRtc_Word8* payload,
|
||||||
|
const WebRtc_Word32 payloadLengthW8,
|
||||||
|
const WebRtcRTPHeader& rtpInfo);
|
||||||
|
|
||||||
private:
|
void LogError(const char* neteqFuncName, const WebRtc_Word16 idx) const;
|
||||||
//
|
|
||||||
// RTPPack()
|
|
||||||
// Creates a Word16 RTP packet out of the payload data in Word16 and
|
|
||||||
// a WebRtcRTPHeader.
|
|
||||||
//
|
|
||||||
// Input:
|
|
||||||
// - payload : Payload to be packetized.
|
|
||||||
// - payloadLengthW8 : Length of the payload in bytes.
|
|
||||||
// - rtpInfo : RTP header struct.
|
|
||||||
//
|
|
||||||
// Output:
|
|
||||||
// - rtpPacket : The RTP packet.
|
|
||||||
//
|
|
||||||
static void RTPPack(
|
|
||||||
WebRtc_Word16* rtpPacket,
|
|
||||||
const WebRtc_Word8* payload,
|
|
||||||
const WebRtc_Word32 payloadLengthW8,
|
|
||||||
const WebRtcRTPHeader& rtpInfo);
|
|
||||||
|
|
||||||
void LogError(
|
WebRtc_Word16 InitByIdxSafe(const WebRtc_Word16 idx);
|
||||||
const char* neteqFuncName,
|
|
||||||
const WebRtc_Word16 idx) const;
|
|
||||||
|
|
||||||
WebRtc_Word16 InitByIdxSafe(
|
// EnableVAD()
|
||||||
const WebRtc_Word16 idx);
|
// Enable VAD.
|
||||||
|
//
|
||||||
|
// Return value : 0 if ok.
|
||||||
|
// -1 if an error occurred.
|
||||||
|
//
|
||||||
|
WebRtc_Word16 EnableVAD();
|
||||||
|
|
||||||
// EnableVAD()
|
WebRtc_Word16 EnableVADByIdxSafe(const WebRtc_Word16 idx);
|
||||||
// Enable VAD.
|
|
||||||
//
|
|
||||||
// Return value : 0 if ok.
|
|
||||||
// -1 if an error occurred.
|
|
||||||
//
|
|
||||||
WebRtc_Word16 EnableVAD();
|
|
||||||
|
|
||||||
WebRtc_Word16 EnableVADByIdxSafe(
|
WebRtc_Word16 AllocatePacketBufferByIdxSafe(
|
||||||
const WebRtc_Word16 idx);
|
const WebRtcNetEQDecoder* usedCodecs,
|
||||||
|
WebRtc_Word16 noOfCodecs,
|
||||||
|
const WebRtc_Word16 idx);
|
||||||
|
|
||||||
WebRtc_Word16 AllocatePacketBufferByIdxSafe(
|
// Delete the NetEQ corresponding to |index|.
|
||||||
const WebRtcNetEQDecoder* usedCodecs,
|
void RemoveNetEQSafe(int index);
|
||||||
WebRtc_Word16 noOfCodecs,
|
|
||||||
const WebRtc_Word16 idx);
|
|
||||||
|
|
||||||
// Delete the NetEQ corresponding to |index|.
|
void RemoveSlavesSafe();
|
||||||
void RemoveNetEQSafe(int index);
|
|
||||||
|
|
||||||
void RemoveSlavesSafe();
|
void* _inst[MAX_NUM_SLAVE_NETEQ + 1];
|
||||||
|
void* _instMem[MAX_NUM_SLAVE_NETEQ + 1];
|
||||||
|
|
||||||
void* _inst[MAX_NUM_SLAVE_NETEQ + 1];
|
WebRtc_Word16* _netEqPacketBuffer[MAX_NUM_SLAVE_NETEQ + 1];
|
||||||
void* _instMem[MAX_NUM_SLAVE_NETEQ + 1];
|
|
||||||
|
|
||||||
WebRtc_Word16* _netEqPacketBuffer[MAX_NUM_SLAVE_NETEQ + 1];
|
WebRtc_Word32 _id;
|
||||||
|
float _currentSampFreqKHz;
|
||||||
|
bool _avtPlayout;
|
||||||
|
AudioPlayoutMode _playoutMode;
|
||||||
|
CriticalSectionWrapper* _netEqCritSect;
|
||||||
|
|
||||||
WebRtc_Word32 _id;
|
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1];
|
||||||
float _currentSampFreqKHz;
|
|
||||||
bool _avtPlayout;
|
|
||||||
AudioPlayoutMode _playoutMode;
|
|
||||||
CriticalSectionWrapper* _netEqCritSect;
|
|
||||||
|
|
||||||
WebRtcVadInst* _ptrVADInst[MAX_NUM_SLAVE_NETEQ + 1];
|
bool _vadStatus;
|
||||||
|
ACMVADMode _vadMode;
|
||||||
|
RWLockWrapper* _decodeLock;
|
||||||
|
bool _isInitialized[MAX_NUM_SLAVE_NETEQ + 1];
|
||||||
|
WebRtc_UWord8 _numSlaves;
|
||||||
|
bool _receivedStereo;
|
||||||
|
void* _masterSlaveInfo;
|
||||||
|
AudioFrame::VADActivity _previousAudioActivity;
|
||||||
|
WebRtc_Word32 _extraDelay;
|
||||||
|
|
||||||
bool _vadStatus;
|
CriticalSectionWrapper* _callbackCritSect;
|
||||||
ACMVADMode _vadMode;
|
|
||||||
RWLockWrapper* _decodeLock;
|
|
||||||
bool _isInitialized[MAX_NUM_SLAVE_NETEQ + 1];
|
|
||||||
WebRtc_UWord8 _numSlaves;
|
|
||||||
bool _receivedStereo;
|
|
||||||
void* _masterSlaveInfo;
|
|
||||||
AudioFrame::VADActivity _previousAudioActivity;
|
|
||||||
WebRtc_Word32 _extraDelay;
|
|
||||||
|
|
||||||
CriticalSectionWrapper* _callbackCritSect;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} //namespace webrtc
|
} //namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_NETEQ_H_
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_PCM16
|
#ifdef WEBRTC_CODEC_PCM16
|
||||||
#include "pcm16b.h"
|
#include "pcm16b.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -90,7 +90,6 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* /*payload*/,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else //===================== Actual Implementation =======================
|
#else //===================== Actual Implementation =======================
|
||||||
|
|
||||||
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
|
ACMPCM16B::ACMPCM16B(WebRtc_Word16 codecID) {
|
||||||
_codecID = codecID;
|
_codecID = codecID;
|
||||||
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
_samplingFreqHz = ACMCodecDB::CodecFreq(_codecID);
|
||||||
@ -103,8 +102,8 @@ ACMPCM16B::~ACMPCM16B() {
|
|||||||
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitStream,
|
WebRtc_Word16 ACMPCM16B::InternalEncode(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_Word16* bitStreamLenByte) {
|
WebRtc_Word16* bitStreamLenByte) {
|
||||||
*bitStreamLenByte = WebRtcPcm16b_Encode(&_inAudio[_inAudioIxRead],
|
*bitStreamLenByte = WebRtcPcm16b_Encode(&_inAudio[_inAudioIxRead],
|
||||||
_frameLenSmpl * _noChannels,
|
_frameLenSmpl * _noChannels,
|
||||||
bitStream);
|
bitStream);
|
||||||
// Increment the read index to tell the caller that how far
|
// Increment the read index to tell the caller that how far
|
||||||
// we have gone forward in reading the audio buffer.
|
// we have gone forward in reading the audio buffer.
|
||||||
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
_inAudioIxRead += _frameLenSmpl * _noChannels;
|
||||||
@ -144,13 +143,13 @@ WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
|||||||
}
|
}
|
||||||
case 16000: {
|
case 16000: {
|
||||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb, codecInst.pltype, NULL,
|
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb, codecInst.pltype, NULL,
|
||||||
16000);
|
16000);
|
||||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 32000: {
|
case 32000: {
|
||||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz, codecInst.pltype,
|
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz, codecInst.pltype,
|
||||||
NULL, 32000);
|
NULL, 32000);
|
||||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -162,19 +161,19 @@ WebRtc_Word32 ACMPCM16B::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
|||||||
switch(_samplingFreqHz) {
|
switch(_samplingFreqHz) {
|
||||||
case 8000: {
|
case 8000: {
|
||||||
SET_CODEC_PAR(codecDef, kDecoderPCM16B_2ch, codecInst.pltype, NULL,
|
SET_CODEC_PAR(codecDef, kDecoderPCM16B_2ch, codecInst.pltype, NULL,
|
||||||
8000);
|
8000);
|
||||||
SET_PCM16B_FUNCTIONS(codecDef);
|
SET_PCM16B_FUNCTIONS(codecDef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 16000: {
|
case 16000: {
|
||||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb_2ch, codecInst.pltype,
|
SET_CODEC_PAR(codecDef, kDecoderPCM16Bwb_2ch, codecInst.pltype,
|
||||||
NULL, 16000);
|
NULL, 16000);
|
||||||
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
SET_PCM16B_WB_FUNCTIONS(codecDef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 32000: {
|
case 32000: {
|
||||||
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz_2ch, codecInst.pltype,
|
SET_CODEC_PAR(codecDef, kDecoderPCM16Bswb32kHz_2ch, codecInst.pltype,
|
||||||
NULL, 32000);
|
NULL, 32000);
|
||||||
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
SET_PCM16B_SWB32_FUNCTIONS(codecDef);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -244,4 +243,4 @@ void ACMPCM16B::SplitStereoPacket(uint8_t* payload, int32_t* payload_length) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -13,55 +13,47 @@
|
|||||||
|
|
||||||
#include "acm_generic_codec.h"
|
#include "acm_generic_codec.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
class ACMPCM16B : public ACMGenericCodec
|
class ACMPCM16B : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMPCM16B(WebRtc_Word16 codecID);
|
||||||
ACMPCM16B(WebRtc_Word16 codecID);
|
~ACMPCM16B();
|
||||||
~ACMPCM16B();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||||
|
|
||||||
WebRtc_Word32 _samplingFreqHz;
|
WebRtc_Word32 _samplingFreqHz;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCM16B_H_
|
||||||
|
@ -120,11 +120,11 @@ void ACMPCMA::SplitStereoPacket(uint8_t* payload, int32_t* payload_length) {
|
|||||||
// end of the bytestream vector. After looping the data is reordered to:
|
// end of the bytestream vector. After looping the data is reordered to:
|
||||||
// l1 l2 l3 l4 ... l(N-1) lN r1 r2 r3 r4 ... r(N-1) r(N),
|
// l1 l2 l3 l4 ... l(N-1) lN r1 r2 r3 r4 ... r(N-1) r(N),
|
||||||
// where N is the total number of samples.
|
// where N is the total number of samples.
|
||||||
for (int i = 0; i < *payload_length / 2; i ++) {
|
for (int i = 0; i < *payload_length / 2; i++) {
|
||||||
right_byte = payload[i + 1];
|
right_byte = payload[i + 1];
|
||||||
memmove(&payload[i + 1], &payload[i + 2], *payload_length - i - 2);
|
memmove(&payload[i + 1], &payload[i + 2], *payload_length - i - 2);
|
||||||
payload[*payload_length - 1] = right_byte;
|
payload[*payload_length - 1] = right_byte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -13,53 +13,45 @@
|
|||||||
|
|
||||||
#include "acm_generic_codec.h"
|
#include "acm_generic_codec.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
class ACMPCMA : public ACMGenericCodec
|
class ACMPCMA : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMPCMA(WebRtc_Word16 codecID);
|
||||||
ACMPCMA(WebRtc_Word16 codecID);
|
~ACMPCMA();
|
||||||
~ACMPCMA();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMA_H_
|
||||||
|
@ -56,8 +56,8 @@ WebRtc_Word16 ACMPCMU::InternalInitEncoder(
|
|||||||
|
|
||||||
WebRtc_Word16 ACMPCMU::InternalInitDecoder(
|
WebRtc_Word16 ACMPCMU::InternalInitDecoder(
|
||||||
WebRtcACMCodecParams* /* codecParams */) {
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
// This codec does not need initialization, PCM has no instance.
|
// This codec does not need initialization, PCM has no instance.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
WebRtc_Word32 ACMPCMU::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
@ -122,11 +122,11 @@ void ACMPCMU::SplitStereoPacket(uint8_t* payload, int32_t* payload_length) {
|
|||||||
// end of the bytestream vector. After looping the data is reordered to:
|
// end of the bytestream vector. After looping the data is reordered to:
|
||||||
// l1 l2 l3 l4 ... l(N-1) lN r1 r2 r3 r4 ... r(N-1) r(N),
|
// l1 l2 l3 l4 ... l(N-1) lN r1 r2 r3 r4 ... r(N-1) r(N),
|
||||||
// where N is the total number of samples.
|
// where N is the total number of samples.
|
||||||
for (int i = 0; i < *payload_length / 2; i ++) {
|
for (int i = 0; i < *payload_length / 2; i++) {
|
||||||
right_byte = payload[i + 1];
|
right_byte = payload[i + 1];
|
||||||
memmove(&payload[i + 1], &payload[i + 2], *payload_length - i - 2);
|
memmove(&payload[i + 1], &payload[i + 2], *payload_length - i - 2);
|
||||||
payload[*payload_length - 1] = right_byte;
|
payload[*payload_length - 1] = right_byte;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -13,53 +13,45 @@
|
|||||||
|
|
||||||
#include "acm_generic_codec.h"
|
#include "acm_generic_codec.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
class ACMPCMU : public ACMGenericCodec
|
class ACMPCMU : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMPCMU(WebRtc_Word16 codecID);
|
||||||
ACMPCMU(WebRtc_Word16 codecID);
|
~ACMPCMU();
|
||||||
~ACMPCMU();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
void SplitStereoPacket(uint8_t* payload, int32_t* payload_length);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_PCMU_H_
|
||||||
|
@ -15,129 +15,89 @@
|
|||||||
#include "webrtc_neteq.h"
|
#include "webrtc_neteq.h"
|
||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
ACMRED::ACMRED(WebRtc_Word16 codecID)
|
ACMRED::ACMRED(WebRtc_Word16 codecID) {
|
||||||
{
|
_codecID = codecID;
|
||||||
_codecID = codecID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMRED::~ACMRED() {
|
||||||
ACMRED::~ACMRED()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
ACMRED::InternalEncode(
|
// RED is never used as an encoder
|
||||||
WebRtc_UWord8* /* bitStream */,
|
// RED has no instance
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
return 0;
|
||||||
{
|
|
||||||
// RED is never used as an encoder
|
|
||||||
// RED has no instance
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
WebRtc_Word16
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
ACMRED::DecodeSafe(
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audioSamples */,
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
WebRtc_Word8* /* speechType */) {
|
||||||
WebRtc_Word16* /* audio */,
|
return 0;
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::InternalInitEncoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMRED::InternalInitEncoder(
|
// This codec does not need initialization,
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
// RED has no instance
|
||||||
{
|
return 0;
|
||||||
// This codec does not need initialization,
|
|
||||||
// RED has no instance
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::InternalInitDecoder(
|
||||||
WebRtc_Word16
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
ACMRED::InternalInitDecoder(
|
// This codec does not need initialization,
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
// RED has no instance
|
||||||
{
|
return 0;
|
||||||
// This codec does not need initialization,
|
|
||||||
// RED has no instance
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word32 ACMRED::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
|
const CodecInst& codecInst) {
|
||||||
|
if (!_decoderInitialized) {
|
||||||
|
// Todo:
|
||||||
|
// log error
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
// Fill up the structure by calling
|
||||||
ACMRED::CodecDef(
|
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
// Then call NetEQ to add the codec to it's
|
||||||
const CodecInst& codecInst)
|
// database.
|
||||||
{
|
SET_CODEC_PAR((codecDef), kDecoderRED, codecInst.pltype, NULL, 8000);
|
||||||
if (!_decoderInitialized)
|
SET_RED_FUNCTIONS((codecDef));
|
||||||
{
|
return 0;
|
||||||
// Todo:
|
|
||||||
// log error
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill up the structure by calling
|
|
||||||
// "SET_CODEC_PAR" & "SET_PCMU_FUNCTION."
|
|
||||||
// Then call NetEQ to add the codec to it's
|
|
||||||
// database.
|
|
||||||
SET_CODEC_PAR((codecDef), kDecoderRED, codecInst.pltype, NULL, 8000);
|
|
||||||
SET_RED_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ACMGenericCodec* ACMRED::CreateInstance(void) {
|
||||||
ACMGenericCodec*
|
return NULL;
|
||||||
ACMRED::CreateInstance(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::InternalCreateEncoder() {
|
||||||
WebRtc_Word16
|
// RED has no instance
|
||||||
ACMRED::InternalCreateEncoder()
|
return 0;
|
||||||
{
|
|
||||||
// RED has no instance
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMRED::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
// RED has no instance
|
||||||
ACMRED::InternalCreateDecoder()
|
return 0;
|
||||||
{
|
|
||||||
// RED has no instance
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMRED::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
void
|
// RED has no instance
|
||||||
ACMRED::InternalDestructEncoderInst(
|
return;
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
// RED has no instance
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMRED::DestructEncoderSafe() {
|
||||||
void
|
// RED has no instance
|
||||||
ACMRED::DestructEncoderSafe()
|
return;
|
||||||
{
|
|
||||||
// RED has no instance
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ACMRED::DestructDecoderSafe()
|
void ACMRED::DestructDecoderSafe() {
|
||||||
{
|
// RED has no instance
|
||||||
// RED has no instance
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -13,51 +13,43 @@
|
|||||||
|
|
||||||
#include "acm_generic_codec.h"
|
#include "acm_generic_codec.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
class ACMRED : public ACMGenericCodec
|
class ACMRED : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMRED(WebRtc_Word16 codecID);
|
||||||
ACMRED(WebRtc_Word16 codecID);
|
~ACMRED();
|
||||||
~ACMRED();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_RED_H_
|
||||||
|
@ -17,35 +17,9 @@
|
|||||||
#include "webrtc_neteq_help_macros.h"
|
#include "webrtc_neteq_help_macros.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_CODEC_SPEEX
|
#ifdef WEBRTC_CODEC_SPEEX
|
||||||
// NOTE! Speex is not included in the open-source package. The following
|
// NOTE! Speex is not included in the open-source package. Modify this file or
|
||||||
// interface file is needed:
|
// your codec API to match the function calls and names of used Speex API file.
|
||||||
//
|
#include "speex_interface.h"
|
||||||
// /modules/audio_coding/codecs/speex/main/interface/speex_interface.h
|
|
||||||
//
|
|
||||||
// The API in the header file should match the one below.
|
|
||||||
//
|
|
||||||
// int16_t WebRtcSpeex_CreateEnc(SPEEX_encinst_t **SPEEXenc_inst,
|
|
||||||
// int32_t fs);
|
|
||||||
// int16_t WebRtcSpeex_FreeEnc(SPEEX_encinst_t *SPEEXenc_inst);
|
|
||||||
// int16_t WebRtcSpeex_CreateDec(SPEEX_decinst_t **SPEEXdec_inst,
|
|
||||||
// int32_t fs,
|
|
||||||
// int16_t enh_enabled);
|
|
||||||
// int16_t WebRtcSpeex_FreeDec(SPEEX_decinst_t *SPEEXdec_inst);
|
|
||||||
// int16_t WebRtcSpeex_Encode(SPEEX_encinst_t *SPEEXenc_inst,
|
|
||||||
// int16_t *speechIn,
|
|
||||||
// int32_t rate);
|
|
||||||
// int16_t WebRtcSpeex_EncoderInit(SPEEX_encinst_t *SPEEXenc_inst,
|
|
||||||
// int16_t vbr, int16_t complexity,
|
|
||||||
// int16_t vad_enable);
|
|
||||||
// int16_t WebRtcSpeex_GetBitstream(SPEEX_encinst_t *SPEEXenc_inst,
|
|
||||||
// int16_t *encoded);
|
|
||||||
// int16_t WebRtcSpeex_DecodePlc(SPEEX_decinst_t *SPEEXdec_inst,
|
|
||||||
// int16_t *decoded, int16_t noOfLostFrames);
|
|
||||||
// int16_t WebRtcSpeex_Decode(SPEEX_decinst_t *SPEEXdec_inst,
|
|
||||||
// int16_t *encoded, int16_t len,
|
|
||||||
// int16_t *decoded, int16_t *speechType);
|
|
||||||
// int16_t WebRtcSpeex_DecoderInit(SPEEX_decinst_t *SPEEXdec_inst);
|
|
||||||
#include "speex_interface.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
@ -62,561 +36,431 @@ ACMSPEEX::ACMSPEEX(WebRtc_Word16 /* codecID */)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ACMSPEEX::~ACMSPEEX()
|
ACMSPEEX::~ACMSPEEX() {
|
||||||
{
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* /* bitStream */,
|
||||||
ACMSPEEX::InternalEncode(
|
WebRtc_Word16* /* bitStreamLenByte */) {
|
||||||
WebRtc_UWord8* /* bitStream */,
|
return -1;
|
||||||
WebRtc_Word16* /* bitStreamLenByte */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
ACMSPEEX::DecodeSafe(
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
WebRtc_UWord8* /* bitStream */,
|
WebRtc_Word16* /* audio */,
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
WebRtc_Word16* /* audioSamples */,
|
||||||
WebRtc_Word16* /* audio */,
|
WebRtc_Word8* /* speechType */) {
|
||||||
WebRtc_Word16* /* audioSamples */,
|
return -1;
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||||
ACMSPEEX::EnableDTX()
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||||
ACMSPEEX::DisableDTX()
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(
|
||||||
ACMSPEEX::InternalInitEncoder(
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||||
ACMSPEEX::InternalInitDecoder(
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word32
|
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& /* codecDef */,
|
||||||
ACMSPEEX::CodecDef(
|
const CodecInst& /* codecInst */) {
|
||||||
WebRtcNetEQ_CodecDef& /* codecDef */,
|
return -1;
|
||||||
const CodecInst& /* codecInst */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ACMGenericCodec*
|
ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
|
||||||
ACMSPEEX::CreateInstance(void)
|
return NULL;
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
|
||||||
ACMSPEEX::InternalCreateEncoder()
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ACMSPEEX::DestructEncoderSafe() {
|
||||||
ACMSPEEX::DestructEncoderSafe()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
|
||||||
WebRtc_Word16
|
return -1;
|
||||||
ACMSPEEX::InternalCreateDecoder()
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ACMSPEEX::DestructDecoderSafe() {
|
||||||
ACMSPEEX::DestructDecoderSafe()
|
return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 /* rate */) {
|
||||||
ACMSPEEX::SetBitRateSafe(
|
return -1;
|
||||||
const WebRtc_Word32 /* rate */)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void ACMSPEEX::InternalDestructEncoderInst(void* /* ptrInst */) {
|
||||||
ACMSPEEX::InternalDestructEncoderInst(
|
return;
|
||||||
void* /* ptrInst */)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNUSEDSPEEX
|
#ifdef UNUSEDSPEEX
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||||
ACMSPEEX::EnableVBR()
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||||
ACMSPEEX::DisableVBR()
|
return -1;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||||
ACMSPEEX::SetComplMode(
|
return -1;
|
||||||
WebRtc_Word16 mode)
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#else //===================== Actual Implementation =======================
|
#else //===================== Actual Implementation =======================
|
||||||
|
|
||||||
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID):
|
ACMSPEEX::ACMSPEEX(WebRtc_Word16 codecID)
|
||||||
_encoderInstPtr(NULL),
|
: _encoderInstPtr(NULL),
|
||||||
_decoderInstPtr(NULL)
|
_decoderInstPtr(NULL) {
|
||||||
{
|
_codecID = codecID;
|
||||||
_codecID = codecID;
|
|
||||||
|
|
||||||
// Set sampling frequency, frame size and rate Speex
|
// Set sampling frequency, frame size and rate Speex
|
||||||
if(_codecID == ACMCodecDB::kSPEEX8)
|
if (_codecID == ACMCodecDB::kSPEEX8) {
|
||||||
{
|
_samplingFrequency = 8000;
|
||||||
_samplingFrequency = 8000;
|
_samplesIn20MsAudio = 160;
|
||||||
_samplesIn20MsAudio = 160;
|
_encodingRate = 11000;
|
||||||
_encodingRate = 11000;
|
} else if (_codecID == ACMCodecDB::kSPEEX16) {
|
||||||
}
|
_samplingFrequency = 16000;
|
||||||
else if(_codecID == ACMCodecDB::kSPEEX16)
|
_samplesIn20MsAudio = 320;
|
||||||
{
|
_encodingRate = 22000;
|
||||||
_samplingFrequency = 16000;
|
} else {
|
||||||
_samplesIn20MsAudio = 320;
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
_encodingRate = 22000;
|
"Wrong codec id for Speex.");
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Wrong codec id for Speex.");
|
|
||||||
|
|
||||||
_samplingFrequency = -1;
|
_samplingFrequency = -1;
|
||||||
_samplesIn20MsAudio = -1;
|
_samplesIn20MsAudio = -1;
|
||||||
_encodingRate = -1;
|
_encodingRate = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_hasInternalDTX = true;
|
||||||
|
_dtxEnabled = false;
|
||||||
|
_vbrEnabled = false;
|
||||||
|
_complMode = 3; // default complexity value
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ACMSPEEX::~ACMSPEEX() {
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::InternalEncode(WebRtc_UWord8* bitStream,
|
||||||
|
WebRtc_Word16* bitStreamLenByte) {
|
||||||
|
WebRtc_Word16 status;
|
||||||
|
WebRtc_Word16 numEncodedSamples = 0;
|
||||||
|
WebRtc_Word16 n = 0;
|
||||||
|
|
||||||
|
while (numEncodedSamples < _frameLenSmpl) {
|
||||||
|
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
||||||
|
_encodingRate);
|
||||||
|
|
||||||
|
// increment the read index this tell the caller that how far
|
||||||
|
// we have gone forward in reading the audio buffer
|
||||||
|
_inAudioIxRead += _samplesIn20MsAudio;
|
||||||
|
numEncodedSamples += _samplesIn20MsAudio;
|
||||||
|
|
||||||
|
if (status < 0) {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Error in Speex encoder");
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasInternalDTX = true;
|
// Update VAD, if internal DTX is used
|
||||||
|
if (_hasInternalDTX && _dtxEnabled) {
|
||||||
|
_vadLabel[n++] = status;
|
||||||
|
_vadLabel[n++] = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status == 0) {
|
||||||
|
// This frame is detected as inactive. We need send whatever
|
||||||
|
// encoded so far.
|
||||||
|
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
||||||
|
(WebRtc_Word16*) bitStream);
|
||||||
|
|
||||||
|
return *bitStreamLenByte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
||||||
|
(WebRtc_Word16*) bitStream);
|
||||||
|
return *bitStreamLenByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::DecodeSafe(WebRtc_UWord8* /* bitStream */,
|
||||||
|
WebRtc_Word16 /* bitStreamLenByte */,
|
||||||
|
WebRtc_Word16* /* audio */,
|
||||||
|
WebRtc_Word16* /* audioSamples */,
|
||||||
|
WebRtc_Word8* /* speechType */) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::EnableDTX() {
|
||||||
|
if (_dtxEnabled) {
|
||||||
|
return 0;
|
||||||
|
} else if (_encoderExist) { // check if encoder exist
|
||||||
|
// enable DTX
|
||||||
|
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 {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::DisableDTX() {
|
||||||
|
if (!_dtxEnabled) {
|
||||||
|
return 0;
|
||||||
|
} else if (_encoderExist) { // check if encoder exist
|
||||||
|
// disable DTX
|
||||||
|
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;
|
_dtxEnabled = false;
|
||||||
_vbrEnabled = false;
|
|
||||||
_complMode = 3; // default complexity value
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ACMSPEEX::~ACMSPEEX()
|
|
||||||
{
|
|
||||||
if(_encoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::InternalEncode(
|
|
||||||
WebRtc_UWord8* bitStream,
|
|
||||||
WebRtc_Word16* bitStreamLenByte)
|
|
||||||
{
|
|
||||||
WebRtc_Word16 status;
|
|
||||||
WebRtc_Word16 numEncodedSamples = 0;
|
|
||||||
WebRtc_Word16 n = 0;
|
|
||||||
|
|
||||||
while( numEncodedSamples < _frameLenSmpl)
|
|
||||||
{
|
|
||||||
status = WebRtcSpeex_Encode(_encoderInstPtr, &_inAudio[_inAudioIxRead],
|
|
||||||
_encodingRate);
|
|
||||||
|
|
||||||
// increment the read index this tell the caller that how far
|
|
||||||
// we have gone forward in reading the audio buffer
|
|
||||||
_inAudioIxRead += _samplesIn20MsAudio;
|
|
||||||
numEncodedSamples += _samplesIn20MsAudio;
|
|
||||||
|
|
||||||
if(status < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Error in Speex encoder");
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update VAD, if internal DTX is used
|
|
||||||
if(_hasInternalDTX && _dtxEnabled)
|
|
||||||
{
|
|
||||||
_vadLabel[n++] = status;
|
|
||||||
_vadLabel[n++] = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(status == 0)
|
|
||||||
{
|
|
||||||
// This frame is detected as inactive. We need send whatever
|
|
||||||
// encoded so far.
|
|
||||||
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
|
||||||
(WebRtc_Word16*)bitStream);
|
|
||||||
|
|
||||||
return *bitStreamLenByte;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
*bitStreamLenByte = WebRtcSpeex_GetBitstream(_encoderInstPtr,
|
|
||||||
(WebRtc_Word16*)bitStream);
|
|
||||||
return *bitStreamLenByte;
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::DecodeSafe(
|
|
||||||
WebRtc_UWord8* /* bitStream */,
|
|
||||||
WebRtc_Word16 /* bitStreamLenByte */,
|
|
||||||
WebRtc_Word16* /* audio */,
|
|
||||||
WebRtc_Word16* /* audioSamples */,
|
|
||||||
WebRtc_Word8* /* speechType */)
|
|
||||||
{
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
|
// encoder doesn't exists, therefore disabling is harmless
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::EnableDTX()
|
|
||||||
{
|
|
||||||
if(_dtxEnabled)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(_encoderExist) // check if encoder exist
|
|
||||||
{
|
|
||||||
// enable DTX
|
|
||||||
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
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalInitEncoder(WebRtcACMCodecParams* codecParams) {
|
||||||
ACMSPEEX::DisableDTX()
|
// sanity check
|
||||||
{
|
if (_encoderInstPtr == NULL) {
|
||||||
if(!_dtxEnabled)
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
{
|
"Cannot initialize Speex encoder, instance does not exist");
|
||||||
return 0;
|
return -1;
|
||||||
}
|
}
|
||||||
else if(_encoderExist) // check if encoder exist
|
|
||||||
{
|
|
||||||
// disable DTX
|
|
||||||
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
|
|
||||||
{
|
|
||||||
// encoder doesn't exists, therefore disabling is harmless
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
WebRtc_Word16 status = SetBitRateSafe((codecParams->codecInstant).rate);
|
||||||
|
status +=
|
||||||
|
(WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode,
|
||||||
|
((codecParams->enableDTX) ? 1 : 0)) < 0) ?
|
||||||
|
-1 : 0;
|
||||||
|
|
||||||
|
if (status >= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Error in initialization of Speex encoder");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::InternalInitDecoder(
|
||||||
ACMSPEEX::InternalInitEncoder(
|
WebRtcACMCodecParams* /* codecParams */) {
|
||||||
WebRtcACMCodecParams* codecParams)
|
WebRtc_Word16 status;
|
||||||
{
|
|
||||||
// sanity check
|
|
||||||
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);
|
// sanity check
|
||||||
status += (WebRtcSpeex_EncoderInit(_encoderInstPtr, _vbrEnabled, _complMode, ((codecParams->enableDTX)? 1:0)) < 0)? -1:0;
|
if (_decoderInstPtr == NULL) {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Cannot initialize Speex decoder, instance does not exist");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0) ? -1 : 0);
|
||||||
|
|
||||||
if (status >= 0) {
|
if (status >= 0) {
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Error in initialization of Speex encoder");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::InternalInitDecoder(
|
|
||||||
WebRtcACMCodecParams* /* codecParams */)
|
|
||||||
{
|
|
||||||
WebRtc_Word16 status;
|
|
||||||
|
|
||||||
// sanity check
|
|
||||||
if (_decoderInstPtr == NULL)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Cannot initialize Speex decoder, instance does not exist");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
status = ((WebRtcSpeex_DecoderInit(_decoderInstPtr) < 0)? -1:0);
|
|
||||||
|
|
||||||
if (status >= 0) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Error in initialization of Speex decoder");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill up the structure by calling
|
|
||||||
// "SET_CODEC_PAR" & "SET_SPEEX_FUNCTION."
|
|
||||||
// Then call NetEQ to add the codec to its
|
|
||||||
// database.
|
|
||||||
|
|
||||||
switch(_samplingFrequency)
|
|
||||||
{
|
|
||||||
case 8000:
|
|
||||||
{
|
|
||||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype,
|
|
||||||
_decoderInstPtr, 8000);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 16000:
|
|
||||||
{
|
|
||||||
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype,
|
|
||||||
_decoderInstPtr, 16000);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Unsupported sampling frequency for Speex");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SET_SPEEX_FUNCTIONS((codecDef));
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Error in initialization of Speex decoder");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ACMGenericCodec*
|
WebRtc_Word32 ACMSPEEX::CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
ACMSPEEX::CreateInstance(void)
|
const CodecInst& codecInst) {
|
||||||
{
|
if (!_decoderInitialized) {
|
||||||
return NULL;
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
}
|
"Error, Speex decoder is not initialized");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
// Fill up the structure by calling
|
||||||
ACMSPEEX::InternalCreateEncoder()
|
// "SET_CODEC_PAR" & "SET_SPEEX_FUNCTION."
|
||||||
{
|
// Then call NetEQ to add the codec to its
|
||||||
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
|
// database.
|
||||||
}
|
|
||||||
|
|
||||||
void
|
switch (_samplingFrequency) {
|
||||||
ACMSPEEX::DestructEncoderSafe()
|
case 8000: {
|
||||||
{
|
SET_CODEC_PAR((codecDef), kDecoderSPEEX_8, codecInst.pltype,
|
||||||
if(_encoderInstPtr != NULL)
|
_decoderInstPtr, 8000);
|
||||||
{
|
break;
|
||||||
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
|
||||||
_encoderInstPtr = NULL;
|
|
||||||
}
|
}
|
||||||
// there is no encoder set the following
|
case 16000: {
|
||||||
_encoderExist = false;
|
SET_CODEC_PAR((codecDef), kDecoderSPEEX_16, codecInst.pltype,
|
||||||
_encoderInitialized = false;
|
_decoderInstPtr, 16000);
|
||||||
_encodingRate = 0;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::InternalCreateDecoder()
|
|
||||||
{
|
|
||||||
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ACMSPEEX::DestructDecoderSafe()
|
|
||||||
{
|
|
||||||
if(_decoderInstPtr != NULL)
|
|
||||||
{
|
|
||||||
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
|
||||||
_decoderInstPtr = NULL;
|
|
||||||
}
|
}
|
||||||
// there is no encoder instance set the followings
|
default: {
|
||||||
_decoderExist = false;
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
_decoderInitialized = false;
|
"Unsupported sampling frequency for Speex");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SET_SPEEX_FUNCTIONS((codecDef));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtc_Word16
|
ACMGenericCodec* ACMSPEEX::CreateInstance(void) {
|
||||||
ACMSPEEX::SetBitRateSafe(
|
return NULL;
|
||||||
const WebRtc_Word32 rate)
|
}
|
||||||
{
|
|
||||||
// Check if changed rate
|
|
||||||
if (rate == _encodingRate) {
|
|
||||||
return 0;
|
|
||||||
} else if (rate > 2000) {
|
|
||||||
_encodingRate = rate;
|
|
||||||
_encoderParams.codecInstant.rate = rate;
|
|
||||||
} else {
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Unsupported encoding rate for Speex");
|
|
||||||
|
|
||||||
return -1;
|
WebRtc_Word16 ACMSPEEX::InternalCreateEncoder() {
|
||||||
}
|
return WebRtcSpeex_CreateEnc(&_encoderInstPtr, _samplingFrequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMSPEEX::DestructEncoderSafe() {
|
||||||
|
if (_encoderInstPtr != NULL) {
|
||||||
|
WebRtcSpeex_FreeEnc(_encoderInstPtr);
|
||||||
|
_encoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
// there is no encoder set the following
|
||||||
|
_encoderExist = false;
|
||||||
|
_encoderInitialized = false;
|
||||||
|
_encodingRate = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::InternalCreateDecoder() {
|
||||||
|
return WebRtcSpeex_CreateDec(&_decoderInstPtr, _samplingFrequency, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ACMSPEEX::DestructDecoderSafe() {
|
||||||
|
if (_decoderInstPtr != NULL) {
|
||||||
|
WebRtcSpeex_FreeDec(_decoderInstPtr);
|
||||||
|
_decoderInstPtr = NULL;
|
||||||
|
}
|
||||||
|
// there is no encoder instance set the followings
|
||||||
|
_decoderExist = false;
|
||||||
|
_decoderInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
WebRtc_Word16 ACMSPEEX::SetBitRateSafe(const WebRtc_Word32 rate) {
|
||||||
|
// Check if changed rate
|
||||||
|
if (rate == _encodingRate) {
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if (rate > 2000) {
|
||||||
|
_encodingRate = rate;
|
||||||
|
_encoderParams.codecInstant.rate = rate;
|
||||||
|
} else {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Unsupported encoding rate for Speex");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ACMSPEEX::InternalDestructEncoderInst(void* ptrInst) {
|
||||||
void
|
if (ptrInst != NULL) {
|
||||||
ACMSPEEX::InternalDestructEncoderInst(
|
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*) ptrInst);
|
||||||
void* ptrInst)
|
}
|
||||||
{
|
return;
|
||||||
if(ptrInst != NULL)
|
|
||||||
{
|
|
||||||
WebRtcSpeex_FreeEnc((SPEEX_encinst_t_*)ptrInst);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UNUSEDSPEEX
|
#ifdef UNUSEDSPEEX
|
||||||
|
|
||||||
// This API is currently not in use. If requested to be able to enable/disable VBR
|
// This API is currently not in use. If requested to be able to enable/disable VBR
|
||||||
// an ACM API need to be added.
|
// an ACM API need to be added.
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::EnableVBR() {
|
||||||
ACMSPEEX::EnableVBR()
|
if (_vbrEnabled) {
|
||||||
{
|
return 0;
|
||||||
if(_vbrEnabled)
|
} else if (_encoderExist) // check if encoder exist
|
||||||
{
|
{
|
||||||
return 0;
|
// enable Variable Bit Rate (VBR)
|
||||||
}
|
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode,
|
||||||
else if(_encoderExist) // check if encoder exist
|
(_dtxEnabled ? 1 : 0)) < 0) {
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
// enable Variable Bit Rate (VBR)
|
"Cannot enable VBR mode for Speex");
|
||||||
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 1, _complMode, (_dtxEnabled? 1:0)) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Cannot enable VBR mode for Speex");
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
_vbrEnabled = true;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
_vbrEnabled = true;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This API is currently not in use. If requested to be able to enable/disable
|
||||||
|
// VBR an ACM API need to be added.
|
||||||
|
WebRtc_Word16 ACMSPEEX::DisableVBR() {
|
||||||
|
if (!_vbrEnabled) {
|
||||||
|
return 0;
|
||||||
|
} else if (_encoderExist) { // check if encoder exist
|
||||||
|
// disable DTX
|
||||||
|
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode,
|
||||||
|
(_dtxEnabled ? 1 : 0)) < 0) {
|
||||||
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
|
"Cannot disable DTX for Speex");
|
||||||
|
|
||||||
// This API is currently not in use. If requested to be able to enable/disable VBR
|
return -1;
|
||||||
// an ACM API need to be added.
|
|
||||||
WebRtc_Word16
|
|
||||||
ACMSPEEX::DisableVBR()
|
|
||||||
{
|
|
||||||
if(!_vbrEnabled)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if(_encoderExist) // check if encoder exist
|
|
||||||
{
|
|
||||||
// disable DTX
|
|
||||||
if(WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, _complMode, (_dtxEnabled? 1:0)) < 0)
|
|
||||||
{
|
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
|
||||||
"Cannot disable DTX for Speex");
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
_vbrEnabled = false;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// encoder doesn't exists, therefore disabling is harmless
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
_vbrEnabled = false;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// encoder doesn't exists, therefore disabling is harmless
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This API is currently not in use. If requested to be able to set complexity
|
// This API is currently not in use. If requested to be able to set complexity
|
||||||
// an ACM API need to be added.
|
// an ACM API need to be added.
|
||||||
WebRtc_Word16
|
WebRtc_Word16 ACMSPEEX::SetComplMode(WebRtc_Word16 mode) {
|
||||||
ACMSPEEX::SetComplMode(
|
// Check if new mode
|
||||||
WebRtc_Word16 mode)
|
if (mode == _complMode) {
|
||||||
{
|
return 0;
|
||||||
// Check if new mode
|
} else if (_encoderExist) { // check if encoder exist
|
||||||
if(mode == _complMode)
|
// Set new mode
|
||||||
{
|
if (WebRtcSpeex_EncoderInit(_encoderInstPtr, 0, mode, (_dtxEnabled ? 1 : 0))
|
||||||
return 0;
|
< 0) {
|
||||||
}
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, _uniqueID,
|
||||||
else if(_encoderExist) // check if encoder exist
|
"Error in complexity mode for Speex");
|
||||||
{
|
return -1;
|
||||||
// Set new mode
|
|
||||||
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
|
|
||||||
{
|
|
||||||
// encoder doesn't exists, therefore disabling is harmless
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
_complMode = mode;
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
// encoder doesn't exists, therefore disabling is harmless
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
@ -19,72 +19,63 @@ struct SPEEX_decinst_t_;
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ACMSPEEX : public ACMGenericCodec
|
class ACMSPEEX : public ACMGenericCodec {
|
||||||
{
|
public:
|
||||||
public:
|
ACMSPEEX(WebRtc_Word16 codecID);
|
||||||
ACMSPEEX(WebRtc_Word16 codecID);
|
~ACMSPEEX();
|
||||||
~ACMSPEEX();
|
// for FEC
|
||||||
// for FEC
|
ACMGenericCodec* CreateInstance(void);
|
||||||
ACMGenericCodec* CreateInstance(void);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalEncode(
|
WebRtc_Word16 InternalEncode(WebRtc_UWord8* bitstream,
|
||||||
WebRtc_UWord8* bitstream,
|
WebRtc_Word16* bitStreamLenByte);
|
||||||
WebRtc_Word16* bitStreamLenByte);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitEncoder(
|
WebRtc_Word16 InternalInitEncoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
WebRtc_Word16 InternalInitDecoder(
|
WebRtc_Word16 InternalInitDecoder(WebRtcACMCodecParams *codecParams);
|
||||||
WebRtcACMCodecParams *codecParams);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
WebRtc_Word16 DecodeSafe(
|
WebRtc_Word16 DecodeSafe(WebRtc_UWord8* bitStream,
|
||||||
WebRtc_UWord8* bitStream,
|
WebRtc_Word16 bitStreamLenByte,
|
||||||
WebRtc_Word16 bitStreamLenByte,
|
WebRtc_Word16* audio,
|
||||||
WebRtc_Word16* audio,
|
WebRtc_Word16* audioSamples,
|
||||||
WebRtc_Word16* audioSamples,
|
WebRtc_Word8* speechType);
|
||||||
WebRtc_Word8* speechType);
|
|
||||||
|
|
||||||
WebRtc_Word32 CodecDef(
|
WebRtc_Word32 CodecDef(WebRtcNetEQ_CodecDef& codecDef,
|
||||||
WebRtcNetEQ_CodecDef& codecDef,
|
const CodecInst& codecInst);
|
||||||
const CodecInst& codecInst);
|
|
||||||
|
|
||||||
void DestructEncoderSafe();
|
void DestructEncoderSafe();
|
||||||
|
|
||||||
void DestructDecoderSafe();
|
void DestructDecoderSafe();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateEncoder();
|
WebRtc_Word16 InternalCreateEncoder();
|
||||||
|
|
||||||
WebRtc_Word16 InternalCreateDecoder();
|
WebRtc_Word16 InternalCreateDecoder();
|
||||||
|
|
||||||
void InternalDestructEncoderInst(
|
void InternalDestructEncoderInst(void* ptrInst);
|
||||||
void* ptrInst);
|
|
||||||
|
|
||||||
WebRtc_Word16 SetBitRateSafe(
|
WebRtc_Word16 SetBitRateSafe(const WebRtc_Word32 rate);
|
||||||
const WebRtc_Word32 rate);
|
|
||||||
|
|
||||||
WebRtc_Word16 EnableDTX();
|
WebRtc_Word16 EnableDTX();
|
||||||
|
|
||||||
WebRtc_Word16 DisableDTX();
|
WebRtc_Word16 DisableDTX();
|
||||||
|
|
||||||
#ifdef UNUSEDSPEEX
|
#ifdef UNUSEDSPEEX
|
||||||
WebRtc_Word16 EnableVBR();
|
WebRtc_Word16 EnableVBR();
|
||||||
|
|
||||||
WebRtc_Word16 DisableVBR();
|
WebRtc_Word16 DisableVBR();
|
||||||
|
|
||||||
WebRtc_Word16 SetComplMode(
|
WebRtc_Word16 SetComplMode(WebRtc_Word16 mode);
|
||||||
WebRtc_Word16 mode);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SPEEX_encinst_t_* _encoderInstPtr;
|
SPEEX_encinst_t_* _encoderInstPtr;
|
||||||
SPEEX_decinst_t_* _decoderInstPtr;
|
SPEEX_decinst_t_* _decoderInstPtr;
|
||||||
WebRtc_Word16 _complMode;
|
WebRtc_Word16 _complMode;
|
||||||
bool _vbrEnabled;
|
bool _vbrEnabled;
|
||||||
WebRtc_Word32 _encodingRate;
|
WebRtc_Word32 _encodingRate;
|
||||||
WebRtc_Word16 _samplingFrequency;
|
WebRtc_Word16 _samplingFrequency;
|
||||||
WebRtc_UWord16 _samplesIn20MsAudio;
|
WebRtc_UWord16 _samplesIn20MsAudio;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
|
#endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_SOURCE_ACM_SPEEX_H_
|
||||||
|
@ -8,51 +8,38 @@
|
|||||||
* be found in the AUTHORS file in the root of the source tree.
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "acm_dtmf_detection.h"
|
#include "acm_dtmf_detection.h"
|
||||||
#include "audio_coding_module.h"
|
#include "audio_coding_module.h"
|
||||||
#include "audio_coding_module_impl.h"
|
#include "audio_coding_module_impl.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
namespace webrtc
|
namespace webrtc {
|
||||||
{
|
|
||||||
|
|
||||||
// Create module
|
// Create module
|
||||||
AudioCodingModule*
|
AudioCodingModule* AudioCodingModule::Create(const WebRtc_Word32 id) {
|
||||||
AudioCodingModule::Create(
|
return new AudioCodingModuleImpl(id);
|
||||||
const WebRtc_Word32 id)
|
|
||||||
{
|
|
||||||
return new AudioCodingModuleImpl(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destroy module
|
// Destroy module
|
||||||
void
|
void AudioCodingModule::Destroy(AudioCodingModule* module) {
|
||||||
AudioCodingModule::Destroy(
|
delete static_cast<AudioCodingModuleImpl*>(module);
|
||||||
AudioCodingModule* module)
|
|
||||||
{
|
|
||||||
delete static_cast<AudioCodingModuleImpl*> (module);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get number of supported codecs
|
// Get number of supported codecs
|
||||||
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs()
|
WebRtc_UWord8 AudioCodingModule::NumberOfCodecs() {
|
||||||
{
|
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
|
||||||
return static_cast<WebRtc_UWord8>(ACMCodecDB::kNumCodecs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get supported codec param with id
|
// Get supported codec param with id
|
||||||
WebRtc_Word32
|
WebRtc_Word32 AudioCodingModule::Codec(const WebRtc_UWord8 listId,
|
||||||
AudioCodingModule::Codec(
|
CodecInst& codec) {
|
||||||
const WebRtc_UWord8 listId,
|
// Get the codec settings for the codec with the given list ID
|
||||||
CodecInst& codec)
|
return ACMCodecDB::Codec(listId, &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.
|
// Get supported codec Param with name, frequency and number of channels.
|
||||||
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
||||||
CodecInst& codec,
|
CodecInst& codec, int sampling_freq_hz,
|
||||||
int sampling_freq_hz,
|
|
||||||
int channels) {
|
int channels) {
|
||||||
int codec_id;
|
int codec_id;
|
||||||
|
|
||||||
@ -62,10 +49,10 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
|||||||
// We couldn't find a matching codec, set the parameterss to unacceptable
|
// We couldn't find a matching codec, set the parameterss to unacceptable
|
||||||
// values and return.
|
// values and return.
|
||||||
codec.plname[0] = '\0';
|
codec.plname[0] = '\0';
|
||||||
codec.pltype = -1;
|
codec.pltype = -1;
|
||||||
codec.pacsize = 0;
|
codec.pacsize = 0;
|
||||||
codec.rate = 0;
|
codec.rate = 0;
|
||||||
codec.plfreq = 0;
|
codec.plfreq = 0;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,30 +64,23 @@ WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
|||||||
|
|
||||||
// Get supported codec Index with name, frequency and number of channels.
|
// Get supported codec Index with name, frequency and number of channels.
|
||||||
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
WebRtc_Word32 AudioCodingModule::Codec(const char* payload_name,
|
||||||
int sampling_freq_hz,
|
int sampling_freq_hz, int channels) {
|
||||||
int channels) {
|
|
||||||
return ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
|
return ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks the validity of the parameters of the given codec
|
// Checks the validity of the parameters of the given codec
|
||||||
bool
|
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
|
||||||
AudioCodingModule::IsCodecValid(
|
int mirrorID;
|
||||||
const CodecInst& codec)
|
char errMsg[500];
|
||||||
{
|
|
||||||
int mirrorID;
|
|
||||||
char errMsg[500];
|
|
||||||
|
|
||||||
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
|
int codecNumber = ACMCodecDB::CodecNumber(&codec, &mirrorID, errMsg, 500);
|
||||||
|
|
||||||
if(codecNumber < 0)
|
if (codecNumber < 0) {
|
||||||
{
|
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);
|
||||||
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, errMsg);
|
return false;
|
||||||
return false;
|
} else {
|
||||||
}
|
return true;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user