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

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

Issue 8786013: Replace media::Limits struct with media::limits namespace and update documentation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix logic Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | webkit/media/audio_decoder.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 #include "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/base/limits.h" 10 #include "media/base/limits.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Discard frames until we reach our desired seek timestamp. 370 // Discard frames until we reach our desired seek timestamp.
371 if (state_ == kSeeking && !frame->IsEndOfStream() && 371 if (state_ == kSeeking && !frame->IsEndOfStream() &&
372 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) { 372 (frame->GetTimestamp() + frame->GetDuration()) <= seek_timestamp_) {
373 AttemptRead_Locked(); 373 AttemptRead_Locked();
374 return; 374 return;
375 } 375 }
376 376
377 // This one's a keeper! Place it in the ready queue. 377 // This one's a keeper! Place it in the ready queue.
378 frames_queue_ready_.push_back(frame); 378 frames_queue_ready_.push_back(frame);
379 DCHECK_LE(frames_queue_ready_.size(), 379 DCHECK_LE(frames_queue_ready_.size(),
380 static_cast<size_t>(Limits::kMaxVideoFrames)); 380 static_cast<size_t>(limits::kMaxVideoFrames));
381 frame_available_.Signal(); 381 frame_available_.Signal();
382 382
383 PipelineStatistics statistics; 383 PipelineStatistics statistics;
384 statistics.video_frames_decoded = 1; 384 statistics.video_frames_decoded = 1;
385 statistics_callback_.Run(statistics); 385 statistics_callback_.Run(statistics);
386 386
387 // Always request more decoded video if we have capacity. This serves two 387 // Always request more decoded video if we have capacity. This serves two
388 // purposes: 388 // purposes:
389 // 1) Prerolling while paused 389 // 1) Prerolling while paused
390 // 2) Keeps decoding going if video rendering thread starts falling behind 390 // 2) Keeps decoding going if video rendering thread starts falling behind
391 if (frames_queue_ready_.size() < Limits::kMaxVideoFrames && 391 if (frames_queue_ready_.size() < limits::kMaxVideoFrames &&
392 !frame->IsEndOfStream()) { 392 !frame->IsEndOfStream()) {
393 AttemptRead_Locked(); 393 AttemptRead_Locked();
394 return; 394 return;
395 } 395 }
396 396
397 // If we're at capacity or end of stream while seeking we need to transition 397 // If we're at capacity or end of stream while seeking we need to transition
398 // to prerolled. 398 // to prerolled.
399 if (state_ == kSeeking) { 399 if (state_ == kSeeking) {
400 state_ = kPrerolled; 400 state_ = kPrerolled;
401 401
(...skipping 11 matching lines...) Expand all
413 413
414 base::AutoUnlock ul(lock_); 414 base::AutoUnlock ul(lock_);
415 OnFrameAvailable(); 415 OnFrameAvailable();
416 } 416 }
417 } 417 }
418 418
419 void VideoRendererBase::AttemptRead_Locked() { 419 void VideoRendererBase::AttemptRead_Locked() {
420 lock_.AssertAcquired(); 420 lock_.AssertAcquired();
421 DCHECK_NE(kEnded, state_); 421 DCHECK_NE(kEnded, state_);
422 422
423 if (pending_read_ || frames_queue_ready_.size() == Limits::kMaxVideoFrames) { 423 if (pending_read_ || frames_queue_ready_.size() == limits::kMaxVideoFrames) {
424 return; 424 return;
425 } 425 }
426 426
427 pending_read_ = true; 427 pending_read_ = true;
428 decoder_->Read(read_cb_); 428 decoder_->Read(read_cb_);
429 } 429 }
430 430
431 void VideoRendererBase::AttemptFlush_Locked() { 431 void VideoRendererBase::AttemptFlush_Locked() {
432 lock_.AssertAcquired(); 432 lock_.AssertAcquired();
433 DCHECK_EQ(kFlushing, state_); 433 DCHECK_EQ(kFlushing, state_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 void VideoRendererBase::DoStopOrError_Locked() { 476 void VideoRendererBase::DoStopOrError_Locked() {
477 DCHECK(!pending_paint_); 477 DCHECK(!pending_paint_);
478 DCHECK(!pending_paint_with_last_available_); 478 DCHECK(!pending_paint_with_last_available_);
479 lock_.AssertAcquired(); 479 lock_.AssertAcquired();
480 current_frame_ = NULL; 480 current_frame_ = NULL;
481 last_available_frame_ = NULL; 481 last_available_frame_ = NULL;
482 DCHECK(!pending_read_); 482 DCHECK(!pending_read_);
483 } 483 }
484 484
485 } // namespace media 485 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer.cc ('k') | webkit/media/audio_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698