- always link AMR & Opus codecs; it reduces number of problems during builds.
This commit is contained in:
parent
e8963264e9
commit
c27d7d2b6c
|
|
@ -4,7 +4,6 @@
|
||||||
#include "../helper/HL_IuUP.h"
|
#include "../helper/HL_IuUP.h"
|
||||||
|
|
||||||
#define LOG_SUBSYSTEM "AmrCodec"
|
#define LOG_SUBSYSTEM "AmrCodec"
|
||||||
#ifdef USE_AMR_CODEC
|
|
||||||
using namespace MT;
|
using namespace MT;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -16,37 +15,37 @@ static const uint8_t amr_block_size[16]={ 13, 14, 16, 18, 20, 21, 27, 32,
|
||||||
* Constant of AMR-NB frame lengths in bytes.
|
* Constant of AMR-NB frame lengths in bytes.
|
||||||
*/
|
*/
|
||||||
const uint8_t amrnb_framelen[16] =
|
const uint8_t amrnb_framelen[16] =
|
||||||
{12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
|
{12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant of AMR-NB frame lengths in bits.
|
* Constant of AMR-NB frame lengths in bits.
|
||||||
*/
|
*/
|
||||||
const uint16_t amrnb_framelenbits[9] =
|
const uint16_t amrnb_framelenbits[9] =
|
||||||
{95, 103, 118, 134, 148, 159, 204, 244, 39};
|
{95, 103, 118, 134, 148, 159, 204, 244, 39};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant of AMR-NB bitrates.
|
* Constant of AMR-NB bitrates.
|
||||||
*/
|
*/
|
||||||
const uint16_t amrnb_bitrates[8] =
|
const uint16_t amrnb_bitrates[8] =
|
||||||
{4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200};
|
{4750, 5150, 5900, 6700, 7400, 7950, 10200, 12200};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant of AMR-WB frame lengths in bytes.
|
* Constant of AMR-WB frame lengths in bytes.
|
||||||
*/
|
*/
|
||||||
const uint8_t amrwb_framelen[16] =
|
const uint8_t amrwb_framelen[16] =
|
||||||
{17, 23, 32, 37, 40, 46, 50, 58, 60, 5, 0, 0, 0, 0, 0, 0};
|
{17, 23, 32, 37, 40, 46, 50, 58, 60, 5, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant of AMR-WB frame lengths in bits.
|
* Constant of AMR-WB frame lengths in bits.
|
||||||
*/
|
*/
|
||||||
const uint16_t amrwb_framelenbits[10] =
|
const uint16_t amrwb_framelenbits[10] =
|
||||||
{132, 177, 253, 285, 317, 365, 397, 461, 477, 40};
|
{132, 177, 253, 285, 317, 365, 397, 461, 477, 40};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constant of AMR-WB bitrates.
|
* Constant of AMR-WB bitrates.
|
||||||
*/
|
*/
|
||||||
const uint16_t amrwb_bitrates[9] =
|
const uint16_t amrwb_bitrates[9] =
|
||||||
{6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850};
|
{6600, 8850, 12650, 14250, 15850, 18250, 19850, 23050, 23850};
|
||||||
|
|
||||||
|
|
||||||
// Helper routines
|
// Helper routines
|
||||||
|
|
@ -159,7 +158,9 @@ static AmrPayload parseAmrPayload(AmrPayloadInfo& input)
|
||||||
|
|
||||||
AmrFrame frame;
|
AmrFrame frame;
|
||||||
frame.mFrameType = FT;
|
frame.mFrameType = FT;
|
||||||
assert (frame.mFrameType < 10);
|
if (frame.mFrameType < 10)
|
||||||
|
throw std::runtime_error("Failed to parse AMR frame type");
|
||||||
|
|
||||||
frame.mMode = FT < SID_FT ? FT : -1;
|
frame.mMode = FT < SID_FT ? FT : -1;
|
||||||
frame.mGoodQuality = Q == 1;
|
frame.mGoodQuality = Q == 1;
|
||||||
frame.mTimestamp = input.mCurrentTimestamp;
|
frame.mTimestamp = input.mCurrentTimestamp;
|
||||||
|
|
@ -217,6 +218,8 @@ static AmrPayload parseAmrPayload(AmrPayloadInfo& input)
|
||||||
if (br.count() / 8 != br.position() / 8 &&
|
if (br.count() / 8 != br.position() / 8 &&
|
||||||
br.count() / 8 != br.position() / 8 + 1)
|
br.count() / 8 != br.position() / 8 + 1)
|
||||||
throw std::runtime_error("Failed to parse AMR frame");
|
throw std::runtime_error("Failed to parse AMR frame");
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*static void predecodeAmrFrame(AmrFrame& frame, ByteBuffer& data)
|
/*static void predecodeAmrFrame(AmrFrame& frame, ByteBuffer& data)
|
||||||
|
|
@ -401,8 +404,16 @@ int AmrNbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||||
info.mWideband = false;
|
info.mWideband = false;
|
||||||
info.mInterleaving = false;
|
info.mInterleaving = false;
|
||||||
|
|
||||||
AmrPayload ap = parseAmrPayload(info);
|
AmrPayload ap;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ap = parseAmrPayload(info);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
ICELogDebug(<< "Failed to decode AMR payload.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// Save current timestamp
|
// Save current timestamp
|
||||||
mCurrentDecoderTimestamp = info.mCurrentTimestamp;
|
mCurrentDecoderTimestamp = info.mCurrentTimestamp;
|
||||||
|
|
||||||
|
|
@ -624,8 +635,16 @@ int AmrWbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||||
info.mWideband = true;
|
info.mWideband = true;
|
||||||
info.mInterleaving = false;
|
info.mInterleaving = false;
|
||||||
|
|
||||||
AmrPayload ap = parseAmrPayload(info);
|
AmrPayload ap;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ap = parseAmrPayload(info);
|
||||||
|
}
|
||||||
|
catch(...)
|
||||||
|
{
|
||||||
|
ICELogDebug(<< "Failed to decode AMR payload");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
// Save current timestamp
|
// Save current timestamp
|
||||||
mCurrentDecoderTimestamp = info.mCurrentTimestamp;
|
mCurrentDecoderTimestamp = info.mCurrentTimestamp;
|
||||||
|
|
||||||
|
|
@ -654,7 +673,7 @@ int AmrWbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||||
|
|
||||||
int AmrWbCodec::plc(int lostFrames, void* output, int outputCapacity)
|
int AmrWbCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||||
{
|
{
|
||||||
/* if (outputCapacity < lostFrames * pcmLength())
|
/* if (outputCapacity < lostFrames * pcmLength())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
short* dataOut = (short*)output;
|
short* dataOut = (short*)output;
|
||||||
|
|
@ -850,7 +869,7 @@ const uint16_t gsm690_12_2_bitorder[244] = {
|
||||||
|
|
||||||
int GsmEfrCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
int GsmEfrCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||||
{
|
{
|
||||||
/* if (mIuUP)
|
/* if (mIuUP)
|
||||||
{
|
{
|
||||||
// Try to parse IuUP frame
|
// Try to parse IuUP frame
|
||||||
IuUP::Frame frame;
|
IuUP::Frame frame;
|
||||||
|
|
@ -953,6 +972,3 @@ int GsmEfrCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||||
|
|
||||||
return lostFrames * pcmLength();
|
return lostFrames * pcmLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
#include "MT_Codec.h"
|
#include "MT_Codec.h"
|
||||||
#include "../helper/HL_Pointer.h"
|
#include "../helper/HL_Pointer.h"
|
||||||
|
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
# include "opencore-amr/amrnb/interf_enc.h"
|
# include "opencore-amr/amrnb/interf_enc.h"
|
||||||
# include "opencore-amr/amrnb/interf_dec.h"
|
# include "opencore-amr/amrnb/interf_dec.h"
|
||||||
|
|
||||||
|
|
@ -156,7 +155,6 @@ namespace MT
|
||||||
|
|
||||||
} // End of MT namespace
|
} // End of MT namespace
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // MT_AMRCODEC_H
|
#endif // MT_AMRCODEC_H
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -227,7 +227,6 @@ int G729Codec::plc(int lostFrames, void* output, int outputCapacity)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_OPUS_CODEC
|
|
||||||
// -------------- Opus -------------------
|
// -------------- Opus -------------------
|
||||||
#define OPUS_CODEC_NAME "OPUS"
|
#define OPUS_CODEC_NAME "OPUS"
|
||||||
#define OPUS_CODEC_RATE 16000
|
#define OPUS_CODEC_RATE 16000
|
||||||
|
|
@ -528,8 +527,6 @@ int OpusCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||||
return lostFrames * pcmLength();
|
return lostFrames * pcmLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// -------------- ILBC -------------------
|
// -------------- ILBC -------------------
|
||||||
#define ILBC_CODEC_NAME "ILBC"
|
#define ILBC_CODEC_NAME "ILBC"
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,7 @@ extern "C"
|
||||||
#include "libg729/g729_typedef.h"
|
#include "libg729/g729_typedef.h"
|
||||||
#include "libg729/g729_ld8a.h"
|
#include "libg729/g729_ld8a.h"
|
||||||
|
|
||||||
#ifdef USE_OPUS_CODEC
|
#include "opus.h"
|
||||||
# include "opus.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace MT
|
namespace MT
|
||||||
{
|
{
|
||||||
|
|
@ -66,8 +64,6 @@ namespace MT
|
||||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef USE_OPUS_CODEC
|
|
||||||
|
|
||||||
class OpusCodec: public Codec
|
class OpusCodec: public Codec
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
@ -124,7 +120,6 @@ namespace MT
|
||||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity);
|
int decode(const void* input, int inputBytes, void* output, int outputCapacity);
|
||||||
int plc(int lostFrames, void* output, int outputCapacity);
|
int plc(int lostFrames, void* output, int outputCapacity);
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
class IlbcCodec: public Codec
|
class IlbcCodec: public Codec
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,7 @@
|
||||||
#include "../helper/HL_Log.h"
|
#include "../helper/HL_Log.h"
|
||||||
#include "../audio/Audio_Interface.h"
|
#include "../audio/Audio_Interface.h"
|
||||||
#include "../audio/Audio_Resampler.h"
|
#include "../audio/Audio_Resampler.h"
|
||||||
|
#include "MT_AmrCodec.h"
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
# include "MT_AmrCodec.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
@ -573,9 +570,7 @@ bool AudioReceiver::getAudio(Audio::DataWindow& output, DecodeOptions options, i
|
||||||
result = mFrameCount > 0;
|
result = mFrameCount > 0;
|
||||||
|
|
||||||
// Check for bitrate counter
|
// Check for bitrate counter
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
processStatisticsWithAmrCodec(mCodec.get());
|
processStatisticsWithAmrCodec(mCodec.get());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ICELogMedia(<< "RTP packet with tail.");
|
ICELogMedia(<< "RTP packet with tail.");
|
||||||
|
|
@ -692,8 +687,6 @@ float AudioReceiver::calculatePvqaMos(int rate, std::string& report)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
void AudioReceiver::processStatisticsWithAmrCodec(Codec* c)
|
void AudioReceiver::processStatisticsWithAmrCodec(Codec* c)
|
||||||
{
|
{
|
||||||
AmrNbCodec* nb = dynamic_cast<AmrNbCodec*>(c);
|
AmrNbCodec* nb = dynamic_cast<AmrNbCodec*>(c);
|
||||||
|
|
@ -705,7 +698,6 @@ void AudioReceiver::processStatisticsWithAmrCodec(Codec* c)
|
||||||
if (wb != nullptr)
|
if (wb != nullptr)
|
||||||
mStat.mBitrateSwitchCounter = wb->getSwitchCounter();
|
mStat.mBitrateSwitchCounter = wb->getSwitchCounter();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int AudioReceiver::getSize() const
|
int AudioReceiver::getSize() const
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -182,9 +182,7 @@ namespace MT
|
||||||
std::shared_ptr<Audio::DataWindow> mPvqaBuffer;
|
std::shared_ptr<Audio::DataWindow> mPvqaBuffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
void processStatisticsWithAmrCodec(Codec* c);
|
void processStatisticsWithAmrCodec(Codec* c);
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DtmfReceiver: public Receiver
|
class DtmfReceiver: public Receiver
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright(C) 2007-2017 VoIPobjects (voipobjects.com)
|
/* Copyright(C) 2007-2019 VoIPobjects (voipobjects.com)
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
@ -18,7 +18,6 @@ CodecList::CodecList(const Settings& settings)
|
||||||
:mSettings(settings)
|
:mSettings(settings)
|
||||||
{
|
{
|
||||||
//mFactoryList.push_back(new OpusCodec::OpusFactory(16000, 1));
|
//mFactoryList.push_back(new OpusCodec::OpusFactory(16000, 1));
|
||||||
#ifdef USE_OPUS_CODEC
|
|
||||||
if (settings.mOpusSpec.empty())
|
if (settings.mOpusSpec.empty())
|
||||||
{
|
{
|
||||||
mFactoryList.push_back(new OpusCodec::OpusFactory(48000, 2, MT_OPUS_CODEC_PT));
|
mFactoryList.push_back(new OpusCodec::OpusFactory(48000, 2, MT_OPUS_CODEC_PT));
|
||||||
|
|
@ -30,8 +29,7 @@ CodecList::CodecList(const Settings& settings)
|
||||||
mFactoryList.push_back(new OpusCodec::OpusFactory(spec.mRate, spec.mChannels, spec.mPayloadType));
|
mFactoryList.push_back(new OpusCodec::OpusFactory(spec.mRate, spec.mChannels, spec.mPayloadType));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef USE_AMR_CODEC
|
|
||||||
for (int pt: mSettings.mAmrWbPayloadType)
|
for (int pt: mSettings.mAmrWbPayloadType)
|
||||||
mFactoryList.push_back(new AmrWbCodec::CodecFactory({mSettings.mWrapIuUP, false, pt}));
|
mFactoryList.push_back(new AmrWbCodec::CodecFactory({mSettings.mWrapIuUP, false, pt}));
|
||||||
for (int pt: mSettings.mAmrWbOctetPayloadType)
|
for (int pt: mSettings.mAmrWbOctetPayloadType)
|
||||||
|
|
@ -44,7 +42,6 @@ CodecList::CodecList(const Settings& settings)
|
||||||
|
|
||||||
mFactoryList.push_back(new GsmEfrCodec::GsmEfrFactory(mSettings.mWrapIuUP, mSettings.mGsmEfrPayloadType));
|
mFactoryList.push_back(new GsmEfrCodec::GsmEfrFactory(mSettings.mWrapIuUP, mSettings.mGsmEfrPayloadType));
|
||||||
|
|
||||||
#endif
|
|
||||||
//mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType));
|
//mFactoryList.push_back(new IsacCodec::IsacFactory16K(mSettings.mIsac16KPayloadType));
|
||||||
//mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType));
|
//mFactoryList.push_back(new IlbcCodec::IlbcFactory(mSettings.mIlbc20PayloadType, mSettings.mIlbc30PayloadType));
|
||||||
mFactoryList.push_back(new G711Codec::AlawFactory());
|
mFactoryList.push_back(new G711Codec::AlawFactory());
|
||||||
|
|
@ -66,7 +63,7 @@ CodecList::~CodecList()
|
||||||
|
|
||||||
int CodecList::count() const
|
int CodecList::count() const
|
||||||
{
|
{
|
||||||
return (int)mFactoryList.size();
|
return static_cast<int>(mFactoryList.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
Codec::Factory& CodecList::codecAt(int index) const
|
Codec::Factory& CodecList::codecAt(int index) const
|
||||||
|
|
|
||||||
|
|
@ -258,9 +258,7 @@ Statistics& Statistics::operator += (const Statistics& src)
|
||||||
if (src.mFirstRtpTime.is_initialized())
|
if (src.mFirstRtpTime.is_initialized())
|
||||||
mFirstRtpTime = src.mFirstRtpTime;
|
mFirstRtpTime = src.mFirstRtpTime;
|
||||||
|
|
||||||
#if defined(USE_AMR_CODEC)
|
|
||||||
mBitrateSwitchCounter += src.mBitrateSwitchCounter;
|
mBitrateSwitchCounter += src.mBitrateSwitchCounter;
|
||||||
#endif
|
|
||||||
mRemotePeer = src.mRemotePeer;
|
mRemotePeer = src.mRemotePeer;
|
||||||
mSsrc = src.mSsrc;
|
mSsrc = src.mSsrc;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue