提交 8721a713 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

RtpStreamSend: refactor new buffer design to use less memory

上级 0025c89a
......@@ -19,19 +19,18 @@ namespace RTC
};
public:
struct BufferItem
{
RTC::RtpPacket* packet{ nullptr };
uint64_t resentAtTime{ 0 }; // Last time this packet was resent.
uint8_t sentTimes{ 0 }; // Number of times this packet was resent.
bool rtxEncoded{ false }; // Whether the packet has already been RTX encoded.
};
private:
struct StorageItem
{
// Allow some more space for RTX encoding.
uint8_t store[RTC::MtuSize + 200];
// Cloned packet.
RTC::RtpPacket* packet{ nullptr };
// Memory to hold the cloned packet (with extra space for RTX encoding).
uint8_t store[RTC::MtuSize + 100];
// Last time this packet was resent.
uint64_t resentAtTime{ 0 };
// Number of times this packet was resent.
uint8_t sentTimes{ 0 };
// Whether the packet has been already RTX encoded.
bool rtxEncoded{ false };
};
public:
......@@ -55,16 +54,16 @@ namespace RTC
private:
void StorePacket(RTC::RtpPacket* packet);
void ResetBufferItem(BufferItem& bufferItem);
void ClearBuffer();
void ResetStorageItem(StorageItem* storateItem);
void UpdateBufferStartIdx();
void ClearRetransmissionBuffer();
void FillRetransmissionContainer(uint16_t seq, uint16_t bitmask);
void UpdateScore(RTC::RTCP::ReceiverReport* report);
private:
uint32_t lostPrior{ 0 }; // Packets lost at last interval.
uint32_t sentPrior{ 0 }; // Packets sent at last interval.
std::vector<BufferItem> buffer;
std::vector<StorageItem*> buffer;
uint16_t bufferStartIdx{ 0 };
size_t bufferSize{ 0 };
std::vector<StorageItem> storage;
......@@ -86,19 +85,6 @@ namespace RTC
{
return this->transmissionCounter.GetBitrate(now);
}
inline void RtpStreamSend::ResetBufferItem(BufferItem& bufferItem)
{
if (!bufferItem.packet)
return;
delete bufferItem.packet;
bufferItem.packet = nullptr;
bufferItem.resentAtTime = 0;
bufferItem.sentTimes = 0;
bufferItem.rtxEncoded = false;
}
} // namespace RTC
#endif
......@@ -413,7 +413,7 @@ namespace RTC
}
// Create a RtpStreamSend for sending a single media stream.
size_t bufferSize = params.useNack ? 1500 : 0;
size_t bufferSize = params.useNack ? 600 : 0;
this->rtpStream = new RTC::RtpStreamSend(this, params, bufferSize);
this->rtpStreams.push_back(this->rtpStream);
......
......@@ -895,7 +895,7 @@ namespace RTC
}
// Create a RtpStreamSend for sending a single media stream.
size_t bufferSize = params.useNack ? 1500 : 0;
size_t bufferSize = params.useNack ? 600 : 0;
this->rtpStream = new RTC::RtpStreamSend(this, params, bufferSize);
this->rtpStreams.push_back(this->rtpStream);
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论