Add possibility to get the last processed RTT from the call stats class (to be used by RTP/RTCP module).
R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2383004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5139 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -39,7 +39,7 @@ RtpRtcp::Configuration::Configuration()
|
||||
rtcp_feedback(NULL),
|
||||
intra_frame_callback(NULL),
|
||||
bandwidth_callback(NULL),
|
||||
rtt_observer(NULL),
|
||||
rtt_stats(NULL),
|
||||
audio_messages(NullObjectRtpAudioFeedback()),
|
||||
remote_bitrate_estimator(NULL),
|
||||
paced_sender(NULL) {
|
||||
@ -92,7 +92,9 @@ ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Configuration& configuration)
|
||||
#ifdef MATLAB
|
||||
, plot1_(NULL),
|
||||
#endif
|
||||
rtt_observer_(configuration.rtt_observer) {
|
||||
rtt_stats_(configuration.rtt_stats),
|
||||
critical_section_rtt_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
rtt_ms_(0) {
|
||||
send_video_codec_.codecType = kVideoCodecUnknown;
|
||||
|
||||
if (default_module_) {
|
||||
@ -212,8 +214,8 @@ int32_t ModuleRtpRtcpImpl::Process() {
|
||||
max_rtt = (rtt > max_rtt) ? rtt : max_rtt;
|
||||
}
|
||||
// Report the rtt.
|
||||
if (rtt_observer_ && max_rtt != 0)
|
||||
rtt_observer_->OnRttUpdate(max_rtt);
|
||||
if (rtt_stats_ && max_rtt != 0)
|
||||
rtt_stats_->OnRttUpdate(max_rtt);
|
||||
}
|
||||
|
||||
// Verify receiver reports are delivered and the reported sequence number
|
||||
@ -240,14 +242,18 @@ int32_t ModuleRtpRtcpImpl::Process() {
|
||||
// Report rtt from receiver.
|
||||
if (process_rtt) {
|
||||
uint16_t rtt_ms;
|
||||
if (rtt_observer_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
|
||||
rtt_observer_->OnRttUpdate(rtt_ms);
|
||||
if (rtt_stats_ && rtcp_receiver_.GetAndResetXrRrRtt(&rtt_ms)) {
|
||||
rtt_stats_->OnRttUpdate(rtt_ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get processed rtt.
|
||||
if (process_rtt) {
|
||||
last_rtt_process_time_ = now;
|
||||
if (rtt_stats_) {
|
||||
set_rtt_ms(rtt_stats_->LastProcessedRtt());
|
||||
}
|
||||
}
|
||||
|
||||
if (rtcp_sender_.TimeToSendRTCPReport()) {
|
||||
@ -1623,4 +1629,14 @@ void ModuleRtpRtcpImpl::SetRtcpReceiverSsrcs(uint32_t main_ssrc) {
|
||||
rtcp_receiver_.SetSsrcs(main_ssrc, ssrcs);
|
||||
}
|
||||
|
||||
void ModuleRtpRtcpImpl::set_rtt_ms(uint32_t rtt_ms) {
|
||||
CriticalSectionScoped cs(critical_section_rtt_.get());
|
||||
rtt_ms_ = rtt_ms;
|
||||
}
|
||||
|
||||
uint32_t ModuleRtpRtcpImpl::rtt_ms() const {
|
||||
CriticalSectionScoped cs(critical_section_rtt_.get());
|
||||
return rtt_ms_;
|
||||
}
|
||||
|
||||
} // Namespace webrtc
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_sender.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_sender.h"
|
||||
#include "webrtc/system_wrappers/interface/scoped_ptr.h"
|
||||
#include "webrtc/test/testsupport/gtest_prod_util.h"
|
||||
|
||||
#ifdef MATLAB
|
||||
class MatlabPlot;
|
||||
@ -383,9 +384,13 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
Clock* clock_;
|
||||
|
||||
private:
|
||||
FRIEND_TEST_ALL_PREFIXES(RtpRtcpImplTest, RttForReceiverOnly);
|
||||
int64_t RtcpReportInterval();
|
||||
void SetRtcpReceiverSsrcs(uint32_t main_ssrc);
|
||||
|
||||
void set_rtt_ms(uint32_t rtt_ms);
|
||||
uint32_t rtt_ms() const;
|
||||
|
||||
int32_t id_;
|
||||
const bool audio_;
|
||||
bool collision_detected_;
|
||||
@ -414,7 +419,11 @@ class ModuleRtpRtcpImpl : public RtpRtcp {
|
||||
MatlabPlot* plot1_;
|
||||
#endif
|
||||
|
||||
RtcpRttObserver* rtt_observer_;
|
||||
RtcpRttStats* rtt_stats_;
|
||||
|
||||
// The processed RTT from RtcpRttStats.
|
||||
scoped_ptr<CriticalSectionWrapper> critical_section_rtt_;
|
||||
uint32_t rtt_ms_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
class RtcpRttStatsTestImpl : public RtcpRttObserver {
|
||||
class RtcpRttStatsTestImpl : public RtcpRttStats {
|
||||
public:
|
||||
RtcpRttStatsTestImpl() : rtt_ms_(0) {}
|
||||
virtual ~RtcpRttStatsTestImpl() {}
|
||||
@ -26,6 +26,9 @@ class RtcpRttStatsTestImpl : public RtcpRttObserver {
|
||||
virtual void OnRttUpdate(uint32_t rtt_ms) {
|
||||
rtt_ms_ = rtt_ms;
|
||||
}
|
||||
virtual uint32_t LastProcessedRtt() const {
|
||||
return rtt_ms_;
|
||||
}
|
||||
uint32_t rtt_ms_;
|
||||
};
|
||||
|
||||
@ -70,7 +73,7 @@ class RtpRtcpImplTest : public ::testing::Test {
|
||||
configuration.clock = &clock_;
|
||||
configuration.outgoing_transport = &transport_;
|
||||
configuration.receive_statistics = receive_statistics_.get();
|
||||
configuration.rtt_observer = &rtt_stats_;
|
||||
configuration.rtt_stats = &rtt_stats_;
|
||||
|
||||
rtp_rtcp_impl_.reset(new ModuleRtpRtcpImpl(configuration));
|
||||
transport_.SetRtpRtcpModule(rtp_rtcp_impl_.get());
|
||||
@ -136,10 +139,12 @@ TEST_F(RtpRtcpImplTest, RttForReceiverOnly) {
|
||||
EXPECT_EQ(0, rtp_rtcp_impl_->SendRTCP(kRtcpReport));
|
||||
|
||||
// Verify RTT.
|
||||
EXPECT_EQ(0U, rtt_stats_.rtt_ms_);
|
||||
EXPECT_EQ(0U, rtt_stats_.LastProcessedRtt());
|
||||
EXPECT_EQ(0U, rtp_rtcp_impl_->rtt_ms());
|
||||
|
||||
rtp_rtcp_impl_->Process();
|
||||
EXPECT_EQ(100U, rtt_stats_.rtt_ms_);
|
||||
EXPECT_EQ(100U, rtt_stats_.LastProcessedRtt());
|
||||
EXPECT_EQ(100U, rtp_rtcp_impl_->rtt_ms());
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user