- fix clang build (build_linux.py) + fix problems reported by Kimi LLM
This commit is contained in:
@@ -19,7 +19,8 @@ def make_build() -> Path:
|
||||
os.mkdir(DIR_BUILD)
|
||||
os.chdir(DIR_BUILD)
|
||||
|
||||
cmd = f'cmake ../src -G Ninja'
|
||||
# OPUS_X86_MAY_HAVE_SSE4_1 is for clang builds
|
||||
cmd = f'cmake ../src -G Ninja -D OPUS_X86_MAY_HAVE_SSE4_1=ON'
|
||||
retcode = os.system(cmd)
|
||||
if retcode != 0:
|
||||
raise RuntimeError('Problem when configuring the project')
|
||||
|
||||
@@ -687,7 +687,7 @@ void AgentImpl::processUseStreamForSession(JsonCpp::Value& request, JsonCpp::Val
|
||||
answer["status"] = Status_Ok;
|
||||
}
|
||||
else
|
||||
answer["status"] = Status_AccountNotFound;
|
||||
answer["status"] = Status_NoCommand;
|
||||
}
|
||||
else
|
||||
answer["status"] = Status_NoMediaAction;
|
||||
@@ -709,11 +709,13 @@ void AgentImpl::onMedia(const void* data, int length, MT::Stream::MediaDirection
|
||||
|
||||
PDataProvider AgentImpl::onProviderNeeded(const std::string& name)
|
||||
{
|
||||
assert(mTerminal);
|
||||
|
||||
EVENT_WITH_NAME("provider_needed");
|
||||
v["provider_name"] = name;
|
||||
addEvent(v);
|
||||
|
||||
return PDataProvider(new AudioProvider(*this, *mTerminal));
|
||||
return std::make_shared<AudioProvider>(*this, *mTerminal);
|
||||
}
|
||||
|
||||
// Called on new session offer
|
||||
|
||||
@@ -883,7 +883,7 @@ void Session::refreshMediaPath()
|
||||
|
||||
// Bring new socket to provider and stream
|
||||
RtpPair<PDatagramSocket> s4 = SocketHeap::instance().allocSocketPair(AF_INET, this, IS_MULTIPLEX() ),
|
||||
s6 = SocketHeap::instance().allocSocketPair(AF_INET, this, IS_MULTIPLEX());
|
||||
s6 = SocketHeap::instance().allocSocketPair(AF_INET6, this, IS_MULTIPLEX());
|
||||
|
||||
p->setSocket(s4, s6);
|
||||
s.setSocket4(s4);
|
||||
|
||||
@@ -36,6 +36,9 @@ uint16_t update_crc10_by_bytes(uint16_t crc10, const uint8_t *data_blk_ptr, int
|
||||
|
||||
bool IuUP::parse2(const uint8_t* packet, int size, Frame& result)
|
||||
{
|
||||
if (size < 2)
|
||||
return false;
|
||||
|
||||
if (TwoBytePseudoheader)
|
||||
{
|
||||
packet += 2;
|
||||
|
||||
@@ -65,6 +65,7 @@ void thread_pool::run_worker()
|
||||
tasks.pop();
|
||||
}
|
||||
}
|
||||
if (t)
|
||||
t(); // function<void()> type
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ int64_t Variant::asInt64() const
|
||||
if (mType != VTYPE_INT64)
|
||||
throw Exception(ERR_BAD_VARIANT_TYPE);
|
||||
|
||||
return mInt;
|
||||
return mInt64;
|
||||
}
|
||||
|
||||
bool Variant::asBool() const
|
||||
|
||||
@@ -3,11 +3,8 @@
|
||||
|
||||
#include "MT_AmrCodec.h"
|
||||
#include "../helper/HL_ByteBuffer.h"
|
||||
#include "../helper/HL_Log.h"
|
||||
#include "../helper/HL_IuUP.h"
|
||||
#include "../helper/HL_Exception.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "../helper/HL_Log.h"
|
||||
|
||||
#define LOG_SUBSYSTEM "AmrCodec"
|
||||
using namespace MT;
|
||||
@@ -287,44 +284,31 @@ AmrNbCodec::~AmrNbCodec()
|
||||
}
|
||||
}
|
||||
|
||||
const char* AmrNbCodec::name()
|
||||
Codec::Info AmrNbCodec::info()
|
||||
{
|
||||
return MT_AMRNB_CODECNAME;
|
||||
return {
|
||||
.mName = MT_AMRNB_CODECNAME,
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 20 * 16,
|
||||
.mFrameTime = 20,
|
||||
.mRtpLength = 0
|
||||
};
|
||||
}
|
||||
|
||||
int AmrNbCodec::pcmLength()
|
||||
Codec::EncodeResult AmrNbCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 20 * 16;
|
||||
}
|
||||
|
||||
int AmrNbCodec::rtpLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AmrNbCodec::frameTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
int AmrNbCodec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int AmrNbCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
if (inputBytes % pcmLength())
|
||||
return 0;
|
||||
if (input.size_bytes() % pcmLength())
|
||||
return {.mEncoded = 0};
|
||||
|
||||
// Declare the data input pointer
|
||||
auto *dataIn = (const short *)input;
|
||||
auto *dataIn = (const short *)input.data();
|
||||
|
||||
// Declare the data output pointer
|
||||
auto *dataOut = (unsigned char *)output;
|
||||
auto *dataOut = (unsigned char *)output.data();
|
||||
|
||||
// Find how much RTP frames will be generated
|
||||
unsigned int frames = inputBytes / pcmLength();
|
||||
unsigned int frames = input.size_bytes() / pcmLength();
|
||||
|
||||
// Generate frames
|
||||
for (unsigned int i = 0; i < frames; i++)
|
||||
@@ -333,28 +317,28 @@ int AmrNbCodec::encode(const void* input, int inputBytes, void* output, int outp
|
||||
dataIn += pcmLength() / 2;
|
||||
}
|
||||
|
||||
return dataOut - (unsigned char*)output;
|
||||
return {.mEncoded = (size_t)(dataOut - (unsigned char*)output.data())};
|
||||
}
|
||||
|
||||
#define L_FRAME 160
|
||||
#define AMR_BITRATE_DTX 15
|
||||
int AmrNbCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult AmrNbCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
if (mConfig.mOctetAligned)
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
|
||||
if (mConfig.mIuUP)
|
||||
{
|
||||
// Try to parse IuUP frame
|
||||
IuUP::Frame frame;
|
||||
if (!IuUP::parse2((const uint8_t*)input, inputBytes, frame))
|
||||
return 0;
|
||||
if (!IuUP::parse2((const uint8_t*)input.data(), input.size_bytes(), frame))
|
||||
return {0};
|
||||
|
||||
// Check if CRC failed - it is check from IuUP data
|
||||
if (!frame.mHeaderCrcOk || !frame.mPayloadCrcOk)
|
||||
{
|
||||
ICELogInfo(<< "CRC check failed.");
|
||||
return 0;
|
||||
return {0};
|
||||
}
|
||||
|
||||
// Build NB frame to decode
|
||||
@@ -371,31 +355,31 @@ int AmrNbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||
|
||||
// Check if frameType comparing is correct
|
||||
if (frameType == 0xFF)
|
||||
return 0;
|
||||
return {0};
|
||||
|
||||
dataToDecode.mutableData()[0] = (frameType << 3) | (1 << 2);
|
||||
|
||||
Decoder_Interface_Decode(mDecoderCtx, (const unsigned char*)dataToDecode.data(), (short*)output, 0);
|
||||
return pcmLength();
|
||||
Decoder_Interface_Decode(mDecoderCtx, (const unsigned char*)dataToDecode.data(), (short*)output.data(), 0);
|
||||
return {.mDecoded = (size_t)pcmLength()};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (outputCapacity < pcmLength())
|
||||
return 0;
|
||||
if (output.size_bytes() < pcmLength())
|
||||
return {.mDecoded = 0};
|
||||
|
||||
if (inputBytes == 0)
|
||||
if (input.size_bytes() == 0)
|
||||
{ // PLC part
|
||||
unsigned char buffer[32];
|
||||
buffer[0] = (AMR_BITRATE_DTX << 3)|4;
|
||||
Decoder_Interface_Decode(mDecoderCtx, buffer, (short*)output, 0); // Handle missing data
|
||||
return pcmLength();
|
||||
Decoder_Interface_Decode(mDecoderCtx, buffer, (short*)output.data(), 0); // Handle missing data
|
||||
return {.mDecoded = (size_t)pcmLength()};
|
||||
}
|
||||
|
||||
AmrPayloadInfo info;
|
||||
info.mCurrentTimestamp = mCurrentDecoderTimestamp;
|
||||
info.mOctetAligned = mConfig.mOctetAligned;
|
||||
info.mPayload = (const uint8_t*)input;
|
||||
info.mPayloadLength = inputBytes;
|
||||
info.mPayload = input.data();
|
||||
info.mPayloadLength = input.size_bytes();
|
||||
info.mWideband = false;
|
||||
info.mInterleaving = false;
|
||||
|
||||
@@ -407,25 +391,25 @@ int AmrNbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||
catch(...)
|
||||
{
|
||||
ICELogDebug(<< "Failed to decode AMR payload.");
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
}
|
||||
// Save current timestamp
|
||||
mCurrentDecoderTimestamp = info.mCurrentTimestamp;
|
||||
|
||||
// Check if packet is corrupted
|
||||
if (ap.mDiscardPacket)
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
|
||||
|
||||
// Check for output buffer capacity
|
||||
if (outputCapacity < (int)ap.mFrames.size() * pcmLength())
|
||||
return 0;
|
||||
if (output.size_bytes() < (int)ap.mFrames.size() * pcmLength())
|
||||
return {.mDecoded = 0};
|
||||
|
||||
if (ap.mFrames.empty())
|
||||
{
|
||||
ICELogError(<< "No AMR frames");
|
||||
}
|
||||
short* dataOut = (short*)output;
|
||||
short* dataOut = (short*)output.data();
|
||||
for (AmrFrame& frame: ap.mFrames)
|
||||
{
|
||||
if (frame.mData)
|
||||
@@ -435,18 +419,18 @@ int AmrNbCodec::decode(const void* input, int inputBytes, void* output, int outp
|
||||
dataOut += pcmLength() / 2;
|
||||
}
|
||||
}
|
||||
return pcmLength() * ap.mFrames.size();
|
||||
return {.mDecoded = pcmLength() * ap.mFrames.size()};
|
||||
}
|
||||
|
||||
return pcmLength();
|
||||
return {.mDecoded = (size_t)pcmLength()};
|
||||
}
|
||||
|
||||
int AmrNbCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t AmrNbCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
if (outputCapacity < lostFrames * pcmLength())
|
||||
if (output.size_bytes() < lostFrames * pcmLength())
|
||||
return 0;
|
||||
|
||||
short* dataOut = (short*)output;
|
||||
short* dataOut = (short*)output.data();
|
||||
|
||||
for (int i=0; i < lostFrames; i++)
|
||||
{
|
||||
@@ -510,11 +494,9 @@ PCodec AmrWbCodec::CodecFactory::create()
|
||||
AmrWbStatistics MT::GAmrWbStatistics;
|
||||
|
||||
AmrWbCodec::AmrWbCodec(const AmrCodecConfig& config)
|
||||
:mEncoderCtx(nullptr), mDecoderCtx(nullptr), mConfig(config),
|
||||
mSwitchCounter(0), mPreviousPacketLength(0)
|
||||
:mConfig(config)
|
||||
{
|
||||
mDecoderCtx = D_IF_init();
|
||||
mCurrentDecoderTimestamp = 0;
|
||||
}
|
||||
|
||||
AmrWbCodec::~AmrWbCodec()
|
||||
@@ -532,34 +514,22 @@ AmrWbCodec::~AmrWbCodec()
|
||||
}
|
||||
}
|
||||
|
||||
const char* AmrWbCodec::name()
|
||||
{
|
||||
return MT_AMRWB_CODECNAME;
|
||||
Codec::Info AmrWbCodec::info() {
|
||||
return {
|
||||
.mName = MT_AMRWB_CODECNAME,
|
||||
.mSamplerate = 16000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 20 * 16 * 2,
|
||||
.mFrameTime = 20,
|
||||
.mRtpLength = 0 /* There is complex structure inside AMR packet which may include multilple frames with various length. */
|
||||
};
|
||||
}
|
||||
|
||||
int AmrWbCodec::pcmLength()
|
||||
{
|
||||
return 20 * 16 * 2;
|
||||
}
|
||||
|
||||
int AmrWbCodec::rtpLength()
|
||||
Codec::EncodeResult AmrWbCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 0; // VBR
|
||||
}
|
||||
|
||||
int AmrWbCodec::frameTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
int AmrWbCodec::samplerate()
|
||||
{
|
||||
return 16000;
|
||||
}
|
||||
|
||||
int AmrWbCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
throw Exception(ERR_NOT_IMPLEMENTED);
|
||||
// Still no support for encoding - emit silence instead
|
||||
return {.mEncoded = 0};
|
||||
}
|
||||
|
||||
#define L_FRAME 160
|
||||
@@ -657,22 +627,24 @@ int AmrWbCodec::decodePlain(std::span<const uint8_t> input, std::span<uint8_t> o
|
||||
return dataOutSizeInBytes;
|
||||
}
|
||||
|
||||
int AmrWbCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult AmrWbCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
auto inputBuffer = std::span<const uint8_t>((uint8_t*)input, (size_t)inputBytes);
|
||||
auto outputBuffer = std::span<uint8_t>((uint8_t*)output, (size_t)outputCapacity);
|
||||
|
||||
if (mConfig.mIuUP)
|
||||
return decodeIuup(inputBuffer, outputBuffer);
|
||||
return {.mDecoded = (size_t)decodeIuup(input, output)};
|
||||
else
|
||||
return decodePlain(inputBuffer, outputBuffer);
|
||||
return {.mDecoded = (size_t)decodePlain(input, output)};
|
||||
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
}
|
||||
|
||||
int AmrWbCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t AmrWbCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
/* if (outputCapacity < lostFrames * pcmLength())
|
||||
// ToDo: Check again if PLC works for AMR-WB
|
||||
// For now return the silence
|
||||
memset(output.data(), 0, output.size_bytes());
|
||||
return lostFrames * pcmLength();
|
||||
/*
|
||||
if (outputCapacity < lostFrames * pcmLength())
|
||||
return 0;
|
||||
|
||||
short* dataOut = (short*)output;
|
||||
@@ -685,7 +657,6 @@ int AmrWbCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
dataOut += L_FRAME;
|
||||
}
|
||||
*/
|
||||
return lostFrames * pcmLength();
|
||||
}
|
||||
|
||||
int AmrWbCodec::getSwitchCounter() const
|
||||
@@ -702,9 +673,7 @@ int AmrWbCodec::getCngCounter() const
|
||||
|
||||
GsmEfrCodec::GsmEfrFactory::GsmEfrFactory(bool iuup, int ptype)
|
||||
:mIuUP(iuup), mPayloadType(ptype)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
const char* GsmEfrCodec::GsmEfrFactory::name()
|
||||
{
|
||||
@@ -722,9 +691,7 @@ int GsmEfrCodec::GsmEfrFactory::payloadType()
|
||||
}
|
||||
|
||||
void GsmEfrCodec::GsmEfrFactory::updateSdp(resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction)
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
|
||||
int GsmEfrCodec::GsmEfrFactory::processSdp(const resip::SdpContents::Session::Medium::CodecContainer& codecs, SdpDirection direction)
|
||||
{
|
||||
@@ -742,7 +709,7 @@ PCodec GsmEfrCodec::GsmEfrFactory::create()
|
||||
}
|
||||
|
||||
GsmEfrCodec::GsmEfrCodec(bool iuup)
|
||||
:mEncoderCtx(nullptr), mDecoderCtx(nullptr), mIuUP(iuup)
|
||||
:mIuUP(iuup)
|
||||
{
|
||||
mEncoderCtx = Encoder_Interface_init(1);
|
||||
mDecoderCtx = Decoder_Interface_init();
|
||||
@@ -763,44 +730,31 @@ GsmEfrCodec::~GsmEfrCodec()
|
||||
}
|
||||
}
|
||||
|
||||
const char* GsmEfrCodec::name()
|
||||
Codec::Info GsmEfrCodec::info()
|
||||
{
|
||||
return MT_GSMEFR_CODECNAME;
|
||||
return {
|
||||
.mName = MT_GSMEFR_CODECNAME,
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 20 * 16,
|
||||
.mFrameTime = 20,
|
||||
.mRtpLength = 0
|
||||
};
|
||||
}
|
||||
|
||||
int GsmEfrCodec::pcmLength()
|
||||
Codec::EncodeResult GsmEfrCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 20 * 16;
|
||||
}
|
||||
|
||||
int GsmEfrCodec::rtpLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GsmEfrCodec::frameTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
int GsmEfrCodec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int GsmEfrCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
if (inputBytes % pcmLength())
|
||||
return 0;
|
||||
if (input.size_bytes() % pcmLength())
|
||||
return {.mEncoded = 0};
|
||||
|
||||
// Declare the data input pointer
|
||||
const short *dataIn = (const short *)input;
|
||||
const short *dataIn = (const short *)input.data();
|
||||
|
||||
// Declare the data output pointer
|
||||
unsigned char *dataOut = (unsigned char *)output;
|
||||
unsigned char *dataOut = (unsigned char *)output.data();
|
||||
|
||||
// Find how much RTP frames will be generated
|
||||
unsigned int frames = inputBytes / pcmLength();
|
||||
unsigned int frames = input.size_bytes() / pcmLength();
|
||||
|
||||
// Generate frames
|
||||
for (unsigned int i = 0; i < frames; i++)
|
||||
@@ -809,7 +763,7 @@ int GsmEfrCodec::encode(const void* input, int inputBytes, void* output, int out
|
||||
dataIn += pcmLength() / 2;
|
||||
}
|
||||
|
||||
return frames * rtpLength();
|
||||
return {.mEncoded = frames * rtpLength()};
|
||||
}
|
||||
|
||||
#define L_FRAME 160
|
||||
@@ -866,59 +820,22 @@ const uint16_t gsm690_12_2_bitorder[244] = {
|
||||
237, 236, 96, 199,
|
||||
};
|
||||
|
||||
int GsmEfrCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult GsmEfrCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
/* if (mIuUP)
|
||||
{
|
||||
// Try to parse IuUP frame
|
||||
IuUP::Frame frame;
|
||||
if (!IuUP::parse2((const uint8_t*)input, inputBytes, frame))
|
||||
return 0;
|
||||
if (output.size_bytes() < pcmLength())
|
||||
return {.mDecoded = 0};
|
||||
|
||||
// Check if CRC failed - it is check from IuUP data
|
||||
if (!frame.mHeaderCrcOk || !frame.mPayloadCrcOk)
|
||||
{
|
||||
ICELogInfo(<< "CRC check failed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Build NB frame to decode
|
||||
ByteBuffer dataToDecode;
|
||||
dataToDecode.resize(1 + frame.mPayloadSize); // Reserve place
|
||||
|
||||
// Copy AMR data
|
||||
memmove(dataToDecode.mutableData() + 1, frame.mPayload, frame.mPayloadSize);
|
||||
|
||||
uint8_t frameType = 0xFF;
|
||||
for (uint8_t ftIndex = 0; ftIndex <= 9 && frameType == 0xFF; ftIndex++)
|
||||
if (amrnb_framelen[ftIndex] == frame.mPayloadSize)
|
||||
frameType = ftIndex;
|
||||
|
||||
// Check if frameType comparing is correct
|
||||
if (frameType == 0xFF)
|
||||
return 0;
|
||||
|
||||
dataToDecode.mutableData()[0] = (frameType << 3) | (1 << 2);
|
||||
|
||||
Decoder_Interface_Decode(mDecoderCtx, (const unsigned char*)dataToDecode.data(), (short*)output, 0);
|
||||
return pcmLength();
|
||||
}
|
||||
else */
|
||||
{
|
||||
if (outputCapacity < pcmLength())
|
||||
return 0;
|
||||
|
||||
if (inputBytes == 0)
|
||||
if (input.size_bytes() == 0)
|
||||
{ // PLC part
|
||||
unsigned char buffer[32];
|
||||
buffer[0] = (AMR_BITRATE_DTX << 3)|4;
|
||||
Decoder_Interface_Decode(mDecoderCtx, buffer, (short*)output, 0); // Handle missing data
|
||||
Decoder_Interface_Decode(mDecoderCtx, buffer, (short*)output.data(), 0); // Handle missing data
|
||||
}
|
||||
else
|
||||
{
|
||||
// Reorder bytes from input to dst
|
||||
uint8_t dst[GSM_EFR_FRAME_LEN];
|
||||
const uint8_t* src = (const uint8_t*)input;
|
||||
const uint8_t* src = input.data();
|
||||
for (int i=0; i<(GSM_EFR_FRAME_LEN-1); i++)
|
||||
dst[i] = (src[i] << 4) | (src[i+1] >> 4);
|
||||
dst[GSM_EFR_FRAME_LEN-1] = src[GSM_EFR_FRAME_LEN-1] << 4;
|
||||
@@ -937,29 +854,27 @@ int GsmEfrCodec::decode(const void* input, int inputBytes, void* output, int out
|
||||
}
|
||||
|
||||
// Decode
|
||||
memset(output, 0, pcmLength());
|
||||
Decoder_Interface_Decode(mDecoderCtx, in, (short*)output, 0);
|
||||
memset(output.data(), 0, pcmLength());
|
||||
Decoder_Interface_Decode(mDecoderCtx, in, (short*)output.data(), 0);
|
||||
|
||||
|
||||
uint8_t* pcm = (uint8_t*)output;
|
||||
uint8_t* pcm = (uint8_t*)output.data();
|
||||
for (int i=0; i<160; i++)
|
||||
{
|
||||
uint16_t w = ((uint16_t*)output)[i];
|
||||
uint16_t w = ((uint16_t*)output.data())[i];
|
||||
pcm[(i<<1) ] = w & 0xff;
|
||||
pcm[(i<<1)+1] = (w >> 8) & 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
return {.mDecoded = (size_t)pcmLength()};
|
||||
}
|
||||
|
||||
return pcmLength();
|
||||
}
|
||||
|
||||
int GsmEfrCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t GsmEfrCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
if (outputCapacity < lostFrames * pcmLength())
|
||||
if (output.size_bytes() < lostFrames * pcmLength())
|
||||
return 0;
|
||||
|
||||
short* dataOut = (short*)output;
|
||||
short* dataOut = (short*)output.data();
|
||||
|
||||
for (int i=0; i < lostFrames; i++)
|
||||
{
|
||||
|
||||
@@ -54,16 +54,14 @@ public:
|
||||
};
|
||||
|
||||
AmrNbCodec(const AmrCodecConfig& config);
|
||||
~AmrNbCodec();
|
||||
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
|
||||
virtual ~AmrNbCodec();
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||
int getSwitchCounter() const;
|
||||
int getCngCounter() const;
|
||||
};
|
||||
@@ -113,14 +111,11 @@ public:
|
||||
AmrWbCodec(const AmrCodecConfig& config);
|
||||
virtual ~AmrWbCodec();
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
int getSwitchCounter() const;
|
||||
int getCngCounter() const;
|
||||
};
|
||||
@@ -147,23 +142,19 @@ public:
|
||||
void create(CodecMap& codecs) override;
|
||||
|
||||
PCodec create() override;
|
||||
|
||||
protected:
|
||||
bool mIuUP;
|
||||
int mPayloadType;
|
||||
};
|
||||
|
||||
GsmEfrCodec(bool iuup = false);
|
||||
~GsmEfrCodec();
|
||||
|
||||
virtual ~GsmEfrCodec();
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
};
|
||||
|
||||
} // End of MT namespace
|
||||
|
||||
@@ -91,38 +91,20 @@ G729Codec::~G729Codec()
|
||||
}
|
||||
}
|
||||
|
||||
const char* G729Codec::name()
|
||||
Codec::Info G729Codec::info()
|
||||
{
|
||||
return "G729";
|
||||
}
|
||||
|
||||
int G729Codec::pcmLength()
|
||||
{
|
||||
return 10 * 8 * 2;
|
||||
}
|
||||
|
||||
int G729Codec::rtpLength()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
int G729Codec::frameTime()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
int G729Codec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int G729Codec::channels()
|
||||
{
|
||||
return 1;
|
||||
return {
|
||||
.mName = "G729",
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 10 * 8 * 2,
|
||||
.mFrameTime = 10,
|
||||
.mRtpLength = 10
|
||||
};
|
||||
}
|
||||
|
||||
// static const int SamplesPerFrame = 80;
|
||||
int G729Codec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::EncodeResult G729Codec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
// Create encoder if it is not done yet
|
||||
if (!mEncoder)
|
||||
@@ -131,24 +113,24 @@ int G729Codec::encode(const void* input, int inputBytes, void* output, int outpu
|
||||
if (mEncoder)
|
||||
Init_Pre_Process(mEncoder);
|
||||
}
|
||||
int result = 0;
|
||||
size_t result = 0;
|
||||
if (mEncoder)
|
||||
{
|
||||
int nrOfFrames = inputBytes / 160; // 10ms frames
|
||||
int nrOfFrames = input.size_bytes() / 160; // 10ms frames
|
||||
Word16 parm[PRM_SIZE]; // ITU's service buffer
|
||||
for (int frameIndex = 0; frameIndex < nrOfFrames; frameIndex++)
|
||||
{
|
||||
Copy((int16_t*)input + frameIndex * pcmLength() / 2, mEncoder->new_speech, pcmLength() / 2);
|
||||
Pre_Process(mEncoder, mEncoder->new_speech, pcmLength() / 2);
|
||||
Copy((int16_t*)input.data() + frameIndex * info().mPcmLength / 2, mEncoder->new_speech, info().mPcmLength / 2);
|
||||
Pre_Process(mEncoder, mEncoder->new_speech, info().mPcmLength / 2);
|
||||
Coder_ld8a(mEncoder, parm);
|
||||
Store_Params(parm, (uint8_t*)output + frameIndex * rtpLength());
|
||||
result += rtpLength();
|
||||
Store_Params(parm, output.data() + frameIndex * info().mRtpLength);
|
||||
result += info().mRtpLength;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return {result};
|
||||
}
|
||||
|
||||
int G729Codec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult G729Codec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
if (!mDecoder)
|
||||
{
|
||||
@@ -160,29 +142,29 @@ int G729Codec::decode(const void* input, int inputBytes, void* output, int outpu
|
||||
}
|
||||
}
|
||||
|
||||
int result = 0;
|
||||
size_t result = 0;
|
||||
if (mDecoder)
|
||||
{
|
||||
// See if there are silence bytes in the end
|
||||
bool isSilence = (inputBytes % rtpLength()) / 2 != 0;
|
||||
bool isSilence = (input.size_bytes() % info().mRtpLength) / 2 != 0;
|
||||
|
||||
// Find number of frames
|
||||
int nrOfFrames = inputBytes / rtpLength();
|
||||
nrOfFrames = std::min(outputCapacity / pcmLength(), nrOfFrames);
|
||||
int nrOfFrames = input.size_bytes() / info().mRtpLength;
|
||||
nrOfFrames = std::min(output.size_bytes() / info().mPcmLength, (size_t)nrOfFrames);
|
||||
|
||||
for (int frameIndex = 0; frameIndex < nrOfFrames; frameIndex++)
|
||||
decodeFrame((const uint8_t*)input + frameIndex * rtpLength(), (int16_t*)output + frameIndex * pcmLength());
|
||||
decodeFrame(input.data() + frameIndex * info().mRtpLength, (int16_t*)output.data() + frameIndex * info().mPcmLength);
|
||||
|
||||
result += nrOfFrames * pcmLength();
|
||||
result += nrOfFrames * info().mPcmLength;
|
||||
|
||||
if (isSilence && nrOfFrames < outputCapacity / pcmLength())
|
||||
if (isSilence && nrOfFrames < output.size_bytes() / info().mPcmLength)
|
||||
{
|
||||
memset((uint8_t*)output + nrOfFrames * pcmLength(), 0, pcmLength());
|
||||
result += pcmLength();
|
||||
memset(output.data() + nrOfFrames * info().mPcmLength, 0, info().mPcmLength);
|
||||
result += info().mPcmLength;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return {.mDecoded = result, .mIsCng = false};
|
||||
}
|
||||
|
||||
void G729Codec::decodeFrame(const uint8_t* rtp, int16_t* pcm)
|
||||
@@ -217,7 +199,7 @@ void G729Codec::decodeFrame(const uint8_t* rtp, int16_t* pcm)
|
||||
}
|
||||
|
||||
|
||||
int G729Codec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t G729Codec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -390,7 +372,7 @@ int OpusCodec::OpusFactory::processSdp(const resip::SdpContents::Session::Medium
|
||||
|
||||
PCodec OpusCodec::OpusFactory::create()
|
||||
{
|
||||
OpusCodec* result = new OpusCodec(mSamplerate, mChannels, mParams.mPtime);
|
||||
OpusCodec* result = new OpusCodec(Audio::Format(mSamplerate, mChannels), mParams.mPtime);
|
||||
result->applyParams(mParams);
|
||||
PCodec c(result);
|
||||
mCodecList.push_back(c);
|
||||
@@ -398,8 +380,8 @@ PCodec OpusCodec::OpusFactory::create()
|
||||
return c;
|
||||
}
|
||||
|
||||
OpusCodec::OpusCodec(int samplerate, int channels, int ptime)
|
||||
:mEncoderCtx(nullptr), mDecoderCtx(nullptr), mChannels(channels), mPTime(ptime), mSamplerate(samplerate), mDecoderChannels(0)
|
||||
OpusCodec::OpusCodec(Audio::Format fmt, int ptime)
|
||||
:mEncoderCtx(nullptr), mDecoderCtx(nullptr), mChannels(fmt.channels()), mPTime(ptime), mSamplerate(fmt.rate()), mDecoderChannels(0)
|
||||
{
|
||||
int status;
|
||||
mEncoderCtx = opus_encoder_create(mSamplerate, mChannels, OPUS_APPLICATION_VOIP, &status);
|
||||
@@ -441,52 +423,34 @@ OpusCodec::~OpusCodec()
|
||||
}
|
||||
}
|
||||
|
||||
const char* OpusCodec::name()
|
||||
{
|
||||
return OPUS_CODEC_NAME;
|
||||
Codec::Info OpusCodec::info() {
|
||||
return {
|
||||
.mName = OPUS_CODEC_NAME,
|
||||
.mSamplerate = mSamplerate,
|
||||
.mChannels = mChannels,
|
||||
.mPcmLength = (int)(mSamplerate / 1000 * sizeof(short) * mChannels * mPTime),
|
||||
.mFrameTime = mPTime,
|
||||
.mRtpLength = 0 /* VBR */
|
||||
};
|
||||
}
|
||||
|
||||
int OpusCodec::pcmLength()
|
||||
{
|
||||
return (samplerate() / 1000 ) * frameTime() * sizeof(short) * channels();
|
||||
}
|
||||
|
||||
int OpusCodec::channels()
|
||||
{
|
||||
return mChannels;
|
||||
}
|
||||
|
||||
int OpusCodec::rtpLength()
|
||||
{
|
||||
return 0; // VBR
|
||||
}
|
||||
|
||||
int OpusCodec::frameTime()
|
||||
{
|
||||
return mPTime;
|
||||
}
|
||||
|
||||
int OpusCodec::samplerate()
|
||||
{
|
||||
return mSamplerate;
|
||||
}
|
||||
|
||||
int OpusCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::EncodeResult OpusCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
// Send number of samples for input and number of bytes for output
|
||||
int written = opus_encode(mEncoderCtx, (const opus_int16*)input, inputBytes / (sizeof(short) * channels()), (unsigned char*)output, outputCapacity / (sizeof(short) * channels()));
|
||||
int written = opus_encode(mEncoderCtx, (const opus_int16*)input.data(), input.size_bytes() / (sizeof(short) * channels()),
|
||||
output.data(), output.size_bytes() / (sizeof(short) * channels()));
|
||||
if (written < 0)
|
||||
return 0;
|
||||
return {.mEncoded = 0};
|
||||
else
|
||||
return written;
|
||||
return {.mEncoded = (size_t)written};
|
||||
}
|
||||
|
||||
int OpusCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult OpusCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
// Examine the number of channels available in incoming packet
|
||||
int nr_of_channels = opus_packet_get_nb_channels((const unsigned char *) input);
|
||||
int nr_of_channels = opus_packet_get_nb_channels(input.data());
|
||||
|
||||
// Recreate decoder if needed
|
||||
if (mDecoderChannels != nr_of_channels)
|
||||
@@ -504,24 +468,22 @@ int OpusCodec::decode(const void* input, int inputBytes, void* output, int outpu
|
||||
int status = 0;
|
||||
mDecoderCtx = opus_decoder_create(mSamplerate, mDecoderChannels, &status);
|
||||
if (status)
|
||||
return 0;
|
||||
return {0};
|
||||
}
|
||||
|
||||
int nr_of_frames = opus_decoder_get_nb_samples(mDecoderCtx, (const unsigned char *) input,
|
||||
inputBytes);
|
||||
int nr_of_frames = opus_decoder_get_nb_samples(mDecoderCtx, input.data(), input.size_bytes());
|
||||
if (nr_of_frames <= 0)
|
||||
return 0;
|
||||
return {0};
|
||||
|
||||
// We support stereo and mono here.
|
||||
int buffer_capacity = nr_of_frames * sizeof(opus_int16) * nr_of_channels;
|
||||
opus_int16 *buffer_decode = (opus_int16 *)alloca(buffer_capacity);
|
||||
int decoded = opus_decode(mDecoderCtx,
|
||||
reinterpret_cast<const unsigned char *>(input), inputBytes,
|
||||
int decoded = opus_decode(mDecoderCtx, input.data(), input.size_bytes(),
|
||||
buffer_decode, nr_of_frames, 0);
|
||||
if (decoded < 0)
|
||||
{
|
||||
ICELogCritical(<< "opus_decode() returned " << decoded);
|
||||
return 0;
|
||||
return {0};
|
||||
}
|
||||
|
||||
opus_int16 *buffer_stereo = nullptr;
|
||||
@@ -535,14 +497,14 @@ int OpusCodec::decode(const void* input, int inputBytes, void* output, int outpu
|
||||
buffer_stereo[i * 2 + 1] = buffer_decode[i];
|
||||
buffer_stereo[i * 2] = buffer_decode[i];
|
||||
}
|
||||
assert(buffer_stereo_capacity <= outputCapacity);
|
||||
memcpy(output, buffer_stereo, buffer_stereo_capacity);
|
||||
assert(buffer_stereo_capacity <= output.size_bytes());
|
||||
memcpy(output.data(), buffer_stereo, buffer_stereo_capacity);
|
||||
result = buffer_stereo_capacity;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
assert(buffer_capacity <= outputCapacity);
|
||||
memcpy(output, buffer_decode, buffer_capacity);
|
||||
assert(buffer_capacity <= output.size_bytes());
|
||||
memcpy(output.data(), buffer_decode, buffer_capacity);
|
||||
result = buffer_capacity;
|
||||
break;
|
||||
|
||||
@@ -550,17 +512,17 @@ int OpusCodec::decode(const void* input, int inputBytes, void* output, int outpu
|
||||
assert(0);
|
||||
}
|
||||
|
||||
return result;
|
||||
return {.mDecoded = (size_t)result};
|
||||
}
|
||||
|
||||
int OpusCodec::plc(int lostPackets, void* output, int outputCapacity)
|
||||
size_t OpusCodec::plc(int lostPackets, std::span<uint8_t> output)
|
||||
{
|
||||
// Find how much frames do we need to produce and prefill it with silence
|
||||
int frames_per_packet = (int)pcmLength() / (sizeof(opus_int16) * channels());
|
||||
memset(output, 0, outputCapacity);
|
||||
memset(output.data(), 0, output.size_bytes());
|
||||
|
||||
// Use this pointer as output
|
||||
opus_int16* data_output = reinterpret_cast<opus_int16*>(output);
|
||||
opus_int16* data_output = reinterpret_cast<opus_int16*>(output.data());
|
||||
|
||||
int nr_of_decoded_frames = 0;
|
||||
|
||||
@@ -575,10 +537,7 @@ int OpusCodec::plc(int lostPackets, void* output, int outputCapacity)
|
||||
case 1:
|
||||
// Convert mono to stereo
|
||||
for (int i=0; i < nr_of_decoded_frames; i++)
|
||||
{
|
||||
data_output[i * 2] = buffer_plc[i];
|
||||
data_output[i * 2 + 1] = buffer_plc[i+1];
|
||||
}
|
||||
data_output[i * 2] = data_output[i * 2 + 1] = buffer_plc[i];
|
||||
data_output += frames_per_packet * mChannels;
|
||||
break;
|
||||
|
||||
@@ -589,14 +548,14 @@ int OpusCodec::plc(int lostPackets, void* output, int outputCapacity)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ((char*)data_output - (char*)output) * sizeof(opus_int16);
|
||||
return ((uint8_t*)data_output - output.data());
|
||||
}
|
||||
|
||||
// -------------- ILBC -------------------
|
||||
#define ILBC_CODEC_NAME "ILBC"
|
||||
|
||||
IlbcCodec::IlbcCodec(int packetTime)
|
||||
:mPacketTime(packetTime), mEncoderCtx(nullptr), mDecoderCtx(nullptr)
|
||||
:mPacketTime(packetTime)
|
||||
{
|
||||
WebRtcIlbcfix_EncoderCreate(&mEncoderCtx);
|
||||
WebRtcIlbcfix_DecoderCreate(&mDecoderCtx);
|
||||
@@ -610,44 +569,31 @@ IlbcCodec::~IlbcCodec()
|
||||
WebRtcIlbcfix_EncoderFree(mEncoderCtx);
|
||||
}
|
||||
|
||||
const char* IlbcCodec::name()
|
||||
Codec::Info IlbcCodec::info()
|
||||
{
|
||||
return "ilbc";
|
||||
return {
|
||||
.mName = ILBC_CODEC_NAME,
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = mPacketTime * 8 * (int)sizeof(short),
|
||||
.mFrameTime = mPacketTime,
|
||||
.mRtpLength = (mPacketTime == 20) ? 38 : 50
|
||||
};
|
||||
}
|
||||
|
||||
int IlbcCodec::rtpLength()
|
||||
Codec::EncodeResult IlbcCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return (mPacketTime == 20 ) ? 38 : 50;
|
||||
}
|
||||
|
||||
int IlbcCodec::pcmLength()
|
||||
{
|
||||
return mPacketTime * 16;
|
||||
}
|
||||
|
||||
int IlbcCodec::frameTime()
|
||||
{
|
||||
return mPacketTime;
|
||||
}
|
||||
|
||||
int IlbcCodec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
Codec::EncodeResult IlbcCodec::encode(const void *input, int inputBytes, void* outputBuffer, int outputCapacity)
|
||||
{
|
||||
if (inputBytes % pcmLength())
|
||||
if (input.size_bytes() % pcmLength())
|
||||
return {};
|
||||
|
||||
// Declare the data input pointer
|
||||
short *dataIn = (short *)input;
|
||||
short *dataIn = (short *)input.data();
|
||||
|
||||
// Declare the data output pointer
|
||||
char *dataOut = (char *)outputBuffer;
|
||||
char *dataOut = (char *)output.data();
|
||||
|
||||
// Find how much RTP frames will be generated
|
||||
unsigned int frames = inputBytes / pcmLength();
|
||||
unsigned int frames = input.size_bytes() / pcmLength();
|
||||
|
||||
// Generate frames
|
||||
for (unsigned int i=0; i<frames; i++)
|
||||
@@ -660,12 +606,12 @@ Codec::EncodeResult IlbcCodec::encode(const void *input, int inputBytes, void* o
|
||||
return {frames * rtpLength()};
|
||||
}
|
||||
|
||||
Codec::DecodeResult IlbcCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult IlbcCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
unsigned frames = inputBytes / rtpLength();
|
||||
unsigned frames = input.size_bytes() / rtpLength();
|
||||
|
||||
char* dataIn = (char*)input;
|
||||
short* dataOut = (short*)output;
|
||||
char* dataIn = (char*)input.data();
|
||||
short* dataOut = (short*)output.data();
|
||||
|
||||
for (unsigned i=0; i < frames; ++i)
|
||||
{
|
||||
@@ -678,7 +624,7 @@ Codec::DecodeResult IlbcCodec::decode(const void* input, int inputBytes, void* o
|
||||
return {frames * pcmLength()};
|
||||
}
|
||||
|
||||
int IlbcCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
size_t IlbcCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
return sizeof(short) * WebRtcIlbcfix_DecodePlc(mDecoderCtx, (WebRtc_Word16*)output.data(), lostFrames);
|
||||
}
|
||||
@@ -795,38 +741,24 @@ IsacCodec::~IsacCodec()
|
||||
WebRtcIsacfix_Free(mDecoderCtx); mDecoderCtx = NULL;
|
||||
}
|
||||
|
||||
const char* IsacCodec::name()
|
||||
{
|
||||
return "isac";
|
||||
Codec::Info IsacCodec::info() {
|
||||
return {
|
||||
.mName = "isac",
|
||||
.mSamplerate = mSamplerate,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 60 * mSamplerate / 1000 * 2,
|
||||
.mFrameTime = 60,
|
||||
.mRtpLength = 0
|
||||
};
|
||||
}
|
||||
|
||||
int IsacCodec::frameTime()
|
||||
Codec::EncodeResult IsacCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 60;
|
||||
}
|
||||
|
||||
int IsacCodec::samplerate()
|
||||
{
|
||||
return mSamplerate;
|
||||
}
|
||||
|
||||
int IsacCodec::pcmLength()
|
||||
{
|
||||
return frameTime() * samplerate() / 1000 * sizeof(short);
|
||||
}
|
||||
|
||||
int IsacCodec::rtpLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int IsacCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
unsigned nrOfSamples = inputBytes / 2;
|
||||
unsigned nrOfSamples = input.size_bytes() / 2;
|
||||
unsigned timeLength = nrOfSamples / (mSamplerate / 1000);
|
||||
int encoded = 0;
|
||||
char* dataOut = (char*)output;
|
||||
const WebRtc_Word16* dataIn = (const WebRtc_Word16*)input;
|
||||
char* dataOut = (char*)output.data();
|
||||
const WebRtc_Word16* dataIn = (const WebRtc_Word16*)input.data();
|
||||
|
||||
// Iterate 10 milliseconds chunks
|
||||
for (unsigned i=0; i<timeLength/10; i++)
|
||||
@@ -835,25 +767,25 @@ int IsacCodec::encode(const void* input, int inputBytes, void* output, int outpu
|
||||
if (encoded > 0)
|
||||
dataOut += encoded;
|
||||
}
|
||||
return dataOut - (char*)output;
|
||||
return {.mEncoded = (size_t)(dataOut - (char*)output.data())};
|
||||
}
|
||||
|
||||
int IsacCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult IsacCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
WebRtc_Word16 speechType = 0;
|
||||
unsigned produced = WebRtcIsacfix_Decode(mDecoderCtx, (const WebRtc_UWord16*)input, inputBytes, (WebRtc_Word16*)output, &speechType);
|
||||
unsigned produced = WebRtcIsacfix_Decode(mDecoderCtx, (const WebRtc_UWord16*)input.data(), input.size_bytes(), (WebRtc_Word16*)output.data(), &speechType);
|
||||
if (produced == (unsigned)-1)
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
|
||||
return produced * 2;
|
||||
return {.mDecoded = produced * 2};
|
||||
}
|
||||
|
||||
int IsacCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t IsacCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
// lostFrames are 30-milliseconds frames; but used encoding mode is 60 milliseconds.
|
||||
// So lostFrames * 2
|
||||
lostFrames *=2 ;
|
||||
if (-1 == WebRtcIsacfix_DecodePlc(mDecoderCtx, (WebRtc_Word16*)output, lostFrames ))
|
||||
if (-1 == WebRtcIsacfix_DecodePlc(mDecoderCtx, (WebRtc_Word16*)output.data(), lostFrames ))
|
||||
return 0;
|
||||
|
||||
return lostFrames * 30 * (samplerate()/1000 * sizeof(short));
|
||||
@@ -916,71 +848,55 @@ PCodec IsacCodec::IsacFactory32K::create()
|
||||
|
||||
G711Codec::G711Codec(int type)
|
||||
:mType(type)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
G711Codec::~G711Codec()
|
||||
{
|
||||
{}
|
||||
|
||||
Codec::Info G711Codec::info() {
|
||||
return {
|
||||
.mName = mType == ALaw ? "PCMA" : "PCMU",
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 10 * 16,
|
||||
.mFrameTime = 10,
|
||||
.mRtpLength = 10 * 8
|
||||
};
|
||||
}
|
||||
|
||||
const char* G711Codec::name()
|
||||
{
|
||||
return "g711";
|
||||
}
|
||||
|
||||
int G711Codec::pcmLength()
|
||||
{
|
||||
return frameTime() * 16;
|
||||
}
|
||||
|
||||
int G711Codec::rtpLength()
|
||||
{
|
||||
return frameTime() * 8;
|
||||
}
|
||||
|
||||
int G711Codec::frameTime()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
int G711Codec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int G711Codec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::EncodeResult G711Codec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
int result;
|
||||
if (mType == ALaw)
|
||||
result = WebRtcG711_EncodeA(NULL, (WebRtc_Word16*)input, inputBytes/2, (WebRtc_Word16*)output);
|
||||
result = WebRtcG711_EncodeA(nullptr, (WebRtc_Word16*)input.data(), input.size_bytes() / 2, (WebRtc_Word16*)output.data());
|
||||
else
|
||||
result = WebRtcG711_EncodeU(NULL, (WebRtc_Word16*)input, inputBytes/2, (WebRtc_Word16*)output);
|
||||
result = WebRtcG711_EncodeU(nullptr, (WebRtc_Word16*)input.data(), input.size_bytes() / 2, (WebRtc_Word16*)output.data());
|
||||
|
||||
if (result == -1)
|
||||
throw Exception(ERR_WEBRTC, -1);
|
||||
if (result < 0)
|
||||
return {.mEncoded = 0};
|
||||
|
||||
return result;
|
||||
return {.mEncoded = (size_t) result};
|
||||
}
|
||||
|
||||
int G711Codec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult G711Codec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
assert(outputCapacity >= inputBytes * 2);
|
||||
assert(output.size_bytes() >= input.size_bytes() * 2);
|
||||
|
||||
int result;
|
||||
WebRtc_Word16 speechType;
|
||||
|
||||
if (mType == ALaw)
|
||||
result = WebRtcG711_DecodeA(NULL, (WebRtc_Word16*)input, inputBytes, (WebRtc_Word16*)output, &speechType);
|
||||
result = WebRtcG711_DecodeA(nullptr, (WebRtc_Word16*)input.data(), input.size_bytes(), (WebRtc_Word16*)output.data(), &speechType);
|
||||
else
|
||||
result = WebRtcG711_DecodeU(NULL, (WebRtc_Word16*)input, inputBytes, (WebRtc_Word16*)output, &speechType);
|
||||
result = WebRtcG711_DecodeU(nullptr, (WebRtc_Word16*)input.data(), input.size_bytes(), (WebRtc_Word16*)output.data(), &speechType);
|
||||
|
||||
if (result == -1)
|
||||
throw Exception(ERR_WEBRTC, -1);
|
||||
if (result < 0)
|
||||
return {.mDecoded = 0};
|
||||
|
||||
return result * 2;
|
||||
return {.mDecoded = (size_t)result * 2};
|
||||
}
|
||||
|
||||
int G711Codec::plc(int lostSamples, void* output, int outputCapacity)
|
||||
size_t G711Codec::plc(int lostSamples, std::span<uint8_t> output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -1060,86 +976,64 @@ GsmCodec::GsmCodec(Type codecType)
|
||||
|
||||
GsmCodec::~GsmCodec()
|
||||
{
|
||||
gsm_destroy(mGSM);
|
||||
gsm_destroy(mGSM); mGSM = nullptr;
|
||||
}
|
||||
|
||||
const char* GsmCodec::name()
|
||||
{
|
||||
return "GSM-06.10";
|
||||
}
|
||||
|
||||
int GsmCodec::rtpLength()
|
||||
{
|
||||
Codec::Info GsmCodec::info() {
|
||||
int rtpLength = 0;
|
||||
switch (mCodecType)
|
||||
{
|
||||
case Type::Bytes_31:
|
||||
return GSM_RTPFRAME_SIZE_31;
|
||||
break;
|
||||
|
||||
case Type::Bytes_32:
|
||||
return GSM_RTPFRAME_SIZE_32;
|
||||
|
||||
case Type::Bytes_33:
|
||||
return GSM_RTPFRAME_SIZE_33;
|
||||
|
||||
case Type::Bytes_65:
|
||||
return GSM_RTPFRAME_SIZE_32 + GSM_RTPFRAME_SIZE_33;
|
||||
|
||||
case Type::Bytes_31: rtpLength = GSM_RTPFRAME_SIZE_31; break;
|
||||
case Type::Bytes_32: rtpLength = GSM_RTPFRAME_SIZE_32; break;
|
||||
case Type::Bytes_33: rtpLength = GSM_RTPFRAME_SIZE_33; break;
|
||||
case Type::Bytes_65: rtpLength = GSM_RTPFRAME_SIZE_32 + GSM_RTPFRAME_SIZE_33; break;
|
||||
default: rtpLength = GSM_RTPFRAME_SIZE_33;
|
||||
}
|
||||
|
||||
return GSM_RTPFRAME_SIZE_33;
|
||||
return {
|
||||
.mName = "GSM-06.10",
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = GSM_AUDIOFRAME_TIME * 16,
|
||||
.mFrameTime = GSM_AUDIOFRAME_TIME,
|
||||
.mRtpLength = rtpLength
|
||||
};
|
||||
}
|
||||
|
||||
int GsmCodec::pcmLength()
|
||||
{
|
||||
return GSM_AUDIOFRAME_TIME * 16;
|
||||
}
|
||||
|
||||
int GsmCodec::frameTime()
|
||||
{
|
||||
return GSM_AUDIOFRAME_TIME;
|
||||
}
|
||||
|
||||
int GsmCodec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int GsmCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::EncodeResult GsmCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
int outputBytes = 0;
|
||||
char* outputBuffer = (char*)output.data();
|
||||
|
||||
char* outputBuffer = (char*)output;
|
||||
|
||||
for (int i = 0; i < inputBytes/pcmLength(); i++)
|
||||
for (int i = 0; i < input.size_bytes() / pcmLength(); i++)
|
||||
{
|
||||
gsm_encode(mGSM, (gsm_signal *)input+160*i, (gsm_byte*)outputBuffer);
|
||||
gsm_encode(mGSM, (gsm_signal *)input.data()+160*i, (gsm_byte*)outputBuffer);
|
||||
outputBuffer += rtpLength();
|
||||
outputBytes += rtpLength();
|
||||
}
|
||||
return outputBytes;
|
||||
return {.mEncoded = (size_t)outputBytes};
|
||||
}
|
||||
|
||||
|
||||
int GsmCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult GsmCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
if (inputBytes % rtpLength() != 0)
|
||||
return 0;
|
||||
if (input.size_bytes() % rtpLength() != 0)
|
||||
return {.mDecoded = 0};
|
||||
|
||||
int i=0;
|
||||
for (i = 0; i < inputBytes/rtpLength(); i++)
|
||||
gsm_decode(mGSM, (gsm_byte *)input + 33 * i, (gsm_signal *)output + 160 * i);
|
||||
for (i = 0; i < input.size_bytes() / rtpLength(); i++)
|
||||
gsm_decode(mGSM, (gsm_byte *)input.data() + 33 * i, (gsm_signal *)output.data() + 160 * i);
|
||||
|
||||
return i * 320;
|
||||
return {.mDecoded = (size_t)i * 320};
|
||||
}
|
||||
|
||||
int GsmCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t GsmCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
if (outputCapacity < lostFrames * pcmLength())
|
||||
if (output.size_bytes() < lostFrames * pcmLength())
|
||||
return 0;
|
||||
|
||||
// Return silence frames
|
||||
memset(output, 0, lostFrames * pcmLength());
|
||||
memset(output.data(), 0, lostFrames * pcmLength());
|
||||
return lostFrames * pcmLength();
|
||||
}
|
||||
|
||||
@@ -1155,58 +1049,52 @@ G722Codec::G722Codec()
|
||||
|
||||
G722Codec::~G722Codec()
|
||||
{
|
||||
g722_decode_release((g722_decode_state_t*)mDecoder);
|
||||
g722_encode_release((g722_encode_state_t*)mEncoder);
|
||||
g722_decode_release((g722_decode_state_t*)mDecoder); mDecoder = nullptr;
|
||||
g722_encode_release((g722_encode_state_t*)mEncoder); mEncoder = nullptr;
|
||||
}
|
||||
|
||||
const char* G722Codec::name()
|
||||
{
|
||||
return G722_MIME_NAME;
|
||||
Codec::Info G722Codec::info() {
|
||||
// ToDo: double check the G722 calls - remember RFC has bug about samplerate
|
||||
return {
|
||||
.mName = G722_MIME_NAME,
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 640,
|
||||
.mFrameTime = 20,
|
||||
.mRtpLength = 160
|
||||
};
|
||||
}
|
||||
|
||||
int G722Codec::pcmLength()
|
||||
Codec::EncodeResult G722Codec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 640;
|
||||
if (output.size_bytes() < input.size_bytes() / 4)
|
||||
return {.mEncoded = 0}; // Destination buffer not big enough
|
||||
|
||||
int r = g722_encode((g722_encode_state_t *)mEncoder, (unsigned char*)output.data(), ( short*)input.data(), input.size_bytes() / 2);
|
||||
if (r < 0)
|
||||
return {.mEncoded = 0};
|
||||
|
||||
return {.mEncoded = (size_t)r};
|
||||
}
|
||||
|
||||
int G722Codec::frameTime()
|
||||
Codec::DecodeResult G722Codec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return 20;
|
||||
if (output.size_bytes() < input.size_bytes() * 4)
|
||||
return {.mDecoded = 0}; // Destination buffer not big enough
|
||||
|
||||
int r = g722_decode((g722_decode_state_t *)mDecoder, (short*)output.data(), (unsigned char*)input.data(), input.size_bytes()) * 2;
|
||||
if (r < 0)
|
||||
return {.mDecoded = 0};
|
||||
return {.mDecoded = (size_t)r};
|
||||
}
|
||||
|
||||
int G722Codec::rtpLength()
|
||||
size_t G722Codec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
return 160;
|
||||
}
|
||||
|
||||
int G722Codec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int G722Codec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
if (outputCapacity < inputBytes / 4)
|
||||
return 0; // Destination buffer not big enough
|
||||
|
||||
return g722_encode((g722_encode_state_t *)mEncoder, (unsigned char*)output, ( short*)input, inputBytes / 2);
|
||||
}
|
||||
|
||||
int G722Codec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
if (outputCapacity < inputBytes * 4)
|
||||
return 0; // Destination buffer not big enough
|
||||
|
||||
return g722_decode((g722_decode_state_t *)mDecoder, ( short*)output, (unsigned char*)input, inputBytes) * 2;
|
||||
}
|
||||
|
||||
int G722Codec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
{
|
||||
if (outputCapacity < lostFrames * pcmLength())
|
||||
if (output.size_bytes() < lostFrames * pcmLength())
|
||||
return 0;
|
||||
|
||||
// Return silence frames
|
||||
memset(output, 0, lostFrames * pcmLength());
|
||||
memset(output.data(), 0, lostFrames * pcmLength());
|
||||
return lostFrames * pcmLength();
|
||||
}
|
||||
|
||||
@@ -1318,7 +1206,6 @@ static bool repackHalfRate(BitReader& br, uint16_t frame[22], bool& lastItem)
|
||||
}
|
||||
|
||||
GsmHrCodec::GsmHrCodec()
|
||||
:mDecoder(nullptr)
|
||||
{
|
||||
mDecoder = new GsmHr::Codec();
|
||||
}
|
||||
@@ -1329,34 +1216,21 @@ GsmHrCodec::~GsmHrCodec()
|
||||
mDecoder = nullptr;
|
||||
}
|
||||
|
||||
const char* GsmHrCodec::name()
|
||||
{
|
||||
return "GSM-HR-08";
|
||||
Codec::Info GsmHrCodec::info() {
|
||||
return {
|
||||
.mName = "GSM-HR-08",
|
||||
.mSamplerate = 8000,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = 20 * 8 * 2,
|
||||
.mFrameTime = 20,
|
||||
.mRtpLength = 0
|
||||
};
|
||||
}
|
||||
|
||||
int GsmHrCodec::pcmLength()
|
||||
Codec::EncodeResult GsmHrCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
return frameTime() * 8 * 2;
|
||||
}
|
||||
|
||||
int GsmHrCodec::rtpLength()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GsmHrCodec::frameTime()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
|
||||
int GsmHrCodec::samplerate()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
int GsmHrCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
{
|
||||
return 0;
|
||||
// Not supported yet
|
||||
return {.mEncoded = 0};
|
||||
}
|
||||
|
||||
static const int params_unvoiced[] = {
|
||||
@@ -1447,23 +1321,23 @@ hr_ref_from_canon(uint16_t *hr_ref, const uint8_t *canon)
|
||||
[+] PQ: Adding conversion from canon to rawpcm-s16le (for codec pcm)
|
||||
[+] PQ: Adding file output (blk_len=320)
|
||||
*/
|
||||
int GsmHrCodec::decode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::DecodeResult GsmHrCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
ByteBuffer bb(input, inputBytes, ByteBuffer::CopyBehavior::UseExternal);
|
||||
ByteBuffer bb(input, ByteBuffer::CopyBehavior::UseExternal);
|
||||
BitReader br(bb);
|
||||
uint16_t hr_ref[22];
|
||||
|
||||
hr_ref_from_canon(hr_ref, (const uint8_t*)input + 1);
|
||||
hr_ref_from_canon(hr_ref, input.data() + 1);
|
||||
hr_ref[18] = 0; /* BFI : 1 bit */
|
||||
hr_ref[19] = 0; /* UFI : 1 bit */
|
||||
hr_ref[20] = 0; /* SID : 2 bit */
|
||||
hr_ref[21] = 0; /* TAF : 1 bit */
|
||||
|
||||
reinterpret_cast<GsmHr::Codec*>(mDecoder)->speechDecoder((int16_t*)hr_ref, (int16_t*)output);
|
||||
return 320;
|
||||
reinterpret_cast<GsmHr::Codec*>(mDecoder)->speechDecoder((int16_t*)hr_ref, (int16_t*)output.data());
|
||||
return {.mDecoded = 320};
|
||||
}
|
||||
|
||||
int GsmHrCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t GsmHrCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -52,12 +52,7 @@ public:
|
||||
G729Codec();
|
||||
~G729Codec() override;
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
int channels() override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
@@ -67,16 +62,19 @@ public:
|
||||
class OpusCodec: public Codec
|
||||
{
|
||||
protected:
|
||||
OpusEncoder *mEncoderCtx;
|
||||
OpusDecoder *mDecoderCtx;
|
||||
int mPTime, mSamplerate, mChannels;
|
||||
// Audio::SpeexResampler mDecodeResampler;
|
||||
int mDecoderChannels;
|
||||
OpusEncoder *mEncoderCtx = nullptr;
|
||||
OpusDecoder *mDecoderCtx = nullptr;
|
||||
int mPTime = 0, mSamplerate = 0, mChannels = 0;
|
||||
int mDecoderChannels = 0;
|
||||
public:
|
||||
struct Params
|
||||
{
|
||||
bool mUseDtx, mUseInbandFec, mStereo;
|
||||
int mPtime, mTargetBitrate, mExpectedPacketLoss;
|
||||
bool mUseDtx = false,
|
||||
mUseInbandFec = false,
|
||||
mStereo = false;
|
||||
int mPtime = 0,
|
||||
mTargetBitrate = 0,
|
||||
mExpectedPacketLoss = 0;
|
||||
|
||||
Params();
|
||||
resip::Data toString() const;
|
||||
@@ -103,29 +101,24 @@ public:
|
||||
PCodec create() override;
|
||||
};
|
||||
|
||||
OpusCodec(int samplerate, int channels, int ptime);
|
||||
OpusCodec(Audio::Format fmt, int ptime);
|
||||
~OpusCodec();
|
||||
void applyParams(const Params& params);
|
||||
|
||||
const char* name();
|
||||
int pcmLength();
|
||||
int rtpLength();
|
||||
int frameTime();
|
||||
int samplerate();
|
||||
int channels();
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output);
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output);
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output);
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
};
|
||||
|
||||
|
||||
class IlbcCodec: public Codec
|
||||
{
|
||||
protected:
|
||||
int mPacketTime; /// Single frame time (20 or 30 ms)
|
||||
iLBC_encinst_t* mEncoderCtx;
|
||||
iLBC_decinst_t* mDecoderCtx;
|
||||
int mPacketTime = 0; /// Single frame time (20 or 30 ms)
|
||||
iLBC_encinst_t* mEncoderCtx = nullptr;
|
||||
iLBC_decinst_t* mDecoderCtx = nullptr;
|
||||
|
||||
public:
|
||||
class IlbcFactory: public Factory
|
||||
@@ -148,11 +141,7 @@ public:
|
||||
|
||||
IlbcCodec(int packetTime);
|
||||
virtual ~IlbcCodec();
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
@@ -189,11 +178,7 @@ public:
|
||||
G711Codec(int type);
|
||||
~G711Codec();
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int frameTime() override;
|
||||
int rtpLength() override;
|
||||
int samplerate() override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
@@ -206,9 +191,9 @@ protected:
|
||||
class IsacCodec: public Codec
|
||||
{
|
||||
protected:
|
||||
int mSamplerate;
|
||||
ISACFIX_MainStruct* mEncoderCtx;
|
||||
ISACFIX_MainStruct* mDecoderCtx;
|
||||
int mSamplerate = 0;
|
||||
ISACFIX_MainStruct* mEncoderCtx = nullptr;
|
||||
ISACFIX_MainStruct* mDecoderCtx = nullptr;
|
||||
public:
|
||||
class IsacFactory16K: public Factory
|
||||
{
|
||||
@@ -240,11 +225,7 @@ public:
|
||||
IsacCodec(int sampleRate);
|
||||
~IsacCodec();
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
@@ -312,17 +293,13 @@ public:
|
||||
GsmCodec(Type codecType);
|
||||
|
||||
/*! Destructor. */
|
||||
virtual ~GsmCodec();
|
||||
~GsmCodec();
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
Info info() override;
|
||||
|
||||
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);
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
};
|
||||
|
||||
/// GSM MIME name
|
||||
@@ -361,25 +338,19 @@ public:
|
||||
PCodec create();
|
||||
};
|
||||
G722Codec();
|
||||
virtual ~G722Codec();
|
||||
~G722Codec();
|
||||
|
||||
const char* name();
|
||||
int pcmLength();
|
||||
int rtpLength();
|
||||
int frameTime();
|
||||
int samplerate();
|
||||
Info info() override;
|
||||
|
||||
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);
|
||||
|
||||
//unsigned GetSamplerate() { return 16000; }
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
};
|
||||
|
||||
class GsmHrCodec: public Codec
|
||||
{
|
||||
protected:
|
||||
void* mDecoder;
|
||||
void* mDecoder = nullptr;
|
||||
|
||||
public:
|
||||
class GsmHrFactory: public Factory
|
||||
@@ -399,15 +370,11 @@ public:
|
||||
GsmHrCodec();
|
||||
~GsmHrCodec() override;
|
||||
|
||||
const char* name() override;
|
||||
int pcmLength() override;
|
||||
int rtpLength() override;
|
||||
int frameTime() override;
|
||||
int samplerate() override;
|
||||
Info info() override;
|
||||
|
||||
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -396,12 +396,10 @@ size_t decode_packet(Codec& codec, RTPPacket& p, void* output_buffer, size_t out
|
||||
|
||||
for (int i=0; i < frame_count; i++)
|
||||
{
|
||||
auto decoded_length = codec.decode(p.GetPayloadData() + i * codec.rtpLength(),
|
||||
frame_length,
|
||||
output_buffer,
|
||||
output_capacity);
|
||||
auto r = codec.decode({p.GetPayloadData() + i * codec.rtpLength(), (size_t)frame_length},
|
||||
{(uint8_t*)output_buffer, output_capacity});
|
||||
|
||||
result += decoded_length;
|
||||
result += r.mDecoded;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -572,7 +570,7 @@ AudioReceiver::DecodeResult AudioReceiver::decodeGapTo(Audio::DataWindow& output
|
||||
mDecodedLength = 0;
|
||||
else
|
||||
{
|
||||
mDecodedLength = mCodec->plc(mFrameCount, mDecodedFrame, sizeof mDecodedFrame);
|
||||
mDecodedLength = mCodec->plc(mFrameCount, {(uint8_t*)mDecodedFrame, sizeof mDecodedFrame});
|
||||
if (!mDecodedLength)
|
||||
{
|
||||
// PLC is not support or failed
|
||||
@@ -587,7 +585,7 @@ AudioReceiver::DecodeResult AudioReceiver::decodeGapTo(Audio::DataWindow& output
|
||||
if (mDecodedLength)
|
||||
{
|
||||
processDecoded(output, options);
|
||||
return {.mStatus = DecodeResult::Status::Ok,.mChannels = mCodec->channels(), .mSamplerate = mCodec->samplerate()};
|
||||
return {.mStatus = DecodeResult::Status::Ok, .mSamplerate = mCodec->samplerate(), .mChannels = mCodec->channels()};
|
||||
}
|
||||
else
|
||||
return {.mStatus = DecodeResult::Status::Skip};
|
||||
@@ -683,9 +681,15 @@ AudioReceiver::DecodeResult AudioReceiver::decodePacketTo(Audio::DataWindow& out
|
||||
else
|
||||
{
|
||||
// Decode frame by frame
|
||||
mDecodedLength = mCodec->decode(rtp.GetPayloadData() + i * mCodec->rtpLength(), frameLength, mDecodedFrame, sizeof mDecodedFrame);
|
||||
auto r = mCodec->decode({rtp.GetPayloadData() + i * mCodec->rtpLength(), (size_t)frameLength},
|
||||
{(uint8_t*)mDecodedFrame, sizeof mDecodedFrame});
|
||||
mDecodedLength = r.mDecoded;
|
||||
if (mDecodedLength > 0)
|
||||
processDecoded(output, options);
|
||||
|
||||
// What is important - here we may have packet marked as CNG
|
||||
if (r.mIsCng)
|
||||
mCngPacket = packet;
|
||||
}
|
||||
}
|
||||
result.mStatus = mFrameCount > 0 ? DecodeResult::Status::Ok : DecodeResult::Status::Skip;
|
||||
@@ -705,14 +709,40 @@ AudioReceiver::DecodeResult AudioReceiver::decodePacketTo(Audio::DataWindow& out
|
||||
|
||||
AudioReceiver::DecodeResult AudioReceiver::decodeEmptyTo(Audio::DataWindow& output, DecodeOptions options)
|
||||
{
|
||||
// There are two cases
|
||||
// First is we have no ready time estimated how much audio should be emitted i.e. audio is decoded right after the next packet arrives.
|
||||
// In this case we just skip the analysis - we should not be called in this situation
|
||||
if (options.mElapsed == 0ms || !mCodec)
|
||||
return {.mStatus = DecodeResult::Status::Skip};
|
||||
|
||||
// No packet available at all (and no previous CNG packet) - so return the silence
|
||||
if (options.mElapsed != 0ms && mCodec)
|
||||
{
|
||||
Audio::Format fmt = options.mResampleToMainRate ? Audio::Format(AUDIO_SAMPLERATE, 1) : mCodec->getAudioFormat();
|
||||
if (mCngPacket)
|
||||
{
|
||||
// Try to decode it - replay previous audio decoded or use CNG decoder (if payload type is 13)
|
||||
if (mCngPacket->rtp()->GetPayloadType() == 13)
|
||||
{
|
||||
// Using latest CNG packet to produce comfort noise
|
||||
auto produced = mCngDecoder.produce(fmt.rate(), options.mElapsed.count(), (short*)(output.data() + output.filled()), false);
|
||||
output.setFilled(output.filled() + produced);
|
||||
return {.mStatus = DecodeResult::Status::Ok, .mSamplerate = fmt.rate(), .mChannels = fmt.channels()};
|
||||
}
|
||||
else
|
||||
{
|
||||
// Here we have another packet marked as CNG - for another decoder
|
||||
// Just decode it +1 time
|
||||
return decodePacketTo(output, options, mCngPacket);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Emit silence if codec information is available - it is to properly handle the gaps
|
||||
auto avail = output.getTimeLength(fmt.rate(), fmt.channels());
|
||||
if (options.mElapsed > avail)
|
||||
mAvailable.addZero(fmt.sizeFromTime(options.mElapsed - avail));
|
||||
output.addZero(fmt.sizeFromTime(options.mElapsed - avail));
|
||||
}
|
||||
}
|
||||
|
||||
mFailedCount++;
|
||||
@@ -871,11 +901,10 @@ void AudioReceiver::updateAmrCodecStats(Codec* c)
|
||||
int AudioReceiver::getSize() const
|
||||
{
|
||||
int result = 0;
|
||||
result += sizeof(*this) + mResampler8.getSize() + mResampler16.getSize() + mResampler32.getSize()
|
||||
+ mResampler48.getSize();
|
||||
result += sizeof(*this) + mResampler8.getSize() + mResampler16.getSize() + mResampler32.getSize() + mResampler48.getSize();
|
||||
|
||||
if (mCodec)
|
||||
result += mCodec->getSize();
|
||||
; // ToDo: need the way to calculate size of codec instances
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -210,18 +210,17 @@ void AudioStream::addData(const void* buffer, int bytes)
|
||||
if (mSendingDump)
|
||||
mSendingDump->write((const char*)mCapturedAudio.data() + codec->pcmLength() * i, codec->pcmLength());
|
||||
|
||||
int produced;
|
||||
produced = codec->encode((const char*)mCapturedAudio.data() + codec->pcmLength()*i,
|
||||
codec->pcmLength(), mFrameBuffer, MT_MAXAUDIOFRAME);
|
||||
auto r = codec->encode({(const uint8_t*)mCapturedAudio.data() + codec->pcmLength()*i, (size_t)codec->pcmLength()},
|
||||
{(uint8_t*)mFrameBuffer, MT_MAXAUDIOFRAME});
|
||||
|
||||
// Counter of processed input bytes of raw pcm data from microphone
|
||||
processed += codec->pcmLength();
|
||||
encodedTime += codec->frameTime();
|
||||
mEncodedTime += codec->frameTime();
|
||||
|
||||
if (produced)
|
||||
if (r.mEncoded)
|
||||
{
|
||||
mEncodedAudio.appendBuffer(mFrameBuffer, produced);
|
||||
mEncodedAudio.appendBuffer(mFrameBuffer, r.mEncoded);
|
||||
if (packetTime <= encodedTime)
|
||||
{
|
||||
// Time to send packet
|
||||
|
||||
@@ -23,6 +23,7 @@ class CodecMap: public std::map<int, PCodec>
|
||||
class Codec
|
||||
{
|
||||
public:
|
||||
|
||||
class Factory
|
||||
{
|
||||
public:
|
||||
@@ -41,21 +42,30 @@ public:
|
||||
resip::Codec resipCodec();
|
||||
};
|
||||
virtual ~Codec() {}
|
||||
virtual const char* name() = 0;
|
||||
virtual int samplerate() = 0;
|
||||
virtual float timestampUnit() { return float(1.0 / samplerate()); }
|
||||
|
||||
// Size of decoded audio frame in bytes
|
||||
virtual int pcmLength() = 0;
|
||||
struct Info
|
||||
{
|
||||
std::string mName;
|
||||
int mSamplerate = 0; // Hz
|
||||
int mChannels = 0;
|
||||
int mPcmLength = 0; // In bytes
|
||||
int mFrameTime = 0; // In milliseconds
|
||||
int mRtpLength = 0; // In bytes
|
||||
};
|
||||
// Returns information about this codec instance
|
||||
virtual Info info() = 0;
|
||||
|
||||
// Time length of single audio frame
|
||||
virtual int frameTime() = 0;
|
||||
// Helper functions to return information - they are based on info() method
|
||||
int pcmLength() { return info().mPcmLength; }
|
||||
int rtpLength() { return info().mRtpLength; }
|
||||
int channels() { return info().mChannels; }
|
||||
int samplerate() { return info().mSamplerate; }
|
||||
int frameTime() { return info().mFrameTime; }
|
||||
std::string name() { return info().mName; }
|
||||
|
||||
// Size of RTP frame in bytes. Can be zero for variable sized codecs.
|
||||
virtual int rtpLength() = 0;
|
||||
|
||||
// Number of audio channels
|
||||
virtual int channels() { return 1; }
|
||||
Audio::Format getAudioFormat() {
|
||||
return Audio::Format(this->info().mSamplerate, this->info().mChannels);
|
||||
}
|
||||
|
||||
// Returns size of encoded data (RTP) in bytes
|
||||
struct EncodeResult
|
||||
@@ -75,10 +85,6 @@ public:
|
||||
// Returns size of produced data (PCM signed short) in bytes
|
||||
virtual size_t plc(int lostFrames, std::span<uint8_t> output) = 0;
|
||||
|
||||
// Returns size of codec in memory
|
||||
virtual size_t getSize() const { return 0; };
|
||||
|
||||
virtual Audio::Format getAudioFormat() { return Audio::Format(this->samplerate(), this->channels());};
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "MT_EvsCodec.h"
|
||||
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
|
||||
/*-------------------------------------------------------------------*
|
||||
* rate2AMRWB_IOmode()
|
||||
@@ -167,67 +167,58 @@ EVSCodec::~EVSCodec()
|
||||
}
|
||||
}
|
||||
|
||||
int EVSCodec::samplerate()
|
||||
{
|
||||
return st_dec->output_Fs;
|
||||
Codec::Info EVSCodec::info() {
|
||||
return {
|
||||
.mName = MT_EVS_CODECNAME,
|
||||
.mSamplerate = st_dec->output_Fs,
|
||||
.mChannels = 1,
|
||||
.mPcmLength = st_dec->output_Fs / 1000 * sp.ptime * 2,
|
||||
.mFrameTime = sp.ptime,
|
||||
.mRtpLength = 0
|
||||
};
|
||||
}
|
||||
|
||||
int EVSCodec::pcmLength()
|
||||
{
|
||||
return samplerate() / 50 * 2;
|
||||
}
|
||||
|
||||
int EVSCodec::frameTime()
|
||||
{
|
||||
return sp.ptime;
|
||||
}
|
||||
|
||||
int EVSCodec::rtpLength()
|
||||
{
|
||||
// Variable sized codec - bitrate can be changed during the call
|
||||
return 0;
|
||||
}
|
||||
|
||||
int EVSCodec::encode(const void* input, int inputBytes, void* output, int outputCapacity)
|
||||
Codec::EncodeResult EVSCodec::encode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
// Encoding is not supported yet.
|
||||
return 0;
|
||||
return {.mEncoded = 0};
|
||||
}
|
||||
|
||||
int EVSCodec::decode(const void* input, int input_length, void* output, int outputCapacity)
|
||||
Codec::DecodeResult EVSCodec::decode(std::span<const uint8_t> input, std::span<uint8_t> output)
|
||||
{
|
||||
if (outputCapacity < pcmLength())
|
||||
return 0;
|
||||
if (output.size_bytes() < pcmLength())
|
||||
return {.mDecoded = 0};
|
||||
|
||||
std::string buffer;
|
||||
|
||||
// Check if we get payload with CMR
|
||||
auto payload_iter = FixedPayload_EVSPrimary.find((input_length - 2) * 8);
|
||||
auto payload_iter = FixedPayload_EVSPrimary.find((input.size_bytes() - 2) * 8);
|
||||
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||
{
|
||||
// Check if we get payload with ToC and without CMR
|
||||
payload_iter = FixedPayload_EVSPrimary.find((input_length - 1) * 8);
|
||||
payload_iter = FixedPayload_EVSPrimary.find((input.size_bytes() - 1) * 8);
|
||||
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||
{
|
||||
// Maybe there is no ToC ?
|
||||
payload_iter = FixedPayload_EVSPrimary.find(input_length * 8);
|
||||
payload_iter = FixedPayload_EVSPrimary.find(input.size_bytes() * 8);
|
||||
if (payload_iter == FixedPayload_EVSPrimary.end())
|
||||
{
|
||||
// Bad payload size at all
|
||||
return 0;
|
||||
return {.mDecoded = 0};
|
||||
}
|
||||
/* Add ToC byte.
|
||||
* WARNING maybe it will be work incorrect with 56bit payload,
|
||||
* see 3GPP TS 26.445 Annex A, A.2.1.3 */
|
||||
char c = evs::rate2EVSmode(FixedPayload_EVSPrimary.find(input_length * 8)->second);
|
||||
char c = evs::rate2EVSmode(FixedPayload_EVSPrimary.find(input.size_bytes() * 8)->second);
|
||||
buffer += c;
|
||||
buffer += std::string(reinterpret_cast<const char*>(input), input_length);
|
||||
buffer += std::string(reinterpret_cast<const char*>(input.data()), input.size_bytes());
|
||||
}
|
||||
else
|
||||
buffer = std::string(reinterpret_cast<const char*>(input), input_length);
|
||||
buffer = std::string(reinterpret_cast<const char*>(input.data()), input.size_bytes());
|
||||
}
|
||||
else // Skip CMR byte
|
||||
buffer = std::string(reinterpret_cast<const char*>(input) + 1, input_length-1);
|
||||
buffer = std::string(reinterpret_cast<const char*>(input.data()) + 1, input.size_bytes()-1);
|
||||
|
||||
|
||||
// Output buffer for 48 KHz
|
||||
@@ -263,7 +254,7 @@ int EVSCodec::decode(const void* input, int input_length, void* output, int outp
|
||||
}
|
||||
|
||||
/* convert 'float' output data to 'short' */
|
||||
evs::syn_output(data, static_cast<short>(pcmLength() / 2), static_cast<short*>(output) + offset);
|
||||
evs::syn_output(data, static_cast<short>(pcmLength() / 2), reinterpret_cast<short*>(output.data()) + offset);
|
||||
offset += pcmLength() / 2;
|
||||
if (st_dec->ini_frame < MAX_FRAME_COUNTER)
|
||||
{
|
||||
@@ -271,10 +262,10 @@ int EVSCodec::decode(const void* input, int input_length, void* output, int outp
|
||||
}
|
||||
}
|
||||
|
||||
return pcmLength();
|
||||
return {.mDecoded = (size_t)pcmLength()};
|
||||
}
|
||||
|
||||
int EVSCodec::plc(int lostFrames, void* output, int outputCapacity)
|
||||
size_t EVSCodec::plc(int lostFrames, std::span<uint8_t> output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,11 @@
|
||||
#define __MT_EVS_CODEC_H
|
||||
|
||||
#include "../engine_config.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "MT_Codec.h"
|
||||
|
||||
@@ -52,18 +48,14 @@ public:
|
||||
EVSCodec(const StreamParameters& sp);
|
||||
~EVSCodec() override;
|
||||
|
||||
const char* name() override { return MT_EVS_CODECNAME; }
|
||||
int samplerate() override;
|
||||
int pcmLength() override;
|
||||
int frameTime() override;
|
||||
int rtpLength() override;
|
||||
int encode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int decode(const void* input, int inputBytes, void* output, int outputCapacity) override;
|
||||
int plc(int lostFrames, void* output, int outputCapacity) override;
|
||||
Info info() override;
|
||||
|
||||
EncodeResult encode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
DecodeResult decode(std::span<const uint8_t> input, std::span<uint8_t> output) override;
|
||||
size_t plc(int lostFrames, std::span<uint8_t> output) override;
|
||||
|
||||
private:
|
||||
evs::Decoder_State* st_dec;
|
||||
//Encoder_State_fx* st_enc;
|
||||
evs::Decoder_State* st_dec = nullptr;
|
||||
StreamParameters sp;
|
||||
void initDecoder(const StreamParameters& sp);
|
||||
};
|
||||
|
||||
@@ -212,15 +212,13 @@ void SrtpSession::close()
|
||||
|
||||
SrtpKeySalt& SrtpSession::outgoingKey(SrtpSuite suite)
|
||||
{
|
||||
Lock l(mGuard);
|
||||
assert(suite > SRTP_NONE && suite <= SRTP_LAST);
|
||||
return mOutgoingKey[int(suite)-1];
|
||||
Lock l(mGuard);
|
||||
return mOutgoingKey[int(suite)-1]; // The automated review sometimes give the hints about the possible underflow array index access
|
||||
}
|
||||
|
||||
bool SrtpSession::protectRtp(void* buffer, int* length)
|
||||
{
|
||||
// addSsrc(RtpHelper::findSsrc(buffer, *length), sdOutgoing);
|
||||
|
||||
Lock l(mGuard);
|
||||
if (mOutboundSession)
|
||||
{
|
||||
|
||||
@@ -20,20 +20,17 @@
|
||||
|
||||
enum SrtpSuite
|
||||
{
|
||||
SRTP_NONE,
|
||||
SRTP_AES_128_AUTH_80,
|
||||
SRTP_AES_256_AUTH_80,
|
||||
SRTP_AES_192_AUTH_80,
|
||||
SRTP_AES_128_AUTH_32,
|
||||
SRTP_AES_256_AUTH_32,
|
||||
SRTP_AES_192_AUTH_32,
|
||||
SRTP_AES_128_AUTH_NULL,
|
||||
SRTP_AED_AES_256_GCM,
|
||||
SRTP_AED_AES_128_GCM,
|
||||
SRTP_NONE = 0,
|
||||
SRTP_AES_128_AUTH_80 = 1,
|
||||
SRTP_AES_256_AUTH_80 = 2,
|
||||
SRTP_AES_192_AUTH_80 = 3,
|
||||
SRTP_AES_128_AUTH_32 = 4,
|
||||
SRTP_AES_256_AUTH_32 = 5,
|
||||
SRTP_AES_192_AUTH_32 = 6,
|
||||
SRTP_AES_128_AUTH_NULL = 7,
|
||||
SRTP_AED_AES_256_GCM = 8,
|
||||
SRTP_AED_AES_128_GCM = 9,
|
||||
SRTP_LAST = SRTP_AED_AES_128_GCM
|
||||
// ToDo:
|
||||
// a=crypto:1 AEAD_AES_256_GCM_8 inline:tN2A0vRjFBimpQsW2GasuJuPe7hKE26gki30APC8DVuySqCOYTs8lYBPR5I=
|
||||
// a=crypto:3 AEAD_AES_128_GCM_8 inline:Ok7VL8SmBHSbZLw4dK6iQgpliYKGdY9BHLJcRw==
|
||||
};
|
||||
|
||||
extern SrtpSuite toSrtpSuite(const std::string_view& s);
|
||||
|
||||
Reference in New Issue
Block a user