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}
This commit is contained in:
gustavogb
2017-08-09 05:43:08 -07:00
committed by Commit Bot
parent 5ca60cc91c
commit f1e08d0b58
5 changed files with 22 additions and 1 deletions

View File

@ -61,6 +61,7 @@ Agora IO <*@agora.io>
ARM Holdings <*@arm.com> ARM Holdings <*@arm.com>
BroadSoft Inc. <*@broadsoft.com> BroadSoft Inc. <*@broadsoft.com>
Google Inc. <*@google.com> Google Inc. <*@google.com>
Life On Air Inc. <*@lifeonair.com>
Intel Corporation <*@intel.com> Intel Corporation <*@intel.com>
MIPS Technologies <*@mips.com> MIPS Technologies <*@mips.com>
Mozilla Foundation <*@mozilla.com> Mozilla Foundation <*@mozilla.com>

View File

@ -147,6 +147,8 @@ FrameBuffer::ReturnReason FrameBuffer::NextFrame(
float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0;
timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult));
timing_->UpdateCurrentDelay(frame->RenderTime(), now_ms); timing_->UpdateCurrentDelay(frame->RenderTime(), now_ms);
} else {
jitter_estimator_->FrameNacked();
} }
// Gracefully handle bad RTP timestamps and render time issues. // Gracefully handle bad RTP timestamps and render time issues.
@ -247,6 +249,11 @@ void FrameBuffer::Stop() {
new_continuous_frame_event_.Set(); 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 { bool FrameBuffer::ValidReferences(const FrameObject& frame) const {
for (size_t i = 0; i < frame.num_references; ++i) { for (size_t i = 0; i < frame.num_references; ++i) {
if (AheadOrAt(frame.references[i], frame.picture_id)) if (AheadOrAt(frame.references[i], frame.picture_id))

View File

@ -74,6 +74,9 @@ class FrameBuffer {
// return immediately. // return immediately.
void Stop(); void Stop();
// Updates the RTT for jitter buffer estimation.
void UpdateRtt(int64_t rtt_ms);
private: private:
struct FrameKey { struct FrameKey {
FrameKey() : picture_id(0), spatial_layer(0) {} FrameKey() : picture_id(0), spatial_layer(0) {}

View File

@ -267,6 +267,7 @@ void VideoReceiveStream::Start() {
frame_buffer_->Start(); frame_buffer_->Start();
call_stats_->RegisterStatsObserver(&rtp_video_stream_receiver_); call_stats_->RegisterStatsObserver(&rtp_video_stream_receiver_);
call_stats_->RegisterStatsObserver(this);
if (rtp_video_stream_receiver_.IsRetransmissionsEnabled() && if (rtp_video_stream_receiver_.IsRetransmissionsEnabled() &&
protected_by_fec) { protected_by_fec) {
@ -316,6 +317,7 @@ void VideoReceiveStream::Stop() {
rtp_video_stream_receiver_.StopReceive(); rtp_video_stream_receiver_.StopReceive();
frame_buffer_->Stop(); frame_buffer_->Stop();
call_stats_->DeregisterStatsObserver(this);
call_stats_->DeregisterStatsObserver(&rtp_video_stream_receiver_); call_stats_->DeregisterStatsObserver(&rtp_video_stream_receiver_);
process_thread_->DeRegisterModule(&video_receiver_); process_thread_->DeRegisterModule(&video_receiver_);
@ -443,6 +445,10 @@ void VideoReceiveStream::OnCompleteFrame(
rtp_video_stream_receiver_.FrameContinuous(last_continuous_pid); 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 { int VideoReceiveStream::id() const {
RTC_DCHECK_RUN_ON(&worker_thread_checker_); RTC_DCHECK_RUN_ON(&worker_thread_checker_);
return config_.rtp.remote_ssrc; return config_.rtp.remote_ssrc;

View File

@ -49,7 +49,8 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
public NackSender, public NackSender,
public KeyFrameRequestSender, public KeyFrameRequestSender,
public video_coding::OnCompleteFrameCallback, public video_coding::OnCompleteFrameCallback,
public Syncable { public Syncable,
public CallStatsObserver {
public: public:
VideoReceiveStream(RtpStreamReceiverControllerInterface* receiver_controller, VideoReceiveStream(RtpStreamReceiverControllerInterface* receiver_controller,
int num_cpu_cores, int num_cpu_cores,
@ -104,6 +105,9 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream,
void OnCompleteFrame( void OnCompleteFrame(
std::unique_ptr<video_coding::FrameObject> frame) override; std::unique_ptr<video_coding::FrameObject> frame) override;
// Implements CallStatsObserver::OnRttUpdate
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
// Implements Syncable. // Implements Syncable.
int id() const override; int id() const override;
rtc::Optional<Syncable::Info> GetInfo() const override; rtc::Optional<Syncable::Info> GetInfo() const override;