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_controller.h" |
| 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 |
| 12 namespace media { |
| 13 |
| 14 RemotingCdmController::RemotingCdmController( |
| 15 scoped_refptr<RemotingSourceImpl> remoting_source) |
| 16 : remoting_source_(std::move(remoting_source)) { |
| 17 remoting_source_->AddClient(this); |
| 18 } |
| 19 |
| 20 RemotingCdmController::~RemotingCdmController() { |
| 21 DCHECK(thread_checker_.CalledOnValidThread()); |
| 22 |
| 23 remoting_source_->RemoveClient(this); |
| 24 } |
| 25 |
| 26 void RemotingCdmController::OnStarted(bool success) { |
| 27 DCHECK(thread_checker_.CalledOnValidThread()); |
| 28 |
| 29 DCHECK(!cdm_check_cb_.is_null()); |
| 30 is_remoting_ = success; |
| 31 base::ResetAndReturn(&cdm_check_cb_).Run(success); |
| 32 } |
| 33 |
| 34 void RemotingCdmController::OnSessionStateChanged() { |
| 35 DCHECK(thread_checker_.CalledOnValidThread()); |
| 36 |
| 37 if (is_remoting_ && |
| 38 remoting_source_->state() == RemotingSessionState::SESSION_STOPPING) { |
| 39 remoting_source_->Shutdown(); |
| 40 is_remoting_ = false; |
| 41 } |
| 42 } |
| 43 |
| 44 void RemotingCdmController::ShouldCreateRemotingCdm( |
| 45 const CdmCheckCallback& cb) { |
| 46 DCHECK(thread_checker_.CalledOnValidThread()); |
| 47 DCHECK(!cb.is_null()); |
| 48 |
| 49 if (is_remoting_) { |
| 50 cb.Run(true); |
| 51 return; |
| 52 } |
| 53 |
| 54 DCHECK(cdm_check_cb_.is_null()); |
| 55 cdm_check_cb_ = cb; |
| 56 remoting_source_->StartRemoting(this); |
| 57 } |
| 58 |
| 59 } // namespace media |
OLD | NEW |