Skip to content

Commit

Permalink
bugfix: Fix seqnum overflow handling in rtcp::PacketCounter
Browse files Browse the repository at this point in the history
  • Loading branch information
gavv authored and jeshwanthreddy13 committed Aug 6, 2024
1 parent 44cba89 commit d525f03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/internal_modules/roc_rtcp/packet_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ uint64_t PacketCounter::update(const uint32_t begin, const uint32_t end) {
// Update end.
if (int32_t(end - end64_lo_) > 0) {
if (end < end64_lo_) {
end64_hi_ += (uint32_t)-1;
end64_hi_ += (uint64_t)1 << 32;
}
end64_lo_ = end;
}
Expand Down
8 changes: 4 additions & 4 deletions src/tests/roc_rtcp/test_packet_counter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ TEST(packet_counter, wrap) {

UNSIGNED_LONGS_EQUAL(10, pc.update(0xFFFFFFFF - 30, 0xFFFFFFFF - 20));
UNSIGNED_LONGS_EQUAL(20, pc.update(0xFFFFFFFF - 30, 0xFFFFFFFF - 10));
UNSIGNED_LONGS_EQUAL(40, pc.update(0xFFFFFFFF - 30, 10));
UNSIGNED_LONGS_EQUAL(60, pc.update(0xFFFFFFFF - 30, 30));
UNSIGNED_LONGS_EQUAL(60, pc.update(0xFFFFFFFF - 30, 20));
UNSIGNED_LONGS_EQUAL(70, pc.update(0xFFFFFFFF - 30, 40));
UNSIGNED_LONGS_EQUAL(41, pc.update(0xFFFFFFFF - 30, 10));
UNSIGNED_LONGS_EQUAL(61, pc.update(0xFFFFFFFF - 30, 30));
UNSIGNED_LONGS_EQUAL(61, pc.update(0xFFFFFFFF - 30, 20));
UNSIGNED_LONGS_EQUAL(71, pc.update(0xFFFFFFFF - 30, 40));

UNSIGNED_LONGS_EQUAL(10, pc.update(10, 20));
}
Expand Down

0 comments on commit d525f03

Please sign in to comment.