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

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

Issue 9860027: Remove DemuxerFactory and URL parameter from Pipeline. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: added some todos Created 8 years, 9 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 | Annotate | Revision Log
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/filters/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 read_cbs_.pop_front(); 328 read_cbs_.pop_front();
329 } 329 }
330 330
331 ChangeState_Locked(RETURNING_EOS_FOR_READS); 331 ChangeState_Locked(RETURNING_EOS_FOR_READS);
332 } 332 }
333 333
334 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client) 334 ChunkDemuxer::ChunkDemuxer(ChunkDemuxerClient* client)
335 : state_(WAITING_FOR_INIT), 335 : state_(WAITING_FOR_INIT),
336 client_(client), 336 client_(client),
337 buffered_bytes_(0), 337 buffered_bytes_(0),
338 seek_waits_for_data_(true), 338 seek_waits_for_data_(true) {
339 deferred_error_(PIPELINE_OK) {
340 DCHECK(client); 339 DCHECK(client);
341 } 340 }
342 341
343 ChunkDemuxer::~ChunkDemuxer() { 342 ChunkDemuxer::~ChunkDemuxer() {
344 DCHECK_NE(state_, INITIALIZED); 343 DCHECK_NE(state_, INITIALIZED);
345 } 344 }
346 345
347 void ChunkDemuxer::Init(const PipelineStatusCB& cb) { 346 void ChunkDemuxer::Initialize(const PipelineStatusCB& cb) {
348 DVLOG(1) << "Init()"; 347 DVLOG(1) << "Init()";
349 { 348 {
350 base::AutoLock auto_lock(lock_); 349 base::AutoLock auto_lock(lock_);
351 DCHECK_EQ(state_, WAITING_FOR_INIT); 350 DCHECK_EQ(state_, WAITING_FOR_INIT);
352 351
353 ChangeState_Locked(INITIALIZING); 352 ChangeState_Locked(INITIALIZING);
354 init_cb_ = cb; 353 init_cb_ = cb;
355 stream_parser_.reset(new WebMStreamParser()); 354 stream_parser_.reset(new WebMStreamParser());
356 355
357 stream_parser_->Init( 356 stream_parser_->Init(
358 base::Bind(&ChunkDemuxer::OnStreamParserInitDone, this), 357 base::Bind(&ChunkDemuxer::OnStreamParserInitDone, this),
359 this); 358 this);
360 } 359 }
361 360
362 client_->DemuxerOpened(this); 361 client_->DemuxerOpened(this);
363 } 362 }
364 363
365 void ChunkDemuxer::set_host(DemuxerHost* host) { 364 void ChunkDemuxer::set_host(DemuxerHost* host) {
366 DCHECK(state_ == INITIALIZED || state_ == PARSE_ERROR); 365 // XXXXXXX can we tighten up the set_host() requirements to be done before
366 // Initialize() is called?
scherkus (not reviewing) 2012/03/27 16:51:11 NOTE: I did precisely that. It's crazy that you sh
acolwell GONE FROM CHROMIUM 2012/03/27 20:11:35 I'm fine with you removing this method. On 2012/0
scherkus (not reviewing) 2012/03/27 20:44:09 Done.
367 DCHECK_EQ(state_, WAITING_FOR_INIT);
367 Demuxer::set_host(host); 368 Demuxer::set_host(host);
368 host->SetDuration(duration_);
369 host->SetCurrentReadPosition(0);
370 if (deferred_error_ != PIPELINE_OK) {
371 host->OnDemuxerError(deferred_error_);
372 deferred_error_ = PIPELINE_OK;
373 }
374 } 369 }
375 370
376 void ChunkDemuxer::Stop(const base::Closure& callback) { 371 void ChunkDemuxer::Stop(const base::Closure& callback) {
377 DVLOG(1) << "Stop()"; 372 DVLOG(1) << "Stop()";
378 Shutdown(); 373 Shutdown();
379 callback.Run(); 374 callback.Run();
380 } 375 }
381 376
382 void ChunkDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { 377 void ChunkDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
383 DVLOG(1) << "Seek(" << time.InSecondsF() << ")"; 378 DVLOG(1) << "Seek(" << time.InSecondsF() << ")";
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 if (video_.get()) 650 if (video_.get())
656 video_->Shutdown(); 651 video_->Shutdown();
657 } 652 }
658 653
659 if (!cb.is_null()) { 654 if (!cb.is_null()) {
660 base::AutoUnlock auto_unlock(lock_); 655 base::AutoUnlock auto_unlock(lock_);
661 cb.Run(error); 656 cb.Run(error);
662 return; 657 return;
663 } 658 }
664 659
665 DemuxerHost* demuxer_host = host(); 660 base::AutoUnlock auto_unlock(lock_);
666 if (demuxer_host) { 661 host()->OnDemuxerError(error);
667 base::AutoUnlock auto_unlock(lock_);
668 demuxer_host->OnDemuxerError(error);
669 return;
670 }
671
672 deferred_error_ = error;
673 } 662 }
674 663
675 void ChunkDemuxer::OnStreamParserInitDone(bool success, 664 void ChunkDemuxer::OnStreamParserInitDone(bool success,
676 base::TimeDelta duration) { 665 base::TimeDelta duration) {
677 lock_.AssertAcquired(); 666 lock_.AssertAcquired();
678 DCHECK_EQ(state_, INITIALIZING); 667 DCHECK_EQ(state_, INITIALIZING);
679 if (!success || (!audio_.get() && !video_.get())) { 668 if (!success || (!audio_.get() && !video_.get())) {
680 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN); 669 ReportError_Locked(DEMUXER_ERROR_COULD_NOT_OPEN);
681 return; 670 return;
682 } 671 }
683 672
684 duration_ = duration; 673 duration_ = duration;
674 host()->SetDuration(duration_);
675 host()->SetCurrentReadPosition(0);
685 676
686 ChangeState_Locked(INITIALIZED); 677 ChangeState_Locked(INITIALIZED);
687 PipelineStatusCB cb; 678 PipelineStatusCB cb;
688 std::swap(cb, init_cb_); 679 std::swap(cb, init_cb_);
689 cb.Run(PIPELINE_OK); 680 cb.Run(PIPELINE_OK);
690 } 681 }
691 682
692 bool ChunkDemuxer::OnNewAudioConfig(const AudioDecoderConfig& config) { 683 bool ChunkDemuxer::OnNewAudioConfig(const AudioDecoderConfig& config) {
693 lock_.AssertAcquired(); 684 lock_.AssertAcquired();
694 // Only allow a single audio config for now. 685 // Only allow a single audio config for now.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (!video_->CanAddBuffers(buffers)) 720 if (!video_->CanAddBuffers(buffers))
730 return false; 721 return false;
731 722
732 video_->AddBuffers(buffers); 723 video_->AddBuffers(buffers);
733 seek_waits_for_data_ = false; 724 seek_waits_for_data_ = false;
734 725
735 return true; 726 return true;
736 } 727 }
737 728
738 } // namespace media 729 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698