Index: content/renderer/media/android/webmediaplayer_android.cc |
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc |
index 9a87ecfd7175e353fd1b0e1d0d912136beb01fc0..2daf1c711e6899553b2e650e0a1cbcf43e5cb264 100644 |
--- a/content/renderer/media/android/webmediaplayer_android.cc |
+++ b/content/renderer/media/android/webmediaplayer_android.cc |
@@ -21,6 +21,7 @@ |
#include "content/renderer/media/android/renderer_demuxer_android.h" |
#include "content/renderer/media/android/renderer_media_player_manager.h" |
#include "content/renderer/media/crypto/key_systems.h" |
+#include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
#include "content/renderer/media/webmediaplayer_delegate.h" |
#include "content/renderer/media/webmediaplayer_util.h" |
#include "content/renderer/render_frame_impl.h" |
@@ -118,6 +119,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
current_time_(0), |
is_remote_(false), |
media_log_(media_log), |
+ web_cdm_(NULL), |
weak_factory_(this) { |
DCHECK(manager_); |
@@ -1206,8 +1208,8 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal( |
frame_, |
#else |
manager_, |
- player_id_, // TODO(xhwang): Use cdm_id when MediaKeys are |
- // separated from WebMediaPlayer. |
+ player_id_, // For prefixed EME API, the CDM ID is always the same |
+ // as the player ID. |
#endif // defined(ENABLE_PEPPER_CDMS) |
base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, |
weak_factory_.GetWeakPtr()), |
@@ -1222,11 +1224,17 @@ WebMediaPlayerAndroid::GenerateKeyRequestInternal( |
return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
} |
- if (proxy_decryptor_ && !decryptor_ready_cb_.is_null()) { |
+ if (!decryptor_ready_cb_.is_null()) { |
ddorwin
2014/03/11 04:06:33
This is only for CK now?
xhwang
2014/03/12 01:07:52
Yes.
|
base::ResetAndReturn(&decryptor_ready_cb_) |
.Run(proxy_decryptor_->GetDecryptor()); |
ddorwin
2014/03/11 04:06:33
proxy_decryptor_ will never be NULL in this case?
xhwang
2014/03/12 01:07:52
Yes, see line 1205 and 1227.
|
} |
+ int cdm_id = proxy_decryptor_->GetCdmId(); |
ddorwin
2014/03/11 04:06:33
Do you still want to run this for CK?
xhwang
2014/03/12 01:07:52
Here we don't have key system specific info. We ca
|
+ if (cdm_id != media::MediaKeys::kInvalidCdmId) { |
+ DCHECK_EQ(player_id_, cdm_id) << "In prefixed EME, CDM ID == player ID."; |
+ manager_->SetMediaKeys(player_id_, cdm_id); |
+ } |
+ |
current_key_system_ = key_system; |
} else if (key_system != current_key_system_) { |
return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
@@ -1322,6 +1330,26 @@ WebMediaPlayerAndroid::CancelKeyRequestInternal(const std::string& key_system, |
return WebMediaPlayer::MediaKeyExceptionNoError; |
} |
+void WebMediaPlayerAndroid::setContentDecryptionModule( |
ddorwin
2014/03/11 04:06:33
PSA: When adding APIs on the Blink side, let's try
xhwang
2014/03/12 01:07:52
Agreed. My bad.
|
+ blink::WebContentDecryptionModule* cdm) { |
+ DCHECK(main_loop_->BelongsToCurrentThread()); |
+ |
+ // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
ddorwin
2014/03/11 04:06:33
Just a thought: Maybe we should ask the CDM if it
xhwang
2014/03/12 01:07:52
sgtm. So setContentDecryptionModule() should retur
ddorwin
2014/03/25 23:03:59
Yes, but I think we might need an explicit call si
|
+ if (!cdm) |
+ return; |
+ |
+ web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
+ if (!web_cdm_) |
+ return; |
+ |
+ if (!decryptor_ready_cb_.is_null()) |
+ base::ResetAndReturn(&decryptor_ready_cb_).Run(web_cdm_->GetDecryptor()); |
+ |
+ int cdm_id = web_cdm_->GetCdmId(); |
ddorwin
2014/03/11 04:06:33
ditto about CK
xhwang
2014/03/12 01:07:52
ditto.
|
+ if (cdm_id != media::MediaKeys::kInvalidCdmId) |
+ manager_->SetMediaKeys(player_id_, cdm_id); |
xhwang
2014/03/10 23:35:40
This is kind of ugly; we'll need some cleanup. But
ddorwin
2014/03/11 04:06:33
What in particular (that I haven't mentioned)?
I t
ddorwin
2014/03/11 18:05:14
I'm not sure that SetMediaKeys is the right term.
xhwang
2014/03/12 01:07:52
Renamed.
xhwang
2014/03/12 01:07:52
I was talking about having two ways to setMediaKey
|
+} |
+ |
void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { |
EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); |
@@ -1410,13 +1438,18 @@ void WebMediaPlayerAndroid::SetDecryptorReadyCB( |
// detail. |
DCHECK(decryptor_ready_cb_.is_null()); |
+ // Mixed use of prefixed and unprefixed EME APIs is disallowed by Blink. |
+ DCHECK(!(proxy_decryptor_ && web_cdm_)); |
ddorwin
2014/03/11 04:06:33
nit: simplify to ! || !
xhwang
2014/03/12 01:07:52
Done.
|
+ |
if (proxy_decryptor_) { |
decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor()); |
return; |
} |
- // TODO(xhwang): Also notify |web_cdm_| when we implement |
- // setContentDecryptionModule(). See: http://crbug.com/224786 |
+ if (web_cdm_) { |
+ decryptor_ready_cb.Run(web_cdm_->GetDecryptor()); |
ddorwin
2014/03/11 04:06:33
not really just used by CK?
xhwang
2014/03/12 01:07:52
ditto
|
+ return; |
+ } |
decryptor_ready_cb_ = decryptor_ready_cb; |
} |