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

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: Created 6 years, 9 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_SetMediaKeys, OnSetMediaKeys)
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
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);
532
533 if (pending_set_media_keys_map_.find(player_id) ==
534 pending_set_media_keys_map_.end()) {
535 return;
536 }
537
538 int cdm_id = pending_set_media_keys_map_[player_id];
ddorwin 2014/03/11 04:06:33 Better to save a temp iterator above?
xhwang 2014/03/12 01:07:52 Obsolete.
539 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id);
ddorwin 2014/03/11 04:06:33 Should we erase it from the map? Otherwise, we'll
xhwang 2014/03/12 01:07:52 You are right. But this code is obsolete now.
540 if (!drm_bridge)
ddorwin 2014/03/11 04:06:33 Should this ever fail?
xhwang 2014/03/12 01:07:52 This code is obsolete. But this is possible. OnIni
541 player->SetDrmBridge(drm_bridge);
527 } 542 }
528 543
529 void BrowserMediaPlayerManager::OnStart(int player_id) { 544 void BrowserMediaPlayerManager::OnStart(int player_id) {
530 MediaPlayerAndroid* player = GetPlayer(player_id); 545 MediaPlayerAndroid* player = GetPlayer(player_id);
531 if (player) 546 if (player)
532 player->Start(); 547 player->Start();
533 } 548 }
534 549
535 void BrowserMediaPlayerManager::OnSeek( 550 void BrowserMediaPlayerManager::OnSeek(
536 int player_id, 551 int player_id,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 NOTREACHED() << "Invalid key system: " << key_system; 596 NOTREACHED() << "Invalid key system: " << key_system;
582 return; 597 return;
583 } 598 }
584 599
585 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) { 600 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) {
586 NOTREACHED() << "Unsupported key system: " << key_system; 601 NOTREACHED() << "Unsupported key system: " << key_system;
587 return; 602 return;
588 } 603 }
589 604
590 AddDrmBridge(cdm_id, key_system, frame_url); 605 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 } 606 }
595 607
596 void BrowserMediaPlayerManager::OnCreateSession( 608 void BrowserMediaPlayerManager::OnCreateSession(
597 int cdm_id, 609 int cdm_id,
598 uint32 session_id, 610 uint32 session_id,
599 CdmHostMsg_CreateSession_ContentType content_type, 611 CdmHostMsg_CreateSession_ContentType content_type,
600 const std::vector<uint8>& init_data) { 612 const std::vector<uint8>& init_data) {
601 if (init_data.size() > kMaxInitDataLength) { 613 if (init_data.size() > kMaxInitDataLength) {
602 LOG(WARNING) << "InitData for ID: " << cdm_id 614 LOG(WARNING) << "InitData for ID: " << cdm_id
603 << " too long: " << init_data.size(); 615 << " too long: " << init_data.size();
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); 800 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin();
789 it != drm_bridges_.end(); ++it) { 801 it != drm_bridges_.end(); ++it) {
790 if ((*it)->cdm_id() == cdm_id) { 802 if ((*it)->cdm_id() == cdm_id) {
791 drm_bridges_.erase(it); 803 drm_bridges_.erase(it);
792 break; 804 break;
793 } 805 }
794 } 806 }
795 } 807 }
796 808
797 void BrowserMediaPlayerManager::OnSetMediaKeys(int player_id, int cdm_id) { 809 void BrowserMediaPlayerManager::OnSetMediaKeys(int player_id, int cdm_id) {
798 MediaPlayerAndroid* player = GetPlayer(player_id);
799 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id); 810 MediaDrmBridge* drm_bridge = GetDrmBridge(cdm_id);
800 if (!player || !drm_bridge) { 811 if (!drm_bridge) {
801 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; 812 DVLOG(1) << "OnSetMediaKeys(): MediaDrmBridge must be present.";
802 return; 813 return;
803 } 814 }
815
816 MediaPlayerAndroid* player = GetPlayer(player_id);
817 // SetMediaKeys() may be called before the player is loaded.
ddorwin 2014/03/11 04:06:33 How do we know the player_id in that case?
xhwang 2014/03/12 01:07:52 Removed.
818 if (!player) {
819 pending_set_media_keys_map_[player_id] = cdm_id;
820 return;
821 }
822
804 // TODO(qinmin): add the logic to decide whether we should create the 823 // TODO(qinmin): add the logic to decide whether we should create the
805 // fullscreen surface for EME lv1. 824 // fullscreen surface for EME lv1.
806 player->SetDrmBridge(drm_bridge); 825 player->SetDrmBridge(drm_bridge);
807 } 826 }
808 827
809 void BrowserMediaPlayerManager::CreateSessionIfPermitted( 828 void BrowserMediaPlayerManager::CreateSessionIfPermitted(
810 int cdm_id, 829 int cdm_id,
811 uint32 session_id, 830 uint32 session_id,
812 const std::string& content_type, 831 const std::string& content_type,
813 const std::vector<uint8>& init_data, 832 const std::vector<uint8>& init_data,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 if (player && player->IsSurfaceInUse()) 903 if (player && player->IsSurfaceInUse())
885 return; 904 return;
886 ExternalVideoSurfaceContainer* surface_container = 905 ExternalVideoSurfaceContainer* surface_container =
887 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); 906 ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
888 if (surface_container) 907 if (surface_container)
889 surface_container->ReleaseExternalVideoSurface(player_id); 908 surface_container->ReleaseExternalVideoSurface(player_id);
890 #endif // defined(VIDEO_HOLE) 909 #endif // defined(VIDEO_HOLE)
891 } 910 }
892 911
893 } // namespace content 912 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698