1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "media/base/browser_cdm_factory.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "media/base/android/media_drm_bridge.h"
11 #include "media/base/media_switches.h"
15 scoped_ptr
<BrowserCdm
> CreateBrowserCdm(
16 const std::string
& key_system
,
17 const BrowserCdm::SessionCreatedCB
& session_created_cb
,
18 const BrowserCdm::SessionMessageCB
& session_message_cb
,
19 const BrowserCdm::SessionReadyCB
& session_ready_cb
,
20 const BrowserCdm::SessionClosedCB
& session_closed_cb
,
21 const BrowserCdm::SessionErrorCB
& session_error_cb
) {
22 if (!MediaDrmBridge::IsKeySystemSupported(key_system
)) {
23 NOTREACHED() << "Unsupported key system: " << key_system
;
24 return scoped_ptr
<BrowserCdm
>();
27 scoped_ptr
<MediaDrmBridge
> cdm(MediaDrmBridge::Create(key_system
,
34 NOTREACHED() << "MediaDrmBridge cannot be created for " << key_system
;
35 return scoped_ptr
<BrowserCdm
>();
38 // TODO(xhwang/ddorwin): Pass the security level from key system.
39 MediaDrmBridge::SecurityLevel security_level
=
40 MediaDrmBridge::SECURITY_LEVEL_3
;
41 if (CommandLine::ForCurrentProcess()->HasSwitch(
42 switches::kMediaDrmEnableNonCompositing
)) {
43 security_level
= MediaDrmBridge::SECURITY_LEVEL_1
;
45 if (!cdm
->SetSecurityLevel(security_level
)) {
46 DVLOG(1) << "failed to set security level " << security_level
;
47 return scoped_ptr
<BrowserCdm
>();