Chromium Code Reviews| 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 #include "media/remoting/remoting_controller.h" | |
| 12 | |
| 13 namespace media { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 void CreateCdm(const std::string& key_system, | |
| 18 const GURL& security_origin, | |
| 19 const CdmConfig& cdm_config, | |
| 20 const SessionMessageCB& session_message_cb, | |
| 21 const SessionClosedCB& session_closed_cb, | |
| 22 const SessionKeysChangeCB& session_keys_change_cb, | |
| 23 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
| 24 const CdmCreatedCB& cdm_created_cb, | |
| 25 std::unique_ptr<RemotingController> remoting_controller, | |
| 26 CdmFactory* const default_cdm_factory, | |
| 27 bool is_remoting) { | |
| 28 if (is_remoting) { | |
| 29 VLOG(1) << "Create remoting CDM."; | |
| 30 // TODO(xjz): Merge with Eric's implementation to create remoting CDM. | |
| 31 RemotingCdm::Create(key_system, security_origin, cdm_config, | |
| 32 session_message_cb, session_closed_cb, | |
| 33 session_keys_change_cb, session_expiration_update_cb, | |
| 34 cdm_created_cb, std::move(remoting_controller)); | |
| 35 } else { | |
| 36 VLOG(1) << "Create local CDM."; | |
| 37 default_cdm_factory->Create(key_system, security_origin, cdm_config, | |
| 38 session_message_cb, session_closed_cb, | |
| 39 session_keys_change_cb, | |
| 40 session_expiration_update_cb, cdm_created_cb); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 } // namespace | |
| 45 | |
| 46 RemotingCdmFactory::RemotingCdmFactory( | |
| 47 std::unique_ptr<CdmFactory> default_cdm_factory, | |
| 48 mojom::RemoterFactory* remoter_factory) | |
| 49 : default_cdm_factory_(std::move(default_cdm_factory)), | |
| 50 remoter_factory_(remoter_factory) {} | |
| 51 | |
| 52 RemotingCdmFactory::~RemotingCdmFactory() {} | |
| 53 | |
| 54 std::unique_ptr<RemotingController> | |
| 55 RemotingCdmFactory::CreateRemotingController() { | |
|
miu
2016/10/08 01:06:16
Folks are probably going to suggest this code go i
xjz
2016/10/20 21:25:27
This is a different case. The RendererFactory is c
| |
| 56 mojom::RemotingSourcePtr remoting_source; | |
| 57 mojom::RemotingSourceRequest remoting_source_request = | |
| 58 mojo::GetProxy(&remoting_source); | |
| 59 mojom::RemoterPtr remoter; | |
| 60 remoter_factory_->Create(std::move(remoting_source), | |
| 61 mojo::GetProxy(&remoter)); | |
| 62 return base::MakeUnique<RemotingController>( | |
| 63 std::move(remoting_source_request), std::move(remoter)); | |
| 64 } | |
| 65 | |
| 66 void RemotingCdmFactory::Create( | |
| 67 const std::string& key_system, | |
| 68 const GURL& security_origin, | |
| 69 const CdmConfig& cdm_config, | |
| 70 const SessionMessageCB& session_message_cb, | |
|
miu
2016/10/08 01:06:16
Not your problem, but this spaghetti mess of callb
xjz
2016/10/20 21:25:27
Done.
| |
| 71 const SessionClosedCB& session_closed_cb, | |
| 72 const SessionKeysChangeCB& session_keys_change_cb, | |
| 73 const SessionExpirationUpdateCB& session_expiration_update_cb, | |
| 74 const CdmCreatedCB& cdm_created_cb) { | |
| 75 std::unique_ptr<RemotingController> remoting_controller = | |
|
miu
2016/10/08 01:06:16
It's okay (and probably better) to create the Remo
xjz
2016/10/20 21:25:27
Please see my reply above. This is created one for
| |
| 76 CreateRemotingController(); | |
| 77 remoting_controller->ShouldCreateRemotingCdm(base::Bind( | |
|
miu
2016/10/08 01:06:16
This will crash: base::Passed(&remoting_controller
xjz
2016/10/20 21:25:27
Done.
| |
| 78 &CreateCdm, key_system, security_origin, cdm_config, session_message_cb, | |
| 79 session_closed_cb, session_keys_change_cb, session_expiration_update_cb, | |
| 80 cdm_created_cb, base::Passed(&remoting_controller), | |
| 81 default_cdm_factory_.get())); | |
| 82 } | |
| 83 | |
| 84 } // namespace media | |
| OLD | NEW |