Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: media/remoting/remoting_cdm_factory.cc

Issue 2457563002: Media Remoting: Add remoting control logic for encrypted contents. (Closed)
Patch Set: Addressed xhwang's comments. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 : default_cdm_factory_(std::move(default_cdm_factory)),
18 remoter_factory_(remoter_factory),
19 weak_factory_(this) {
20 DCHECK(default_cdm_factory_);
21 DCHECK(remoter_factory_);
22 }
23
24 RemotingCdmFactory::~RemotingCdmFactory() {}
25
26 std::unique_ptr<RemotingCdmController>
27 RemotingCdmFactory::CreateRemotingCdmController() {
28 mojom::RemotingSourcePtr remoting_source;
29 mojom::RemotingSourceRequest remoting_source_request =
30 mojo::GetProxy(&remoting_source);
31 mojom::RemoterPtr remoter;
32 remoter_factory_->Create(std::move(remoting_source),
33 mojo::GetProxy(&remoter));
34 return base::MakeUnique<RemotingCdmController>(
35 make_scoped_refptr(new RemotingSourceImpl(
36 std::move(remoting_source_request), std::move(remoter))));
37 }
38
39 // TODO(xjz): Replace the callbacks with an interface. http://crbug.com/657940.
40 void RemotingCdmFactory::Create(
41 const std::string& key_system,
42 const GURL& security_origin,
43 const CdmConfig& cdm_config,
44 const SessionMessageCB& session_message_cb,
45 const SessionClosedCB& session_closed_cb,
46 const SessionKeysChangeCB& session_keys_change_cb,
47 const SessionExpirationUpdateCB& session_expiration_update_cb,
48 const CdmCreatedCB& cdm_created_cb) {
49 std::unique_ptr<RemotingCdmController> remoting_cdm_controller =
50 CreateRemotingCdmController();
51 // Get the raw pointer of |remoting_cdm_controller| as it will be invalidated
52 // before calling |ShouldCreateRemotingCdm()| by base::Passed().
53 RemotingCdmController* remoting_cdm_controller_ptr =
54 remoting_cdm_controller.get();
55 remoting_cdm_controller_ptr->ShouldCreateRemotingCdm(base::Bind(
56 &RemotingCdmFactory::CreateCdm, weak_factory_.GetWeakPtr(), key_system,
57 security_origin, cdm_config, session_message_cb, session_closed_cb,
58 session_keys_change_cb, session_expiration_update_cb, cdm_created_cb,
59 base::Passed(&remoting_cdm_controller)));
60 }
61
62 void RemotingCdmFactory::CreateCdm(
63 const std::string& key_system,
64 const GURL& security_origin,
65 const CdmConfig& cdm_config,
66 const SessionMessageCB& session_message_cb,
67 const SessionClosedCB& session_closed_cb,
68 const SessionKeysChangeCB& session_keys_change_cb,
69 const SessionExpirationUpdateCB& session_expiration_update_cb,
70 const CdmCreatedCB& cdm_created_cb,
71 std::unique_ptr<RemotingCdmController> remoting_cdm_controller,
72 bool is_remoting) {
73 if (is_remoting) {
74 VLOG(1) << "Create remoting CDM.";
75 // TODO(xjz): Merge this with erickung's implementation to create remoting
76 // CDM.
77 NOTIMPLEMENTED();
78 } else {
79 VLOG(1) << "Create local CDM.";
xhwang 2016/11/02 06:47:05 The CDM could run in ppapi or other process so it'
xjz 2016/11/02 17:38:11 Done.
80 default_cdm_factory_->Create(key_system, security_origin, cdm_config,
81 session_message_cb, session_closed_cb,
82 session_keys_change_cb,
83 session_expiration_update_cb, cdm_created_cb);
84 }
85 }
86
87 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698