- more work on EVS
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright(C) 2007-2015 VoIP objects (voipobjects.com)
|
||||
/* Copyright(C) 2007-2020 VoIP objects (voipobjects.com)
|
||||
* 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
@@ -79,6 +79,9 @@
|
||||
#define MT_GSMEFR_PAYLOADTYPE -1
|
||||
#define MT_GSMEFR_CODECNAME "GERAN-EFR"
|
||||
|
||||
#define MT_EVS_PAYLOADTYPE -1
|
||||
#define MT_EVS_CODECNAME "EVS"
|
||||
|
||||
// OPUS codec defines
|
||||
// #define USE_OPUS_CODEC
|
||||
#define MT_OPUS_CODEC_PT -1
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/* Copyright(C) 2007-2019 VoIPobjects (voipobjects.com)
|
||||
/* Copyright(C) 2007-2020 VoIPobjects (voipobjects.com)
|
||||
* 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
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
#include <algorithm>
|
||||
|
||||
#include "../config.h"
|
||||
#include "MT_CodecList.h"
|
||||
@@ -11,7 +12,7 @@
|
||||
# include "MT_AmrCodec.h"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include "MT_EvsCodec.h"
|
||||
|
||||
using namespace MT;
|
||||
|
||||
@@ -60,6 +61,9 @@ CodecList::CodecList(const Settings& settings)
|
||||
#ifndef TARGET_ANDROID
|
||||
mFactoryList.push_back(new GsmHrCodec::GsmHrFactory(mSettings.mGsmHrPayloadType));
|
||||
#endif
|
||||
|
||||
if (mSettings.mEvsPayloadType != -1)
|
||||
mFactoryList.push_back(new EVSCodec::EVSFactory(EVSCodec::StreamParameters()));
|
||||
}
|
||||
|
||||
CodecList::~CodecList()
|
||||
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
int mGsmFrPayloadLength = 33; // Expected GSM payload length
|
||||
int mGsmHrPayloadType = MT_GSMHR_PAYLOADTYPE;
|
||||
int mGsmEfrPayloadType = MT_GSMEFR_PAYLOADTYPE;
|
||||
int mEvsPayloadType = MT_EVS_PAYLOADTYPE;
|
||||
|
||||
struct OpusSpec
|
||||
{
|
||||
|
||||
@@ -1,6 +1,122 @@
|
||||
#include "MT_EvsCodec.h"
|
||||
|
||||
//bool
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* rate2AMRWB_IOmode()
|
||||
*
|
||||
* lookup AMRWB IO mode
|
||||
*-------------------------------------------------------------------*/
|
||||
|
||||
static Word16 rate2AMRWB_IOmode(
|
||||
Word32 rate /* i: bit rate */
|
||||
);
|
||||
|
||||
/*Revers Function*/
|
||||
extern Word16 AMRWB_IOmode2rate(
|
||||
Word32 mode
|
||||
);
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* rate2EVSmode()
|
||||
*
|
||||
* lookup EVS mode
|
||||
*-------------------------------------------------------------------*/
|
||||
extern Word16 rate2EVSmode(
|
||||
Word32 rate /* i: bit rate */
|
||||
);
|
||||
|
||||
/*Revers Function*/
|
||||
extern Word16 EVSmode2rate(
|
||||
Word32 mode
|
||||
);
|
||||
|
||||
#define CMR_OFF -1
|
||||
#define CMR_ON 0
|
||||
#define CMR_ONLY 1
|
||||
|
||||
|
||||
static const std::map<int, std::set<int>> BitrateToBandwidth_Tab{
|
||||
{5900, {NB, WB}},
|
||||
{7200, {NB, WB}},
|
||||
{8000, {NB, WB}},
|
||||
{9600, {NB, WB, SWB}},
|
||||
{13200, {NB, WB, SWB}}, //if channel aware mode - WB, SWB
|
||||
{16400, {NB, WB, SWB, FB}},
|
||||
{24400, {NB, WB, SWB, FB}},
|
||||
{32000, {WB, SWB, FB}},
|
||||
{48000, {WB, SWB, FB}},
|
||||
{64000, {WB, SWB, FB}},
|
||||
{96000, {WB, SWB, FB}},
|
||||
{128000, {WB, SWB, FB}}
|
||||
};
|
||||
|
||||
/* Protected payload size/Fixed bitrate to EVS ()*/
|
||||
static const std::map<int, int> Bitrate2PayloadSize_EVSAMR_WB{
|
||||
/*{bitrate, payload size}*/
|
||||
{ SID_1k75, 56}, //AMR-WB I/O SIB
|
||||
{ACELP_6k60, 136},
|
||||
{ACELP_8k85, 184},
|
||||
{ACELP_12k65, 256},
|
||||
{ACELP_14k25, 288},
|
||||
{ACELP_15k85, 320},
|
||||
{ACELP_18k25, 368},
|
||||
{ACELP_19k85, 400},
|
||||
{ACELP_23k05, 464},
|
||||
{ACELP_23k85, 480}
|
||||
};
|
||||
|
||||
static const std::map<int, int> Bitrate2PayloadSize_EVS{
|
||||
/*{bitrate, payload size}*/
|
||||
{FRAME__NO_DATA, 0},
|
||||
{SID_2k40, 48}, //EVS Primary SID
|
||||
{PPP_NELP_2k80, 56}, //special for full header
|
||||
{ACELP_7k20, 144},
|
||||
{ACELP_8k00, 160},
|
||||
{ACELP_9k60, 192},
|
||||
{ACELP_13k20, 264},
|
||||
{ACELP_16k40, 328},
|
||||
{ACELP_24k40, 488},
|
||||
{ACELP_32k, 640},
|
||||
{ACELP_48k, 960},
|
||||
{ACELP_64k, 1280},
|
||||
{HQ_96k, 1920},
|
||||
{HQ_128k, 2560}
|
||||
};
|
||||
|
||||
/* Protected payload size/Fixed bitrate to EVS ()*/
|
||||
static const std::map<int, int> FixedPayload_EVSPrimary{
|
||||
/*{payload size , bitrate}*/
|
||||
{48, 2400}, //EVS Primary SID
|
||||
{56, 2800}, //special for full header
|
||||
{144, 7200},
|
||||
{160, 8000},
|
||||
{192, 9600},
|
||||
{264, 13200},
|
||||
{328, 16400},
|
||||
{488, 24400},
|
||||
{640, 32000},
|
||||
{960, 48000},
|
||||
{1280, 64000},
|
||||
{1920, 96000},
|
||||
{2560, 128000}
|
||||
};
|
||||
|
||||
static const std::map<int, int> FixedPayload_EVSAMR_WB{
|
||||
/*{payload size , bitrate}*/
|
||||
{136, 6600},
|
||||
{184, 8850},
|
||||
{256, 12650},
|
||||
{288, 14250},
|
||||
{320, 15850},
|
||||
{368, 18250},
|
||||
{400, 19850},
|
||||
{464, 23050},
|
||||
{480, 23850}
|
||||
};
|
||||
|
||||
namespace MT
|
||||
{
|
||||
|
||||
EVSCodec::EVSFactory::EVSFactory(StreamParameters sp) : _sp(sp)
|
||||
{}
|
||||
@@ -204,3 +320,5 @@ void EVSCodec::initDecoder(const StreamParameters& sp)
|
||||
srand(static_cast<unsigned int>(time(nullptr)));
|
||||
|
||||
}
|
||||
|
||||
} // end of namespace MT
|
||||
|
||||
@@ -10,172 +10,27 @@
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
|
||||
extern "C" {
|
||||
//#include "lib_dec/EvsRXlib.h"
|
||||
#include "libevs/lib_com/prot.h"
|
||||
}
|
||||
#include "config.h"
|
||||
#include "MT_Codec.h"
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* rate2AMRWB_IOmode()
|
||||
*
|
||||
* lookup AMRWB IO mode
|
||||
*-------------------------------------------------------------------*/
|
||||
#include "libevs/lib_com/prot.h"
|
||||
|
||||
static Word16 rate2AMRWB_IOmode(
|
||||
Word32 rate /* i: bit rate */
|
||||
);
|
||||
namespace MT {
|
||||
|
||||
/*Revers Function*/
|
||||
extern Word16 AMRWB_IOmode2rate(
|
||||
Word32 mode
|
||||
);
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* rate2EVSmode()
|
||||
*
|
||||
* lookup EVS mode
|
||||
*-------------------------------------------------------------------*/
|
||||
extern Word16 rate2EVSmode(
|
||||
Word32 rate /* i: bit rate */
|
||||
);
|
||||
|
||||
/*Revers Function*/
|
||||
extern Word16 EVSmode2rate(
|
||||
Word32 mode
|
||||
);
|
||||
|
||||
class Codec;
|
||||
typedef std::shared_ptr<Codec> PCodec;
|
||||
|
||||
#define CMR_OFF -1
|
||||
#define CMR_ON 0
|
||||
#define CMR_ONLY 1
|
||||
|
||||
|
||||
static const std::map<int, std::set<int>> BitrateToBandwidth_Tab{
|
||||
{5900, {NB, WB}},
|
||||
{7200, {NB, WB}},
|
||||
{8000, {NB, WB}},
|
||||
{9600, {NB, WB, SWB}},
|
||||
{13200, {NB, WB, SWB}}, //if channel aware mode - WB, SWB
|
||||
{16400, {NB, WB, SWB, FB}},
|
||||
{24400, {NB, WB, SWB, FB}},
|
||||
{32000, {WB, SWB, FB}},
|
||||
{48000, {WB, SWB, FB}},
|
||||
{64000, {WB, SWB, FB}},
|
||||
{96000, {WB, SWB, FB}},
|
||||
{128000, {WB, SWB, FB}}
|
||||
};
|
||||
|
||||
/* Protected payload size/Fixed bitrate to EVS ()*/
|
||||
static const std::map<int, int> Bitrate2PayloadSize_EVSAMR_WB{
|
||||
/*{bitrate, payload size}*/
|
||||
{ SID_1k75, 56}, //AMR-WB I/O SIB
|
||||
{ACELP_6k60, 136},
|
||||
{ACELP_8k85, 184},
|
||||
{ACELP_12k65, 256},
|
||||
{ACELP_14k25, 288},
|
||||
{ACELP_15k85, 320},
|
||||
{ACELP_18k25, 368},
|
||||
{ACELP_19k85, 400},
|
||||
{ACELP_23k05, 464},
|
||||
{ACELP_23k85, 480}
|
||||
};
|
||||
|
||||
static const std::map<int, int> Bitrate2PayloadSize_EVS{
|
||||
/*{bitrate, payload size}*/
|
||||
{FRAME__NO_DATA, 0},
|
||||
{SID_2k40, 48}, //EVS Primary SID
|
||||
{PPP_NELP_2k80, 56}, //special for full header
|
||||
{ACELP_7k20, 144},
|
||||
{ACELP_8k00, 160},
|
||||
{ACELP_9k60, 192},
|
||||
{ACELP_13k20, 264},
|
||||
{ACELP_16k40, 328},
|
||||
{ACELP_24k40, 488},
|
||||
{ACELP_32k, 640},
|
||||
{ACELP_48k, 960},
|
||||
{ACELP_64k, 1280},
|
||||
{HQ_96k, 1920},
|
||||
{HQ_128k, 2560}
|
||||
};
|
||||
|
||||
/* Protected payload size/Fixed bitrate to EVS ()*/
|
||||
static const std::map<int, int> FixedPayload_EVSPrimary{
|
||||
/*{payload size , bitrate}*/
|
||||
{48, 2400}, //EVS Primary SID
|
||||
{56, 2800}, //special for full header
|
||||
{144, 7200},
|
||||
{160, 8000},
|
||||
{192, 9600},
|
||||
{264, 13200},
|
||||
{328, 16400},
|
||||
{488, 24400},
|
||||
{640, 32000},
|
||||
{960, 48000},
|
||||
{1280, 64000},
|
||||
{1920, 96000},
|
||||
{2560, 128000}
|
||||
};
|
||||
|
||||
static const std::map<int, int> FixedPayload_EVSAMR_WB{
|
||||
/*{payload size , bitrate}*/
|
||||
{136, 6600},
|
||||
{184, 8850},
|
||||
{256, 12650},
|
||||
{288, 14250},
|
||||
{320, 15850},
|
||||
{368, 18250},
|
||||
{400, 19850},
|
||||
{464, 23050},
|
||||
{480, 23850}
|
||||
};
|
||||
|
||||
struct StreamParameters {
|
||||
bool mime = false;
|
||||
bool fh_only = false; /*not use*/
|
||||
int CRMByte = CMR_OFF;/*not use*/
|
||||
int br = 0; /*not use*/
|
||||
int bw = NB;
|
||||
int ptime = 20;
|
||||
}; //Emulated SDP config/meadia type parameters
|
||||
|
||||
class Codec
|
||||
{
|
||||
public:
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
virtual ~Factory() {}
|
||||
virtual const char* name() = 0;
|
||||
virtual int samplerate() = 0;
|
||||
virtual int payloadType() = 0;
|
||||
virtual PCodec create() = 0;
|
||||
|
||||
virtual int channels() = 0;
|
||||
};
|
||||
virtual ~Codec() {}
|
||||
virtual const char* name() = 0;
|
||||
virtual int samplerate() = 0;
|
||||
virtual float timestampUnit() { return float(1.0 / samplerate()); }
|
||||
virtual int pcmLength() = 0;
|
||||
virtual int frameTime() = 0;
|
||||
virtual int rtpLength() = 0;
|
||||
virtual int channels() { return 1; }
|
||||
virtual int encode(const void* input, int inputBytes, void* output, int outputCapacity) = 0;
|
||||
virtual int decode(const void* input, int inputBytes, void* output, int outputCapacity) = 0;
|
||||
virtual int plc(int lostFrames, void* output, int outputCapacity) = 0;
|
||||
|
||||
// Returns size of codec in memory
|
||||
virtual int getSize() const { return 0; };
|
||||
};
|
||||
|
||||
class EVSCodec : public Codec
|
||||
{
|
||||
private:
|
||||
Decoder_State* st_dec;
|
||||
//Encoder_State_fx* st_enc;
|
||||
StreamParameters sp;
|
||||
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;
|
||||
};
|
||||
|
||||
public:
|
||||
class EVSFactory : public Factory
|
||||
@@ -185,7 +40,7 @@ public:
|
||||
|
||||
public:
|
||||
EVSFactory(StreamParameters sp);
|
||||
const char* name() { return "EVS"; };
|
||||
const char* name() { return MT_EVS_CODECNAME; };
|
||||
int samplerate();
|
||||
int payloadType();
|
||||
PCodec create();
|
||||
@@ -196,7 +51,7 @@ public:
|
||||
EVSCodec(const StreamParameters& sp);
|
||||
~EVSCodec() override;
|
||||
|
||||
const char* name() { return "EVS"; };
|
||||
const char* name() { return MT_EVS_CODECNAME; };
|
||||
int samplerate();
|
||||
int samplerate(int CodecMode); // DEC or ENC defined in cnst.h
|
||||
int pcmLength();
|
||||
@@ -206,5 +61,12 @@ public:
|
||||
int encode(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) ;
|
||||
|
||||
private:
|
||||
Decoder_State* st_dec;
|
||||
//Encoder_State_fx* st_enc;
|
||||
StreamParameters sp;
|
||||
void initDecoder(const StreamParameters& sp);
|
||||
};
|
||||
|
||||
} // End of namespace
|
||||
|
||||
Reference in New Issue
Block a user