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}
diff --git a/modules/video_coding/packet_buffer.cc b/modules/video_coding/packet_buffer.cc
index fe93fb3..552de4d 100644
--- a/modules/video_coding/packet_buffer.cc
+++ b/modules/video_coding/packet_buffer.cc
@@ -398,8 +398,12 @@
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 @@
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;
}