Use timestamp instead of seq_num to distinguish between packets.
In the case a frame_object is kept for some time before it is deleted, it may happend that a new frame is received with overlapping sequence numbers. If the old frame_object is removed while receiving the new frame there used to be a crash. Bug: webrtc:9629 Change-Id: I270a8caa2b58b73c000542aa504c0ebe277d49c4 Reviewed-on: https://webrtc-review.googlesource.com/102683 Reviewed-by: Philip Eliasson <philipel@webrtc.org> Commit-Queue: Johannes Kron <kron@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24914}
This commit is contained in:

committed by
Commit Bot

parent
147013a60f
commit
957c62e0d6
@ -398,8 +398,12 @@ void PacketBuffer::ReturnFrame(RtpFrameObject* frame) {
|
||||
size_t index = frame->first_seq_num() % size_;
|
||||
size_t end = (frame->last_seq_num() + 1) % size_;
|
||||
uint16_t seq_num = frame->first_seq_num();
|
||||
uint32_t timestamp = frame->Timestamp();
|
||||
while (index != end) {
|
||||
if (sequence_buffer_[index].seq_num == seq_num) {
|
||||
// Check both seq_num and timestamp to handle the case when seq_num wraps
|
||||
// around too quickly for high packet rates.
|
||||
if (sequence_buffer_[index].seq_num == seq_num &&
|
||||
data_buffer_[index].timestamp == timestamp) {
|
||||
delete[] data_buffer_[index].dataPtr;
|
||||
data_buffer_[index].dataPtr = nullptr;
|
||||
sequence_buffer_[index].used = false;
|
||||
@ -417,11 +421,15 @@ bool PacketBuffer::GetBitstream(const RtpFrameObject& frame,
|
||||
size_t index = frame.first_seq_num() % size_;
|
||||
size_t end = (frame.last_seq_num() + 1) % size_;
|
||||
uint16_t seq_num = frame.first_seq_num();
|
||||
uint32_t timestamp = frame.Timestamp();
|
||||
uint8_t* destination_end = destination + frame.size();
|
||||
|
||||
do {
|
||||
// Check both seq_num and timestamp to handle the case when seq_num wraps
|
||||
// around too quickly for high packet rates.
|
||||
if (!sequence_buffer_[index].used ||
|
||||
sequence_buffer_[index].seq_num != seq_num) {
|
||||
sequence_buffer_[index].seq_num != seq_num ||
|
||||
data_buffer_[index].timestamp != timestamp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user