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/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
8 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
9 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
10 #include "media/base/limits.h" | 11 #include "media/base/limits.h" |
11 #include "media/base/pipeline.h" | 12 #include "media/base/pipeline.h" |
12 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
13 #include "media/filters/video_renderer_base.h" | 14 #include "media/filters/video_renderer_base.h" |
14 | 15 |
15 namespace media { | 16 namespace media { |
16 | 17 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 } | 366 } |
366 | 367 |
367 if (!frame) { | 368 if (!frame) { |
368 if (state_ != kSeeking) | 369 if (state_ != kSeeking) |
369 return; | 370 return; |
370 | 371 |
371 // Abort seek early for a NULL frame because we won't get more frames. | 372 // Abort seek early for a NULL frame because we won't get more frames. |
372 // A new seek will be requested after this one completes so there is no | 373 // A new seek will be requested after this one completes so there is no |
373 // point trying to collect more frames. | 374 // point trying to collect more frames. |
374 state_ = kPrerolled; | 375 state_ = kPrerolled; |
375 ResetAndRunCB(&seek_cb_, PIPELINE_OK); | 376 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |
376 return; | 377 return; |
377 } | 378 } |
378 | 379 |
379 // Discard frames until we reach our desired seek timestamp. | 380 // Discard frames until we reach our desired seek timestamp. |
380 if (state_ == kSeeking && !frame->IsEndOfStream() && | 381 if (state_ == kSeeking && !frame->IsEndOfStream() && |
381 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { | 382 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { |
382 AttemptRead_Locked(); | 383 AttemptRead_Locked(); |
383 return; | 384 return; |
384 } | 385 } |
385 | 386 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 // Because we might remain in the prerolled state for an undetermined amount | 425 // Because we might remain in the prerolled state for an undetermined amount |
425 // of time (i.e., we were not playing before we received a seek), we'll | 426 // of time (i.e., we were not playing before we received a seek), we'll |
426 // manually update the current frame and notify the subclass below. | 427 // manually update the current frame and notify the subclass below. |
427 if (!ready_frames_.front()->IsEndOfStream()) { | 428 if (!ready_frames_.front()->IsEndOfStream()) { |
428 current_frame_ = ready_frames_.front(); | 429 current_frame_ = ready_frames_.front(); |
429 ready_frames_.pop_front(); | 430 ready_frames_.pop_front(); |
430 } | 431 } |
431 | 432 |
432 // ...and we're done seeking! | 433 // ...and we're done seeking! |
433 DCHECK(!seek_cb_.is_null()); | 434 DCHECK(!seek_cb_.is_null()); |
434 ResetAndRunCB(&seek_cb_, PIPELINE_OK); | 435 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); |
435 | 436 |
436 base::AutoUnlock ul(lock_); | 437 base::AutoUnlock ul(lock_); |
437 paint_cb_.Run(); | 438 paint_cb_.Run(); |
438 } | 439 } |
439 } | 440 } |
440 | 441 |
441 void VideoRendererBase::AttemptRead_Locked() { | 442 void VideoRendererBase::AttemptRead_Locked() { |
442 lock_.AssertAcquired(); | 443 lock_.AssertAcquired(); |
443 DCHECK_NE(kEnded, state_); | 444 DCHECK_NE(kEnded, state_); |
444 | 445 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 500 |
500 int VideoRendererBase::NumFrames_Locked() const { | 501 int VideoRendererBase::NumFrames_Locked() const { |
501 lock_.AssertAcquired(); | 502 lock_.AssertAcquired(); |
502 int outstanding_frames = | 503 int outstanding_frames = |
503 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + | 504 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + |
504 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); | 505 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); |
505 return ready_frames_.size() + outstanding_frames; | 506 return ready_frames_.size() + outstanding_frames; |
506 } | 507 } |
507 | 508 |
508 } // namespace media | 509 } // namespace media |
OLD | NEW |