OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 : clock_(clock), | 38 : clock_(clock), |
39 new_countinuous_frame_event_(false, false), | 39 new_countinuous_frame_event_(false, false), |
40 jitter_estimator_(jitter_estimator), | 40 jitter_estimator_(jitter_estimator), |
41 timing_(timing), | 41 timing_(timing), |
42 inter_frame_delay_(clock_->TimeInMilliseconds()), | 42 inter_frame_delay_(clock_->TimeInMilliseconds()), |
43 last_decoded_frame_it_(frames_.end()), | 43 last_decoded_frame_it_(frames_.end()), |
44 last_continuous_frame_it_(frames_.end()), | 44 last_continuous_frame_it_(frames_.end()), |
45 num_frames_history_(0), | 45 num_frames_history_(0), |
46 num_frames_buffered_(0), | 46 num_frames_buffered_(0), |
47 stopped_(false), | 47 stopped_(false), |
48 protection_mode_(kProtectionNack), | 48 protection_mode_(kProtectionNack) {} |
49 num_total_frames_(0), | |
50 num_key_frames_(0) {} | |
51 | 49 |
52 FrameBuffer::~FrameBuffer() { | 50 FrameBuffer::~FrameBuffer() { |
53 UpdateHistograms(); | 51 UpdateHistograms(); |
54 } | 52 } |
55 | 53 |
56 FrameBuffer::ReturnReason FrameBuffer::NextFrame( | 54 FrameBuffer::ReturnReason FrameBuffer::NextFrame( |
57 int64_t max_wait_time_ms, | 55 int64_t max_wait_time_ms, |
58 std::unique_ptr<FrameObject>* frame_out) { | 56 std::unique_ptr<FrameObject>* frame_out) { |
59 int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms; | 57 int64_t latest_return_time = clock_->TimeInMilliseconds() + max_wait_time_ms; |
60 int64_t wait_ms = max_wait_time_ms; | 58 int64_t wait_ms = max_wait_time_ms; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 int64_t frame_delay; | 124 int64_t frame_delay; |
127 if (inter_frame_delay_.CalculateDelay(timestamp, &frame_delay, | 125 if (inter_frame_delay_.CalculateDelay(timestamp, &frame_delay, |
128 received_time)) { | 126 received_time)) { |
129 jitter_estimator_->UpdateEstimate(frame_delay, frame->size()); | 127 jitter_estimator_->UpdateEstimate(frame_delay, frame->size()); |
130 } | 128 } |
131 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; | 129 float rtt_mult = protection_mode_ == kProtectionNackFEC ? 0.0 : 1.0; |
132 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); | 130 timing_->SetJitterDelay(jitter_estimator_->GetJitterEstimate(rtt_mult)); |
133 timing_->UpdateCurrentDelay(frame->RenderTime(), | 131 timing_->UpdateCurrentDelay(frame->RenderTime(), |
134 clock_->TimeInMilliseconds()); | 132 clock_->TimeInMilliseconds()); |
135 | 133 |
| 134 UpdateJitterDelay(); |
| 135 |
136 PropagateDecodability(next_frame_it->second); | 136 PropagateDecodability(next_frame_it->second); |
137 AdvanceLastDecodedFrame(next_frame_it); | 137 AdvanceLastDecodedFrame(next_frame_it); |
138 *frame_out = std::move(frame); | 138 *frame_out = std::move(frame); |
139 return kFrameFound; | 139 return kFrameFound; |
140 } else { | 140 } else { |
141 return kTimeout; | 141 return kTimeout; |
142 } | 142 } |
143 } | 143 } |
144 | 144 |
145 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { | 145 void FrameBuffer::SetProtectionMode(VCMVideoProtection mode) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 RTC_DCHECK_LE(ref_info->second.num_missing_continuous, | 357 RTC_DCHECK_LE(ref_info->second.num_missing_continuous, |
358 ref_info->second.num_missing_decodable); | 358 ref_info->second.num_missing_decodable); |
359 } | 359 } |
360 | 360 |
361 RTC_DCHECK_LE(info->second.num_missing_continuous, | 361 RTC_DCHECK_LE(info->second.num_missing_continuous, |
362 info->second.num_missing_decodable); | 362 info->second.num_missing_decodable); |
363 | 363 |
364 return true; | 364 return true; |
365 } | 365 } |
366 | 366 |
| 367 void FrameBuffer::UpdateJitterDelay() { |
| 368 int unused; |
| 369 int delay; |
| 370 timing_->GetTimings(&unused, &unused, &unused, &unused, &delay, &unused, |
| 371 &unused); |
| 372 |
| 373 accumulated_delay_ += delay; |
| 374 ++accumulated_delay_samples_; |
| 375 } |
| 376 |
367 void FrameBuffer::UpdateHistograms() const { | 377 void FrameBuffer::UpdateHistograms() const { |
368 rtc::CritScope lock(&crit_); | 378 rtc::CritScope lock(&crit_); |
369 if (num_total_frames_ > 0) { | 379 if (num_total_frames_ > 0) { |
370 int key_frames_permille = (static_cast<float>(num_key_frames_) * 1000.0f / | 380 int key_frames_permille = (static_cast<float>(num_key_frames_) * 1000.0f / |
371 static_cast<float>(num_total_frames_) + | 381 static_cast<float>(num_total_frames_) + |
372 0.5f); | 382 0.5f); |
373 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", | 383 RTC_HISTOGRAM_COUNTS_1000("WebRTC.Video.KeyFramesReceivedInPermille", |
374 key_frames_permille); | 384 key_frames_permille); |
375 } | 385 } |
| 386 |
| 387 if (accumulated_delay_samples_ > 0) { |
| 388 RTC_HISTOGRAM_COUNTS_10000("WebRTC.Video.JitterBufferDelayInMs", |
| 389 accumulated_delay_ / accumulated_delay_samples_); |
| 390 } |
376 } | 391 } |
377 | 392 |
378 } // namespace video_coding | 393 } // namespace video_coding |
379 } // namespace webrtc | 394 } // namespace webrtc |
OLD | NEW |