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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 193523002: Encrypted Media: Implement IPC based SetCdm(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 6 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 const GURL& first_party_for_cookies, 516 const GURL& first_party_for_cookies,
516 int demuxer_client_id) { 517 int demuxer_client_id) {
517 DCHECK(type != MEDIA_PLAYER_TYPE_MEDIA_SOURCE || demuxer_client_id > 0) 518 DCHECK(type != MEDIA_PLAYER_TYPE_MEDIA_SOURCE || demuxer_client_id > 0)
518 << "Media source players must have positive demuxer client IDs: " 519 << "Media source players must have positive demuxer client IDs: "
519 << demuxer_client_id; 520 << demuxer_client_id;
520 521
521 RemovePlayer(player_id); 522 RemovePlayer(player_id);
522 523
523 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>( 524 RenderProcessHostImpl* host = static_cast<RenderProcessHostImpl*>(
524 web_contents()->GetRenderProcessHost()); 525 web_contents()->GetRenderProcessHost());
525 AddPlayer(CreateMediaPlayer( 526 MediaPlayerAndroid* player = CreateMediaPlayer(
526 type, player_id, url, first_party_for_cookies, demuxer_client_id, 527 type, player_id, url, first_party_for_cookies, demuxer_client_id,
527 host->GetBrowserContext()->IsOffTheRecord(), this, 528 host->GetBrowserContext()->IsOffTheRecord(), this,
528 host->browser_demuxer_android())); 529 host->browser_demuxer_android());
530 if (!player)
531 return;
532
533 AddPlayer(player);
529 } 534 }
530 535
531 void BrowserMediaPlayerManager::OnStart(int player_id) { 536 void BrowserMediaPlayerManager::OnStart(int player_id) {
532 MediaPlayerAndroid* player = GetPlayer(player_id); 537 MediaPlayerAndroid* player = GetPlayer(player_id);
533 if (player) 538 if (player)
534 player->Start(); 539 player->Start();
535 } 540 }
536 541
537 void BrowserMediaPlayerManager::OnSeek( 542 void BrowserMediaPlayerManager::OnSeek(
538 int player_id, 543 int player_id,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 NOTREACHED() << "Invalid key system: " << key_system; 588 NOTREACHED() << "Invalid key system: " << key_system;
584 return; 589 return;
585 } 590 }
586 591
587 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) { 592 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) {
588 NOTREACHED() << "Unsupported key system: " << key_system; 593 NOTREACHED() << "Unsupported key system: " << key_system;
589 return; 594 return;
590 } 595 }
591 596
592 AddDrmBridge(cdm_id, key_system, frame_url); 597 AddDrmBridge(cdm_id, key_system, frame_url);
593 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id|
594 // is the same as the |player_id|.
595 OnSetMediaKeys(cdm_id, cdm_id);
596 } 598 }
597 599
598 void BrowserMediaPlayerManager::OnCreateSession( 600 void BrowserMediaPlayerManager::OnCreateSession(
599 int cdm_id, 601 int cdm_id,
600 uint32 session_id, 602 uint32 session_id,
601 CdmHostMsg_CreateSession_ContentType content_type, 603 CdmHostMsg_CreateSession_ContentType content_type,
602 const std::vector<uint8>& init_data) { 604 const std::vector<uint8>& init_data) {
603 if (init_data.size() > kMaxInitDataLength) { 605 if (init_data.size() > kMaxInitDataLength) {
604 LOG(WARNING) << "InitData for ID: " << cdm_id 606 LOG(WARNING) << "InitData for ID: " << cdm_id
605 << " too long: " << init_data.size(); 607 << " too long: " << init_data.size();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 void BrowserMediaPlayerManager::RemoveDrmBridge(int cdm_id) { 776 void BrowserMediaPlayerManager::RemoveDrmBridge(int cdm_id) {
775 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); 777 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin();
776 it != drm_bridges_.end(); ++it) { 778 it != drm_bridges_.end(); ++it) {
777 if ((*it)->cdm_id() == cdm_id) { 779 if ((*it)->cdm_id() == cdm_id) {
778 drm_bridges_.erase(it); 780 drm_bridges_.erase(it);
779 break; 781 break;
780 } 782 }
781 } 783 }
782 } 784 }
783 785
784 void BrowserMediaPlayerManager::OnSetMediaKeys(int player_id, int cdm_id) { 786 void BrowserMediaPlayerManager::OnSetCdm(int player_id, int cdm_id) {
785 MediaPlayerAndroid* player = GetPlayer(player_id); 787 MediaPlayerAndroid* player = GetPlayer(player_id);
786 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id); 788 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id);
787 if (!player || !drm_bridge) { 789 if (!drm_bridge || !player) {
788 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; 790 DVLOG(1) << "Cannot set CDM on the specified player.";
789 return; 791 return;
790 } 792 }
793
791 // TODO(qinmin): add the logic to decide whether we should create the 794 // TODO(qinmin): add the logic to decide whether we should create the
792 // fullscreen surface for EME lv1. 795 // fullscreen surface for EME lv1.
793 player->SetDrmBridge(drm_bridge); 796 player->SetDrmBridge(drm_bridge);
794 } 797 }
795 798
796 void BrowserMediaPlayerManager::CreateSessionIfPermitted( 799 void BrowserMediaPlayerManager::CreateSessionIfPermitted(
797 int cdm_id, 800 int cdm_id,
798 uint32 session_id, 801 uint32 session_id,
799 const std::string& content_type, 802 const std::string& content_type,
800 const std::vector<uint8>& init_data, 803 const std::vector<uint8>& init_data,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 if (player && player->IsSurfaceInUse()) 874 if (player && player->IsSurfaceInUse())
872 return; 875 return;
873 ExternalVideoSurfaceContainer* surface_container = 876 ExternalVideoSurfaceContainer* surface_container =
874 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); 877 ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
875 if (surface_container) 878 if (surface_container)
876 surface_container->ReleaseExternalVideoSurface(player_id); 879 surface_container->ReleaseExternalVideoSurface(player_id);
877 #endif // defined(VIDEO_HOLE) 880 #endif // defined(VIDEO_HOLE)
878 } 881 }
879 882
880 } // namespace content 883 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698