1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 20:01:56 +00:00

RTC: Fix bug for wrap exists buffer size

This commit is contained in:
winlin 2021-02-28 17:36:03 +08:00
parent b91d37b78a
commit ee9ef378f9

View file

@ -866,6 +866,9 @@ bool SrsRtpPacket2::recycle()
char* SrsRtpPacket2::wrap(int size) char* SrsRtpPacket2::wrap(int size)
{ {
// The buffer size is larger or equals to the size of packet.
actual_buffer_size_ = size;
// If the buffer is large enough, reuse it. // If the buffer is large enough, reuse it.
if (shared_buffer && shared_buffer->size >= size) { if (shared_buffer && shared_buffer->size >= size) {
return shared_buffer->payload; return shared_buffer->payload;
@ -875,8 +878,6 @@ char* SrsRtpPacket2::wrap(int size)
while (true) { while (true) {
srs_freep(shared_buffer); srs_freep(shared_buffer);
shared_buffer = _srs_rtp_msg_cache_buffers->allocate(); shared_buffer = _srs_rtp_msg_cache_buffers->allocate();
// The buffer size is larger or equals to the size of packet.
actual_buffer_size_ = size;
// If got a cached message(which has payload), but it's too small, // If got a cached message(which has payload), but it's too small,
// we free it and allocate a larger one. // we free it and allocate a larger one.