OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/remoting/remoting_cdm_controller.h" | 5 #include "media/remoting/remoting_cdm_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
11 | 11 |
12 namespace media { | 12 namespace media { |
| 13 namespace remoting { |
13 | 14 |
14 RemotingCdmController::RemotingCdmController( | 15 RemotingCdmController::RemotingCdmController( |
15 scoped_refptr<RemotingSourceImpl> remoting_source) | 16 scoped_refptr<SharedSession> session) |
16 : remoting_source_(std::move(remoting_source)) { | 17 : session_(std::move(session)) { |
17 remoting_source_->AddClient(this); | 18 session_->AddClient(this); |
18 } | 19 } |
19 | 20 |
20 RemotingCdmController::~RemotingCdmController() { | 21 RemotingCdmController::~RemotingCdmController() { |
21 DCHECK(thread_checker_.CalledOnValidThread()); | 22 DCHECK(thread_checker_.CalledOnValidThread()); |
22 | 23 |
23 remoting_source_->RemoveClient(this); | 24 session_->RemoveClient(this); |
24 } | 25 } |
25 | 26 |
26 void RemotingCdmController::OnStarted(bool success) { | 27 void RemotingCdmController::OnStarted(bool success) { |
27 DCHECK(thread_checker_.CalledOnValidThread()); | 28 DCHECK(thread_checker_.CalledOnValidThread()); |
28 | 29 |
29 DCHECK(!cdm_check_cb_.is_null()); | 30 DCHECK(!cdm_check_cb_.is_null()); |
30 is_remoting_ = success; | 31 is_remoting_ = success; |
31 base::ResetAndReturn(&cdm_check_cb_).Run(success); | 32 base::ResetAndReturn(&cdm_check_cb_).Run(success); |
32 } | 33 } |
33 | 34 |
34 void RemotingCdmController::OnSessionStateChanged() { | 35 void RemotingCdmController::OnSessionStateChanged() { |
35 DCHECK(thread_checker_.CalledOnValidThread()); | 36 DCHECK(thread_checker_.CalledOnValidThread()); |
36 | 37 |
37 if (is_remoting_ && | 38 if (is_remoting_ && session_->state() == SharedSession::SESSION_STOPPING) { |
38 remoting_source_->state() == RemotingSessionState::SESSION_STOPPING) { | 39 session_->Shutdown(); |
39 remoting_source_->Shutdown(); | |
40 is_remoting_ = false; | 40 is_remoting_ = false; |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 void RemotingCdmController::ShouldCreateRemotingCdm( | 44 void RemotingCdmController::ShouldCreateRemotingCdm( |
45 const CdmCheckCallback& cb) { | 45 const CdmCheckCallback& cb) { |
46 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
47 DCHECK(!cb.is_null()); | 47 DCHECK(!cb.is_null()); |
48 | 48 |
49 if (is_remoting_) { | 49 if (is_remoting_) { |
50 cb.Run(true); | 50 cb.Run(true); |
51 return; | 51 return; |
52 } | 52 } |
53 | 53 |
54 if (!remoting_source_->is_remote_decryption_available()) { | 54 if (!session_->is_remote_decryption_available()) { |
55 cb.Run(false); | 55 cb.Run(false); |
56 return; | 56 return; |
57 } | 57 } |
58 | 58 |
59 DCHECK(cdm_check_cb_.is_null()); | 59 DCHECK(cdm_check_cb_.is_null()); |
60 cdm_check_cb_ = cb; | 60 cdm_check_cb_ = cb; |
61 remoting_source_->StartRemoting(this); | 61 session_->StartRemoting(this); |
62 } | 62 } |
63 | 63 |
| 64 } // namespace remoting |
64 } // namespace media | 65 } // namespace media |
OLD | NEW |