| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 max_video_delay_ms_) { | 176 max_video_delay_ms_) { |
| 177 LOG(LS_WARNING) << "The video target delay has grown larger than " | 177 LOG(LS_WARNING) << "The video target delay has grown larger than " |
| 178 << max_video_delay_ms_ << " ms. Resetting jitter buffer."; | 178 << max_video_delay_ms_ << " ms. Resetting jitter buffer."; |
| 179 timing_error = true; | 179 timing_error = true; |
| 180 } | 180 } |
| 181 | 181 |
| 182 if (timing_error) { | 182 if (timing_error) { |
| 183 // Timing error => reset timing and flush the jitter buffer. | 183 // Timing error => reset timing and flush the jitter buffer. |
| 184 jitter_buffer_.Flush(); | 184 jitter_buffer_.Flush(); |
| 185 timing_->Reset(); | 185 timing_->Reset(); |
| 186 return NULL; | 186 return nullptr; |
| 187 } | 187 } |
| 188 | 188 |
| 189 if (prefer_late_decoding) { | 189 if (prefer_late_decoding) { |
| 190 // Decode frame as close as possible to the render timestamp. | 190 // Decode frame as close as possible to the render timestamp. |
| 191 const int32_t available_wait_time = | 191 const int32_t available_wait_time = |
| 192 max_wait_time_ms - | 192 max_wait_time_ms - |
| 193 static_cast<int32_t>(clock_->TimeInMilliseconds() - start_time_ms); | 193 static_cast<int32_t>(clock_->TimeInMilliseconds() - start_time_ms); |
| 194 uint16_t new_max_wait_time = | 194 uint16_t new_max_wait_time = |
| 195 static_cast<uint16_t>(VCM_MAX(available_wait_time, 0)); | 195 static_cast<uint16_t>(VCM_MAX(available_wait_time, 0)); |
| 196 uint32_t wait_time_ms = | 196 uint32_t wait_time_ms = |
| 197 timing_->MaxWaitingTime(render_time_ms, clock_->TimeInMilliseconds()); | 197 timing_->MaxWaitingTime(render_time_ms, clock_->TimeInMilliseconds()); |
| 198 if (new_max_wait_time < wait_time_ms) { | 198 if (new_max_wait_time < wait_time_ms) { |
| 199 // We're not allowed to wait until the frame is supposed to be rendered, | 199 // We're not allowed to wait until the frame is supposed to be rendered, |
| 200 // waiting as long as we're allowed to avoid busy looping, and then return | 200 // waiting as long as we're allowed to avoid busy looping, and then return |
| 201 // NULL. Next call to this function might return the frame. | 201 // null. Next call to this function might return the frame. |
| 202 render_wait_event_->Wait(new_max_wait_time); | 202 render_wait_event_->Wait(new_max_wait_time); |
| 203 return NULL; | 203 return nullptr; |
| 204 } | 204 } |
| 205 // Wait until it's time to render. | 205 // Wait until it's time to render. |
| 206 render_wait_event_->Wait(wait_time_ms); | 206 render_wait_event_->Wait(wait_time_ms); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Extract the frame from the jitter buffer and set the render time. | 209 // Extract the frame from the jitter buffer and set the render time. |
| 210 VCMEncodedFrame* frame = jitter_buffer_.ExtractAndSetDecode(frame_timestamp); | 210 VCMEncodedFrame* frame = jitter_buffer_.ExtractAndSetDecode(frame_timestamp); |
| 211 if (frame == NULL) { | 211 if (frame == nullptr) { |
| 212 return NULL; | 212 return nullptr; |
| 213 } | 213 } |
| 214 frame->SetRenderTime(render_time_ms); | 214 frame->SetRenderTime(render_time_ms); |
| 215 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", frame->TimeStamp(), "SetRenderTS", | 215 TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", frame->TimeStamp(), "SetRenderTS", |
| 216 "render_time", frame->RenderTimeMs()); | 216 "render_time", frame->RenderTimeMs()); |
| 217 if (!frame->Complete()) { | 217 if (!frame->Complete()) { |
| 218 // Update stats for incomplete frames. | 218 // Update stats for incomplete frames. |
| 219 bool retransmitted = false; | 219 bool retransmitted = false; |
| 220 const int64_t last_packet_time_ms = | 220 const int64_t last_packet_time_ms = |
| 221 jitter_buffer_.LastPacketTime(frame, &retransmitted); | 221 jitter_buffer_.LastPacketTime(frame, &retransmitted); |
| 222 if (last_packet_time_ms >= 0 && !retransmitted) { | 222 if (last_packet_time_ms >= 0 && !retransmitted) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 timing_->set_min_playout_delay(desired_delay_ms); | 286 timing_->set_min_playout_delay(desired_delay_ms); |
| 287 return 0; | 287 return 0; |
| 288 } | 288 } |
| 289 | 289 |
| 290 void VCMReceiver::RegisterStatsCallback( | 290 void VCMReceiver::RegisterStatsCallback( |
| 291 VCMReceiveStatisticsCallback* callback) { | 291 VCMReceiveStatisticsCallback* callback) { |
| 292 jitter_buffer_.RegisterStatsCallback(callback); | 292 jitter_buffer_.RegisterStatsCallback(callback); |
| 293 } | 293 } |
| 294 | 294 |
| 295 } // namespace webrtc | 295 } // namespace webrtc |
| OLD | NEW |