Index: media/base/android/browser_cdm_factory_android.cc |
diff --git a/media/base/android/browser_cdm_factory_android.cc b/media/base/android/browser_cdm_factory_android.cc |
index 82f11d1385f4318d429f3a0b433f1e7d61a0582f..4afe9cb17fb61b211203f023d3b8283cf4cf5cd6 100644 |
--- a/media/base/android/browser_cdm_factory_android.cc |
+++ b/media/base/android/browser_cdm_factory_android.cc |
@@ -8,12 +8,13 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "media/base/android/media_drm_bridge.h" |
+#include "media/base/android/media_drm_proxy.h" |
#include "media/base/media_switches.h" |
#include "third_party/widevine/cdm/widevine_cdm_common.h" |
namespace media { |
-scoped_ptr<BrowserCdm> BrowserCdmFactoryAndroid::CreateBrowserCdm( |
+BrowserCdmPtr BrowserCdmFactoryAndroid::CreateBrowserCdm( |
const std::string& key_system, |
bool use_hw_secure_codecs, |
const SessionMessageCB& session_message_cb, |
@@ -23,35 +24,41 @@ scoped_ptr<BrowserCdm> BrowserCdmFactoryAndroid::CreateBrowserCdm( |
const SessionExpirationUpdateCB& session_expiration_update_cb) { |
if (!MediaDrmBridge::IsKeySystemSupported(key_system)) { |
NOTREACHED() << "Unsupported key system: " << key_system; |
- return scoped_ptr<BrowserCdm>(); |
+ return BrowserCdmPtr(); |
} |
- scoped_ptr<MediaDrmBridge> cdm( |
- MediaDrmBridge::Create(key_system, session_message_cb, session_closed_cb, |
- legacy_session_error_cb, session_keys_change_cb, |
- session_expiration_update_cb)); |
- if (!cdm) { |
- NOTREACHED() << "MediaDrmBridge cannot be created for " << key_system; |
- return scoped_ptr<BrowserCdm>(); |
- } |
+ MediaDrmBridge::SecurityLevel security_level = |
+ MediaDrmBridge::SECURITY_LEVEL_NONE; |
if (key_system == kWidevineKeySystem) { |
- MediaDrmBridge::SecurityLevel security_level = |
- use_hw_secure_codecs ? MediaDrmBridge::SECURITY_LEVEL_1 |
- : MediaDrmBridge::SECURITY_LEVEL_3; |
- if (!cdm->SetSecurityLevel(security_level)) { |
- DVLOG(1) << "failed to set security level " << security_level; |
- return scoped_ptr<BrowserCdm>(); |
- } |
- } else { |
+ security_level = use_hw_secure_codecs ? MediaDrmBridge::SECURITY_LEVEL_1 |
+ : MediaDrmBridge::SECURITY_LEVEL_3; |
+ } else if (!use_hw_secure_codecs) { |
// Assume other key systems require hardware-secure codecs and thus do not |
// support full compositing. |
- if (!use_hw_secure_codecs) { |
- NOTREACHED() |
- << key_system |
- << " may require use_video_overlay_for_embedded_encrypted_video"; |
- return scoped_ptr<BrowserCdm>(); |
- } |
+ NOTREACHED() |
+ << key_system |
+ << " may require use_video_overlay_for_embedded_encrypted_video"; |
+ return scoped_ptr<BrowserCdm, BrowserCdmDeleter>(); |
+ } |
+ |
+ BrowserCdmPtr cdm; |
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableMediaThreadForMediaPlayback)) { |
+ cdm = BrowserCdmPtr(MediaDrmProxy::Create( |
+ key_system, security_level, session_message_cb, session_closed_cb, |
+ legacy_session_error_cb, session_keys_change_cb, |
+ session_expiration_update_cb)); |
+ |
+ if (!cdm) |
+ NOTREACHED() << "MediaDrmProxy cannot be created for " << key_system; |
+ } else { |
+ cdm = BrowserCdmPtr(MediaDrmBridge::Create( |
+ key_system, security_level, session_message_cb, session_closed_cb, |
+ legacy_session_error_cb, session_keys_change_cb, |
+ session_expiration_update_cb)); |
+ if (!cdm) |
+ NOTREACHED() << "MediaDrmBridge cannot be created for " << key_system; |
} |
return cdm.Pass(); |