| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return VCM_OK; | 89 return VCM_OK; |
| 90 } | 90 } |
| 91 | 91 |
| 92 void VCMReceiver::TriggerDecoderShutdown() { | 92 void VCMReceiver::TriggerDecoderShutdown() { |
| 93 jitter_buffer_.Stop(); | 93 jitter_buffer_.Stop(); |
| 94 render_wait_event_->Set(); | 94 render_wait_event_->Set(); |
| 95 } | 95 } |
| 96 | 96 |
| 97 VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, | 97 VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, |
| 98 int64_t& next_render_time_ms, | 98 int64_t& next_render_time_ms, |
| 99 bool render_timing) { | 99 bool prefer_late_decoding) { |
| 100 const int64_t start_time_ms = clock_->TimeInMilliseconds(); | 100 const int64_t start_time_ms = clock_->TimeInMilliseconds(); |
| 101 uint32_t frame_timestamp = 0; | 101 uint32_t frame_timestamp = 0; |
| 102 // Exhaust wait time to get a complete frame for decoding. | 102 // Exhaust wait time to get a complete frame for decoding. |
| 103 bool found_frame = jitter_buffer_.NextCompleteTimestamp( | 103 bool found_frame = jitter_buffer_.NextCompleteTimestamp( |
| 104 max_wait_time_ms, &frame_timestamp); | 104 max_wait_time_ms, &frame_timestamp); |
| 105 | 105 |
| 106 if (!found_frame) | 106 if (!found_frame) |
| 107 found_frame = jitter_buffer_.NextMaybeIncompleteTimestamp(&frame_timestamp); | 107 found_frame = jitter_buffer_.NextMaybeIncompleteTimestamp(&frame_timestamp); |
| 108 | 108 |
| 109 if (!found_frame) | 109 if (!found_frame) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 133 timing_error = true; | 133 timing_error = true; |
| 134 } | 134 } |
| 135 | 135 |
| 136 if (timing_error) { | 136 if (timing_error) { |
| 137 // Timing error => reset timing and flush the jitter buffer. | 137 // Timing error => reset timing and flush the jitter buffer. |
| 138 jitter_buffer_.Flush(); | 138 jitter_buffer_.Flush(); |
| 139 timing_->Reset(); | 139 timing_->Reset(); |
| 140 return NULL; | 140 return NULL; |
| 141 } | 141 } |
| 142 | 142 |
| 143 if (!render_timing) { | 143 if (prefer_late_decoding) { |
| 144 // Decode frame as close as possible to the render timestamp. | 144 // Decode frame as close as possible to the render timestamp. |
| 145 const int32_t available_wait_time = max_wait_time_ms - | 145 const int32_t available_wait_time = max_wait_time_ms - |
| 146 static_cast<int32_t>(clock_->TimeInMilliseconds() - start_time_ms); | 146 static_cast<int32_t>(clock_->TimeInMilliseconds() - start_time_ms); |
| 147 uint16_t new_max_wait_time = static_cast<uint16_t>( | 147 uint16_t new_max_wait_time = static_cast<uint16_t>( |
| 148 VCM_MAX(available_wait_time, 0)); | 148 VCM_MAX(available_wait_time, 0)); |
| 149 uint32_t wait_time_ms = timing_->MaxWaitingTime( | 149 uint32_t wait_time_ms = timing_->MaxWaitingTime( |
| 150 next_render_time_ms, clock_->TimeInMilliseconds()); | 150 next_render_time_ms, clock_->TimeInMilliseconds()); |
| 151 if (new_max_wait_time < wait_time_ms) { | 151 if (new_max_wait_time < wait_time_ms) { |
| 152 // We're not allowed to wait until the frame is supposed to be rendered, | 152 // We're not allowed to wait until the frame is supposed to be rendered, |
| 153 // waiting as long as we're allowed to avoid busy looping, and then return | 153 // waiting as long as we're allowed to avoid busy looping, and then return |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 uint32_t render_end = timing_->RenderTimeMs(timestamp_end, now_ms); | 259 uint32_t render_end = timing_->RenderTimeMs(timestamp_end, now_ms); |
| 260 return render_end - render_start; | 260 return render_end - render_start; |
| 261 } | 261 } |
| 262 | 262 |
| 263 void VCMReceiver::RegisterStatsCallback( | 263 void VCMReceiver::RegisterStatsCallback( |
| 264 VCMReceiveStatisticsCallback* callback) { | 264 VCMReceiveStatisticsCallback* callback) { |
| 265 jitter_buffer_.RegisterStatsCallback(callback); | 265 jitter_buffer_.RegisterStatsCallback(callback); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace webrtc | 268 } // namespace webrtc |
| OLD | NEW |