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

Unified Diff: media/filters/decrypting_audio_decoder.cc

Issue 11787012: Encrypted Media: Add config change support in DecryptingAudioDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 12 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/decrypting_audio_decoder.cc
diff --git a/media/filters/decrypting_audio_decoder.cc b/media/filters/decrypting_audio_decoder.cc
index b55907ee6bb3acb8dc2076148e7e4a476e09c92c..9d635818a925ad9c7ab1a522616bee32779e8ecc 100644
--- a/media/filters/decrypting_audio_decoder.cc
+++ b/media/filters/decrypting_audio_decoder.cc
@@ -79,6 +79,7 @@ void DecryptingAudioDecoder::Reset(const base::Closure& closure) {
DVLOG(2) << "Reset() - state: " << state_;
DCHECK(state_ == kIdle ||
+ state_ == kPendingConfigChange ||
state_ == kPendingDemuxerRead ||
state_ == kPendingDecode ||
state_ == kWaitingForKey ||
@@ -94,7 +95,9 @@ void DecryptingAudioDecoder::Reset(const base::Closure& closure) {
// Defer the resetting process in this case. The |reset_cb_| will be fired
// after the read callback is fired - see DoDecryptAndDecodeBuffer() and
// DoDeliverFrame().
- if (state_ == kPendingDemuxerRead || state_ == kPendingDecode) {
+ if (state_ == kPendingConfigChange ||
+ state_ == kPendingDemuxerRead ||
+ state_ == kPendingDecode) {
DCHECK(!read_cb_.is_null());
return;
}
@@ -206,6 +209,31 @@ void DecryptingAudioDecoder::FinishInitialization(bool success) {
base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
}
+void DecryptingAudioDecoder::FinishConfigChange(bool success) {
+ DVLOG(2) << "FinishConfigChange()";
+ DCHECK(message_loop_->BelongsToCurrentThread());
+ DCHECK_EQ(state_, kPendingConfigChange) << state_;
+ DCHECK(!read_cb_.is_null());
+
+ if (!success) {
+ base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
+ state_ = kDecodeFinished;
+ if (!reset_cb_.is_null())
+ base::ResetAndReturn(&reset_cb_).Run();
+ return;
+ }
+
+ // Config change succeeded.
+ if (!reset_cb_.is_null()) {
+ base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
+ DoReset();
+ return;
+ }
+
+ state_ = kPendingDemuxerRead;
+ ReadFromDemuxerStream();
+}
+
void DecryptingAudioDecoder::DoRead(const ReadCB& read_cb) {
DVLOG(3) << "DoRead()";
DCHECK(message_loop_->BelongsToCurrentThread());
@@ -254,6 +282,20 @@ void DecryptingAudioDecoder::DoDecryptAndDecodeBuffer(
DCHECK(!read_cb_.is_null());
DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status;
+ if (status == DemuxerStream::kConfigChanged) {
+ DVLOG(2) << "DoDecryptAndDecodeBuffer() - kConfigChanged";
+
+ scoped_ptr<AudioDecoderConfig> scoped_config(new AudioDecoderConfig());
+ scoped_config->CopyFrom(demuxer_stream_->audio_decoder_config());
+
+ state_ = kPendingConfigChange;
+ decryptor_->DeinitializeDecoder(Decryptor::kAudio);
+ decryptor_->InitializeAudioDecoder(
acolwell GONE FROM CHROMIUM 2013/01/05 01:25:30 same comment for this method as in the other CL. :
xhwang 2013/01/05 04:09:24 :) will think about it more and probably do it in
+ scoped_config.Pass(), BindToCurrentLoop(base::Bind(
+ &DecryptingAudioDecoder::FinishConfigChange, this)));
+ return;
+ }
+
if (!reset_cb_.is_null()) {
base::ResetAndReturn(&read_cb_).Run(kAborted, NULL);
DoReset();
@@ -267,16 +309,6 @@ void DecryptingAudioDecoder::DoDecryptAndDecodeBuffer(
return;
}
- if (status == DemuxerStream::kConfigChanged) {
- // TODO(xhwang): Add config change support.
- // The |state_| is chosen to be kDecodeFinished here to be consistent with
- // the implementation of FFmpegVideoDecoder.
- DVLOG(2) << "DoDecryptAndDecodeBuffer() - kConfigChanged";
- state_ = kDecodeFinished;
- base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
- return;
- }
-
DCHECK_EQ(status, DemuxerStream::kOk);
// Initialize the |next_output_timestamp_| to be the timestamp of the first

Powered by Google App Engine
This is Rietveld 408576698