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/browser/media/android/browser_media_player_manager.h" | 5 #include "content/browser/media/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "content/browser/android/content_view_core_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
| 9 #include "content/browser/media/android/browser_demuxer_android.h" | 9 #include "content/browser/media/android/browser_demuxer_android.h" |
| 10 #include "content/browser/media/android/media_resource_getter_impl.h" | 10 #include "content/browser/media/android/media_resource_getter_impl.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Initialize, OnInitialize) | 142 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Initialize, OnInitialize) |
| 143 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Start, OnStart) | 143 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Start, OnStart) |
| 144 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Seek, OnSeek) | 144 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Seek, OnSeek) |
| 145 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Pause, OnPause) | 145 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Pause, OnPause) |
| 146 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume) | 146 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume) |
| 147 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetPoster, OnSetPoster) | 147 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetPoster, OnSetPoster) |
| 148 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources) | 148 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources) |
| 149 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) | 149 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) |
| 150 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, | 150 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, |
| 151 DestroyAllMediaPlayers) | 151 DestroyAllMediaPlayers) |
| 152 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetCdm, OnSetCdm) | |
| 152 IPC_MESSAGE_HANDLER(CdmHostMsg_InitializeCdm, OnInitializeCdm) | 153 IPC_MESSAGE_HANDLER(CdmHostMsg_InitializeCdm, OnInitializeCdm) |
| 153 IPC_MESSAGE_HANDLER(CdmHostMsg_CreateSession, OnCreateSession) | 154 IPC_MESSAGE_HANDLER(CdmHostMsg_CreateSession, OnCreateSession) |
| 154 IPC_MESSAGE_HANDLER(CdmHostMsg_UpdateSession, OnUpdateSession) | 155 IPC_MESSAGE_HANDLER(CdmHostMsg_UpdateSession, OnUpdateSession) |
| 155 IPC_MESSAGE_HANDLER(CdmHostMsg_ReleaseSession, OnReleaseSession) | 156 IPC_MESSAGE_HANDLER(CdmHostMsg_ReleaseSession, OnReleaseSession) |
| 156 IPC_MESSAGE_HANDLER(CdmHostMsg_DestroyCdm, OnDestroyCdm) | 157 IPC_MESSAGE_HANDLER(CdmHostMsg_DestroyCdm, OnDestroyCdm) |
| 157 #if defined(VIDEO_HOLE) | 158 #if defined(VIDEO_HOLE) |
| 158 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface, | 159 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface, |
| 159 OnNotifyExternalSurface) | 160 OnNotifyExternalSurface) |
| 160 #endif // defined(VIDEO_HOLE) | 161 #endif // defined(VIDEO_HOLE) |
| 161 IPC_MESSAGE_UNHANDLED(handled = false) | 162 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 const GURL& first_party_for_cookies, | 514 const GURL& first_party_for_cookies, |
| 514 int demuxer_client_id) { | 515 int demuxer_client_id) { |
| 515 DCHECK(type != MEDIA_PLAYER_TYPE_MEDIA_SOURCE || demuxer_client_id > 0) | 516 DCHECK(type != MEDIA_PLAYER_TYPE_MEDIA_SOURCE || demuxer_client_id > 0) |
| 516 << "Media source players must have positive demuxer client IDs: " | 517 << "Media source players must have positive demuxer client IDs: " |
| 517 << demuxer_client_id; | 518 << demuxer_client_id; |
| 518 | 519 |
| 519 RemovePlayer(player_id); | 520 RemovePlayer(player_id); |
| 520 | 521 |
| 521 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( | 522 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( |
| 522 web_contents()->GetRenderProcessHost()); | 523 web_contents()->GetRenderProcessHost()); |
| 523 AddPlayer(CreateMediaPlayer( | 524 MediaPlayerAndroid* player = CreateMediaPlayer( |
| 524 type, player_id, url, first_party_for_cookies, demuxer_client_id, | 525 type, player_id, url, first_party_for_cookies, demuxer_client_id, |
| 525 host->GetBrowserContext()->IsOffTheRecord(), this, | 526 host->GetBrowserContext()->IsOffTheRecord(), this, |
| 526 host->browser_demuxer_android())); | 527 host->browser_demuxer_android()); |
| 528 if (!player) | |
| 529 return; | |
| 530 | |
| 531 AddPlayer(player); | |
| 527 } | 532 } |
| 528 | 533 |
| 529 void BrowserMediaPlayerManager::OnStart(int player_id) { | 534 void BrowserMediaPlayerManager::OnStart(int player_id) { |
| 530 MediaPlayerAndroid* player = GetPlayer(player_id); | 535 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 531 if (player) | 536 if (player) |
| 532 player->Start(); | 537 player->Start(); |
| 533 } | 538 } |
| 534 | 539 |
| 535 void BrowserMediaPlayerManager::OnSeek( | 540 void BrowserMediaPlayerManager::OnSeek( |
| 536 int player_id, | 541 int player_id, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 581 NOTREACHED() << "Invalid key system: " << key_system; | 586 NOTREACHED() << "Invalid key system: " << key_system; |
| 582 return; | 587 return; |
| 583 } | 588 } |
| 584 | 589 |
| 585 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) { | 590 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) { |
| 586 NOTREACHED() << "Unsupported key system: " << key_system; | 591 NOTREACHED() << "Unsupported key system: " << key_system; |
| 587 return; | 592 return; |
| 588 } | 593 } |
| 589 | 594 |
| 590 AddDrmBridge(cdm_id, key_system, frame_url); | 595 AddDrmBridge(cdm_id, key_system, frame_url); |
| 591 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id| | |
| 592 // is the same as the |player_id|. | |
| 593 OnSetMediaKeys(cdm_id, cdm_id); | |
| 594 } | 596 } |
| 595 | 597 |
| 596 void BrowserMediaPlayerManager::OnCreateSession( | 598 void BrowserMediaPlayerManager::OnCreateSession( |
| 597 int cdm_id, | 599 int cdm_id, |
| 598 uint32 session_id, | 600 uint32 session_id, |
| 599 CdmHostMsg_CreateSession_ContentType content_type, | 601 CdmHostMsg_CreateSession_ContentType content_type, |
| 600 const std::vector<uint8>& init_data) { | 602 const std::vector<uint8>& init_data) { |
| 601 if (init_data.size() > kMaxInitDataLength) { | 603 if (init_data.size() > kMaxInitDataLength) { |
| 602 LOG(WARNING) << "InitData for ID: " << cdm_id | 604 LOG(WARNING) << "InitData for ID: " << cdm_id |
| 603 << " too long: " << init_data.size(); | 605 << " too long: " << init_data.size(); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 void BrowserMediaPlayerManager::RemoveDrmBridge(int cdm_id) { | 774 void BrowserMediaPlayerManager::RemoveDrmBridge(int cdm_id) { |
| 773 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); | 775 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); |
| 774 it != drm_bridges_.end(); ++it) { | 776 it != drm_bridges_.end(); ++it) { |
| 775 if ((*it)->cdm_id() == cdm_id) { | 777 if ((*it)->cdm_id() == cdm_id) { |
| 776 drm_bridges_.erase(it); | 778 drm_bridges_.erase(it); |
| 777 break; | 779 break; |
| 778 } | 780 } |
| 779 } | 781 } |
| 780 } | 782 } |
| 781 | 783 |
| 782 void BrowserMediaPlayerManager::OnSetMediaKeys(int player_id, int cdm_id) { | 784 void BrowserMediaPlayerManager::OnSetCdm(int player_id, int cdm_id) { |
| 783 MediaPlayerAndroid* player = GetPlayer(player_id); | 785 MediaPlayerAndroid* player = GetPlayer(player_id); |
| 784 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id); | 786 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id); |
| 785 if (!player || !drm_bridge) { | 787 if (!drm_bridge || !player) { |
| 786 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; | 788 DVLOG(1) << "MediaDrmBridge and MediaPlayerAndroid must be present!"; |
|
ddorwin
2014/03/25 23:03:59
nit: "present" doesn't seem like the right word.
xhwang
2014/03/26 06:02:04
Done.
| |
| 787 return; | 789 return; |
| 788 } | 790 } |
| 791 | |
| 789 // TODO(qinmin): add the logic to decide whether we should create the | 792 // TODO(qinmin): add the logic to decide whether we should create the |
| 790 // fullscreen surface for EME lv1. | 793 // fullscreen surface for EME lv1. |
| 791 player->SetDrmBridge(drm_bridge); | 794 player->SetDrmBridge(drm_bridge); |
| 792 } | 795 } |
| 793 | 796 |
| 794 void BrowserMediaPlayerManager::CreateSessionIfPermitted( | 797 void BrowserMediaPlayerManager::CreateSessionIfPermitted( |
| 795 int cdm_id, | 798 int cdm_id, |
| 796 uint32 session_id, | 799 uint32 session_id, |
| 797 const std::string& content_type, | 800 const std::string& content_type, |
| 798 const std::vector<uint8>& init_data, | 801 const std::vector<uint8>& init_data, |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 869 if (player && player->IsSurfaceInUse()) | 872 if (player && player->IsSurfaceInUse()) |
| 870 return; | 873 return; |
| 871 ExternalVideoSurfaceContainer* surface_container = | 874 ExternalVideoSurfaceContainer* surface_container = |
| 872 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); | 875 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); |
| 873 if (surface_container) | 876 if (surface_container) |
| 874 surface_container->ReleaseExternalVideoSurface(player_id); | 877 surface_container->ReleaseExternalVideoSurface(player_id); |
| 875 #endif // defined(VIDEO_HOLE) | 878 #endif // defined(VIDEO_HOLE) |
| 876 } | 879 } |
| 877 | 880 |
| 878 } // namespace content | 881 } // namespace content |
| OLD | NEW |