Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: media/filters/video_renderer_base.cc

Issue 155230: Made MediaFilter::host_ and MediaFilter::message_loop_ private. (Closed)
Patch Set: Merge with ToT Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/filters/file_data_source_unittest.cc ('k') | webkit/glue/media/simple_data_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 #include "media/base/buffers.h" 5 #include "media/base/buffers.h"
6 #include "media/base/filter_host.h" 6 #include "media/base/filter_host.h"
7 #include "media/filters/video_renderer_base.h" 7 #include "media/filters/video_renderer_base.h"
8 8
9 namespace media { 9 namespace media {
10 10
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AutoLock auto_lock(lock_); 97 AutoLock auto_lock(lock_);
98 DCHECK_EQ(state_, UNINITIALIZED); 98 DCHECK_EQ(state_, UNINITIALIZED);
99 state_ = INITIALIZING; 99 state_ = INITIALIZING;
100 decoder_ = decoder; 100 decoder_ = decoder;
101 101
102 // Notify the pipeline of the video dimensions. 102 // Notify the pipeline of the video dimensions.
103 int width = 0; 103 int width = 0;
104 int height = 0; 104 int height = 0;
105 if (!ParseMediaFormat(decoder->media_format(), &width, &height)) 105 if (!ParseMediaFormat(decoder->media_format(), &width, &height))
106 return false; 106 return false;
107 host_->SetVideoSize(width, height); 107 host()->SetVideoSize(width, height);
108 108
109 // Initialize the subclass. 109 // Initialize the subclass.
110 // TODO(scherkus): do we trust subclasses not to do something silly while 110 // TODO(scherkus): do we trust subclasses not to do something silly while
111 // we're holding the lock? 111 // we're holding the lock?
112 if (!OnInitialize(decoder)) 112 if (!OnInitialize(decoder))
113 return false; 113 return false;
114 114
115 // Create our video thread. 115 // Create our video thread.
116 if (!PlatformThread::Create(0, this, &thread_)) { 116 if (!PlatformThread::Create(0, this, &thread_)) {
117 NOTREACHED() << "Video thread creation failed"; 117 NOTREACHED() << "Video thread creation failed";
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 current_frame_ = frames_.front(); 181 current_frame_ = frames_.front();
182 if (frames_.size() >= 2) { 182 if (frames_.size() >= 2) {
183 next_frame = frames_[1]; 183 next_frame = frames_[1];
184 } 184 }
185 } 185 }
186 186
187 // Notify subclass that |current_frame_| has been updated. 187 // Notify subclass that |current_frame_| has been updated.
188 OnFrameAvailable(); 188 OnFrameAvailable();
189 189
190 // Determine the current and next presentation timestamps. 190 // Determine the current and next presentation timestamps.
191 base::TimeDelta now = host_->GetTime(); 191 base::TimeDelta now = host()->GetTime();
192 base::TimeDelta this_pts = current_frame_->GetTimestamp(); 192 base::TimeDelta this_pts = current_frame_->GetTimestamp();
193 base::TimeDelta next_pts; 193 base::TimeDelta next_pts;
194 if (next_frame) { 194 if (next_frame) {
195 next_pts = next_frame->GetTimestamp(); 195 next_pts = next_frame->GetTimestamp();
196 } else { 196 } else {
197 next_pts = this_pts + current_frame_->GetDuration(); 197 next_pts = this_pts + current_frame_->GetDuration();
198 } 198 }
199 199
200 // Determine our sleep duration based on whether time advanced. 200 // Determine our sleep duration based on whether time advanced.
201 base::TimeDelta sleep; 201 base::TimeDelta sleep;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 DCHECK_LE(frames_.size(), kMaxFrames); 241 DCHECK_LE(frames_.size(), kMaxFrames);
242 frame_available_.Signal(); 242 frame_available_.Signal();
243 } 243 }
244 244
245 // Check for our initialization condition. 245 // Check for our initialization condition.
246 if (state_ == INITIALIZING && 246 if (state_ == INITIALIZING &&
247 (frames_.size() == kMaxFrames || frame->IsEndOfStream())) { 247 (frames_.size() == kMaxFrames || frame->IsEndOfStream())) {
248 if (frames_.empty()) { 248 if (frames_.empty()) {
249 // We should have initialized but there's no decoded frames in the queue. 249 // We should have initialized but there's no decoded frames in the queue.
250 // Raise an error. 250 // Raise an error.
251 host_->Error(PIPELINE_ERROR_NO_DATA); 251 host()->Error(PIPELINE_ERROR_NO_DATA);
252 } else { 252 } else {
253 state_ = INITIALIZED; 253 state_ = INITIALIZED;
254 current_frame_ = frames_.front(); 254 current_frame_ = frames_.front();
255 host_->InitializationComplete(); 255 host()->InitializationComplete();
256 } 256 }
257 } 257 }
258 } 258 }
259 259
260 void VideoRendererBase::ScheduleRead() { 260 void VideoRendererBase::ScheduleRead() {
261 decoder_->Read(NewCallback(this, &VideoRendererBase::OnReadComplete)); 261 decoder_->Read(NewCallback(this, &VideoRendererBase::OnReadComplete));
262 } 262 }
263 263
264 bool VideoRendererBase::WaitForInitialized() { 264 bool VideoRendererBase::WaitForInitialized() {
265 // This loop essentially handles preroll. We wait until we've been fully 265 // This loop essentially handles preroll. We wait until we've been fully
266 // initialized so we can call OnFrameAvailable() to provide subclasses with 266 // initialized so we can call OnFrameAvailable() to provide subclasses with
267 // the first frame. 267 // the first frame.
268 AutoLock auto_lock(lock_); 268 AutoLock auto_lock(lock_);
269 DCHECK_EQ(state_, INITIALIZING); 269 DCHECK_EQ(state_, INITIALIZING);
270 while (state_ == INITIALIZING) { 270 while (state_ == INITIALIZING) {
271 frame_available_.Wait(); 271 frame_available_.Wait();
272 if (state_ == STOPPED) { 272 if (state_ == STOPPED) {
273 return false; 273 return false;
274 } 274 }
275 } 275 }
276 DCHECK_EQ(state_, INITIALIZED); 276 DCHECK_EQ(state_, INITIALIZED);
277 DCHECK(current_frame_); 277 DCHECK(current_frame_);
278 return true; 278 return true;
279 } 279 }
280 280
281 } // namespace media 281 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/file_data_source_unittest.cc ('k') | webkit/glue/media/simple_data_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698