OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void VCMReceiver::TriggerDecoderShutdown() { | 137 void VCMReceiver::TriggerDecoderShutdown() { |
138 jitter_buffer_.Stop(); | 138 jitter_buffer_.Stop(); |
139 render_wait_event_->Set(); | 139 render_wait_event_->Set(); |
140 } | 140 } |
141 | 141 |
142 VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, | 142 VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, |
143 int64_t* next_render_time_ms, | 143 int64_t* next_render_time_ms, |
144 bool prefer_late_decoding) { | 144 bool prefer_late_decoding) { |
145 const int64_t start_time_ms = clock_->TimeInMilliseconds(); | 145 const int64_t start_time_ms = clock_->TimeInMilliseconds(); |
146 uint32_t frame_timestamp = 0; | 146 uint32_t frame_timestamp = 0; |
| 147 int min_playout_delay_ms = -1; |
| 148 int max_playout_delay_ms = -1; |
147 // Exhaust wait time to get a complete frame for decoding. | 149 // Exhaust wait time to get a complete frame for decoding. |
148 bool found_frame = | 150 VCMEncodedFrame* found_frame = |
149 jitter_buffer_.NextCompleteTimestamp(max_wait_time_ms, &frame_timestamp); | 151 jitter_buffer_.NextCompleteFrame(max_wait_time_ms); |
150 | 152 |
151 if (!found_frame) | 153 if (found_frame) { |
152 found_frame = jitter_buffer_.NextMaybeIncompleteTimestamp(&frame_timestamp); | 154 frame_timestamp = found_frame->TimeStamp(); |
| 155 min_playout_delay_ms = found_frame->EncodedImage().playout_delay_.min_ms; |
| 156 max_playout_delay_ms = found_frame->EncodedImage().playout_delay_.max_ms; |
| 157 } else { |
| 158 if (!jitter_buffer_.NextMaybeIncompleteTimestamp(&frame_timestamp)) |
| 159 return nullptr; |
| 160 } |
153 | 161 |
154 if (!found_frame) | 162 if (min_playout_delay_ms >= 0) |
155 return NULL; | 163 timing_->set_min_playout_delay(min_playout_delay_ms); |
| 164 |
| 165 if (max_playout_delay_ms >= 0) |
| 166 timing_->set_max_playout_delay(max_playout_delay_ms); |
156 | 167 |
157 // We have a frame - Set timing and render timestamp. | 168 // We have a frame - Set timing and render timestamp. |
158 timing_->SetJitterDelay(jitter_buffer_.EstimatedJitterMs()); | 169 timing_->SetJitterDelay(jitter_buffer_.EstimatedJitterMs()); |
159 const int64_t now_ms = clock_->TimeInMilliseconds(); | 170 const int64_t now_ms = clock_->TimeInMilliseconds(); |
160 timing_->UpdateCurrentDelay(frame_timestamp); | 171 timing_->UpdateCurrentDelay(frame_timestamp); |
161 *next_render_time_ms = timing_->RenderTimeMs(frame_timestamp, now_ms); | 172 *next_render_time_ms = timing_->RenderTimeMs(frame_timestamp, now_ms); |
162 // Check render timing. | 173 // Check render timing. |
163 bool timing_error = false; | 174 bool timing_error = false; |
164 // Assume that render timing errors are due to changes in the video stream. | 175 // Assume that render timing errors are due to changes in the video stream. |
165 if (*next_render_time_ms < 0) { | 176 if (*next_render_time_ms < 0) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 timing_->set_min_playout_delay(desired_delay_ms); | 296 timing_->set_min_playout_delay(desired_delay_ms); |
286 return 0; | 297 return 0; |
287 } | 298 } |
288 | 299 |
289 void VCMReceiver::RegisterStatsCallback( | 300 void VCMReceiver::RegisterStatsCallback( |
290 VCMReceiveStatisticsCallback* callback) { | 301 VCMReceiveStatisticsCallback* callback) { |
291 jitter_buffer_.RegisterStatsCallback(callback); | 302 jitter_buffer_.RegisterStatsCallback(callback); |
292 } | 303 } |
293 | 304 |
294 } // namespace webrtc | 305 } // namespace webrtc |
OLD | NEW |