- more changes for EVS decoder
This commit is contained in:
parent
345853f941
commit
cb037b5ae0
|
|
@ -167,13 +167,13 @@ set (LIBS ice_stack jrtplib g729_codec gsm_codec
|
|||
uuid)
|
||||
|
||||
if (CMAKE_SYSTEM MATCHES "Win*")
|
||||
set (LIBS ${LIBS} opus )
|
||||
set (LIBS ${LIBS} )
|
||||
else ()
|
||||
set (LIBS ${LIBS} dl opus uuid)
|
||||
set (LIBS ${LIBS} dl uuid)
|
||||
endif ()
|
||||
|
||||
if (USE_AMR_CODEC)
|
||||
set (LIBS ${LIBS} opencore-amrnb opencore-amrwb)
|
||||
set (LIBS ${LIBS})
|
||||
endif (USE_AMR_CODEC)
|
||||
|
||||
if (USE_EVS_CODEC)
|
||||
|
|
@ -187,7 +187,7 @@ target_link_libraries(rtphone
|
|||
audio_lib
|
||||
webrtc
|
||||
speexdsp
|
||||
opus
|
||||
# opus
|
||||
uuid
|
||||
${OPENSSL_SSL}
|
||||
${OPENSSL_CRYPTO}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,11 @@ void FileHelper::remove(const char* s)
|
|||
|
||||
std::string FileHelper::gettempname()
|
||||
{
|
||||
#if defined(TARGET_LINUX) || defined(TARGET_WIN)
|
||||
#if defined(TARGET_LINUX)
|
||||
char template_filename[L_tmpnam] = "rtphone_XXXXXXX.tmp";
|
||||
mkstemp(template_filename);
|
||||
return template_filename;
|
||||
#elif defined(TARGET_WIN)
|
||||
char buffer[L_tmpnam];
|
||||
tmpnam(buffer);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ int iosVersion();
|
|||
#include <sys/select.h>
|
||||
#include <termios.h>
|
||||
#if defined(TARGET_LINUX)
|
||||
// # include <stropts.h>
|
||||
//# include <stropts.h>
|
||||
#endif
|
||||
|
||||
extern int _kbhit();
|
||||
|
|
|
|||
|
|
@ -13,9 +13,74 @@
|
|||
#endif
|
||||
|
||||
#include "MT_EvsCodec.h"
|
||||
#include "helper/HL_String.h"
|
||||
|
||||
using namespace MT;
|
||||
|
||||
using strx = StringHelper;
|
||||
|
||||
// ---------------- EvsSpec ---------------
|
||||
bool CodecList::Settings::EvsSpec::isValid() const
|
||||
{
|
||||
return mPayloadType >= 96 && mPayloadType <= 127;
|
||||
}
|
||||
|
||||
CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::string& spec)
|
||||
{
|
||||
EvsSpec result;
|
||||
|
||||
auto parts = strx::split(spec, "-/");
|
||||
if (parts.size() == 3)
|
||||
{
|
||||
result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1);
|
||||
std::string& encoding_type = parts[1];
|
||||
if (encoding_type == "mime")
|
||||
result.mEncodingType = Encoding_MIME;
|
||||
else
|
||||
if (encoding_type == "g192")
|
||||
result.mEncodingType = Encoding_G192;
|
||||
else
|
||||
throw std::logic_error("Bad EVS codec encoding type");
|
||||
|
||||
std::string& bandwidth = parts.back();
|
||||
if (bandwidth == "nb" || bandwidth == "NB")
|
||||
result.mBandwidth = Bandwidth_NB;
|
||||
else
|
||||
if (bandwidth == "wb" || bandwidth == "WB")
|
||||
result.mBandwidth = Bandwidth_WB;
|
||||
else
|
||||
if (bandwidth == "swb" || bandwidth == "SWB")
|
||||
result.mBandwidth = Bandwidth_SWB;
|
||||
else
|
||||
if (bandwidth == "fb" || bandwidth == "FB")
|
||||
result.mBandwidth = Bandwidth_FB;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CodecList::Settings::OpusSpec::isValid() const
|
||||
{
|
||||
return (mPayloadType >= 96 && mPayloadType <= 127 &&
|
||||
mRate > 0 &&
|
||||
mChannels > 0);
|
||||
}
|
||||
|
||||
CodecList::Settings::OpusSpec CodecList::Settings::OpusSpec::parse(const std::string &spec)
|
||||
{
|
||||
OpusSpec result;
|
||||
|
||||
auto parts = strx::split(spec, "-");
|
||||
if (parts.size() == 3)
|
||||
{
|
||||
result.mPayloadType = strx::toInt(strx::trim(parts.front()).c_str(), -1);
|
||||
result.mRate = strx::toInt(strx::trim(parts[1]).c_str(), -1);
|
||||
result.mChannels = strx::toInt(strx::trim(parts.back()).c_str(), -1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
CodecList::Settings CodecList::Settings::DefaultSettings;
|
||||
|
||||
CodecList::CodecList(const Settings& settings)
|
||||
|
|
@ -62,6 +127,19 @@ CodecList::CodecList(const Settings& settings)
|
|||
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
|
||||
#endif
|
||||
|
||||
#if !defined(TARGET_ANDROID)
|
||||
for (auto& spec: settings.mEvsSpec)
|
||||
{
|
||||
EVSCodec::StreamParameters evs_params;
|
||||
evs_params.mime = spec.mEncodingType == Settings::EvsSpec::Encoding_MIME;
|
||||
evs_params.bw = (int)spec.mBandwidth;
|
||||
evs_params.ptime = 20;
|
||||
evs_params.ptype = spec.mPayloadType;
|
||||
|
||||
mFactoryList.push_back(new EVSCodec::EVSFactory(evs_params));
|
||||
}
|
||||
#endif
|
||||
|
||||
EVSCodec::StreamParameters evs_params;
|
||||
evs_params.mime = true;
|
||||
evs_params.bw = WB;
|
||||
|
|
|
|||
|
|
@ -44,13 +44,41 @@ public:
|
|||
int mGsmFrPayloadLength = 33; // Expected GSM payload length
|
||||
int mGsmHrPayloadType = MT_GSMHR_PAYLOADTYPE;
|
||||
int mGsmEfrPayloadType = MT_GSMEFR_PAYLOADTYPE;
|
||||
int mEvsPayloadType = MT_EVS_PAYLOADTYPE;
|
||||
|
||||
struct EvsSpec
|
||||
{
|
||||
int mPayloadType = 0;
|
||||
enum Bandwidth
|
||||
{
|
||||
Bandwidth_NB = 0,
|
||||
Bandwidth_WB,
|
||||
Bandwidth_SWB,
|
||||
Bandwidth_FB
|
||||
};
|
||||
|
||||
Bandwidth mBandwidth = Bandwidth_NB;
|
||||
|
||||
enum Encoding
|
||||
{
|
||||
Encoding_MIME,
|
||||
Encoding_G192
|
||||
};
|
||||
|
||||
Encoding mEncodingType = Encoding_MIME;
|
||||
bool isValid() const;
|
||||
static EvsSpec parse(const std::string& spec);
|
||||
};
|
||||
|
||||
std::vector<EvsSpec> mEvsSpec;
|
||||
|
||||
struct OpusSpec
|
||||
{
|
||||
int mPayloadType = 0;
|
||||
int mRate = 0;
|
||||
int mChannels = 0;
|
||||
int mPayloadType = -1;
|
||||
int mRate = -1;
|
||||
int mChannels = -1;
|
||||
|
||||
bool isValid() const;
|
||||
static OpusSpec parse(const std::string& spec);
|
||||
};
|
||||
std::vector<OpusSpec> mOpusSpec;
|
||||
|
||||
|
|
|
|||
|
|
@ -119,17 +119,25 @@ static const std::map<int, int> FixedPayload_EVSAMR_WB{
|
|||
namespace MT
|
||||
{
|
||||
|
||||
EVSCodec::EVSFactory::EVSFactory(StreamParameters sp) : _sp(sp)
|
||||
EVSCodec::EVSFactory::EVSFactory(StreamParameters& sp) : _sp(sp)
|
||||
{}
|
||||
|
||||
int EVSCodec::EVSFactory::samplerate()
|
||||
{
|
||||
switch (_sp.bw)
|
||||
{
|
||||
case 0: return 8000;
|
||||
case 1: return 16000;
|
||||
case 2: return 32000;
|
||||
case 3: return 48000;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EVSCodec::EVSFactory::payloadType()
|
||||
{
|
||||
return MT_EVS_PAYLOADTYPE;
|
||||
return _sp.ptype;
|
||||
}
|
||||
|
||||
PCodec EVSCodec::EVSFactory::create()
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@ public:
|
|||
// Emulated SDP config/media type parameters
|
||||
struct StreamParameters
|
||||
{
|
||||
bool mime = false;
|
||||
bool fh_only = false; /*not use*/
|
||||
int CRMByte = -1/*CMR_OFF*/; /*not use*/
|
||||
int br = 0; /*not use*/
|
||||
int bw = NB;
|
||||
int ptime = 20;
|
||||
bool mime = false; /* encoding */
|
||||
bool fh_only = false; /* not use*/
|
||||
int CRMByte = -1/*CMR_OFF*/; /* not use*/
|
||||
int br = 0; /* not use*/
|
||||
int bw = NB; /* bandwidth */
|
||||
int ptime = 20; /* ptime */
|
||||
int ptype = -1; /* payload type */
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -39,7 +40,7 @@ public:
|
|||
StreamParameters _sp;
|
||||
|
||||
public:
|
||||
EVSFactory(StreamParameters sp);
|
||||
EVSFactory(StreamParameters& sp);
|
||||
const char* name() { return MT_EVS_CODECNAME; };
|
||||
int samplerate();
|
||||
int payloadType();
|
||||
|
|
|
|||
Loading…
Reference in New Issue