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 22 matching lines...) Expand all Loading... | |
| 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 kEmeMaxKeySystemSize = 1024; |
|
ddorwin
2014/03/04 20:00:56
Too long. "Length" would probably be better.
xhwang
2014/03/05 21:52:33
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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 594 fullscreen_player_is_released_ = true; | 594 fullscreen_player_is_released_ = true; |
| 595 } | 595 } |
| 596 | 596 |
| 597 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) { | 597 void BrowserMediaPlayerManager::OnDestroyPlayer(int player_id) { |
| 598 RemovePlayer(player_id); | 598 RemovePlayer(player_id); |
| 599 if (fullscreen_player_id_ == player_id) | 599 if (fullscreen_player_id_ == player_id) |
| 600 fullscreen_player_id_ = -1; | 600 fullscreen_player_id_ = -1; |
| 601 } | 601 } |
| 602 | 602 |
| 603 void BrowserMediaPlayerManager::OnInitializeCdm(int cdm_id, | 603 void BrowserMediaPlayerManager::OnInitializeCdm(int cdm_id, |
| 604 const std::vector<uint8>& uuid, | 604 const std::string& key_system, |
| 605 const GURL& frame_url) { | 605 const GURL& frame_url) { |
| 606 if (uuid.size() != kEmeUuidSize) { | 606 if (key_system.size() > kEmeMaxKeySystemSize) { |
| 607 // This failure will be discovered and reported by OnCreateSession() | 607 // This failure will be discovered and reported by OnCreateSession() |
| 608 // as GetDrmBridge() will return null. | 608 // as GetDrmBridge() will return null. |
| 609 NOTREACHED() << "Invalid UUID for ID: " << cdm_id; | 609 NOTREACHED() << "Invalid key system name: " << key_system; |
| 610 return; | 610 return; |
| 611 } | 611 } |
| 612 | 612 |
| 613 AddDrmBridge(cdm_id, uuid, frame_url); | 613 AddDrmBridge(cdm_id, key_system, frame_url); |
| 614 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id| | 614 // In EME v0.1b MediaKeys lives in the media element. So the |cdm_id| |
| 615 // is the same as the |player_id|. | 615 // is the same as the |player_id|. |
| 616 OnSetMediaKeys(cdm_id, cdm_id); | 616 OnSetMediaKeys(cdm_id, cdm_id); |
| 617 } | 617 } |
| 618 | 618 |
| 619 void BrowserMediaPlayerManager::OnCreateSession( | 619 void BrowserMediaPlayerManager::OnCreateSession( |
| 620 int cdm_id, | 620 int cdm_id, |
| 621 uint32 session_id, | 621 uint32 session_id, |
| 622 CdmHostMsg_CreateSession_ContentType content_type, | 622 CdmHostMsg_CreateSession_ContentType content_type, |
| 623 const std::vector<uint8>& init_data) { | 623 const std::vector<uint8>& init_data) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice( | 772 Send(new MediaPlayerMsg_DisconnectedFromRemoteDevice( |
| 773 routing_id(), player->player_id())); | 773 routing_id(), player->player_id())); |
| 774 } | 774 } |
| 775 break; | 775 break; |
| 776 } | 776 } |
| 777 } | 777 } |
| 778 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); | 778 return scoped_ptr<media::MediaPlayerAndroid>(previous_player); |
| 779 } | 779 } |
| 780 | 780 |
| 781 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id, | 781 void BrowserMediaPlayerManager::AddDrmBridge(int cdm_id, |
| 782 const std::vector<uint8>& uuid, | 782 const std::string& key_system, |
| 783 const GURL& frame_url) { | 783 const GURL& frame_url) { |
| 784 DCHECK(!GetDrmBridge(cdm_id)); | 784 DCHECK(!GetDrmBridge(cdm_id)); |
| 785 | 785 |
| 786 scoped_ptr<MediaDrmBridge> drm_bridge( | 786 scoped_ptr<MediaDrmBridge> drm_bridge( |
| 787 MediaDrmBridge::Create(cdm_id, uuid, frame_url, this)); | 787 MediaDrmBridge::Create(cdm_id, key_system, frame_url, this)); |
| 788 if (!drm_bridge) { | 788 if (!drm_bridge) { |
| 789 // This failure will be discovered and reported by OnCreateSession() | 789 // This failure will be discovered and reported by OnCreateSession() |
| 790 // as GetDrmBridge() will return null. | 790 // as GetDrmBridge() will return null. |
| 791 DVLOG(1) << "failed to create drm bridge."; | 791 DVLOG(1) << "failed to create drm bridge."; |
| 792 return; | 792 return; |
| 793 } | 793 } |
| 794 | 794 |
| 795 // TODO(xhwang/ddorwin): Pass the security level from key system. | 795 // TODO(xhwang/ddorwin): Pass the security level from key system. |
| 796 MediaDrmBridge::SecurityLevel security_level = | 796 MediaDrmBridge::SecurityLevel security_level = |
| 797 MediaDrmBridge::SECURITY_LEVEL_3; | 797 MediaDrmBridge::SECURITY_LEVEL_3; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 867 if (player->IsPlaying()) | 867 if (player->IsPlaying()) |
| 868 OnProtectedSurfaceRequested(cdm_id); | 868 OnProtectedSurfaceRequested(cdm_id); |
| 869 } | 869 } |
| 870 | 870 |
| 871 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( | 871 void BrowserMediaPlayerManager::ReleaseFullscreenPlayer( |
| 872 MediaPlayerAndroid* player) { | 872 MediaPlayerAndroid* player) { |
| 873 player->Release(); | 873 player->Release(); |
| 874 } | 874 } |
| 875 | 875 |
| 876 } // namespace content | 876 } // namespace content |
| OLD | NEW |