- better checks for RTP packet + enable EVS codec + improve thread pool

This commit is contained in:
2025-02-03 11:51:11 +03:00
parent 5ce85e3a09
commit 7510ff5697
6 changed files with 54 additions and 42 deletions

View File

@@ -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)

View File

@@ -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()
{

View File

@@ -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;