- better checks for RTP packet + enable EVS codec + improve thread pool
This commit is contained in:
parent
5ce85e3a09
commit
7510ff5697
|
|
@ -52,8 +52,12 @@ bool RtpHelper::isRtp(const void* buffer, size_t length)
|
|||
if (length < 12)
|
||||
return false;
|
||||
|
||||
unsigned char _type = reinterpret_cast<const RtpHeader*>(buffer)->pt;
|
||||
bool rtp = ( (_type & 0x7F) >= 96 && (_type & 0x7F) <= 127) || ((_type & 0x7F) < 35);
|
||||
const RtpHeader* h = reinterpret_cast<const RtpHeader*>(buffer);
|
||||
if (h->version != 0b10)
|
||||
return false;
|
||||
|
||||
unsigned char pt = h->pt;
|
||||
bool rtp = ( (pt & 0x7F) >= 96 && (pt & 0x7F) <= 127) || ((pt & 0x7F) < 35);
|
||||
return rtp;
|
||||
}
|
||||
|
||||
|
|
@ -62,9 +66,8 @@ bool RtpHelper::isRtpOrRtcp(const void* buffer, size_t length)
|
|||
{
|
||||
if (length < 12)
|
||||
return false;
|
||||
unsigned char b = ((const unsigned char*)buffer)[0];
|
||||
|
||||
return (b & 0xC0 ) == 128;
|
||||
const RtcpHeader* h = reinterpret_cast<const RtcpHeader*>(buffer);
|
||||
return h->version == 0b10;
|
||||
}
|
||||
|
||||
bool RtpHelper::isRtcp(const void* buffer, size_t length)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,11 @@ size_t thread_pool::size()
|
|||
return this->tasks.size();
|
||||
}
|
||||
|
||||
size_t thread_pool::threads()
|
||||
{
|
||||
return this->workers.size();
|
||||
}
|
||||
|
||||
// the destructor joins all threads
|
||||
thread_pool::~thread_pool()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ public:
|
|||
void enqueue(const task& task);
|
||||
void wait(std::chrono::milliseconds interval = std::chrono::milliseconds(50));
|
||||
size_t size();
|
||||
size_t threads();
|
||||
|
||||
private:
|
||||
// need to keep track of threads so we can join them
|
||||
std::vector< std::thread > workers;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright(C) 2007-2023 VoIPobjects (voipobjects.com)
|
||||
/* Copyright(C) 2007-2025 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/. */
|
||||
|
|
@ -172,14 +172,14 @@ CodecList::Settings::EvsSpec CodecList::Settings::EvsSpec::parse(const std::stri
|
|||
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;
|
||||
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;
|
||||
|
|
@ -243,33 +243,36 @@ CodecList::Settings CodecList::Settings::parseSdp(const std::list<resip::Codec>&
|
|||
r.mOpusSpec.push_back({ptype, samplerate, channels});
|
||||
}
|
||||
else
|
||||
if (codec_name == "AMR-WB")
|
||||
if (codec_name == "AMR-WB")
|
||||
{
|
||||
int octet_mode = findOctetMode(params.c_str());
|
||||
if (octet_mode != -1)
|
||||
{
|
||||
int octet_mode = findOctetMode(params.c_str());
|
||||
if (octet_mode != -1)
|
||||
{
|
||||
if (octet_mode == 0)
|
||||
r.mAmrWbPayloadType.insert(ptype);
|
||||
else
|
||||
if (octet_mode == 1)
|
||||
r.mAmrWbOctetPayloadType.insert(ptype);
|
||||
}
|
||||
// std::cout << "AMR-WB parameters: " << params.c_str() << ", found octet-mode: " << octet_mode << std::endl;
|
||||
if (octet_mode == 0)
|
||||
r.mAmrWbPayloadType.insert(ptype);
|
||||
else
|
||||
if (octet_mode == 1)
|
||||
r.mAmrWbOctetPayloadType.insert(ptype);
|
||||
}
|
||||
else
|
||||
if (codec_name == "AMR")
|
||||
{
|
||||
int octet_mode = findOctetMode(params.c_str());
|
||||
if (octet_mode != -1)
|
||||
{
|
||||
if (octet_mode == 0)
|
||||
r.mAmrWbPayloadType.insert(ptype);
|
||||
else
|
||||
if (octet_mode == 1)
|
||||
r.mAmrWbOctetPayloadType.insert(ptype);
|
||||
}
|
||||
// std::cout << "AMR parameters: " << params.c_str() << ", found octet-mode: " << octet_mode << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (codec_name == "AMR")
|
||||
{
|
||||
int octet_mode = findOctetMode(params.c_str());
|
||||
if (octet_mode != -1)
|
||||
{
|
||||
if (octet_mode == 0)
|
||||
r.mAmrWbPayloadType.insert(ptype);
|
||||
else
|
||||
if (octet_mode == 1)
|
||||
r.mAmrWbOctetPayloadType.insert(ptype);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (codec_name == "EVS")
|
||||
{
|
||||
r.mEvsSpec.push_back({ptype});
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public:
|
|||
Bandwidth_FB
|
||||
};
|
||||
|
||||
Bandwidth mBandwidth = Bandwidth_NB;
|
||||
Bandwidth mBandwidth = Bandwidth_FB;
|
||||
|
||||
enum Encoding
|
||||
{
|
||||
|
|
|
|||
|
|
@ -146,8 +146,7 @@ PCodec EVSCodec::EVSFactory::create()
|
|||
}
|
||||
|
||||
EVSCodec::EVSCodec(): EVSCodec(StreamParameters())
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
EVSCodec::EVSCodec(const StreamParameters &sp)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue