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

Unified Diff: webkit/media/crypto/ppapi_decryptor.cc

Issue 11144036: Update Decryptor interface to support audio decoding. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: resolve comments Created 8 years, 2 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: webkit/media/crypto/ppapi_decryptor.cc
diff --git a/webkit/media/crypto/ppapi_decryptor.cc b/webkit/media/crypto/ppapi_decryptor.cc
index 5b049266b6528bfec0349ffd0f6ae7ad6b491718..5436f7d69b0afc745b626b3afcac8ece95547d88 100644
--- a/webkit/media/crypto/ppapi_decryptor.cc
+++ b/webkit/media/crypto/ppapi_decryptor.cc
@@ -12,6 +12,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
#include "base/message_loop_proxy.h"
+#include "media/base/audio_decoder_config.h"
#include "media/base/decoder_buffer.h"
#include "media/base/decryptor_client.h"
#include "media/base/video_decoder_config.h"
@@ -73,8 +74,11 @@ void PpapiDecryptor::AddKey(const std::string& key_system,
ReportFailureToCallPlugin(key_system, session_id);
}
- if (!key_added_cb_.is_null())
- key_added_cb_.Run();
+ if (!audio_key_added_cb_.is_null())
+ audio_key_added_cb_.Run();
+
+ if (!video_key_added_cb_.is_null())
+ video_key_added_cb_.Run();
}
void PpapiDecryptor::CancelKeyRequest(const std::string& key_system,
@@ -90,26 +94,57 @@ void PpapiDecryptor::CancelKeyRequest(const std::string& key_system,
// TODO(xhwang): Remove Unretained in the following methods.
void PpapiDecryptor::Decrypt(
+ StreamType stream_type,
const scoped_refptr<media::DecoderBuffer>& encrypted,
const DecryptCB& decrypt_cb) {
if (!render_loop_proxy_->BelongsToCurrentThread()) {
render_loop_proxy_->PostTask(
FROM_HERE,
base::Bind(&PpapiDecryptor::Decrypt, base::Unretained(this),
- encrypted, decrypt_cb));
+ stream_type, encrypted, decrypt_cb));
return;
}
- DVLOG(3) << "Decrypt()";
+ DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
if (!cdm_plugin_->Decrypt(encrypted, decrypt_cb))
decrypt_cb.Run(kError, NULL);
}
-void PpapiDecryptor::CancelDecrypt() {
- DVLOG(1) << "CancelDecrypt()";
+void PpapiDecryptor::CancelDecrypt(StreamType stream_type) {
+ DVLOG(1) << "CancelDecrypt() - stream_type: " << stream_type;
// TODO(xhwang): Implement CancelDecrypt() in PluginInstance and call it here.
}
+void PpapiDecryptor::InitializeAudioDecoder(
+ scoped_ptr<media::AudioDecoderConfig> config,
+ const DecoderInitCB& init_cb,
+ const KeyAddedCB& key_added_cb) {
+ if (!render_loop_proxy_->BelongsToCurrentThread()) {
+ render_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&PpapiDecryptor::InitializeAudioDecoder,
+ base::Unretained(this), base::Passed(&config),
+ init_cb, key_added_cb));
+ return;
+ }
+
+ DVLOG(2) << "InitializeAudioDecoder()";
+ DCHECK(config->is_encrypted());
+ DCHECK(config->IsValidConfig());
+
+ audio_decoder_init_cb_ = init_cb;
+ // TODO(xhwang): Implement InitializeAudioDecoder() in PluginInstance and call
+ // it here.
+ NOTIMPLEMENTED();
+ // if (!cdm_plugin_->InitializeAudioDecoder(
scherkus (not reviewing) 2012/10/18 02:08:36 use #if 0 instead
+ // *config,
+ // base::Bind(&PpapiDecryptor::OnDecoderInitialized,
+ // base::Unretained(this), kAudio, key_added_cb))) {
+ base::ResetAndReturn(&audio_decoder_init_cb_).Run(false);
+ // return;
+ // }
+}
+
void PpapiDecryptor::InitializeVideoDecoder(
scoped_ptr<media::VideoDecoderConfig> config,
const DecoderInitCB& init_cb,
@@ -128,18 +163,33 @@ void PpapiDecryptor::InitializeVideoDecoder(
DCHECK(config->IsValidConfig());
video_decoder_init_cb_ = init_cb;
- key_added_cb_ = key_added_cb;
-
if (!cdm_plugin_->InitializeVideoDecoder(
*config,
- base::Bind(&PpapiDecryptor::OnVideoDecoderInitialized,
- base::Unretained(this)))) {
- key_added_cb_.Reset();
+ base::Bind(&PpapiDecryptor::OnDecoderInitialized,
+ base::Unretained(this), kVideo, key_added_cb))) {
base::ResetAndReturn(&video_decoder_init_cb_).Run(false);
return;
}
}
+void PpapiDecryptor::DecryptAndDecodeAudio(
+ const scoped_refptr<media::DecoderBuffer>& encrypted,
+ const AudioDecodeCB& audio_decode_cb) {
+ if (!render_loop_proxy_->BelongsToCurrentThread()) {
+ render_loop_proxy_->PostTask(
+ FROM_HERE,
+ base::Bind(&PpapiDecryptor::DecryptAndDecodeAudio,
+ base::Unretained(this), encrypted, audio_decode_cb));
+ return;
+ }
+
+ DVLOG(1) << "DecryptAndDecodeAudio()";
+ NOTIMPLEMENTED();
+ // TODO(xhwang): Enable this once PluginInstance is updated.
+ // if (!cdm_plugin_->DecryptAndDecodeAudio(encrypted, audio_decode_cb))
scherkus (not reviewing) 2012/10/18 02:08:36 use #if 0 instead
+ audio_decode_cb.Run(kError, AudioBuffers());
+}
+
void PpapiDecryptor::DecryptAndDecodeVideo(
const scoped_refptr<media::DecoderBuffer>& encrypted,
const VideoDecodeCB& video_decode_cb) {
@@ -156,28 +206,31 @@ void PpapiDecryptor::DecryptAndDecodeVideo(
video_decode_cb.Run(kError, NULL);
}
-void PpapiDecryptor::CancelDecryptAndDecodeVideo() {
+void PpapiDecryptor::ResetDecoder(StreamType stream_type) {
if (!render_loop_proxy_->BelongsToCurrentThread()) {
render_loop_proxy_->PostTask(
FROM_HERE,
- base::Bind(&PpapiDecryptor::CancelDecryptAndDecodeVideo,
- base::Unretained(this)));
+ base::Bind(&PpapiDecryptor::ResetDecoder,
+ base::Unretained(this), stream_type));
return;
}
- DVLOG(2) << "CancelDecryptAndDecodeVideo()";
+ DVLOG(2) << "ResetDecoder() - stream_type: " << stream_type;
+ // TODO(xhwang): Support stream type in PluginInstance.
cdm_plugin_->ResetDecoder();
}
-void PpapiDecryptor::StopVideoDecoder() {
+void PpapiDecryptor::DeinitializeDecoder(StreamType stream_type) {
if (!render_loop_proxy_->BelongsToCurrentThread()) {
render_loop_proxy_->PostTask(
FROM_HERE,
- base::Bind(&PpapiDecryptor::StopVideoDecoder, base::Unretained(this)));
+ base::Bind(&PpapiDecryptor::DeinitializeDecoder,
+ base::Unretained(this), stream_type));
return;
}
- DVLOG(2) << "StopVideoDecoder()";
+ DVLOG(2) << "DeinitializeDecoder() - stream_type: " << stream_type;
+ // TODO(xhwang): Support stream type in PluginInstance.
cdm_plugin_->DeinitializeDecoder();
}
@@ -187,14 +240,31 @@ void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system,
client_->KeyError(key_system, session_id, kUnknownError, 0);
}
-void PpapiDecryptor::OnVideoDecoderInitialized(bool success) {
- DCHECK(!key_added_cb_.is_null());
- DCHECK(!video_decoder_init_cb_.is_null());
-
- if (!success)
- key_added_cb_.Reset();
-
- base::ResetAndReturn(&video_decoder_init_cb_).Run(success);
+void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type,
+ const KeyAddedCB& key_added_cb,
+ bool success) {
+ DCHECK(!key_added_cb.is_null());
+
+ switch (stream_type) {
+ case kAudio:
+ DCHECK(audio_key_added_cb_.is_null());
+ DCHECK(!audio_decoder_init_cb_.is_null());
+ if (success)
+ audio_key_added_cb_ = key_added_cb;
+ base::ResetAndReturn(&audio_decoder_init_cb_).Run(success);
+ break;
+
+ case kVideo:
+ DCHECK(video_key_added_cb_.is_null());
+ DCHECK(!video_decoder_init_cb_.is_null());
+ if (success)
+ video_key_added_cb_ = key_added_cb;
+ base::ResetAndReturn(&video_decoder_init_cb_).Run(success);
+ break;
+
+ default:
+ NOTREACHED();
+ }
}
} // namespace webkit_media

Powered by Google App Engine
This is Rietveld 408576698