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

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

Issue 1446713003: Revert of 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.
520 DecoderStreamTraits<StreamType>::InitializeDecoder( 519 DecoderStreamTraits<StreamType>::InitializeDecoder(
521 decoder_.get(), stream_, SetCdmReadyCB(), 520 decoder_.get(), stream_,
522 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized, 521 base::Bind(&DecoderStream<StreamType>::OnDecoderReinitialized,
523 weak_factory_.GetWeakPtr()), 522 weak_factory_.GetWeakPtr()),
524 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady, 523 base::Bind(&DecoderStream<StreamType>::OnDecodeOutputReady,
525 weak_factory_.GetWeakPtr())); 524 weak_factory_.GetWeakPtr()));
526 } 525 }
527 526
528 template <DemuxerStream::Type StreamType> 527 template <DemuxerStream::Type StreamType>
529 void DecoderStream<StreamType>::OnDecoderReinitialized(bool success) { 528 void DecoderStream<StreamType>::OnDecoderReinitialized(bool success) {
530 FUNCTION_DVLOG(2); 529 FUNCTION_DVLOG(2);
531 DCHECK(task_runner_->BelongsToCurrentThread()); 530 DCHECK(task_runner_->BelongsToCurrentThread());
532 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER); 531 DCHECK_EQ(state_, STATE_REINITIALIZING_DECODER);
533 532
534 // ReinitializeDecoder() can be called in two cases: 533 // ReinitializeDecoder() can be called in two cases:
535 // 1, Flushing decoder finished (see OnDecodeOutputReady()). 534 // 1, Flushing decoder finished (see OnDecodeOutputReady()).
536 // 2, Reset() was called during flushing decoder (see OnDecoderReset()). 535 // 2, Reset() was called during flushing decoder (see OnDecoderReset()).
537 // Also, Reset() can be called during pending ReinitializeDecoder(). 536 // Also, Reset() can be called during pending ReinitializeDecoder().
538 // This function needs to handle them all! 537 // This function needs to handle them all!
539 538
540 if (!success) { 539 if (!success) {
541 // Reinitialization failed. Try to fall back to one of the remaining 540 // Reinitialization failed. Try to fall back to one of the remaining
542 // decoders. This will consume at least one decoder so doing it more than 541 // decoders. This will consume at least one decoder so doing it more than
543 // once is safe. 542 // once is safe.
544 // For simplicity, don't attempt to fall back to a decrypting decoder. 543 // For simplicity, don't attempt to fall back to a decryptor. Calling this
545 // Calling this with a null callback ensures that one won't be selected. 544 // with a null callback ensures that one won't be selected.
546 SelectDecoder(SetCdmReadyCB()); 545 SelectDecoder(SetCdmReadyCB());
547 } else { 546 } else {
548 CompleteDecoderReinitialization(true); 547 CompleteDecoderReinitialization(true);
549 } 548 }
550 } 549 }
551 550
552 template <DemuxerStream::Type StreamType> 551 template <DemuxerStream::Type StreamType>
553 void DecoderStream<StreamType>::CompleteDecoderReinitialization(bool success) { 552 void DecoderStream<StreamType>::CompleteDecoderReinitialization(bool success) {
554 FUNCTION_DVLOG(2); 553 FUNCTION_DVLOG(2);
555 DCHECK(task_runner_->BelongsToCurrentThread()); 554 DCHECK(task_runner_->BelongsToCurrentThread());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 } 605 }
607 606
608 // The resetting process will be continued in OnDecoderReinitialized(). 607 // The resetting process will be continued in OnDecoderReinitialized().
609 ReinitializeDecoder(); 608 ReinitializeDecoder();
610 } 609 }
611 610
612 template class DecoderStream<DemuxerStream::VIDEO>; 611 template class DecoderStream<DemuxerStream::VIDEO>;
613 template class DecoderStream<DemuxerStream::AUDIO>; 612 template class DecoderStream<DemuxerStream::AUDIO>;
614 613
615 } // namespace media 614 } // 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