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

Unified Diff: media/blink/encrypted_media_player_support.cc

Issue 759933003: Move OnNeedKey() to WebMediaPlayerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years 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 | « media/blink/encrypted_media_player_support.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/encrypted_media_player_support.cc
diff --git a/media/blink/encrypted_media_player_support.cc b/media/blink/encrypted_media_player_support.cc
index bfb6ed526fda120f54a1dbf0c3457ad69706f0b0..01422e5a2ac8e9793c27276cbe7ad3391fa2e36e 100644
--- a/media/blink/encrypted_media_player_support.cc
+++ b/media/blink/encrypted_media_player_support.cc
@@ -20,7 +20,6 @@
#include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
#include "third_party/WebKit/public/web/WebDocument.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
using blink::WebMediaPlayer;
using blink::WebMediaPlayerClient;
@@ -138,9 +137,8 @@ EncryptedMediaPlayerSupport::GenerateKeyRequest(
std::string ascii_key_system =
GetUnprefixedKeySystemName(ToASCIIOrEmpty(key_system));
- WebMediaPlayer::MediaKeyException e =
- GenerateKeyRequestInternal(frame, ascii_key_system, init_data,
- init_data_length);
+ WebMediaPlayer::MediaKeyException e = GenerateKeyRequestInternal(
+ frame, ascii_key_system, init_data, init_data_length);
ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e);
return e;
}
@@ -185,11 +183,8 @@ EncryptedMediaPlayerSupport::GenerateKeyRequestInternal(
if (init_data_type.empty())
init_data_type = GuessInitDataType(init_data, init_data_length);
- // 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 (!proxy_decryptor_->GenerateKeyRequest(
- init_data_type, init_data, init_data_length)) {
+ if (!proxy_decryptor_->GenerateKeyRequest(init_data_type, init_data,
+ init_data_length)) {
current_key_system_.clear();
return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
}
@@ -278,34 +273,20 @@ EncryptedMediaPlayerSupport::CancelKeyRequestInternal(
return WebMediaPlayer::MediaKeyExceptionNoError;
}
-Demuxer::NeedKeyCB EncryptedMediaPlayerSupport::CreateNeedKeyCB() {
- return BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnNeedKey);
+void EncryptedMediaPlayerSupport::SetInitDataType(
+ const std::string& init_data_type) {
+ DCHECK(!init_data_type.empty());
+ DLOG_IF(WARNING,
+ !init_data_type_.empty() && init_data_type != init_data_type_)
+ << "Mixed init data type not supported. The new type is ignored.";
+ if (init_data_type_.empty())
+ init_data_type_ = init_data_type;
}
void EncryptedMediaPlayerSupport::OnPipelineDecryptError() {
EmeUMAHistogramCounts(current_key_system_, "DecryptError", 1);
}
-void EncryptedMediaPlayerSupport::OnNeedKey(
- const std::string& type,
- const std::vector<uint8>& init_data) {
- // Do not fire NeedKey event if encrypted media is not enabled.
- if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
- !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
- return;
- }
-
- UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1);
-
- DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_);
- if (init_data_type_.empty())
- init_data_type_ = type;
-
- const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0];
- client_->encrypted(WebString::fromUTF8(type), init_data_ptr,
- base::saturated_cast<unsigned int>(init_data.size()));
-}
-
void EncryptedMediaPlayerSupport::OnKeyAdded(const std::string& session_id) {
EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1);
client_->keyAdded(
« no previous file with comments | « media/blink/encrypted_media_player_support.h ('k') | media/blink/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698