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/android/browser_media_player_manager.h" | 5 #include "content/browser/android/browser_media_player_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "content/browser/android/content_view_core_impl.h" | 8 #include "content/browser/android/content_view_core_impl.h" |
| 8 #include "content/browser/android/media_resource_getter_impl.h" | 9 #include "content/browser/android/media_resource_getter_impl.h" |
| 9 #include "content/browser/web_contents/web_contents_view_android.h" | 10 #include "content/browser/web_contents/web_contents_view_android.h" |
| 10 #include "content/common/media/media_player_messages_android.h" | 11 #include "content/common/media/media_player_messages_android.h" |
| 11 #include "content/public/browser/browser_context.h" | 12 #include "content/public/browser/browser_context.h" |
| 12 #include "content/public/browser/render_process_host.h" | 13 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/render_view_host.h" | 14 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/storage_partition.h" | 15 #include "content/public/browser/storage_partition.h" |
| 15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 16 #include "media/base/android/media_drm_bridge.h" | 17 #include "media/base/android/media_drm_bridge.h" |
| 18 #include "media/base/media_switches.h" | |
| 17 | 19 |
| 18 using media::MediaDrmBridge; | 20 using media::MediaDrmBridge; |
| 19 using media::MediaPlayerAndroid; | 21 using media::MediaPlayerAndroid; |
| 20 | 22 |
| 21 // Threshold on the number of media players per renderer before we start | 23 // Threshold on the number of media players per renderer before we start |
| 22 // attempting to release inactive media players. | 24 // attempting to release inactive media players. |
| 23 static const int kMediaPlayerThreshold = 1; | 25 static const int kMediaPlayerThreshold = 1; |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 | 28 |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 513 if ((*it)->player_id() == player_id) { | 515 if ((*it)->player_id() == player_id) { |
| 514 players_.erase(it); | 516 players_.erase(it); |
| 515 break; | 517 break; |
| 516 } | 518 } |
| 517 } | 519 } |
| 518 } | 520 } |
| 519 | 521 |
| 520 void BrowserMediaPlayerManager::AddDrmBridge(int media_keys_id, | 522 void BrowserMediaPlayerManager::AddDrmBridge(int media_keys_id, |
| 521 const std::vector<uint8>& uuid) { | 523 const std::vector<uint8>& uuid) { |
| 522 DCHECK(!GetDrmBridge(media_keys_id)); | 524 DCHECK(!GetDrmBridge(media_keys_id)); |
| 523 // TODO(qinmin): Pass the security level to MediaDrmBridge instead of using | 525 // TODO(xhwang/ddorwin): Pass the security level from key system. |
| 524 // the default L3. | 526 std::string security_level = "L3"; |
| 527 if (CommandLine::ForCurrentProcess() | |
| 528 ->HasSwitch(switches::kMediaDrmEnableNonCompositing)) { | |
| 529 security_level = "L1"; | |
| 530 } | |
| 531 | |
| 525 scoped_ptr<MediaDrmBridge> drm_bridge( | 532 scoped_ptr<MediaDrmBridge> drm_bridge( |
| 526 MediaDrmBridge::Create(media_keys_id, uuid, "L3", this)); | 533 MediaDrmBridge::Create(media_keys_id, uuid, security_level, this)); |
|
qinmin
2013/09/09 22:23:05
the java side MediaDrmBridge.Create() call will re
xhwang
2013/09/09 22:52:48
Since last CL (https://codereview.chromium.org/234
| |
| 527 if (!drm_bridge) { | 534 if (!drm_bridge) { |
| 528 DVLOG(1) << "failed to create drm bridge."; | 535 DVLOG(1) << "failed to create drm bridge."; |
| 536 OnKeyError(media_keys_id, "", media::MediaKeys::kUnknownError, 0); | |
| 529 return; | 537 return; |
| 530 } | 538 } |
| 531 | 539 |
| 532 drm_bridges_.push_back(drm_bridge.release()); | 540 drm_bridges_.push_back(drm_bridge.release()); |
| 533 } | 541 } |
| 534 | 542 |
| 535 void BrowserMediaPlayerManager::RemoveDrmBridge(int media_keys_id) { | 543 void BrowserMediaPlayerManager::RemoveDrmBridge(int media_keys_id) { |
| 536 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); | 544 for (ScopedVector<MediaDrmBridge>::iterator it = drm_bridges_.begin(); |
| 537 it != drm_bridges_.end(); ++it) { | 545 it != drm_bridges_.end(); ++it) { |
| 538 if ((*it)->media_keys_id() == media_keys_id) { | 546 if ((*it)->media_keys_id() == media_keys_id) { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 549 if (!player || !drm_bridge) { | 557 if (!player || !drm_bridge) { |
| 550 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; | 558 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; |
| 551 return; | 559 return; |
| 552 } | 560 } |
| 553 // TODO(qinmin): add the logic to decide whether we should create the | 561 // TODO(qinmin): add the logic to decide whether we should create the |
| 554 // fullscreen surface for EME lv1. | 562 // fullscreen surface for EME lv1. |
| 555 player->SetDrmBridge(drm_bridge); | 563 player->SetDrmBridge(drm_bridge); |
| 556 } | 564 } |
| 557 | 565 |
| 558 } // namespace content | 566 } // namespace content |
| OLD | NEW |