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