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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 DCHECK(!pending_read_); | 100 DCHECK(!pending_read_); |
101 DCHECK(ready_frames_.empty()); | 101 DCHECK(ready_frames_.empty()); |
102 DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING); | 102 DCHECK_EQ(buffering_state_, BUFFERING_HAVE_NOTHING); |
103 | 103 |
104 state_ = kPlaying; | 104 state_ = kPlaying; |
105 start_timestamp_ = timestamp; | 105 start_timestamp_ = timestamp; |
106 AttemptRead_Locked(); | 106 AttemptRead_Locked(); |
107 } | 107 } |
108 | 108 |
109 void VideoRendererImpl::Initialize(DemuxerStream* stream, | 109 void VideoRendererImpl::Initialize(DemuxerStream* stream, |
110 bool low_delay, | |
111 const PipelineStatusCB& init_cb, | 110 const PipelineStatusCB& init_cb, |
112 const StatisticsCB& statistics_cb, | 111 const StatisticsCB& statistics_cb, |
113 const BufferingStateCB& buffering_state_cb, | 112 const BufferingStateCB& buffering_state_cb, |
114 const base::Closure& ended_cb, | 113 const base::Closure& ended_cb, |
115 const PipelineStatusCB& error_cb, | 114 const PipelineStatusCB& error_cb, |
116 const TimeDeltaCB& get_time_cb) { | 115 const TimeDeltaCB& get_time_cb) { |
117 DCHECK(task_runner_->BelongsToCurrentThread()); | 116 DCHECK(task_runner_->BelongsToCurrentThread()); |
118 base::AutoLock auto_lock(lock_); | 117 base::AutoLock auto_lock(lock_); |
119 DCHECK(stream); | 118 DCHECK(stream); |
120 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); | 119 DCHECK_EQ(stream->type(), DemuxerStream::VIDEO); |
121 DCHECK(!init_cb.is_null()); | 120 DCHECK(!init_cb.is_null()); |
122 DCHECK(!statistics_cb.is_null()); | 121 DCHECK(!statistics_cb.is_null()); |
123 DCHECK(!buffering_state_cb.is_null()); | 122 DCHECK(!buffering_state_cb.is_null()); |
124 DCHECK(!ended_cb.is_null()); | 123 DCHECK(!ended_cb.is_null()); |
125 DCHECK(!get_time_cb.is_null()); | 124 DCHECK(!get_time_cb.is_null()); |
126 DCHECK_EQ(kUninitialized, state_); | 125 DCHECK_EQ(kUninitialized, state_); |
127 | 126 |
128 low_delay_ = low_delay; | 127 low_delay_ = (stream->liveness() == DemuxerStream::LIVENESS_LIVE); |
wolenetz
2014/11/11 23:48:07
nit: This logic is now in multiple places (see als
xhwang
2014/11/14 06:38:04
Hmm, I don't feel
DemuxerStream::is_low_delay(str
wolenetz
2014/11/14 19:21:58
Acknowledged.
| |
129 | 128 |
130 // Always post |init_cb_| because |this| could be destroyed if initialization | 129 // Always post |init_cb_| because |this| could be destroyed if initialization |
131 // failed. | 130 // failed. |
132 init_cb_ = BindToCurrentLoop(init_cb); | 131 init_cb_ = BindToCurrentLoop(init_cb); |
133 | 132 |
134 statistics_cb_ = statistics_cb; | 133 statistics_cb_ = statistics_cb; |
135 buffering_state_cb_ = buffering_state_cb; | 134 buffering_state_cb_ = buffering_state_cb; |
136 ended_cb_ = ended_cb; | 135 ended_cb_ = ended_cb; |
137 error_cb_ = error_cb; | 136 error_cb_ = error_cb; |
138 get_time_cb_ = get_time_cb; | 137 get_time_cb_ = get_time_cb; |
139 state_ = kInitializing; | 138 state_ = kInitializing; |
140 | 139 |
141 video_frame_stream_->Initialize( | 140 video_frame_stream_->Initialize( |
142 stream, | 141 stream, statistics_cb, |
143 low_delay, | |
144 statistics_cb, | |
145 base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, | 142 base::Bind(&VideoRendererImpl::OnVideoFrameStreamInitialized, |
146 weak_factory_.GetWeakPtr())); | 143 weak_factory_.GetWeakPtr())); |
147 } | 144 } |
148 | 145 |
149 void VideoRendererImpl::OnVideoFrameStreamInitialized(bool success) { | 146 void VideoRendererImpl::OnVideoFrameStreamInitialized(bool success) { |
150 DCHECK(task_runner_->BelongsToCurrentThread()); | 147 DCHECK(task_runner_->BelongsToCurrentThread()); |
151 base::AutoLock auto_lock(lock_); | 148 base::AutoLock auto_lock(lock_); |
152 DCHECK_EQ(state_, kInitializing); | 149 DCHECK_EQ(state_, kInitializing); |
153 | 150 |
154 if (!success) { | 151 if (!success) { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); | 438 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); |
442 | 439 |
443 frames_decoded_ = 0; | 440 frames_decoded_ = 0; |
444 frames_dropped_ = 0; | 441 frames_dropped_ = 0; |
445 } | 442 } |
446 | 443 |
447 frame_available_.TimedWait(wait_duration); | 444 frame_available_.TimedWait(wait_duration); |
448 } | 445 } |
449 | 446 |
450 } // namespace media | 447 } // namespace media |
OLD | NEW |