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 | |
| 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 new RemotingCdm(key_system, security_origin, cdm_config, session_message_cb, | |
|
miu
2016/10/25 04:21:25
It's always a little strange to see a "new Foo()"
xjz
2016/10/26 22:00:25
Oh, yes, this is wrong. I made this mistake while
| |
| 31 session_closed_cb, session_keys_change_cb, | |
| 32 session_expiration_update_cb, cdm_created_cb, | |
| 33 std::move(remoting_controller)); | |
| 34 } else { | |
| 35 VLOG(1) << "Create local CDM."; | |
| 36 default_cdm_factory->Create(key_system, security_origin, cdm_config, | |
| 37 session_message_cb, session_closed_cb, | |
| 38 session_keys_change_cb, | |
| 39 session_expiration_update_cb, cdm_created_cb); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 } // namespace | |
| 44 | |
| 45 RemotingCdmFactory::RemotingCdmFactory( | |
| 46 std::unique_ptr<CdmFactory> default_cdm_factory, | |
| 47 mojom::RemoterFactory* remoter_factory) | |
| 48 : default_cdm_factory_(std::move(default_cdm_factory)), | |
| 49 remoter_factory_(remoter_factory) {} | |
|
miu
2016/10/25 04:21:25
Please DCHECK that |default_cdm_factory_| and |rem
xjz
2016/10/26 22:00:25
Done.
| |
| 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 scoped_refptr<RemotingSourceImpl> remoting_source_impl = | |
| 62 new RemotingSourceImpl(std::move(remoting_source_request), | |
| 63 std::move(remoter)); | |
| 64 return base::MakeUnique<RemotingCdmController>( | |
| 65 std::move(remoting_source_impl)); | |
|
miu
2016/10/25 04:21:25
ditto here: Consider using make_scoped_refptr() to
xjz
2016/10/26 22:00:25
Done.
| |
| 66 } | |
| 67 | |
| 68 // TODO: Replace the callbacks with an interface. http://crbug.com/657940. | |
| 69 void RemotingCdmFactory::Create( | |
| 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_controller = | |
| 79 CreateRemotingController(); | |
| 80 RemotingCdmController* remoting_controller_ptr = remoting_controller.get(); | |
| 81 remoting_controller_ptr->ShouldCreateRemotingCdm(base::Bind( | |
| 82 &CreateCdm, key_system, security_origin, cdm_config, session_message_cb, | |
| 83 session_closed_cb, session_keys_change_cb, session_expiration_update_cb, | |
| 84 cdm_created_cb, base::Passed(&remoting_controller), | |
| 85 default_cdm_factory_.get())); | |
| 86 } | |
| 87 | |
| 88 } // namespace media | |
| OLD | NEW |