summaryrefslogtreecommitdiffstats
path: root/media/base/browser_cdm_factory.cc
blob: 88445d890b754d5b2fb261a5b89977e97c1d6715 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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/browser_cdm_factory.h"

#include "base/logging.h"

#if defined(OS_ANDROID)
#include "media/base/android/browser_cdm_factory_android.h"
#endif

namespace media {

namespace {
BrowserCdmFactory* g_cdm_factory = NULL;
}

void SetBrowserCdmFactory(BrowserCdmFactory* factory) {
  DCHECK(!g_cdm_factory);
  g_cdm_factory = factory;
}

scoped_ptr<BrowserCdm> CreateBrowserCdm(
    const std::string& key_system,
    bool use_hw_secure_codecs,
    const SessionMessageCB& session_message_cb,
    const SessionClosedCB& session_closed_cb,
    const LegacySessionErrorCB& legacy_session_error_cb,
    const SessionKeysChangeCB& session_keys_change_cb,
    const SessionExpirationUpdateCB& session_expiration_update_cb) {
  if (!g_cdm_factory) {
#if defined(OS_ANDROID)
    SetBrowserCdmFactory(new BrowserCdmFactoryAndroid);
#else
    LOG(ERROR) << "Cannot create BrowserCdm: no BrowserCdmFactory available!";
    return scoped_ptr<BrowserCdm>();
#endif
  }

  return g_cdm_factory->CreateBrowserCdm(
      key_system, use_hw_secure_codecs, session_message_cb, session_closed_cb,
      legacy_session_error_cb, session_keys_change_cb,
      session_expiration_update_cb);
}

}  // namespace media