From e21be1db4c04d35f90a86ca2376862e58f026602 Mon Sep 17 00:00:00 2001 From: philipel Date: Mon, 25 Sep 2017 06:37:12 -0700 Subject: [PATCH] Reland of Fix the video buffer size should take rtt into consideration (patchset #2 id:160001 of https://codereview.chromium.org/3002033002/ ) Reason for revert: Fixes has landed. Original issue's description: > Revert of Fix the video buffer size should take rtt into consideration (patchset #3 id:40001 of https://codereview.chromium.org/2980413002/ ) > > Reason for revert: > We are not certain this is the behavior we want. > > Original issue's description: > > Fix the video buffer size should take rtt into consideration > > > > BUG=webrtc:8010 > > > > Review-Url: https://codereview.webrtc.org/2980413002 > > Cr-Commit-Position: refs/heads/master@{#19285} > > Committed: https://chromium.googlesource.com/external/webrtc/+/f1e08d0b5848d32fd31c5b6e4e570115c32b7ce5 > > TBR=sprang@webrtc.org,gustavogb@gmail.com > # Not skipping CQ checks because original CL landed more than 1 days ago. > BUG=webrtc:8010 > > Review-Url: https://codereview.webrtc.org/3002033002 > Cr-Commit-Position: refs/heads/master@{#19442} > Committed: https://chromium.googlesource.com/external/webrtc/+/bdbc8895f3a630a4fe28d4661d8e71877ecaf14d TBR=sprang@webrtc.org,gustavogb@gmail.com # Not skipping CQ checks because original CL landed more than 1 days ago. BUG=webrtc:8010 Review-Url: https://codereview.webrtc.org/3016633002 Cr-Commit-Position: refs/heads/master@{#19944} --- AUTHORS | 1 + modules/video_coding/frame_buffer2.cc | 7 +++++++ modules/video_coding/frame_buffer2.h | 3 +++ video/video_receive_stream.cc | 6 ++++++ video/video_receive_stream.h | 6 +++++- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index ed702b6b6..3bf6671fb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -61,6 +61,7 @@ Agora IO <*@agora.io> ARM Holdings <*@arm.com> BroadSoft Inc. <*@broadsoft.com> Google Inc. <*@google.com> +Life On Air Inc. <*@lifeonair.com> Intel Corporation <*@intel.com> MIPS Technologies <*@mips.com> Mozilla Foundation <*@mozilla.com> diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index 50c3763dc..b4bb00280 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -147,6 +147,8 @@ FrameBuffer::ReturnReason FrameBuffer::NextFrame( float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); timing_->UpdateCurrentDelay(frame->RenderTime(), now_ms); + } else { + jitter_estimator_->FrameNacked(); } // Gracefully handle bad RTP timestamps and render time issues. @@ -247,6 +249,11 @@ void FrameBuffer::Stop() { new_continuous_frame_event_.Set(); } +void FrameBuffer::UpdateRtt(int64_t rtt_ms) { + rtc::CritScope lock(&crit_); + jitter_estimator_->UpdateRtt(rtt_ms); +} + bool FrameBuffer::ValidReferences(const FrameObject& frame) const { if (frame.picture_id < 0) return false; diff --git a/modules/video_coding/frame_buffer2.h b/modules/video_coding/frame_buffer2.h index 32eba8a3c..e502666a8 100644 --- a/modules/video_coding/frame_buffer2.h +++ b/modules/video_coding/frame_buffer2.h @@ -74,6 +74,9 @@ class FrameBuffer { // return immediately. void Stop(); + // Updates the RTT for jitter buffer estimation. + void UpdateRtt(int64_t rtt_ms); + private: struct FrameKey { FrameKey() : picture_id(-1), spatial_layer(0) {} diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index 1db768940..36905913f 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -176,6 +176,7 @@ void VideoReceiveStream::Start() { frame_buffer_->Start(); call_stats_->RegisterStatsObserver(&rtp_video_stream_receiver_); + call_stats_->RegisterStatsObserver(this); if (rtp_video_stream_receiver_.IsRetransmissionsEnabled() && protected_by_fec) { @@ -225,6 +226,7 @@ void VideoReceiveStream::Stop() { rtp_video_stream_receiver_.StopReceive(); frame_buffer_->Stop(); + call_stats_->DeregisterStatsObserver(this); call_stats_->DeregisterStatsObserver(&rtp_video_stream_receiver_); process_thread_->DeRegisterModule(&video_receiver_); @@ -347,6 +349,10 @@ void VideoReceiveStream::OnCompleteFrame( rtp_video_stream_receiver_.FrameContinuous(last_continuous_pid); } +void VideoReceiveStream::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { + frame_buffer_->UpdateRtt(max_rtt_ms); +} + int VideoReceiveStream::id() const { RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_sequence_checker_); return config_.rtp.remote_ssrc; diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index 7a4a13e47..b2eaa5e2e 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -50,7 +50,8 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, public NackSender, public KeyFrameRequestSender, public video_coding::OnCompleteFrameCallback, - public Syncable { + public Syncable, + public CallStatsObserver { public: VideoReceiveStream(RtpStreamReceiverControllerInterface* receiver_controller, int num_cpu_cores, @@ -103,6 +104,9 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, void OnCompleteFrame( std::unique_ptr frame) override; + // Implements CallStatsObserver::OnRttUpdate + void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override; + // Implements Syncable. int id() const override; rtc::Optional GetInfo() const override;