Speeding up CallTest.ReceivesAndRetransmitsNack and removed the random packet loss.
R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/6119004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5315 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8ae72560dd
commit
1fa41be66a
@ -143,16 +143,16 @@ class CallTest : public ::testing::Test {
|
|||||||
};
|
};
|
||||||
|
|
||||||
class NackObserver : public test::RtpRtcpObserver {
|
class NackObserver : public test::RtpRtcpObserver {
|
||||||
static const int kNumberOfNacksToObserve = 4;
|
static const int kNumberOfNacksToObserve = 2;
|
||||||
static const int kInverseProbabilityToStartLossBurst = 20;
|
static const int kLossBurstSize = 2;
|
||||||
static const int kMaxLossBurst = 10;
|
static const int kPacketsBetweenLossBursts = 9;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NackObserver()
|
NackObserver()
|
||||||
: test::RtpRtcpObserver(kLongTimeoutMs),
|
: test::RtpRtcpObserver(kLongTimeoutMs),
|
||||||
rtp_parser_(RtpHeaderParser::Create()),
|
rtp_parser_(RtpHeaderParser::Create()),
|
||||||
drop_burst_count_(0),
|
|
||||||
sent_rtp_packets_(0),
|
sent_rtp_packets_(0),
|
||||||
|
packets_left_to_drop_(0),
|
||||||
nacks_left_(kNumberOfNacksToObserve) {}
|
nacks_left_(kNumberOfNacksToObserve) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -166,31 +166,29 @@ class NackObserver : public test::RtpRtcpObserver {
|
|||||||
if (dropped_packets_.find(header.sequenceNumber) !=
|
if (dropped_packets_.find(header.sequenceNumber) !=
|
||||||
dropped_packets_.end()) {
|
dropped_packets_.end()) {
|
||||||
retransmitted_packets_.insert(header.sequenceNumber);
|
retransmitted_packets_.insert(header.sequenceNumber);
|
||||||
|
if (nacks_left_ == 0 &&
|
||||||
|
retransmitted_packets_.size() == dropped_packets_.size()) {
|
||||||
|
observation_complete_->Set();
|
||||||
|
}
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++sent_rtp_packets_;
|
||||||
|
|
||||||
// Enough NACKs received, stop dropping packets.
|
// Enough NACKs received, stop dropping packets.
|
||||||
if (nacks_left_ == 0) {
|
if (nacks_left_ == 0)
|
||||||
++sent_rtp_packets_;
|
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
}
|
|
||||||
|
|
||||||
// Still dropping packets.
|
// Check if it's time for a new loss burst.
|
||||||
if (drop_burst_count_ > 0) {
|
if (sent_rtp_packets_ % kPacketsBetweenLossBursts == 0)
|
||||||
--drop_burst_count_;
|
packets_left_to_drop_ = kLossBurstSize;
|
||||||
|
|
||||||
|
if (packets_left_to_drop_ > 0) {
|
||||||
|
--packets_left_to_drop_;
|
||||||
dropped_packets_.insert(header.sequenceNumber);
|
dropped_packets_.insert(header.sequenceNumber);
|
||||||
return DROP_PACKET;
|
return DROP_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should we start dropping packets?
|
|
||||||
if (sent_rtp_packets_ > 0 &&
|
|
||||||
rand() % kInverseProbabilityToStartLossBurst == 0) {
|
|
||||||
drop_burst_count_ = rand() % kMaxLossBurst;
|
|
||||||
dropped_packets_.insert(header.sequenceNumber);
|
|
||||||
return DROP_PACKET;
|
|
||||||
}
|
|
||||||
|
|
||||||
++sent_rtp_packets_;
|
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,50 +196,24 @@ class NackObserver : public test::RtpRtcpObserver {
|
|||||||
RTCPUtility::RTCPParserV2 parser(packet, length, true);
|
RTCPUtility::RTCPParserV2 parser(packet, length, true);
|
||||||
EXPECT_TRUE(parser.IsValid());
|
EXPECT_TRUE(parser.IsValid());
|
||||||
|
|
||||||
bool received_nack = false;
|
|
||||||
RTCPUtility::RTCPPacketTypes packet_type = parser.Begin();
|
RTCPUtility::RTCPPacketTypes packet_type = parser.Begin();
|
||||||
while (packet_type != RTCPUtility::kRtcpNotValidCode) {
|
while (packet_type != RTCPUtility::kRtcpNotValidCode) {
|
||||||
if (packet_type == RTCPUtility::kRtcpRtpfbNackCode)
|
if (packet_type == RTCPUtility::kRtcpRtpfbNackCode) {
|
||||||
received_nack = true;
|
--nacks_left_;
|
||||||
|
break;
|
||||||
packet_type = parser.Iterate();
|
|
||||||
}
|
}
|
||||||
|
packet_type = parser.Iterate();
|
||||||
if (received_nack) {
|
|
||||||
ReceivedNack();
|
|
||||||
} else {
|
|
||||||
RtcpWithoutNack();
|
|
||||||
}
|
}
|
||||||
return SEND_PACKET;
|
return SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ReceivedNack() {
|
|
||||||
if (nacks_left_ > 0)
|
|
||||||
--nacks_left_;
|
|
||||||
rtcp_without_nack_count_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RtcpWithoutNack() {
|
|
||||||
if (nacks_left_ > 0)
|
|
||||||
return;
|
|
||||||
++rtcp_without_nack_count_;
|
|
||||||
|
|
||||||
// All packets retransmitted and no recent NACKs.
|
|
||||||
if (dropped_packets_.size() == retransmitted_packets_.size() &&
|
|
||||||
rtcp_without_nack_count_ >= kRequiredRtcpsWithoutNack) {
|
|
||||||
observation_complete_->Set();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scoped_ptr<RtpHeaderParser> rtp_parser_;
|
scoped_ptr<RtpHeaderParser> rtp_parser_;
|
||||||
std::set<uint16_t> dropped_packets_;
|
std::set<uint16_t> dropped_packets_;
|
||||||
std::set<uint16_t> retransmitted_packets_;
|
std::set<uint16_t> retransmitted_packets_;
|
||||||
int drop_burst_count_;
|
|
||||||
uint64_t sent_rtp_packets_;
|
uint64_t sent_rtp_packets_;
|
||||||
|
int packets_left_to_drop_;
|
||||||
int nacks_left_;
|
int nacks_left_;
|
||||||
int rtcp_without_nack_count_;
|
|
||||||
static const int kRequiredRtcpsWithoutNack = 2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(CallTest, UsesTraceCallback) {
|
TEST_F(CallTest, UsesTraceCallback) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user