Chromium Code Reviews| Index: media/base/android/cdm_factory_android.cc |
| diff --git a/media/base/android/cdm_factory_android.cc b/media/base/android/cdm_factory_android.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..39772a21d91278c26aa351dd588d6fab9555ce7f |
| --- /dev/null |
| +++ b/media/base/android/cdm_factory_android.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "media/base/android/cdm_factory.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/logging.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "media/base/android/media_drm_bridge.h" |
| +#include "media/base/media_switches.h" |
| + |
| +namespace media { |
| + |
| +scoped_ptr<MediaKeys> CreateCdm(const std::string& key_system, |
| + const SessionCreatedCB& session_created_cb, |
| + const SessionMessageCB& session_message_cb, |
| + const SessionReadyCB& session_ready_cb, |
| + const SessionClosedCB& session_closed_cb, |
| + const SessionErrorCB& session_error_cb) { |
| + if (!MediaDrmBridge::IsKeySystemSupported(key_system)) { |
| + NOTREACHED() << "Unsupported key system: " << key_system; |
| + return scoped_ptr<MediaKeys>(); |
| + } |
| + |
| + scoped_ptr<MediaDrmBridge> cdm(MediaDrmBridge::Create(key_system, |
|
ddorwin
2014/05/13 00:59:38
Are we sure this will never fail? The returned val
xhwang
2014/05/14 16:42:06
Done.
|
| + session_created_cb, |
| + session_message_cb, |
| + session_ready_cb, |
| + session_closed_cb, |
| + session_error_cb)); |
| + |
| + // TODO(xhwang/ddorwin): Pass the security level from key system. |
| + MediaDrmBridge::SecurityLevel security_level = |
| + MediaDrmBridge::SECURITY_LEVEL_3; |
| + if (CommandLine::ForCurrentProcess() |
| + ->HasSwitch(switches::kMediaDrmEnableNonCompositing)) { |
|
damienv1
2014/05/12 21:37:53
nit: looks weird to break the line on "->". Would
xhwang
2014/05/14 16:42:06
Done.
|
| + security_level = MediaDrmBridge::SECURITY_LEVEL_1; |
| + } |
| + if (!cdm->SetSecurityLevel(security_level)) { |
| + DVLOG(1) << "failed to set security level " << security_level; |
| + return scoped_ptr<MediaKeys>(); |
| + } |
| + |
| + return cdm.PassAs<MediaKeys>(); |
| +} |
| + |
| +} // namespace media |