1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Perf: Refine the recycle RTP packet, user should reset it

This commit is contained in:
winlin 2021-02-27 22:09:06 +08:00
parent b71cafea58
commit 8de201b635
4 changed files with 27 additions and 8 deletions

View file

@ -866,6 +866,21 @@ SrsRtpPacket2::~SrsRtpPacket2()
recycle_shared_msg();
}
void SrsRtpPacket2::reset()
{
nalu_type = SrsAvcNaluTypeReserved;
frame_type = SrsFrameTypeReserved;
cached_payload_size = 0;
decode_handler = NULL;
// It's important to reset the header.
header.reset();
// Recyle the payload again, to ensure the packet is new one.
recycle_payload();
recycle_shared_msg();
}
void SrsRtpPacket2::recycle_payload()
{
if (!payload_) {
@ -916,16 +931,10 @@ cleanup:
bool SrsRtpPacket2::recycle()
{
nalu_type = SrsAvcNaluTypeReserved;
frame_type = SrsFrameTypeReserved;
cached_payload_size = 0;
decode_handler = NULL;
header.reset();
// We only recycle the payload and shared messages,
// for header and fields, user will reset or copy it.
recycle_payload();
recycle_shared_msg();
return true;
}