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

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

Issue 185993004: Encrypted Media: Confine UUID code to MediaDrmBridge. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed 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 22 matching lines...) Expand all
33 using media::MediaPlayerManager; 33 using media::MediaPlayerManager;
34 using media::MediaSourcePlayer; 34 using media::MediaSourcePlayer;
35 35
36 // Threshold on the number of media players per renderer before we start 36 // Threshold on the number of media players per renderer before we start
37 // attempting to release inactive media players. 37 // attempting to release inactive media players.
38 static const int kMediaPlayerThreshold = 1; 38 static const int kMediaPlayerThreshold = 1;
39 39
40 // Maximum sizes for various EME message parameters. These are checks to 40 // Maximum sizes for various EME message parameters. These are checks to
41 // prevent unnecessarily large messages from being passed around, and the sizes 41 // prevent unnecessarily large messages from being passed around, and the sizes
42 // are somewhat arbitrary as the EME specification doesn't specify any limits. 42 // are somewhat arbitrary as the EME specification doesn't specify any limits.
43 static const size_t kEmeUuidSize = 16; 43 const size_t kEmeInitDataMaximum = 64 * 1024; // 64 KB
44 static const size_t kEmeInitDataMaximum = 64 * 1024; // 64 KB 44 const size_t kEmeResponseMaximum = 64 * 1024; // 64 KB
45 static const size_t kEmeResponseMaximum = 64 * 1024; // 64 KB 45 const size_t kEmeMaxKeySystemLength = 256;
46 46
47 namespace content { 47 namespace content {
48 48
49 static BrowserMediaPlayerManager::Factory g_factory = NULL; 49 static BrowserMediaPlayerManager::Factory g_factory = NULL;
50 50
51 // static 51 // static
52 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) { 52 void BrowserMediaPlayerManager::RegisterFactory(Factory factory) {
53 g_factory = factory; 53 g_factory = factory;
54 } 54 }
55 55
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 fullscreen_player_is_released_ = true; 566 fullscreen_player_is_released_ = true;
567 } 567 }
568 568
569 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) { 569 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) {
570 RemovePlayer(player_id); 570 RemovePlayer(player_id);
571 if (fullscreen_player_id_ == player_id) 571 if (fullscreen_player_id_ == player_id)
572 fullscreen_player_id_ = -1; 572 fullscreen_player_id_ = -1;
573 } 573 }
574 574
575 void BrowserMediaPlayerManager::OnInitializeCdm(int cdm_id, 575 void BrowserMediaPlayerManager::OnInitializeCdm(int cdm_id,
576 const std::vector<uint8>& uuid, 576 const std::string& key_system,
577 const GURL& frame_url) { 577 const GURL& frame_url) {
578 if (uuid.size() != kEmeUuidSize) { 578 if (key_system.size() > kEmeMaxKeySystemLength) {
579 // This failure will be discovered and reported by OnCreateSession() 579 // This failure will be discovered and reported by OnCreateSession()
580 // as GetDrmBridge() will return null. 580 // as GetDrmBridge() will return null.
581 NOTREACHED() << "Invalid UUID for ID: " << cdm_id; 581 NOTREACHED() << "Invalid key system name: " << key_system;
582 return; 582 return;
583 } 583 }
584 584
585 AddDrmBridge(cdm_id, uuid, frame_url); 585 // IsKeySystemSupported() should have already been checked at the render side.
586 DCHECK(MediaDrmBridge::IsKeySystemSupported(key_system, ""));
ddorwin 2014/03/05 22:11:29 If this is for security, we should probably return
xhwang 2014/03/06 18:09:57 Done.
587
588 AddDrmBridge(cdm_id, key_system, frame_url);
586 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id| 589 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id|
587 // is the same as the |player_id|. 590 // is the same as the |player_id|.
588 OnSetMediaKeys(cdm_id, cdm_id); 591 OnSetMediaKeys(cdm_id, cdm_id);
589 } 592 }
590 593
591 void BrowserMediaPlayerManager::OnCreateSession( 594 void BrowserMediaPlayerManager::OnCreateSession(
592 int cdm_id, 595 int cdm_id,
593 uint32 session_id, 596 uint32 session_id,
594 CdmHostMsg_CreateSession_ContentType content_type, 597 CdmHostMsg_CreateSession_ContentType content_type,
595 const std::vector<uint8>& init_data) { 598 const std::vector<uint8>& init_data) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice( 747 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice(
745 routing_id(), player->player_id())); 748 routing_id(), player->player_id()));
746 } 749 }
747 break; 750 break;
748 } 751 }
749 } 752 }
750 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); 753 return scoped_ptr<media::MediaPlayerAndroid>(previous_player);
751 } 754 }
752 755
753 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id, 756 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id,
754 const std::vector<uint8>& uuid, 757 const std::string& key_system,
755 const GURL& frame_url) { 758 const GURL& frame_url) {
756 DCHECK(!GetDrmBridge(cdm_id)); 759 DCHECK(!GetDrmBridge(cdm_id));
757 760
758 scoped_ptr<MediaDrmBridge> drm_bridge( 761 scoped_ptr<MediaDrmBridge> drm_bridge(
759 MediaDrmBridge::Create(cdm_id, uuid, frame_url, this)); 762 MediaDrmBridge::Create(cdm_id, key_system, frame_url, this));
760 if (!drm_bridge) { 763 if (!drm_bridge) {
761 // This failure will be discovered and reported by OnCreateSession() 764 // This failure will be discovered and reported by OnCreateSession()
762 // as GetDrmBridge() will return null. 765 // as GetDrmBridge() will return null.
763 DVLOG(1) << "failed to create drm bridge."; 766 DVLOG(1) << "failed to create drm bridge.";
764 return; 767 return;
765 } 768 }
766 769
767 // TODO(xhwang/ddorwin): Pass the security level from key system. 770 // TODO(xhwang/ddorwin): Pass the security level from key system.
768 MediaDrmBridge::SecurityLevel security_level = 771 MediaDrmBridge::SecurityLevel security_level =
769 MediaDrmBridge::SECURITY_LEVEL_3; 772 MediaDrmBridge::SECURITY_LEVEL_3;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 if (player && player->IsSurfaceInUse()) 882 if (player && player->IsSurfaceInUse())
880 return; 883 return;
881 ExternalVideoSurfaceContainer* surface_container = 884 ExternalVideoSurfaceContainer* surface_container =
882 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); 885 ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
883 if (surface_container) 886 if (surface_container)
884 surface_container->ReleaseExternalVideoSurface(player_id); 887 surface_container->ReleaseExternalVideoSurface(player_id);
885 #endif // defined(VIDEO_HOLE) 888 #endif // defined(VIDEO_HOLE)
886 } 889 }
887 890
888 } // namespace content 891 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698