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

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

Issue 1447533006: media: Pass SetCdmReadyCB in {Audio|Video}Decoder::Initialize(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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/decoder_selector.cc ('k') | media/filters/decoder_stream_traits.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/decoder_stream.h" 5 #include "media/filters/decoder_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 } 509 }
510 510
511 template <DemuxerStream::Type StreamType> 511 template <DemuxerStream::Type StreamType>
512 void DecoderStream<StreamType>::ReinitializeDecoder() { 512 void DecoderStream<StreamType>::ReinitializeDecoder() {
513 FUNCTION_DVLOG(2); 513 FUNCTION_DVLOG(2);
514 DCHECK(task_runner_->BelongsToCurrentThread()); 514 DCHECK(task_runner_->BelongsToCurrentThread());
515 DCHECK_EQ(state_, STATE_FLUSHING_DECODER); 515 DCHECK_EQ(state_, STATE_FLUSHING_DECODER);
516 DCHECK_EQ(pending_decode_requests_, 0); 516 DCHECK_EQ(pending_decode_requests_, 0);
517 517
518 state_ = STATE_REINITIALIZING_DECODER; 518 state_ = STATE_REINITIALIZING_DECODER;
519 // Decoders should not need CDMs during reinitialization.
519 DecoderStreamTraits<StreamType>::InitializeDecoder( 520 DecoderStreamTraits<StreamType>::InitializeDecoder(
520 decoder_.get(), stream_, 521 decoder_.get(), stream_, SetCdmReadyCB(),
521 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, 522 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized,
522 weak_factory_.GetWeakPtr()), 523 weak_factory_.GetWeakPtr()),
523 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, 524 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady,
524 weak_factory_.GetWeakPtr())); 525 weak_factory_.GetWeakPtr()));
525 } 526 }
526 527
527 template <DemuxerStream::Type StreamType> 528 template <DemuxerStream::Type StreamType>
528 void DecoderStream<StreamType>::OnDecoderReinitialized(bool success) { 529 void DecoderStream<StreamType>::OnDecoderReinitialized(bool success) {
529 FUNCTION_DVLOG(2); 530 FUNCTION_DVLOG(2);
530 DCHECK(task_runner_->BelongsToCurrentThread()); 531 DCHECK(task_runner_->BelongsToCurrentThread());
531 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); 532 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER);
532 533
533 // ReinitializeDecoder() can be called in two cases: 534 // ReinitializeDecoder() can be called in two cases:
534 // 1, Flushing decoder finished (see OnDecodeOutputReady()). 535 // 1, Flushing decoder finished (see OnDecodeOutputReady()).
535 // 2, Reset() was called during flushing decoder (see OnDecoderReset()). 536 // 2, Reset() was called during flushing decoder (see OnDecoderReset()).
536 // Also, Reset() can be called during pending ReinitializeDecoder(). 537 // Also, Reset() can be called during pending ReinitializeDecoder().
537 // This function needs to handle them all! 538 // This function needs to handle them all!
538 539
539 if (!success) { 540 if (!success) {
540 // Reinitialization failed. Try to fall back to one of the remaining 541 // Reinitialization failed. Try to fall back to one of the remaining
541 // decoders. This will consume at least one decoder so doing it more than 542 // decoders. This will consume at least one decoder so doing it more than
542 // once is safe. 543 // once is safe.
543 // For simplicity, don't attempt to fall back to a decryptor. Calling this 544 // For simplicity, don't attempt to fall back to a decrypting decoder.
544 // with a null callback ensures that one won't be selected. 545 // Calling this with a null callback ensures that one won't be selected.
545 SelectDecoder(SetCdmReadyCB()); 546 SelectDecoder(SetCdmReadyCB());
546 } else { 547 } else {
547 CompleteDecoderReinitialization(true); 548 CompleteDecoderReinitialization(true);
548 } 549 }
549 } 550 }
550 551
551 template <DemuxerStream::Type StreamType> 552 template <DemuxerStream::Type StreamType>
552 void DecoderStream<StreamType>::CompleteDecoderReinitialization(bool success) { 553 void DecoderStream<StreamType>::CompleteDecoderReinitialization(bool success) {
553 FUNCTION_DVLOG(2); 554 FUNCTION_DVLOG(2);
554 DCHECK(task_runner_->BelongsToCurrentThread()); 555 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 } 606 }
606 607
607 // The resetting process will be continued in OnDecoderReinitialized(). 608 // The resetting process will be continued in OnDecoderReinitialized().
608 ReinitializeDecoder(); 609 ReinitializeDecoder();
609 } 610 }
610 611
611 template class DecoderStream<DemuxerStream::VIDEO>; 612 template class DecoderStream<DemuxerStream::VIDEO>;
612 template class DecoderStream<DemuxerStream::AUDIO>; 613 template class DecoderStream<DemuxerStream::AUDIO>;
613 614
614 } // namespace media 615 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/decoder_selector.cc ('k') | media/filters/decoder_stream_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698