OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #include "media/remoting/remoting_cdm_factory.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/single_thread_task_runner.h" | |
9 #include "media/base/cdm_config.h" | |
10 #include "media/remoting/remoting_cdm.h" | |
11 | |
12 namespace media { | |
13 | |
14 namespace { | |
15 | |
16 void CreateCdm(const std::string& key_system, | |
17 const GURL& security_origin, | |
18 const CdmConfig& cdm_config, | |
19 const SessionMessageCB& session_message_cb, | |
20 const SessionClosedCB& session_closed_cb, | |
21 const SessionKeysChangeCB& session_keys_change_cb, | |
22 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
23 const CdmCreatedCB& cdm_created_cb, | |
24 std::unique_ptr<RemotingCdmController> remoting_controller, | |
25 CdmFactory* const default_cdm_factory, | |
26 bool is_remoting) { | |
27 if (is_remoting) { | |
28 VLOG(1) << "Create remoting CDM."; | |
29 // TODO(xjz): Merge this with Eric's implementation to create remoting CDM. | |
30 NOTIMPLEMENTED(); | |
xhwang
2016/11/01 08:21:29
If we land this CL now, when we are "remoting" (no
xjz
2016/11/01 21:55:53
No, we will never enable "remoting" if we land thi
miu
2016/11/03 00:03:08
I talked about this issue here: https://codereview
xhwang
2016/11/03 06:41:01
Makes sense. As long as we always pick the default
| |
31 } else { | |
xhwang
2016/11/01 08:21:29
nit: we like to return early:
if (foo) {
Bar();
xjz
2016/11/01 21:55:53
This seems fine to me, as we will merge with the R
| |
32 VLOG(1) << "Create local CDM."; | |
33 default_cdm_factory->Create(key_system, security_origin, cdm_config, | |
34 session_message_cb, session_closed_cb, | |
35 session_keys_change_cb, | |
36 session_expiration_update_cb, cdm_created_cb); | |
37 } | |
38 } | |
39 | |
40 } // namespace | |
41 | |
42 RemotingCdmFactory::RemotingCdmFactory( | |
43 std::unique_ptr<CdmFactory> default_cdm_factory, | |
44 mojom::RemoterFactory* remoter_factory) | |
45 : default_cdm_factory_(std::move(default_cdm_factory)), | |
46 remoter_factory_(remoter_factory) { | |
47 DCHECK(default_cdm_factory_); | |
48 DCHECK(remoter_factory_); | |
49 } | |
50 | |
51 RemotingCdmFactory::~RemotingCdmFactory() {} | |
52 | |
53 std::unique_ptr<RemotingCdmController> | |
54 RemotingCdmFactory::CreateRemotingController() { | |
55 mojom::RemotingSourcePtr remoting_source; | |
56 mojom::RemotingSourceRequest remoting_source_request = | |
57 mojo::GetProxy(&remoting_source); | |
58 mojom::RemoterPtr remoter; | |
59 remoter_factory_->Create(std::move(remoting_source), | |
60 mojo::GetProxy(&remoter)); | |
61 return base::MakeUnique<RemotingCdmController>( | |
62 make_scoped_refptr(new RemotingSourceImpl( | |
63 std::move(remoting_source_request), std::move(remoter)))); | |
64 } | |
65 | |
66 // TODO: Replace the callbacks with an interface. http://crbug.com/657940. | |
xhwang
2016/11/01 08:21:29
nit: Usually you have a name/ladp for the TODO :)
xjz
2016/11/01 21:55:53
Done.
| |
67 void RemotingCdmFactory::Create( | |
68 const std::string& key_system, | |
69 const GURL& security_origin, | |
70 const CdmConfig& cdm_config, | |
71 const SessionMessageCB& session_message_cb, | |
72 const SessionClosedCB& session_closed_cb, | |
73 const SessionKeysChangeCB& session_keys_change_cb, | |
74 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
75 const CdmCreatedCB& cdm_created_cb) { | |
76 std::unique_ptr<RemotingCdmController> remoting_controller = | |
77 CreateRemotingController(); | |
78 RemotingCdmController* remoting_controller_ptr = remoting_controller.get(); | |
xhwang
2016/11/01 08:21:29
nit: It's worth a comment why you are doing this.
xjz
2016/11/01 21:55:53
Done.
| |
79 remoting_controller_ptr->ShouldCreateRemotingCdm(base::Bind( | |
80 &CreateCdm, key_system, security_origin, cdm_config, session_message_cb, | |
81 session_closed_cb, session_keys_change_cb, session_expiration_update_cb, | |
82 cdm_created_cb, base::Passed(&remoting_controller), | |
83 default_cdm_factory_.get())); | |
xhwang
2016/11/01 08:21:29
Is it possible that the callback is fired after |t
xjz
2016/11/01 21:55:53
Changed CreateCdm() as a member function of Remoti
| |
84 } | |
85 | |
86 } // namespace media | |
OLD | NEW |