From 9fd8d87ff5268aa905bc0292da1559879b36b047 Mon Sep 17 00:00:00 2001 From: "jiayl@webrtc.org" Date: Thu, 27 Feb 2014 22:32:40 +0000 Subject: [PATCH] Adds APIs for reporting pacer queuing delay. BUG=2775 R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/8959005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5621 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/modules/pacing/include/paced_sender.h | 1 + .../modules/pacing/paced_sender_unittest.cc | 3 ++- webrtc/video_engine/include/vie_rtp_rtcp.h | 7 +++++++ webrtc/video_engine/vie_encoder.cc | 4 ++++ webrtc/video_engine/vie_encoder.h | 1 + webrtc/video_engine/vie_rtp_rtcp_impl.cc | 19 +++++++++++++++++++ webrtc/video_engine/vie_rtp_rtcp_impl.h | 2 ++ 7 files changed, 36 insertions(+), 1 deletion(-) diff --git a/webrtc/modules/pacing/include/paced_sender.h b/webrtc/modules/pacing/include/paced_sender.h index 045469009..45c89b77e 100644 --- a/webrtc/modules/pacing/include/paced_sender.h +++ b/webrtc/modules/pacing/include/paced_sender.h @@ -49,6 +49,7 @@ class PacedSender : public Module { bool retransmission) = 0; // Called when it's a good time to send a padding data. virtual int TimeToSendPadding(int bytes) = 0; + protected: virtual ~Callback() {} }; diff --git a/webrtc/modules/pacing/paced_sender_unittest.cc b/webrtc/modules/pacing/paced_sender_unittest.cc index f8dcdfc69..a99101db3 100644 --- a/webrtc/modules/pacing/paced_sender_unittest.cc +++ b/webrtc/modules/pacing/paced_sender_unittest.cc @@ -421,7 +421,8 @@ TEST_F(PacedSenderTest, Pause) { EXPECT_EQ(0, send_bucket_->TimeUntilNextProcess()); EXPECT_EQ(0, send_bucket_->Process()); - EXPECT_CALL(callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) + EXPECT_CALL( + callback_, TimeToSendPacket(_, _, second_capture_time_ms, false)) .Times(1) .WillRepeatedly(Return(true)); EXPECT_EQ(5, send_bucket_->TimeUntilNextProcess()); diff --git a/webrtc/video_engine/include/vie_rtp_rtcp.h b/webrtc/video_engine/include/vie_rtp_rtcp.h index c76d2bb28..a358e480e 100644 --- a/webrtc/video_engine/include/vie_rtp_rtcp.h +++ b/webrtc/video_engine/include/vie_rtp_rtcp.h @@ -405,6 +405,13 @@ class WEBRTC_DLLEXPORT ViERTP_RTCP { const int video_channel, ReceiveBandwidthEstimatorStats* output) const { return -1; } + // This function gets the PacedSender queuing delay for the last sent frame. + // TODO(jiayl): remove the default impl when libjingle is updated. + virtual int GetPacerQueuingDelayMs( + const int video_channel, int* delay_ms) const { + return -1; + } + // This function enables capturing of RTP packets to a binary file on a // specific channel and for a given direction. The file can later be // replayed using e.g. RTP Tools rtpplay since the binary file format is diff --git a/webrtc/video_engine/vie_encoder.cc b/webrtc/video_engine/vie_encoder.cc index 6be935063..dae1c1a54 100644 --- a/webrtc/video_engine/vie_encoder.cc +++ b/webrtc/video_engine/vie_encoder.cc @@ -734,6 +734,10 @@ int32_t ViEEncoder::SendCodecStatistics( return 0; } +int32_t ViEEncoder::PacerQueuingDelayMs() const { + return paced_sender_->QueueInMs(); +} + int32_t ViEEncoder::EstimatedSendBandwidth( uint32_t* available_bandwidth) const { WEBRTC_TRACE(kTraceInfo, kTraceVideo, ViEId(engine_id_, channel_id_), "%s", diff --git a/webrtc/video_engine/vie_encoder.h b/webrtc/video_engine/vie_encoder.h index 24bd72023..d3271c313 100644 --- a/webrtc/video_engine/vie_encoder.h +++ b/webrtc/video_engine/vie_encoder.h @@ -109,6 +109,7 @@ class ViEEncoder int32_t SendCodecStatistics(uint32_t* num_key_frames, uint32_t* num_delta_frames); + int PacerQueuingDelayMs() const; int32_t EstimatedSendBandwidth( uint32_t* available_bandwidth) const; diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.cc b/webrtc/video_engine/vie_rtp_rtcp_impl.cc index 627c53085..54afa93c8 100644 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.cc +++ b/webrtc/video_engine/vie_rtp_rtcp_impl.cc @@ -1040,6 +1040,25 @@ int ViERTP_RTCPImpl::GetReceiveBandwidthEstimatorStats( return 0; } +int ViERTP_RTCPImpl::GetPacerQueuingDelayMs( + const int video_channel, int* delay_ms) const { + WEBRTC_TRACE(kTraceApiCall, kTraceVideo, + ViEId(shared_data_->instance_id(), video_channel), + "%s(channel: %d)", __FUNCTION__, video_channel); + ViEChannelManagerScoped cs(*(shared_data_->channel_manager())); + ViEEncoder* vie_encoder = cs.Encoder(video_channel); + if (!vie_encoder) { + WEBRTC_TRACE(kTraceError, kTraceVideo, + ViEId(shared_data_->instance_id(), video_channel), + "%s: Could not get encoder for channel %d", __FUNCTION__, + video_channel); + shared_data_->SetLastError(kViERtpRtcpInvalidChannelId); + return -1; + } + *delay_ms = vie_encoder->PacerQueuingDelayMs(); + return 0; +} + int ViERTP_RTCPImpl::StartRTPDump(const int video_channel, const char file_nameUTF8[1024], RTPDirections direction) { diff --git a/webrtc/video_engine/vie_rtp_rtcp_impl.h b/webrtc/video_engine/vie_rtp_rtcp_impl.h index 0341d74c1..227fa5e4e 100644 --- a/webrtc/video_engine/vie_rtp_rtcp_impl.h +++ b/webrtc/video_engine/vie_rtp_rtcp_impl.h @@ -116,6 +116,8 @@ class ViERTP_RTCPImpl unsigned int* estimated_bandwidth) const; virtual int GetReceiveBandwidthEstimatorStats( const int video_channel, ReceiveBandwidthEstimatorStats* output) const; + virtual int GetPacerQueuingDelayMs(const int video_channel, + int* delay_ms) const; virtual int StartRTPDump(const int video_channel, const char file_nameUTF8[1024], RTPDirections direction);