OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/filters/video_renderer_impl.h" | 5 #include "media/filters/video_renderer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 base::PlatformThread::Join(thread_); | 61 base::PlatformThread::Join(thread_); |
62 | 62 |
63 if (!init_cb_.is_null()) | 63 if (!init_cb_.is_null()) |
64 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); | 64 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); |
65 | 65 |
66 if (!flush_cb_.is_null()) | 66 if (!flush_cb_.is_null()) |
67 base::ResetAndReturn(&flush_cb_).Run(); | 67 base::ResetAndReturn(&flush_cb_).Run(); |
68 } | 68 } |
69 | 69 |
70 void VideoRendererImpl::Flush(const base::Closure& callback) { | 70 void VideoRendererImpl::Flush(const base::Closure& callback) { |
| 71 DVLOG(1) << __FUNCTION__; |
71 DCHECK(task_runner_->BelongsToCurrentThread()); | 72 DCHECK(task_runner_->BelongsToCurrentThread()); |
72 base::AutoLock auto_lock(lock_); | 73 base::AutoLock auto_lock(lock_); |
73 DCHECK_EQ(state_, kPlaying); | 74 DCHECK_EQ(state_, kPlaying); |
74 flush_cb_ = callback; | 75 flush_cb_ = callback; |
75 state_ = kFlushing; | 76 state_ = kFlushing; |
76 | 77 |
77 // This is necessary if the |video_frame_stream_| has already seen an end of | 78 // This is necessary if the |video_frame_stream_| has already seen an end of |
78 // stream and needs to drain it before flushing it. | 79 // stream and needs to drain it before flushing it. |
79 ready_frames_.clear(); | 80 ready_frames_.clear(); |
80 if (buffering_state_ != BUFFERING_HAVE_NOTHING) { | 81 if (buffering_state_ != BUFFERING_HAVE_NOTHING) { |
81 buffering_state_ = BUFFERING_HAVE_NOTHING; | 82 buffering_state_ = BUFFERING_HAVE_NOTHING; |
82 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); | 83 buffering_state_cb_.Run(BUFFERING_HAVE_NOTHING); |
83 } | 84 } |
84 received_end_of_stream_ = false; | 85 received_end_of_stream_ = false; |
85 rendered_end_of_stream_ = false; | 86 rendered_end_of_stream_ = false; |
86 | 87 |
87 video_frame_stream_->Reset( | 88 video_frame_stream_->Reset( |
88 base::Bind(&VideoRendererImpl::OnVideoFrameStreamResetDone, | 89 base::Bind(&VideoRendererImpl::OnVideoFrameStreamResetDone, |
89 weak_factory_.GetWeakPtr())); | 90 weak_factory_.GetWeakPtr())); |
90 } | 91 } |
91 | 92 |
92 void VideoRendererImpl::StartPlaying() { | 93 void VideoRendererImpl::StartPlaying() { |
| 94 DVLOG(1) << __FUNCTION__; |
93 DCHECK(task_runner_->BelongsToCurrentThread()); | 95 DCHECK(task_runner_->BelongsToCurrentThread()); |
94 base::AutoLock auto_lock(lock_); | 96 base::AutoLock auto_lock(lock_); |
95 DCHECK_EQ(state_, kFlushed); | 97 DCHECK_EQ(state_, kFlushed); |
96 DCHECK(!pending_read_); | 98 DCHECK(!pending_read_); |
97 DCHECK(ready_frames_.empty()); | 99 DCHECK(ready_frames_.empty()); |
98 DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING); | 100 DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING); |
99 | 101 |
100 state_ = kPlaying; | 102 state_ = kPlaying; |
101 start_timestamp_ = get_time_cb_.Run(); | 103 start_timestamp_ = get_time_cb_.Run(); |
102 AttemptRead_Locked(); | 104 AttemptRead_Locked(); |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); | 476 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); |
475 | 477 |
476 frames_decoded_ = 0; | 478 frames_decoded_ = 0; |
477 frames_dropped_ = 0; | 479 frames_dropped_ = 0; |
478 } | 480 } |
479 | 481 |
480 frame_available_.TimedWait(wait_duration); | 482 frame_available_.TimedWait(wait_duration); |
481 } | 483 } |
482 | 484 |
483 } // namespace media | 485 } // namespace media |
OLD | NEW |