Work on Windows GN component build.
[chromium-blink-merge.git] / chromecast / browser / media / cast_browser_cdm_factory.cc
blobee2107a0799ac4125844377cba009870b5e107d0
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/message_loop/message_loop_proxy.h"
10 #include "chromecast/browser/media/cma_message_loop.h"
11 #include "chromecast/media/cdm/browser_cdm_cast.h"
13 namespace chromecast {
14 namespace media {
16 scoped_ptr<::media::BrowserCdm> CastBrowserCdmFactory::CreateBrowserCdm(
17 const std::string& key_system_name,
18 bool use_secure_surface,
19 const ::media::SessionMessageCB& session_message_cb,
20 const ::media::SessionClosedCB& session_closed_cb,
21 const ::media::LegacySessionErrorCB& legacy_session_error_cb,
22 const ::media::SessionKeysChangeCB& session_keys_change_cb,
23 const ::media::SessionExpirationUpdateCB& session_expiration_update_cb) {
24 DCHECK(!use_secure_surface) << "Chromecast does not use |use_secure_surface|";
26 CastKeySystem key_system(GetKeySystemByName(key_system_name));
28 scoped_ptr<chromecast::media::BrowserCdmCast> browser_cdm;
29 if (key_system == chromecast::media::KEY_SYSTEM_CLEAR_KEY) {
30 // TODO(gunsch): handle ClearKey decryption. See crbug.com/441957
31 } else {
32 browser_cdm = CreatePlatformBrowserCdm(key_system);
35 if (browser_cdm) {
36 CmaMessageLoop::GetMessageLoopProxy()->PostTask(
37 FROM_HERE,
38 base::Bind(&BrowserCdmCast::Initialize,
39 base::Unretained(browser_cdm.get()), session_message_cb,
40 session_closed_cb, legacy_session_error_cb,
41 session_keys_change_cb, session_expiration_update_cb));
42 return make_scoped_ptr(
43 new BrowserCdmCastUi(browser_cdm.Pass(),
44 CmaMessageLoop::GetMessageLoopProxy()));
47 LOG(INFO) << "No matching key system found.";
48 return scoped_ptr< ::media::BrowserCdm>();
51 } // namespace media
52 } // namespace chromecast