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

Unified Diff: media/filters/decrypting_video_decoder.cc

Issue 11745026: Encrypted Media: Add config change support in DecryptingVideoDecoder. (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_video_decoder.cc
diff --git a/media/filters/decrypting_video_decoder.cc b/media/filters/decrypting_video_decoder.cc
index 7117d753384fa7ab80d6323ceabe14a627f6a6fe..9d3111cc5cf474c4206871664eb87a8c3b4c91c9 100644
--- a/media/filters/decrypting_video_decoder.cc
+++ b/media/filters/decrypting_video_decoder.cc
@@ -86,6 +86,7 @@ void DecryptingVideoDecoder::Reset(const base::Closure& closure) {
DVLOG(2) << "Reset() - state: " << state_;
DCHECK(message_loop_->BelongsToCurrentThread());
DCHECK(state_ == kIdle ||
+ state_ == kPendingConfigChange ||
state_ == kPendingDemuxerRead ||
state_ == kPendingDecode ||
state_ == kWaitingForKey ||
@@ -101,7 +102,9 @@ void DecryptingVideoDecoder::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 DecryptAndDecodeBuffer() and
// DeliverFrame().
- if (state_ == kPendingDemuxerRead || state_ == kPendingDecode) {
+ if (state_ == kPendingConfigChange ||
+ state_ == kPendingDemuxerRead ||
+ state_ == kPendingDecode) {
DCHECK(!read_cb_.is_null());
return;
}
@@ -195,6 +198,34 @@ void DecryptingVideoDecoder::FinishInitialization(bool success) {
base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK);
}
+void DecryptingVideoDecoder::FinishConfigChange(bool success) {
+ DVLOG(2) << "FinishConfigChange()";
+ DCHECK(message_loop_->BelongsToCurrentThread());
+
+ if (state_ == kStopped)
+ return;
+
+ DCHECK_EQ(state_, kPendingConfigChange) << state_;
+ DCHECK(!read_cb_.is_null());
+
+ if (success) {
+ if (reset_cb_.is_null()) {
ddorwin 2013/01/04 17:59:01 Could you also eliminate this indent by moving 222
xhwang 2013/01/05 00:09:55 Done.
+ state_ = kPendingDemuxerRead;
+ ReadFromDemuxerStream();
+ } else {
acolwell GONE FROM CHROMIUM 2013/01/04 16:03:20 nit: add return above and drop else
ddorwin 2013/01/04 17:59:01 Maybe even invert the logic to if (!reset_cb_.is_n
xhwang 2013/01/05 00:09:55 Done.
xhwang 2013/01/05 00:09:55 Done.
+ base::ResetAndReturn(&read_cb_).Run(kOk, NULL);
+ DoReset();
+ }
+ return;
+ }
+
+ // Config change failed.
+ base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
+ state_ = kDecodeFinished;
+ if (!reset_cb_.is_null())
+ base::ResetAndReturn(&reset_cb_).Run();
+}
+
void DecryptingVideoDecoder::ReadFromDemuxerStream() {
DCHECK(message_loop_->BelongsToCurrentThread());
DCHECK_EQ(state_, kPendingDemuxerRead) << state_;
@@ -217,10 +248,23 @@ void DecryptingVideoDecoder::DecryptAndDecodeBuffer(
DCHECK(!read_cb_.is_null());
DCHECK_EQ(buffer != NULL, status == DemuxerStream::kOk) << status;
+ if (status == DemuxerStream::kConfigChanged) {
+ DVLOG(2) << "DecryptAndDecodeBuffer() - kConfigChanged";
+
+ scoped_ptr<VideoDecoderConfig> scoped_config(new VideoDecoderConfig());
+ scoped_config->CopyFrom(demuxer_stream_->video_decoder_config());
+
+ state_ = kPendingConfigChange;
+ decryptor_->DeinitializeDecoder(Decryptor::kVideo);
+ decryptor_->InitializeVideoDecoder(
acolwell GONE FROM CHROMIUM 2013/01/04 16:03:20 nit: In a different CL, consider changing the sign
xhwang 2013/01/05 00:09:55 The original reason that I use the scoped_ptr<> he
acolwell GONE FROM CHROMIUM 2013/01/05 01:17:12 I don't understand. If you make the parameter cons
xhwang 2013/01/05 04:03:51 I remember the original reason is that in PpapiDec
+ scoped_config.Pass(), BindToCurrentLoop(base::Bind(
+ &DecryptingVideoDecoder::FinishConfigChange, this)));
+ return;
+ }
+
if (!reset_cb_.is_null()) {
base::ResetAndReturn(&read_cb_).Run(kOk, NULL);
- if (!reset_cb_.is_null())
- DoReset();
+ DoReset();
return;
}
@@ -231,16 +275,6 @@ void DecryptingVideoDecoder::DecryptAndDecodeBuffer(
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) << "DecryptAndDecodeBuffer() - kConfigChanged";
- state_ = kDecodeFinished;
- base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL);
- return;
- }
-
DCHECK_EQ(status, DemuxerStream::kOk);
pending_buffer_to_decode_ = buffer;
state_ = kPendingDecode;

Powered by Google App Engine
This is Rietveld 408576698