Improved accuracy of packet loss calculation in tests.
Test of packet loss used a simplified calculation of lost packets and
loss ratio. Changed the calculation to be more accurate. This protects
against triggering for future implementations with more precise
calculations.
Bug: webrtc:8415
Change-Id: I721dc83954e8738fdf8ea729dee4cc8b8c8fa091
Reviewed-on: https://webrtc-review.googlesource.com/46740
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21845}
diff --git a/video/video_send_stream_tests.cc b/video/video_send_stream_tests.cc
index d5226bf..3512b85 100644
--- a/video/video_send_stream_tests.cc
+++ b/video/video_send_stream_tests.cc
@@ -893,6 +893,9 @@
test_generic_packetization_(test_generic_packetization),
use_fec_(use_fec),
packet_count_(0),
+ packets_lost_(0),
+ last_packet_count_(0),
+ last_packets_lost_(0),
accumulated_size_(0),
accumulated_payload_(0),
fec_packet_received_(false),
@@ -984,11 +987,18 @@
void TriggerLossReport(const RTPHeader& header) {
// Send lossy receive reports to trigger FEC enabling.
const int kLossPercent = 5;
- if (packet_count_++ % (100 / kLossPercent) != 0) {
+ if (++packet_count_ % (100 / kLossPercent) == 0) {
+ packets_lost_++;
+ int loss_delta = packets_lost_ - last_packets_lost_;
+ int packets_delta = packet_count_ - last_packet_count_;
+ last_packet_count_ = packet_count_;
+ last_packets_lost_ = packets_lost_;
+ uint8_t loss_ratio =
+ static_cast<uint8_t>(loss_delta * 255 / packets_delta);
FakeReceiveStatistics lossy_receive_stats(
kVideoSendSsrcs[0], header.sequenceNumber,
- (packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost.
- static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent.
+ packets_lost_, // Cumulative lost.
+ loss_ratio); // Loss percent.
RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(),
&lossy_receive_stats, nullptr, nullptr,
transport_adapter_.get(), RtcpIntervalConfig{});
@@ -1085,6 +1095,9 @@
const bool use_fec_;
uint32_t packet_count_;
+ uint32_t packets_lost_;
+ uint32_t last_packet_count_;
+ uint32_t last_packets_lost_;
size_t accumulated_size_;
size_t accumulated_payload_;
bool fec_packet_received_;