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/cdm/default_cdm_factory.h"
8 #include "base/bind_helpers.h"
9 #include "base/location.h"
10 #include "base/single_thread_task_runner.h"
11 #include "base/thread_task_runner_handle.h"
12 #include "media/base/key_systems.h"
13 #include "media/cdm/aes_decryptor.h"
18 DefaultCdmFactory::DefaultCdmFactory() {
21 DefaultCdmFactory::~DefaultCdmFactory() {
24 void DefaultCdmFactory::Create(
25 const std::string
& key_system
,
26 const GURL
& security_origin
,
27 const CdmConfig
& cdm_config
,
28 const SessionMessageCB
& session_message_cb
,
29 const SessionClosedCB
& session_closed_cb
,
30 const LegacySessionErrorCB
& legacy_session_error_cb
,
31 const SessionKeysChangeCB
& session_keys_change_cb
,
32 const SessionExpirationUpdateCB
& session_expiration_update_cb
,
33 const CdmCreatedCB
& cdm_created_cb
) {
34 if (!security_origin
.is_valid()) {
35 base::ThreadTaskRunnerHandle::Get()->PostTask(
36 FROM_HERE
, base::Bind(cdm_created_cb
, nullptr, "Invalid origin."));
39 if (!CanUseAesDecryptor(key_system
)) {
40 base::ThreadTaskRunnerHandle::Get()->PostTask(
42 base::Bind(cdm_created_cb
, nullptr, "Unsupported key system."));
46 scoped_ptr
<MediaKeys
> cdm(
47 new AesDecryptor(security_origin
, session_message_cb
, session_closed_cb
,
48 session_keys_change_cb
));
49 base::ThreadTaskRunnerHandle::Get()->PostTask(
50 FROM_HERE
, base::Bind(cdm_created_cb
, base::Passed(&cdm
), ""));