Index: media/remoting/remoting_cdm_controller.cc |
diff --git a/media/remoting/remoting_cdm_controller.cc b/media/remoting/remoting_cdm_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4cce65095d2da9c629bbe2fcf340404cdfadf212 |
--- /dev/null |
+++ b/media/remoting/remoting_cdm_controller.cc |
@@ -0,0 +1,59 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "media/remoting/remoting_cdm_controller.h" |
+ |
+#include "base/bind.h" |
+#include "base/callback_helpers.h" |
+#include "base/logging.h" |
+#include "base/threading/thread_checker.h" |
+ |
+namespace media { |
+ |
+RemotingCdmController::RemotingCdmController( |
+ scoped_refptr<RemotingSourceImpl> remoting_source) |
+ : remoting_source_(std::move(remoting_source)) { |
+ remoting_source_->AddClient(this); |
+} |
+ |
+RemotingCdmController::~RemotingCdmController() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ remoting_source_->RemoveClient(this); |
+} |
+ |
+void RemotingCdmController::OnStarted(bool success) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ DCHECK(!cdm_check_cb_.is_null()); |
+ is_remoting_ = success; |
+ base::ResetAndReturn(&cdm_check_cb_).Run(success); |
xhwang
2016/11/01 08:21:28
Is it possible that |cdm_check_cb_| is null, e.g.
xjz
2016/11/01 21:55:53
No. The RemotingCdmController will only call Start
|
+} |
+ |
+void RemotingCdmController::OnSessionStateChanged() { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ |
+ if (is_remoting_ && |
+ remoting_source_->state() == RemotingSessionState::SESSION_STOPPING) { |
+ remoting_source_->Shutdown(); |
xhwang
2016/11/01 08:21:28
It's a bit confusing to me on the ownership of |re
xjz
2016/11/01 21:55:52
After SetCdm() is called, |remoting_source_| is ow
|
+ is_remoting_ = false; |
+ } |
+} |
+ |
+void RemotingCdmController::ShouldCreateRemotingCdm( |
+ const CdmCheckCallback& cb) { |
+ DCHECK(thread_checker_.CalledOnValidThread()); |
+ DCHECK(!cb.is_null()); |
+ |
+ if (is_remoting_) { |
+ cb.Run(true); |
+ return; |
+ } |
+ |
+ DCHECK(cdm_check_cb_.is_null()); |
+ cdm_check_cb_ = cb; |
+ remoting_source_->StartRemoting(this); |
xhwang
2016/11/01 16:52:37
For the majority (say >99%) of playback sessions w
xjz
2016/11/01 21:55:52
IIUC, this StartRemoting() call does not always en
xhwang
2016/11/02 06:47:05
I see. Thanks for pointing this out.
So now it se
xjz
2016/11/02 17:38:11
+miu
We currently only create the RemotingSourceI
miu
2016/11/03 00:03:08
xhwang brings up a good point. What if we created
xjz
2016/11/03 00:30:15
Yes, we can do that. So there will be always a spa
|
+} |
+ |
+} // namespace media |