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

Unified Diff: webkit/media/webmediaplayer_impl.cc

Issue 11414138: Encrypted Media: No NeedKey if --enable-encrypted-media is not set. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix tests Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_impl.cc
diff --git a/webkit/media/webmediaplayer_impl.cc b/webkit/media/webmediaplayer_impl.cc
index c02e3db281ce72add1f63e4d87bf0393934089e5..9723499bd37f772fee08b4bbaae2bac805b4308b 100644
--- a/webkit/media/webmediaplayer_impl.cc
+++ b/webkit/media/webmediaplayer_impl.cc
@@ -151,11 +151,6 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
audio_renderer_sink_(audio_renderer_sink),
is_local_source_(false),
supports_save_(true),
- decryptor_(message_loop_factory_->GetMessageLoop(
- media::MessageLoopFactory::kPipeline),
- proxy_.get(),
- client,
- frame),
starting_(false) {
media_log_->AddEvent(
media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
@@ -191,6 +186,12 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
// Create default audio renderer.
filter_collection_->AddAudioRenderer(
new media::AudioRendererImpl(new media::NullAudioSink()));
+
+ const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
+ if (cmd_line->HasSwitch(switches::kEnableEncryptedMedia)) {
+ decryptor_.reset(new ProxyDecryptor(message_loop_factory_->GetMessageLoop(
+ media::MessageLoopFactory::kPipeline), proxy_.get(), client, frame));
+ }
}
WebMediaPlayerImpl::~WebMediaPlayerImpl() {
@@ -279,7 +280,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
BuildMediaSourceCollection(chunk_demuxer_,
message_loop,
filter_collection_.get(),
- &decryptor_);
+ decryptor_.get());
supports_save_ = false;
StartPipeline();
return;
@@ -301,7 +302,7 @@ void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
BuildDefaultCollection(proxy_->data_source(),
message_loop,
filter_collection_.get(),
- &decryptor_);
+ decryptor_.get());
}
void WebMediaPlayerImpl::cancelLoad() {
@@ -809,7 +810,7 @@ WebMediaPlayerImpl::GenerateKeyRequestInternal(
// TODO(xhwang): We assume all streams are from the same container (thus have
// the same "type") for now. In the future, the "type" should be passed down
// from the application.
- if (!decryptor_.GenerateKeyRequest(key_system.utf8(),
+ if (!decryptor_->GenerateKeyRequest(key_system.utf8(),
init_data_type_,
init_data, init_data_length)) {
current_key_system_.reset();
@@ -856,7 +857,7 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerImpl::AddKeyInternal(
static_cast<size_t>(init_data_length))
<< " [" << session_id.utf8().data() << "]";
- decryptor_.AddKey(key_system.utf8(), key, key_length,
+ decryptor_->AddKey(key_system.utf8(), key, key_length,
init_data, init_data_length, session_id.utf8());
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -880,7 +881,7 @@ WebMediaPlayerImpl::CancelKeyRequestInternal(
if (current_key_system_.isEmpty() || key_system != current_key_system_)
return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
- decryptor_.CancelKeyRequest(key_system.utf8(), session_id.utf8());
+ decryptor_->CancelKeyRequest(key_system.utf8(), session_id.utf8());
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -1029,6 +1030,10 @@ void WebMediaPlayerImpl::OnNeedKey(const std::string& key_system,
int init_data_size) {
DCHECK_EQ(main_loop_, MessageLoop::current());
+ // Do not fire NeedKey event if encrypted media is not enabled.
+ if (!decryptor_)
+ return;
+
UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1);
DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_);
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698