Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "cc/layers/video_layer.h" | 17 #include "cc/layers/video_layer.h" |
| 18 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
| 19 #include "content/public/renderer/render_frame.h" | 19 #include "content/public/renderer/render_frame.h" |
| 20 #include "content/renderer/media/android/proxy_media_keys.h" | 20 #include "content/renderer/media/android/proxy_media_keys.h" |
|
ddorwin
2014/03/11 18:05:14
Remove - ProxyMediaKeys is not used.
We will tempo
xhwang
2014/03/12 01:07:52
Done.
| |
| 21 #include "content/renderer/media/android/renderer_demuxer_android.h" | 21 #include "content/renderer/media/android/renderer_demuxer_android.h" |
| 22 #include "content/renderer/media/android/renderer_media_player_manager.h" | 22 #include "content/renderer/media/android/renderer_media_player_manager.h" |
| 23 #include "content/renderer/media/crypto/key_systems.h" | 23 #include "content/renderer/media/crypto/key_systems.h" |
| 24 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | |
| 24 #include "content/renderer/media/webmediaplayer_delegate.h" | 25 #include "content/renderer/media/webmediaplayer_delegate.h" |
| 25 #include "content/renderer/media/webmediaplayer_util.h" | 26 #include "content/renderer/media/webmediaplayer_util.h" |
| 26 #include "content/renderer/render_frame_impl.h" | 27 #include "content/renderer/render_frame_impl.h" |
| 27 #include "content/renderer/render_thread_impl.h" | 28 #include "content/renderer/render_thread_impl.h" |
| 28 #include "gpu/GLES2/gl2extchromium.h" | 29 #include "gpu/GLES2/gl2extchromium.h" |
| 29 #include "gpu/command_buffer/client/gles2_interface.h" | 30 #include "gpu/command_buffer/client/gles2_interface.h" |
| 30 #include "gpu/command_buffer/common/mailbox_holder.h" | 31 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 31 #include "grit/content_resources.h" | 32 #include "grit/content_resources.h" |
| 32 #include "media/base/android/media_player_android.h" | 33 #include "media/base/android/media_player_android.h" |
| 33 #include "media/base/bind_to_current_loop.h" | 34 #include "media/base/bind_to_current_loop.h" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 has_media_metadata_(false), | 112 has_media_metadata_(false), |
| 112 has_media_info_(false), | 113 has_media_info_(false), |
| 113 stream_texture_factory_(factory), | 114 stream_texture_factory_(factory), |
| 114 needs_external_surface_(false), | 115 needs_external_surface_(false), |
| 115 video_frame_provider_client_(NULL), | 116 video_frame_provider_client_(NULL), |
| 116 pending_playback_(false), | 117 pending_playback_(false), |
| 117 player_type_(MEDIA_PLAYER_TYPE_URL), | 118 player_type_(MEDIA_PLAYER_TYPE_URL), |
| 118 current_time_(0), | 119 current_time_(0), |
| 119 is_remote_(false), | 120 is_remote_(false), |
| 120 media_log_(media_log), | 121 media_log_(media_log), |
| 122 web_cdm_(NULL), | |
| 121 weak_factory_(this) { | 123 weak_factory_(this) { |
| 122 DCHECK(manager_); | 124 DCHECK(manager_); |
| 123 | 125 |
| 124 DCHECK(main_thread_checker_.CalledOnValidThread()); | 126 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 125 | 127 |
| 126 player_id_ = manager_->RegisterMediaPlayer(this); | 128 player_id_ = manager_->RegisterMediaPlayer(this); |
| 127 | 129 |
| 128 #if defined(VIDEO_HOLE) | 130 #if defined(VIDEO_HOLE) |
| 129 // Defer stream texture creation until we are sure it's necessary. | 131 // Defer stream texture creation until we are sure it's necessary. |
| 130 needs_establish_peer_ = false; | 132 needs_establish_peer_ = false; |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1199 | 1201 |
| 1200 // We do not support run-time switching between key systems for now. | 1202 // We do not support run-time switching between key systems for now. |
| 1201 if (current_key_system_.empty()) { | 1203 if (current_key_system_.empty()) { |
| 1202 if (!proxy_decryptor_) { | 1204 if (!proxy_decryptor_) { |
| 1203 proxy_decryptor_.reset(new ProxyDecryptor( | 1205 proxy_decryptor_.reset(new ProxyDecryptor( |
| 1204 #if defined(ENABLE_PEPPER_CDMS) | 1206 #if defined(ENABLE_PEPPER_CDMS) |
| 1205 client_, | 1207 client_, |
| 1206 frame_, | 1208 frame_, |
| 1207 #else | 1209 #else |
| 1208 manager_, | 1210 manager_, |
| 1209 player_id_, // TODO(xhwang): Use cdm_id when MediaKeys are | 1211 player_id_, // For prefixed EME API, the CDM ID is always the same |
| 1210 // separated from WebMediaPlayer. | 1212 // as the player ID. |
| 1211 #endif // defined(ENABLE_PEPPER_CDMS) | 1213 #endif // defined(ENABLE_PEPPER_CDMS) |
| 1212 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, | 1214 base::Bind(&WebMediaPlayerAndroid::OnKeyAdded, |
| 1213 weak_factory_.GetWeakPtr()), | 1215 weak_factory_.GetWeakPtr()), |
| 1214 base::Bind(&WebMediaPlayerAndroid::OnKeyError, | 1216 base::Bind(&WebMediaPlayerAndroid::OnKeyError, |
| 1215 weak_factory_.GetWeakPtr()), | 1217 weak_factory_.GetWeakPtr()), |
| 1216 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, | 1218 base::Bind(&WebMediaPlayerAndroid::OnKeyMessage, |
| 1217 weak_factory_.GetWeakPtr()))); | 1219 weak_factory_.GetWeakPtr()))); |
| 1218 } | 1220 } |
| 1219 | 1221 |
| 1220 if (!proxy_decryptor_->InitializeCDM(key_system, | 1222 if (!proxy_decryptor_->InitializeCDM(key_system, |
| 1221 frame_->document().url())) { | 1223 frame_->document().url())) { |
| 1222 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 1224 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 1223 } | 1225 } |
| 1224 | 1226 |
| 1225 if (proxy_decryptor_ && !decryptor_ready_cb_.is_null()) { | 1227 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.
| |
| 1226 base::ResetAndReturn(&decryptor_ready_cb_) | 1228 base::ResetAndReturn(&decryptor_ready_cb_) |
| 1227 .Run(proxy_decryptor_->GetDecryptor()); | 1229 .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.
| |
| 1228 } | 1230 } |
| 1229 | 1231 |
| 1232 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
| |
| 1233 if (cdm_id != media::MediaKeys::kInvalidCdmId) { | |
| 1234 DCHECK_EQ(player_id_, cdm_id) << "In prefixed EME, CDM ID == player ID."; | |
| 1235 manager_->SetMediaKeys(player_id_, cdm_id); | |
| 1236 } | |
| 1237 | |
| 1230 current_key_system_ = key_system; | 1238 current_key_system_ = key_system; |
| 1231 } else if (key_system != current_key_system_) { | 1239 } else if (key_system != current_key_system_) { |
| 1232 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 1240 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 1233 } | 1241 } |
| 1234 | 1242 |
| 1235 // TODO(xhwang): We assume all streams are from the same container (thus have | 1243 // TODO(xhwang): We assume all streams are from the same container (thus have |
| 1236 // the same "type") for now. In the future, the "type" should be passed down | 1244 // the same "type") for now. In the future, the "type" should be passed down |
| 1237 // from the application. | 1245 // from the application. |
| 1238 if (!proxy_decryptor_->GenerateKeyRequest( | 1246 if (!proxy_decryptor_->GenerateKeyRequest( |
| 1239 init_data_type_, init_data, init_data_length)) { | 1247 init_data_type_, init_data, init_data_length)) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1315 if (!IsKeySystemSupported(key_system)) | 1323 if (!IsKeySystemSupported(key_system)) |
| 1316 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 1324 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 1317 | 1325 |
| 1318 if (current_key_system_.empty() || key_system != current_key_system_) | 1326 if (current_key_system_.empty() || key_system != current_key_system_) |
| 1319 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 1327 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 1320 | 1328 |
| 1321 proxy_decryptor_->CancelKeyRequest(session_id); | 1329 proxy_decryptor_->CancelKeyRequest(session_id); |
| 1322 return WebMediaPlayer::MediaKeyExceptionNoError; | 1330 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 1323 } | 1331 } |
| 1324 | 1332 |
| 1333 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.
| |
| 1334 blink::WebContentDecryptionModule* cdm) { | |
| 1335 DCHECK(main_loop_->BelongsToCurrentThread()); | |
| 1336 | |
| 1337 // 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
| |
| 1338 if (!cdm) | |
| 1339 return; | |
| 1340 | |
| 1341 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); | |
| 1342 if (!web_cdm_) | |
| 1343 return; | |
| 1344 | |
| 1345 if (!decryptor_ready_cb_.is_null()) | |
| 1346 base::ResetAndReturn(&decryptor_ready_cb_).Run(web_cdm_->GetDecryptor()); | |
| 1347 | |
| 1348 int cdm_id = web_cdm_->GetCdmId(); | |
|
ddorwin
2014/03/11 04:06:33
ditto about CK
xhwang
2014/03/12 01:07:52
ditto.
| |
| 1349 if (cdm_id != media::MediaKeys::kInvalidCdmId) | |
| 1350 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
| |
| 1351 } | |
| 1352 | |
| 1325 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { | 1353 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { |
| 1326 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); | 1354 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); |
| 1327 | 1355 |
| 1328 client_->keyAdded( | 1356 client_->keyAdded( |
| 1329 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), | 1357 WebString::fromUTF8(GetPrefixedKeySystemName(current_key_system_)), |
| 1330 WebString::fromUTF8(session_id)); | 1358 WebString::fromUTF8(session_id)); |
| 1331 } | 1359 } |
| 1332 | 1360 |
| 1333 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, | 1361 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, |
| 1334 media::MediaKeys::KeyError error_code, | 1362 media::MediaKeys::KeyError error_code, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1403 return; | 1431 return; |
| 1404 } | 1432 } |
| 1405 | 1433 |
| 1406 // TODO(xhwang): Support multiple decryptor notification request (e.g. from | 1434 // TODO(xhwang): Support multiple decryptor notification request (e.g. from |
| 1407 // video and audio). The current implementation is okay for the current | 1435 // video and audio). The current implementation is okay for the current |
| 1408 // media pipeline since we initialize audio and video decoders in sequence. | 1436 // media pipeline since we initialize audio and video decoders in sequence. |
| 1409 // But WebMediaPlayerImpl should not depend on media pipeline's implementation | 1437 // But WebMediaPlayerImpl should not depend on media pipeline's implementation |
| 1410 // detail. | 1438 // detail. |
| 1411 DCHECK(decryptor_ready_cb_.is_null()); | 1439 DCHECK(decryptor_ready_cb_.is_null()); |
| 1412 | 1440 |
| 1441 // Mixed use of prefixed and unprefixed EME APIs is disallowed by Blink. | |
| 1442 DCHECK(!(proxy_decryptor_ && web_cdm_)); | |
|
ddorwin
2014/03/11 04:06:33
nit: simplify to ! || !
xhwang
2014/03/12 01:07:52
Done.
| |
| 1443 | |
| 1413 if (proxy_decryptor_) { | 1444 if (proxy_decryptor_) { |
| 1414 decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor()); | 1445 decryptor_ready_cb.Run(proxy_decryptor_->GetDecryptor()); |
| 1415 return; | 1446 return; |
| 1416 } | 1447 } |
| 1417 | 1448 |
| 1418 // TODO(xhwang): Also notify |web_cdm_| when we implement | 1449 if (web_cdm_) { |
| 1419 // setContentDecryptionModule(). See: http://crbug.com/224786 | 1450 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
| |
| 1451 return; | |
| 1452 } | |
| 1420 | 1453 |
| 1421 decryptor_ready_cb_ = decryptor_ready_cb; | 1454 decryptor_ready_cb_ = decryptor_ready_cb; |
| 1422 } | 1455 } |
| 1423 | 1456 |
| 1424 void WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture(uint32 sync_point) { | 1457 void WebMediaPlayerAndroid::DoReleaseRemotePlaybackTexture(uint32 sync_point) { |
| 1425 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1458 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1426 DCHECK(remote_playback_texture_id_); | 1459 DCHECK(remote_playback_texture_id_); |
| 1427 | 1460 |
| 1428 GLES2Interface* gl = stream_texture_factory_->ContextGL(); | 1461 GLES2Interface* gl = stream_texture_factory_->ContextGL(); |
| 1429 | 1462 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1442 | 1475 |
| 1443 void WebMediaPlayerAndroid::exitFullscreen() { | 1476 void WebMediaPlayerAndroid::exitFullscreen() { |
| 1444 manager_->ExitFullscreen(player_id_); | 1477 manager_->ExitFullscreen(player_id_); |
| 1445 } | 1478 } |
| 1446 | 1479 |
| 1447 bool WebMediaPlayerAndroid::canEnterFullscreen() const { | 1480 bool WebMediaPlayerAndroid::canEnterFullscreen() const { |
| 1448 return manager_->CanEnterFullscreen(frame_); | 1481 return manager_->CanEnterFullscreen(frame_); |
| 1449 } | 1482 } |
| 1450 | 1483 |
| 1451 } // namespace content | 1484 } // namespace content |
| OLD | NEW |