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