summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 05:52:59 +0000
committerxhwang@chromium.org <xhwang@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-05 05:52:59 +0000
commit9680cdc110ca880595a88c2498293f4febb3348d (patch)
treedc67cf6a4d92360162137e92122b2589c6e48f5d /webkit
parente76d1454ed9a28d8f07d4c4c43d4edfc09766f94 (diff)
downloadchromium_src-9680cdc110ca880595a88c2498293f4febb3348d.zip
chromium_src-9680cdc110ca880595a88c2498293f4febb3348d.tar.gz
chromium_src-9680cdc110ca880595a88c2498293f4febb3348d.tar.bz2
Add IPC messages and handling code for EME on Clank.
BUG=233420 TEST=Enabled MSE/EME and tested on the WebM EME demo page (http://downloads.webmproject.org/adaptive-encrypted-demo/adaptive/dash-player.html). NeedKey is fired to the app and GenerateKeyRequest is passed to the browser process. Review URL: https://chromiumcodereview.appspot.com/16272005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/renderer/media/android/webmediaplayer_android.cc71
-rw-r--r--webkit/renderer/media/android/webmediaplayer_android.h16
-rw-r--r--webkit/renderer/media/android/webmediaplayer_proxy_android.h15
3 files changed, 76 insertions, 26 deletions
diff --git a/webkit/renderer/media/android/webmediaplayer_android.cc b/webkit/renderer/media/android/webmediaplayer_android.cc
index a8ae5a3..e8f543a 100644
--- a/webkit/renderer/media/android/webmediaplayer_android.cc
+++ b/webkit/renderer/media/android/webmediaplayer_android.cc
@@ -740,6 +740,7 @@ bool WebMediaPlayerAndroid::RetrieveGeometryChange(gfx::RectF* rect) {
last_computed_rect_ = *rect;
return true;
}
+#endif
// The following EME related code is copied from WebMediaPlayerImpl.
// TODO(xhwang): Remove duplicate code between WebMediaPlayerAndroid and
@@ -833,6 +834,7 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal(
<< std::string(reinterpret_cast<const char*>(init_data),
static_cast<size_t>(init_data_length));
+#if defined(GOOGLE_TV)
// 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.
@@ -842,6 +844,16 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal(
current_key_system_.reset();
return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported;
}
+#else
+ if (!proxy_)
+ return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
+
+ proxy_->GenerateKeyRequest(
+ player_id_,
+ key_system.utf8(),
+ init_data_type_,
+ std::vector<uint8>(init_data, init_data + init_data_length));
+#endif // defined(GOOGLE_TV)
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -882,8 +894,20 @@ WebMediaPlayer::MediaKeyException WebMediaPlayerAndroid::AddKeyInternal(
static_cast<size_t>(init_data_length))
<< " [" << session_id.utf8().data() << "]";
+#if defined(GOOGLE_TV)
decryptor_->AddKey(key_system.utf8(), key, key_length,
init_data, init_data_length, session_id.utf8());
+#else
+ if (!proxy_)
+ return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
+
+ proxy_->AddKey(player_id_,
+ key_system.utf8(),
+ std::vector<uint8>(key, key + key_length),
+ std::vector<uint8>(init_data, init_data + init_data_length),
+ session_id.utf8());
+#endif // #if defined(GOOGLE_TV)
+
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -906,7 +930,15 @@ WebMediaPlayerAndroid::CancelKeyRequestInternal(
if (current_key_system_.isEmpty() || key_system != current_key_system_)
return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
+#if defined(GOOGLE_TV)
decryptor_->CancelKeyRequest(key_system.utf8(), session_id.utf8());
+#else
+ if (!proxy_)
+ return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState;
+
+ proxy_->CancelKeyRequest(player_id_, key_system.utf8(), session_id.utf8());
+#endif // #if defined(GOOGLE_TV)
+
return WebMediaPlayer::MediaKeyExceptionNoError;
}
@@ -950,29 +982,17 @@ void WebMediaPlayerAndroid::OnKeyError(const std::string& key_system,
void WebMediaPlayerAndroid::OnKeyMessage(const std::string& key_system,
const std::string& session_id,
const std::string& message,
- const std::string& default_url) {
- const GURL default_url_gurl(default_url);
- DLOG_IF(WARNING, !default_url.empty() && !default_url_gurl.is_valid())
- << "Invalid URL in default_url: " << default_url;
+ const std::string& destination_url) {
+ const GURL destination_url_gurl(destination_url);
+ DLOG_IF(WARNING, !destination_url.empty() && !destination_url_gurl.is_valid())
+ << "Invalid URL in destination_url: " << destination_url;
client_->keyMessage(WebString::fromUTF8(key_system),
WebString::fromUTF8(session_id),
reinterpret_cast<const uint8*>(message.data()),
message.size(),
- default_url_gurl);
-}
-
-bool WebMediaPlayerAndroid::InjectMediaStream(
- MediaStreamClient* media_stream_client,
- media::Demuxer* demuxer,
- const base::Closure& destroy_demuxer_cb) {
- DCHECK(!demuxer);
- media_stream_client_ = media_stream_client;
- demuxer_ = demuxer;
- destroy_demuxer_cb_ = destroy_demuxer_cb;
- return true;
+ destination_url_gurl);
}
-#endif // defined(GOOGLE_TV)
void WebMediaPlayerAndroid::OnNeedKey(const std::string& key_system,
const std::string& session_id,
@@ -980,8 +1000,10 @@ void WebMediaPlayerAndroid::OnNeedKey(const std::string& key_system,
scoped_ptr<uint8[]> init_data,
int init_data_size) {
// Do not fire NeedKey event if encrypted media is not enabled.
- if (!decryptor_)
+ if (!WebKit::WebRuntimeFeatures::isEncryptedMediaEnabled() &&
+ !WebKit::WebRuntimeFeatures::isLegacyEncryptedMediaEnabled()) {
return;
+ }
UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1);
@@ -995,6 +1017,19 @@ void WebMediaPlayerAndroid::OnNeedKey(const std::string& key_system,
init_data_size);
}
+#if defined(GOOGLE_TV)
+bool WebMediaPlayerAndroid::InjectMediaStream(
+ MediaStreamClient* media_stream_client,
+ media::Demuxer* demuxer,
+ const base::Closure& destroy_demuxer_cb) {
+ DCHECK(!demuxer);
+ media_stream_client_ = media_stream_client;
+ demuxer_ = demuxer;
+ destroy_demuxer_cb_ = destroy_demuxer_cb;
+ return true;
+}
+#endif
+
void WebMediaPlayerAndroid::OnReadFromDemuxer(
media::DemuxerStream::Type type, bool seek_done) {
if (media_source_delegate_)
diff --git a/webkit/renderer/media/android/webmediaplayer_android.h b/webkit/renderer/media/android/webmediaplayer_android.h
index 9c00b01..fd78963 100644
--- a/webkit/renderer/media/android/webmediaplayer_android.h
+++ b/webkit/renderer/media/android/webmediaplayer_android.h
@@ -194,6 +194,7 @@ class WebMediaPlayerAndroid
// frame) if changed. Returns true only if the geometry has been changed since
// the last call.
bool RetrieveGeometryChange(gfx::RectF* rect);
+#endif
virtual MediaKeyException generateKeyRequest(
const WebKit::WebString& key_system,
@@ -218,12 +219,7 @@ class WebMediaPlayerAndroid
void OnKeyMessage(const std::string& key_system,
const std::string& session_id,
const std::string& message,
- const std::string& default_url);
-
- bool InjectMediaStream(MediaStreamClient* media_stream_client,
- media::Demuxer* demuxer,
- const base::Closure& destroy_demuxer_cb);
-#endif
+ const std::string& destination_url);
void OnNeedKey(const std::string& key_system,
const std::string& type,
@@ -231,6 +227,12 @@ class WebMediaPlayerAndroid
scoped_ptr<uint8[]> init_data,
int init_data_size);
+#if defined(GOOGLE_TV)
+ bool InjectMediaStream(MediaStreamClient* media_stream_client,
+ media::Demuxer* demuxer,
+ const base::Closure& destroy_demuxer_cb);
+#endif
+
// Called when DemuxerStreamPlayer needs to read data from ChunkDemuxer.
void OnReadFromDemuxer(media::DemuxerStream::Type type, bool seek_done);
@@ -261,7 +263,6 @@ class WebMediaPlayerAndroid
private:
void ReallocateVideoFrame();
-#if defined(GOOGLE_TV)
// Actually do the work for generateKeyRequest/addKey so they can easily
// report results to UMA.
MediaKeyException GenerateKeyRequestInternal(
@@ -277,7 +278,6 @@ class WebMediaPlayerAndroid
MediaKeyException CancelKeyRequestInternal(
const WebKit::WebString& key_system,
const WebKit::WebString& session_id);
-#endif
WebKit::WebFrame* const frame_;
diff --git a/webkit/renderer/media/android/webmediaplayer_proxy_android.h b/webkit/renderer/media/android/webmediaplayer_proxy_android.h
index b2677e6..03f377d 100644
--- a/webkit/renderer/media/android/webmediaplayer_proxy_android.h
+++ b/webkit/renderer/media/android/webmediaplayer_proxy_android.h
@@ -65,6 +65,21 @@ class WebMediaPlayerProxyAndroid {
virtual void ReadFromDemuxerAck(
int player_id,
const media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) = 0;
+
+ virtual void GenerateKeyRequest(int player_id,
+ const std::string& key_system,
+ const std::string& type,
+ const std::vector<uint8>& init_data) = 0;
+
+ virtual void AddKey(int player_id,
+ const std::string& key_system,
+ const std::vector<uint8>& key,
+ const std::vector<uint8>& init_data,
+ const std::string& session_id) = 0;
+
+ virtual void CancelKeyRequest(int player_id,
+ const std::string& key_system,
+ const std::string& session_id) = 0;
};
} // namespace webkit_media