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

Side by Side Diff: media/base/pipeline.cc

Issue 526653002: Replace init_cb in Renderer::Initialize() with base::Closure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 6 years, 3 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
OLDNEW
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 "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 PipelineStatusCB done_cb = 330 PipelineStatusCB done_cb =
331 base::Bind(&Pipeline::OnStateTransition, weak_factory_.GetWeakPtr()); 331 base::Bind(&Pipeline::OnStateTransition, weak_factory_.GetWeakPtr());
332 332
333 // Switch states, performing any entrance actions for the new state as well. 333 // Switch states, performing any entrance actions for the new state as well.
334 SetState(GetNextState()); 334 SetState(GetNextState());
335 switch (state_) { 335 switch (state_) {
336 case kInitDemuxer: 336 case kInitDemuxer:
337 return InitializeDemuxer(done_cb); 337 return InitializeDemuxer(done_cb);
338 338
339 case kInitRenderer: 339 case kInitRenderer:
340 return InitializeRenderer(done_cb); 340 return InitializeRenderer(base::Bind(done_cb, PIPELINE_OK));
341 341
342 case kPlaying: 342 case kPlaying:
343 // Report metadata the first time we enter the playing state. 343 // Report metadata the first time we enter the playing state.
344 if (!is_initialized_) { 344 if (!is_initialized_) {
345 is_initialized_ = true; 345 is_initialized_ = true;
346 ReportMetadata(); 346 ReportMetadata();
347 } 347 }
348 348
349 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 349 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
350 350
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 const AddTextTrackDoneCB& done_cb) { 658 const AddTextTrackDoneCB& done_cb) {
659 DCHECK(task_runner_->BelongsToCurrentThread()); 659 DCHECK(task_runner_->BelongsToCurrentThread());
660 add_text_track_cb_.Run(config, done_cb); 660 add_text_track_cb_.Run(config, done_cb);
661 } 661 }
662 662
663 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) { 663 void Pipeline::InitializeDemuxer(const PipelineStatusCB& done_cb) {
664 DCHECK(task_runner_->BelongsToCurrentThread()); 664 DCHECK(task_runner_->BelongsToCurrentThread());
665 demuxer_->Initialize(this, done_cb, text_renderer_); 665 demuxer_->Initialize(this, done_cb, text_renderer_);
666 } 666 }
667 667
668 void Pipeline::InitializeRenderer(const PipelineStatusCB& done_cb) { 668 void Pipeline::InitializeRenderer(const base::Closure& done_cb) {
669 DCHECK(task_runner_->BelongsToCurrentThread()); 669 DCHECK(task_runner_->BelongsToCurrentThread());
670 670
671 if (!demuxer_->GetStream(DemuxerStream::AUDIO) && 671 if (!demuxer_->GetStream(DemuxerStream::AUDIO) &&
672 !demuxer_->GetStream(DemuxerStream::VIDEO)) { 672 !demuxer_->GetStream(DemuxerStream::VIDEO)) {
673 renderer_.reset(); 673 renderer_.reset();
674 task_runner_->PostTask( 674 OnError(PIPELINE_ERROR_COULD_NOT_RENDER);
675 FROM_HERE, base::Bind(done_cb, PIPELINE_ERROR_COULD_NOT_RENDER));
676 return; 675 return;
677 } 676 }
678 677
679 base::WeakPtr<Pipeline> weak_this = weak_factory_.GetWeakPtr(); 678 base::WeakPtr<Pipeline> weak_this = weak_factory_.GetWeakPtr();
680 renderer_->Initialize( 679 renderer_->Initialize(
681 done_cb, 680 done_cb,
682 base::Bind(&Pipeline::OnUpdateStatistics, weak_this), 681 base::Bind(&Pipeline::OnUpdateStatistics, weak_this),
683 base::Bind(&Pipeline::OnRendererEnded, weak_this), 682 base::Bind(&Pipeline::OnRendererEnded, weak_this),
684 base::Bind(&Pipeline::OnError, weak_this), 683 base::Bind(&Pipeline::OnError, weak_this),
685 base::Bind(&Pipeline::BufferingStateChanged, weak_this), 684 base::Bind(&Pipeline::BufferingStateChanged, weak_this),
(...skipping 14 matching lines...) Expand all
700 metadata_cb_.Run(metadata); 699 metadata_cb_.Run(metadata);
701 } 700 }
702 701
703 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { 702 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) {
704 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; 703 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") ";
705 DCHECK(task_runner_->BelongsToCurrentThread()); 704 DCHECK(task_runner_->BelongsToCurrentThread());
706 buffering_state_cb_.Run(new_buffering_state); 705 buffering_state_cb_.Run(new_buffering_state);
707 } 706 }
708 707
709 } // namespace media 708 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | media/base/renderer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698