Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: webrtc/modules/video_coding/timing.cc

Issue 2007743003: Add sender controlled playout delay limits (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@cleanup_rtp_hdr_extensions
Patch Set: Addressed comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 10 matching lines...) Expand all
21 namespace webrtc { 21 namespace webrtc {
22 22
23 VCMTiming::VCMTiming(Clock* clock, VCMTiming* master_timing) 23 VCMTiming::VCMTiming(Clock* clock, VCMTiming* master_timing)
24 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 24 : crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
25 clock_(clock), 25 clock_(clock),
26 master_(false), 26 master_(false),
27 ts_extrapolator_(), 27 ts_extrapolator_(),
28 codec_timer_(new VCMCodecTimer()), 28 codec_timer_(new VCMCodecTimer()),
29 render_delay_ms_(kDefaultRenderDelayMs), 29 render_delay_ms_(kDefaultRenderDelayMs),
30 min_playout_delay_ms_(0), 30 min_playout_delay_ms_(0),
31 max_playout_delay_ms_(10000),
31 jitter_delay_ms_(0), 32 jitter_delay_ms_(0),
32 current_delay_ms_(0), 33 current_delay_ms_(0),
33 last_decode_ms_(0), 34 last_decode_ms_(0),
34 prev_frame_timestamp_(0), 35 prev_frame_timestamp_(0),
35 num_decoded_frames_(0), 36 num_decoded_frames_(0),
36 num_delayed_decoded_frames_(0), 37 num_delayed_decoded_frames_(0),
37 first_decoded_frame_ms_(-1), 38 first_decoded_frame_ms_(-1),
38 sum_missed_render_deadline_ms_(0) { 39 sum_missed_render_deadline_ms_(0) {
39 if (master_timing == NULL) { 40 if (master_timing == NULL) {
40 master_ = true; 41 master_ = true;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void VCMTiming::set_render_delay(uint32_t render_delay_ms) { 95 void VCMTiming::set_render_delay(uint32_t render_delay_ms) {
95 CriticalSectionScoped cs(crit_sect_); 96 CriticalSectionScoped cs(crit_sect_);
96 render_delay_ms_ = render_delay_ms; 97 render_delay_ms_ = render_delay_ms;
97 } 98 }
98 99
99 void VCMTiming::set_min_playout_delay(uint32_t min_playout_delay_ms) { 100 void VCMTiming::set_min_playout_delay(uint32_t min_playout_delay_ms) {
100 CriticalSectionScoped cs(crit_sect_); 101 CriticalSectionScoped cs(crit_sect_);
101 min_playout_delay_ms_ = min_playout_delay_ms; 102 min_playout_delay_ms_ = min_playout_delay_ms;
102 } 103 }
103 104
105 uint32_t VCMTiming::min_playout_delay() {
106 CriticalSectionScoped cs(crit_sect_);
107 return min_playout_delay_ms_;
108 }
109
110 void VCMTiming::set_max_playout_delay(uint32_t max_playout_delay_ms) {
111 CriticalSectionScoped cs(crit_sect_);
112 max_playout_delay_ms_ = max_playout_delay_ms;
113 }
114
115 uint32_t VCMTiming::max_playout_delay() {
116 CriticalSectionScoped cs(crit_sect_);
117 return max_playout_delay_ms_;
118 }
119
104 void VCMTiming::SetJitterDelay(uint32_t jitter_delay_ms) { 120 void VCMTiming::SetJitterDelay(uint32_t jitter_delay_ms) {
105 CriticalSectionScoped cs(crit_sect_); 121 CriticalSectionScoped cs(crit_sect_);
106 if (jitter_delay_ms != jitter_delay_ms_) { 122 if (jitter_delay_ms != jitter_delay_ms_) {
107 jitter_delay_ms_ = jitter_delay_ms; 123 jitter_delay_ms_ = jitter_delay_ms;
108 // When in initial state, set current delay to minimum delay. 124 // When in initial state, set current delay to minimum delay.
109 if (current_delay_ms_ == 0) { 125 if (current_delay_ms_ == 0) {
110 current_delay_ms_ = jitter_delay_ms_; 126 current_delay_ms_ = jitter_delay_ms_;
111 } 127 }
112 } 128 }
113 } 129 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 } 220 }
205 221
206 int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp, 222 int64_t VCMTiming::RenderTimeMsInternal(uint32_t frame_timestamp,
207 int64_t now_ms) const { 223 int64_t now_ms) const {
208 int64_t estimated_complete_time_ms = 224 int64_t estimated_complete_time_ms =
209 ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp); 225 ts_extrapolator_->ExtrapolateLocalTime(frame_timestamp);
210 if (estimated_complete_time_ms == -1) { 226 if (estimated_complete_time_ms == -1) {
211 estimated_complete_time_ms = now_ms; 227 estimated_complete_time_ms = now_ms;
212 } 228 }
213 229
214 // Make sure that we have at least the playout delay. 230 if (min_playout_delay_ms_ == 0 && max_playout_delay_ms_ == 0) {
231 // Render as soon as possible
232 return now_ms;
233 }
234
235 // Make sure the actual delay stays in the range of |min_playout_delay_ms_|
236 // and |max_playout_delay_ms_|.
215 uint32_t actual_delay = std::max(current_delay_ms_, min_playout_delay_ms_); 237 uint32_t actual_delay = std::max(current_delay_ms_, min_playout_delay_ms_);
238 actual_delay = std::min(actual_delay, max_playout_delay_ms_);
216 return estimated_complete_time_ms + actual_delay; 239 return estimated_complete_time_ms + actual_delay;
217 } 240 }
218 241
219 // Must be called from inside a critical section. 242 // Must be called from inside a critical section.
220 int64_t VCMTiming::RequiredDecodeTimeMs() const { 243 int64_t VCMTiming::RequiredDecodeTimeMs() const {
221 const int64_t decode_time_ms = codec_timer_->RequiredDecodeTimeMs(); 244 const int64_t decode_time_ms = codec_timer_->RequiredDecodeTimeMs();
222 assert(decode_time_ms >= 0); 245 assert(decode_time_ms >= 0);
223 return decode_time_ms; 246 return decode_time_ms;
224 } 247 }
225 248
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 *decode_ms = last_decode_ms_; 300 *decode_ms = last_decode_ms_;
278 *max_decode_ms = static_cast<int>(RequiredDecodeTimeMs()); 301 *max_decode_ms = static_cast<int>(RequiredDecodeTimeMs());
279 *current_delay_ms = current_delay_ms_; 302 *current_delay_ms = current_delay_ms_;
280 *target_delay_ms = TargetDelayInternal(); 303 *target_delay_ms = TargetDelayInternal();
281 *jitter_buffer_ms = jitter_delay_ms_; 304 *jitter_buffer_ms = jitter_delay_ms_;
282 *min_playout_delay_ms = min_playout_delay_ms_; 305 *min_playout_delay_ms = min_playout_delay_ms_;
283 *render_delay_ms = render_delay_ms_; 306 *render_delay_ms = render_delay_ms_;
284 } 307 }
285 308
286 } // namespace webrtc 309 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698