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 RemotingCdmFactory::RemotingCdmFactory( | |
15 std::unique_ptr<CdmFactory> default_cdm_factory, | |
16 mojom::RemoterFactory* remoter_factory, | |
17 RemotingSinkObserver* sink_observer) | |
18 : default_cdm_factory_(std::move(default_cdm_factory)), | |
19 remoter_factory_(remoter_factory), | |
20 sink_observer_(sink_observer), | |
21 weak_factory_(this) { | |
22 DCHECK(default_cdm_factory_); | |
23 DCHECK(remoter_factory_); | |
24 DCHECK(sink_observer_); | |
25 } | |
26 | |
27 RemotingCdmFactory::~RemotingCdmFactory() {} | |
28 | |
29 std::unique_ptr<RemotingCdmController> | |
30 RemotingCdmFactory::CreateRemotingCdmController() { | |
31 mojom::RemotingSourcePtr remoting_source; | |
32 mojom::RemotingSourceRequest remoting_source_request = | |
33 mojo::GetProxy(&remoting_source); | |
34 mojom::RemoterPtr remoter; | |
35 remoter_factory_->Create(std::move(remoting_source), | |
36 mojo::GetProxy(&remoter)); | |
37 scoped_refptr<RemotingSourceImpl> remoting_source_impl = | |
38 new RemotingSourceImpl(std::move(remoting_source_request), | |
39 std::move(remoter)); | |
40 // Initialize the sink availability according to |sink_observer_|. | |
miu
2016/11/05 04:05:15
Please add to this comment: Explain that we are pu
xjz
2016/11/07 19:03:55
Done.
| |
41 if (sink_observer_->is_sink_available()) | |
42 remoting_source_impl->OnSinkAvailable(); | |
43 return base::MakeUnique<RemotingCdmController>(remoting_source_impl); | |
44 } | |
45 | |
46 // TODO(xjz): Replace the callbacks with an interface. http://crbug.com/657940. | |
47 void RemotingCdmFactory::Create( | |
48 const std::string& key_system, | |
49 const GURL& security_origin, | |
50 const CdmConfig& cdm_config, | |
51 const SessionMessageCB& session_message_cb, | |
52 const SessionClosedCB& session_closed_cb, | |
53 const SessionKeysChangeCB& session_keys_change_cb, | |
54 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
55 const CdmCreatedCB& cdm_created_cb) { | |
56 std::unique_ptr<RemotingCdmController> remoting_cdm_controller = | |
57 CreateRemotingCdmController(); | |
58 // Get the raw pointer of |remoting_cdm_controller| as it will be invalidated | |
59 // before calling |ShouldCreateRemotingCdm()| by base::Passed(). | |
60 RemotingCdmController* remoting_cdm_controller_ptr = | |
61 remoting_cdm_controller.get(); | |
62 remoting_cdm_controller_ptr->ShouldCreateRemotingCdm(base::Bind( | |
xhwang
2016/11/05 02:39:58
Can we check sink_observer_->is_sink_available() h
miu
2016/11/05 04:05:15
+1
xjz
2016/11/07 19:03:55
Done.
xjz
2016/11/07 19:03:55
Done.
| |
63 &RemotingCdmFactory::CreateCdm, weak_factory_.GetWeakPtr(), key_system, | |
64 security_origin, cdm_config, session_message_cb, session_closed_cb, | |
65 session_keys_change_cb, session_expiration_update_cb, cdm_created_cb, | |
66 base::Passed(&remoting_cdm_controller))); | |
67 } | |
68 | |
69 void RemotingCdmFactory::CreateCdm( | |
70 const std::string& key_system, | |
71 const GURL& security_origin, | |
72 const CdmConfig& cdm_config, | |
73 const SessionMessageCB& session_message_cb, | |
74 const SessionClosedCB& session_closed_cb, | |
75 const SessionKeysChangeCB& session_keys_change_cb, | |
76 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
77 const CdmCreatedCB& cdm_created_cb, | |
78 std::unique_ptr<RemotingCdmController> remoting_cdm_controller, | |
79 bool is_remoting) { | |
80 if (is_remoting) { | |
81 VLOG(1) << "Create remoting CDM."; | |
82 // TODO(xjz): Merge this with erickung's implementation to create remoting | |
83 // CDM. | |
84 NOTIMPLEMENTED(); | |
85 } else { | |
86 VLOG(1) << "Create default CDM."; | |
87 default_cdm_factory_->Create(key_system, security_origin, cdm_config, | |
88 session_message_cb, session_closed_cb, | |
89 session_keys_change_cb, | |
90 session_expiration_update_cb, cdm_created_cb); | |
91 } | |
92 } | |
93 | |
94 } // namespace media | |
OLD | NEW |