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

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;
ddorwin 2014/03/06 18:28:48 ditto
xhwang 2014/03/06 18:53:49 Done.
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: " << key_system;
582 return; 582 return;
583 } 583 }
584 584
585 AddDrmBridge(cdm_id, uuid, frame_url); 585 if (!MediaDrmBridge::IsKeySystemSupportedWithType(key_system, "")) {
586 NOTREACHED() << "Unsupported key system: " << key_system;
587 return;
588 }
589
590 AddDrmBridge(cdm_id, key_system, frame_url);
586 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id| 591 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id|
587 // is the same as the |player_id|. 592 // is the same as the |player_id|.
588 OnSetMediaKeys(cdm_id, cdm_id); 593 OnSetMediaKeys(cdm_id, cdm_id);
589 } 594 }
590 595
591 void BrowserMediaPlayerManager::OnCreateSession( 596 void BrowserMediaPlayerManager::OnCreateSession(
592 int cdm_id, 597 int cdm_id,
593 uint32 session_id, 598 uint32 session_id,
594 CdmHostMsg_CreateSession_ContentType content_type, 599 CdmHostMsg_CreateSession_ContentType content_type,
595 const std::vector<uint8>& init_data) { 600 const std::vector<uint8>& init_data) {
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice( 749 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice(
745 routing_id(), player->player_id())); 750 routing_id(), player->player_id()));
746 } 751 }
747 break; 752 break;
748 } 753 }
749 } 754 }
750 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); 755 return scoped_ptr<media::MediaPlayerAndroid>(previous_player);
751 } 756 }
752 757
753 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id, 758 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id,
754 const std::vector<uint8>& uuid, 759 const std::string& key_system,
755 const GURL& frame_url) { 760 const GURL& frame_url) {
756 DCHECK(!GetDrmBridge(cdm_id)); 761 DCHECK(!GetDrmBridge(cdm_id));
757 762
758 scoped_ptr<MediaDrmBridge> drm_bridge( 763 scoped_ptr<MediaDrmBridge> drm_bridge(
759 MediaDrmBridge::Create(cdm_id, uuid, frame_url, this)); 764 MediaDrmBridge::Create(cdm_id, key_system, frame_url, this));
760 if (!drm_bridge) { 765 if (!drm_bridge) {
761 // This failure will be discovered and reported by OnCreateSession() 766 // This failure will be discovered and reported by OnCreateSession()
762 // as GetDrmBridge() will return null. 767 // as GetDrmBridge() will return null.
763 DVLOG(1) << "failed to create drm bridge."; 768 DVLOG(1) << "failed to create drm bridge.";
764 return; 769 return;
765 } 770 }
766 771
767 // TODO(xhwang/ddorwin): Pass the security level from key system. 772 // TODO(xhwang/ddorwin): Pass the security level from key system.
768 MediaDrmBridge::SecurityLevel security_level = 773 MediaDrmBridge::SecurityLevel security_level =
769 MediaDrmBridge::SECURITY_LEVEL_3; 774 MediaDrmBridge::SECURITY_LEVEL_3;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 if (player && player->IsSurfaceInUse()) 884 if (player && player->IsSurfaceInUse())
880 return; 885 return;
881 ExternalVideoSurfaceContainer* surface_container = 886 ExternalVideoSurfaceContainer* surface_container =
882 ExternalVideoSurfaceContainer::FromWebContents(web_contents_); 887 ExternalVideoSurfaceContainer::FromWebContents(web_contents_);
883 if (surface_container) 888 if (surface_container)
884 surface_container->ReleaseExternalVideoSurface(player_id); 889 surface_container->ReleaseExternalVideoSurface(player_id);
885 #endif // defined(VIDEO_HOLE) 890 #endif // defined(VIDEO_HOLE)
886 } 891 }
887 892
888 } // namespace content 893 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698