提交 e37dad53 authored 作者: Nazar Mokrynskyi's avatar Nazar Mokrynskyi

Change buffer in producer to be static and shared across instances

上级 914c5058
......@@ -196,7 +196,8 @@ namespace RTC
bool videoOrientationDetected{ false };
struct VideoOrientation videoOrientation;
struct TraceEventTypes traceEventTypes;
uint8_t* buffer{ nullptr };
// Static buffer.
thread_local static uint8_t* buffer;
};
} // namespace RTC
......
......@@ -18,6 +18,10 @@
namespace RTC
{
/* Static variables. */
thread_local uint8_t* Producer::buffer{ nullptr };
/* Static. */
static constexpr unsigned int SendNackDelay{ 10u }; // In ms.
......@@ -332,8 +336,6 @@ namespace RTC
// Delete the KeyFrameRequestManager.
delete this->keyFrameRequestManager;
delete[] this->buffer;
}
void Producer::FillJson(json& jsonObject) const
......@@ -629,13 +631,13 @@ namespace RTC
}
// If this is the first time to receive a RTP packet then allocate the receiving buffer now.
if (!this->buffer)
this->buffer = new uint8_t[RTC::MtuSize + 100];
if (!Producer::buffer)
Producer::buffer = new uint8_t[RTC::MtuSize + 100];
// Copy the received packet into this buffer so it can be expanded later.
std::memcpy(this->buffer, data, static_cast<size_t>(len));
std::memcpy(Producer::buffer, data, static_cast<size_t>(len));
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(this->buffer, len);
RTC::RtpPacket* packet = RTC::RtpPacket::Parse(Producer::buffer, len);
if (!packet)
{
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论