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}
This commit is contained in:
Sebastian Jansson
2018-02-01 13:00:57 +01:00
committed by Commit Bot
parent 10d9d59db1
commit 56fa050125

View File

@ -893,6 +893,9 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
test_generic_packetization_(test_generic_packetization), test_generic_packetization_(test_generic_packetization),
use_fec_(use_fec), use_fec_(use_fec),
packet_count_(0), packet_count_(0),
packets_lost_(0),
last_packet_count_(0),
last_packets_lost_(0),
accumulated_size_(0), accumulated_size_(0),
accumulated_payload_(0), accumulated_payload_(0),
fec_packet_received_(false), fec_packet_received_(false),
@ -984,11 +987,18 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
void TriggerLossReport(const RTPHeader& header) { void TriggerLossReport(const RTPHeader& header) {
// Send lossy receive reports to trigger FEC enabling. // Send lossy receive reports to trigger FEC enabling.
const int kLossPercent = 5; 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( FakeReceiveStatistics lossy_receive_stats(
kVideoSendSsrcs[0], header.sequenceNumber, kVideoSendSsrcs[0], header.sequenceNumber,
(packet_count_ * (100 - kLossPercent)) / 100, // Cumulative lost. packets_lost_, // Cumulative lost.
static_cast<uint8_t>((255 * kLossPercent) / 100)); // Loss percent. loss_ratio); // Loss percent.
RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(), RTCPSender rtcp_sender(false, Clock::GetRealTimeClock(),
&lossy_receive_stats, nullptr, nullptr, &lossy_receive_stats, nullptr, nullptr,
transport_adapter_.get(), RtcpIntervalConfig{}); transport_adapter_.get(), RtcpIntervalConfig{});
@ -1085,6 +1095,9 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
const bool use_fec_; const bool use_fec_;
uint32_t packet_count_; 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_size_;
size_t accumulated_payload_; size_t accumulated_payload_;
bool fec_packet_received_; bool fec_packet_received_;