mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #307, reuse raw cache payload for RTP
This commit is contained in:
parent
d906ced5c3
commit
d5c514cdcb
3 changed files with 26 additions and 2 deletions
|
@ -146,11 +146,19 @@ SrsRtpPacket2::SrsRtpPacket2()
|
|||
{
|
||||
payload = NULL;
|
||||
padding = 0;
|
||||
|
||||
cache_raw = new SrsRtpRawPayload();
|
||||
}
|
||||
|
||||
SrsRtpPacket2::~SrsRtpPacket2()
|
||||
{
|
||||
// We may use the cache as payload.
|
||||
if (payload == cache_raw) {
|
||||
payload = NULL;
|
||||
}
|
||||
|
||||
srs_freep(payload);
|
||||
srs_freep(cache_raw);
|
||||
}
|
||||
|
||||
void SrsRtpPacket2::set_padding(int size)
|
||||
|
@ -163,9 +171,21 @@ void SrsRtpPacket2::reset()
|
|||
{
|
||||
rtp_header.reset();
|
||||
padding = 0;
|
||||
|
||||
// We may use the cache as payload.
|
||||
if (payload == cache_raw) {
|
||||
payload = NULL;
|
||||
}
|
||||
|
||||
srs_freep(payload);
|
||||
}
|
||||
|
||||
SrsRtpRawPayload* SrsRtpPacket2::reuse_raw()
|
||||
{
|
||||
payload = cache_raw;
|
||||
return cache_raw;
|
||||
}
|
||||
|
||||
int SrsRtpPacket2::nb_bytes()
|
||||
{
|
||||
return rtp_header.header_size() + (payload? payload->nb_bytes():0) + padding;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue