Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / chromecast / browser / media / cast_browser_cdm_factory.cc
blob67a0891070fa9cc164e1066262bddfed6dd8261a
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 "chromecast/browser/media/cast_browser_cdm_factory.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "chromecast/media/base/media_message_loop.h"
11 #include "chromecast/media/cdm/browser_cdm_cast.h"
12 #include "media/base/bind_to_current_loop.h"
13 #include "media/base/cdm_key_information.h"
15 namespace chromecast {
16 namespace media {
18 scoped_ptr<::media::BrowserCdm> CastBrowserCdmFactory::CreateBrowserCdm(
19 const std::string& key_system_name,
20 bool use_hw_secure_codecs,
21 const ::media::SessionMessageCB& session_message_cb,
22 const ::media::SessionClosedCB& session_closed_cb,
23 const ::media::LegacySessionErrorCB& legacy_session_error_cb,
24 const ::media::SessionKeysChangeCB& session_keys_change_cb,
25 const ::media::SessionExpirationUpdateCB& session_expiration_update_cb) {
26 DCHECK(!use_hw_secure_codecs)
27 << "Chromecast does not use |use_hw_secure_codecs|";
29 CastKeySystem key_system(GetKeySystemByName(key_system_name));
31 scoped_ptr<chromecast::media::BrowserCdmCast> browser_cdm;
32 if (key_system == chromecast::media::KEY_SYSTEM_CLEAR_KEY) {
33 // TODO(gunsch): handle ClearKey decryption. See crbug.com/441957
34 } else {
35 browser_cdm = CreatePlatformBrowserCdm(key_system);
38 if (browser_cdm) {
39 MediaMessageLoop::GetTaskRunner()->PostTask(
40 FROM_HERE,
41 base::Bind(&BrowserCdmCast::Initialize,
42 base::Unretained(browser_cdm.get()),
43 ::media::BindToCurrentLoop(session_message_cb),
44 ::media::BindToCurrentLoop(session_closed_cb),
45 ::media::BindToCurrentLoop(legacy_session_error_cb),
46 ::media::BindToCurrentLoop(session_keys_change_cb),
47 ::media::BindToCurrentLoop(session_expiration_update_cb)));
48 return make_scoped_ptr(new BrowserCdmCastUi(
49 browser_cdm.Pass(), MediaMessageLoop::GetTaskRunner()));
52 LOG(INFO) << "No matching key system found.";
53 return scoped_ptr< ::media::BrowserCdm>();
56 } // namespace media
57 } // namespace chromecast