OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // Frame dropped: read again. | 277 // Frame dropped: read again. |
278 ++frames_dropped; | 278 ++frames_dropped; |
279 ready_frames_.pop_front(); | 279 ready_frames_.pop_front(); |
280 AttemptRead_Locked(); | 280 AttemptRead_Locked(); |
281 } | 281 } |
282 // Continue waiting for the current paint to finish. | 282 // Continue waiting for the current paint to finish. |
283 frame_available_.TimedWait(kIdleTimeDelta); | 283 frame_available_.TimedWait(kIdleTimeDelta); |
284 continue; | 284 continue; |
285 } | 285 } |
286 | 286 |
287 | |
288 // Congratulations! You've made it past the video frame timing gauntlet. | 287 // Congratulations! You've made it past the video frame timing gauntlet. |
289 // | 288 // |
290 // We can now safely update the current frame, request another frame, and | 289 // We can now safely update the current frame, request another frame, and |
291 // signal to the client that a new frame is available. | 290 // signal to the client that a new frame is available. |
292 DCHECK(!pending_paint_); | 291 DCHECK(!pending_paint_); |
293 DCHECK(!ready_frames_.empty()); | 292 DCHECK(!ready_frames_.empty()); |
| 293 |
| 294 size_t new_width = ready_frames_.front()->natural_width(); |
| 295 size_t new_height = ready_frames_.front()->natural_height(); |
| 296 |
| 297 if (!current_frame_ || |
| 298 current_frame_->natural_width() != new_width || |
| 299 current_frame_->natural_height() != new_height) { |
| 300 host_->SetNaturalVideoSize(gfx::Size(new_width, new_height)); |
| 301 } |
| 302 |
294 current_frame_ = ready_frames_.front(); | 303 current_frame_ = ready_frames_.front(); |
295 ready_frames_.pop_front(); | 304 ready_frames_.pop_front(); |
296 AttemptRead_Locked(); | 305 AttemptRead_Locked(); |
297 | 306 |
298 base::AutoUnlock auto_unlock(lock_); | 307 base::AutoUnlock auto_unlock(lock_); |
299 paint_cb_.Run(); | 308 paint_cb_.Run(); |
300 } | 309 } |
301 } | 310 } |
302 | 311 |
303 void VideoRendererBase::GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out) { | 312 void VideoRendererBase::GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out) { |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 551 |
543 int VideoRendererBase::NumFrames_Locked() const { | 552 int VideoRendererBase::NumFrames_Locked() const { |
544 lock_.AssertAcquired(); | 553 lock_.AssertAcquired(); |
545 int outstanding_frames = | 554 int outstanding_frames = |
546 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + | 555 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + |
547 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); | 556 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); |
548 return ready_frames_.size() + outstanding_frames; | 557 return ready_frames_.size() + outstanding_frames; |
549 } | 558 } |
550 | 559 |
551 } // namespace media | 560 } // namespace media |
OLD | NEW |