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

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: 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
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..7214a55266432f8393b3913698f3578c0aa36804 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;
@@ -129,6 +128,7 @@ WebMediaPlayer::MediaKeyException
EncryptedMediaPlayerSupport::GenerateKeyRequest(
blink::WebLocalFrame* frame,
const WebString& key_system,
+ const std::string& init_data_type,
const unsigned char* init_data,
unsigned init_data_length) {
DVLOG(1) << "generateKeyRequest: " << base::string16(key_system) << ": "
@@ -138,9 +138,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_type, init_data, init_data_length);
ReportMediaKeyExceptionToUMA("generateKeyRequest", ascii_key_system, e);
return e;
}
@@ -149,6 +148,7 @@ WebMediaPlayer::MediaKeyException
EncryptedMediaPlayerSupport::GenerateKeyRequestInternal(
blink::WebLocalFrame* frame,
const std::string& key_system,
+ const std::string& init_data_type,
const unsigned char* init_data,
unsigned init_data_length) {
if (!IsConcreteSupportedKeySystem(key_system))
@@ -181,15 +181,12 @@ EncryptedMediaPlayerSupport::GenerateKeyRequestInternal(
return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
}
- std::string init_data_type = init_data_type_;
- if (init_data_type.empty())
- init_data_type = GuessInitDataType(init_data, init_data_length);
+ std::string local_init_data_type = init_data_type;
+ if (local_init_data_type.empty())
+ local_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)) {
+ local_init_data_type, init_data, init_data_length)) {
current_key_system_.clear();
return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
}
@@ -278,34 +275,10 @@ EncryptedMediaPlayerSupport::CancelKeyRequestInternal(
return WebMediaPlayer::MediaKeyExceptionNoError;
}
-Demuxer::NeedKeyCB EncryptedMediaPlayerSupport::CreateNeedKeyCB() {
- return BIND_TO_RENDER_LOOP(&EncryptedMediaPlayerSupport::OnNeedKey);
-}
-
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(

Powered by Google App Engine
This is Rietveld 408576698