Use the RTT from RtcpRttStats class if provided when sending/receiving NACK.

R=holmer@google.com

Review URL: https://webrtc-codereview.appspot.com/5049004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@5228 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
asapersson@webrtc.org 2013-12-05 15:06:56 +00:00
parent ebad765ee0
commit 96a9b2dcdc
3 changed files with 20 additions and 7 deletions

View File

@ -1135,10 +1135,13 @@ int32_t ModuleRtpRtcpImpl::SendNACK(const uint16_t* nack_list,
id_, id_,
"SendNACK(size:%u)", size); "SendNACK(size:%u)", size);
uint16_t avg_rtt = 0; // Use RTT from RtcpRttStats class if provided.
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &avg_rtt, NULL, NULL); uint16_t rtt = rtt_ms();
if (rtt == 0) {
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL);
}
int64_t wait_time = 5 + ((avg_rtt * 3) >> 1); // 5 + RTT * 1.5. int64_t wait_time = 5 + ((rtt * 3) >> 1); // 5 + RTT * 1.5.
if (wait_time == 5) { if (wait_time == 5) {
wait_time = 100; // During startup we don't have an RTT. wait_time = 100; // During startup we don't have an RTT.
} }
@ -1597,9 +1600,12 @@ void ModuleRtpRtcpImpl::OnReceivedNACK(
nack_sequence_numbers.size() == 0) { nack_sequence_numbers.size() == 0) {
return; return;
} }
uint16_t avg_rtt = 0; // Use RTT from RtcpRttStats class if provided.
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &avg_rtt, NULL, NULL); uint16_t rtt = rtt_ms();
rtp_sender_.OnReceivedNACK(nack_sequence_numbers, avg_rtt); if (rtt == 0) {
rtcp_receiver_.RTT(rtcp_receiver_.RemoteSSRC(), NULL, &rtt, NULL, NULL);
}
rtp_sender_.OnReceivedNACK(nack_sequence_numbers, rtt);
} }
int32_t ModuleRtpRtcpImpl::LastReceivedNTP( int32_t ModuleRtpRtcpImpl::LastReceivedNTP(

View File

@ -405,6 +405,7 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
Clock* clock_; Clock* clock_;
private: private:
FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, Rtt);
FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, RttForReceiverOnly); FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, RttForReceiverOnly);
int64_t RtcpReportInterval(); int64_t RtcpReportInterval();
void SetRtcpReceiverSsrcs(uint32_t main_ssrc); void SetRtcpReceiverSsrcs(uint32_t main_ssrc);

View File

@ -122,6 +122,13 @@ TEST_F(RtpRtcpImplTest, Rtt) {
// No RTT from other ssrc. // No RTT from other ssrc.
EXPECT_EQ(-1, EXPECT_EQ(-1,
rtp_rtcp_impl_->RTT(kSsrc + 1, &rtt, &avg_rtt, &min_rtt, &max_rtt)); rtp_rtcp_impl_->RTT(kSsrc + 1, &rtt, &avg_rtt, &min_rtt, &max_rtt));
// Verify RTT from rtt_stats config.
EXPECT_EQ(0U, rtt_stats_.LastProcessedRtt());
EXPECT_EQ(0U, rtp_rtcp_impl_->rtt_ms());
rtp_rtcp_impl_->Process();
EXPECT_EQ(100U, rtt_stats_.LastProcessedRtt());
EXPECT_EQ(100U, rtp_rtcp_impl_->rtt_ms());
} }
TEST_F(RtpRtcpImplTest, SetRtcpXrRrtrStatus) { TEST_F(RtpRtcpImplTest, SetRtcpXrRrtrStatus) {
@ -147,7 +154,6 @@ TEST_F(RtpRtcpImplTest, RttForReceiverOnly) {
// Verify RTT. // Verify RTT.
EXPECT_EQ(0U, rtt_stats_.LastProcessedRtt()); EXPECT_EQ(0U, rtt_stats_.LastProcessedRtt());
EXPECT_EQ(0U, rtp_rtcp_impl_->rtt_ms()); EXPECT_EQ(0U, rtp_rtcp_impl_->rtt_ms());
rtp_rtcp_impl_->Process(); rtp_rtcp_impl_->Process();
EXPECT_EQ(100U, rtt_stats_.LastProcessedRtt()); EXPECT_EQ(100U, rtt_stats_.LastProcessedRtt());
EXPECT_EQ(100U, rtp_rtcp_impl_->rtt_ms()); EXPECT_EQ(100U, rtp_rtcp_impl_->rtt_ms());