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(); |
| 31 } else { |
| 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. |
| 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(); |
| 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())); |
| 84 } |
| 85 |
| 86 } // namespace media |
OLD | NEW |