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 #ifndef MEDIA_REMOTING_REMOTING_CDM_CONTROLLER_H_ |
| 6 #define MEDIA_REMOTING_REMOTING_CDM_CONTROLLER_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/threading/thread_checker.h" |
| 11 #include "media/remoting/remoting_source_impl.h" |
| 12 |
| 13 namespace media { |
| 14 |
| 15 // This class controlls whether to start a remoting session to create CDM. |
| 16 // The |remoting_source_| will be passed to the RemotingRendererController when |
| 17 // the CDM is attached to a media element. |
| 18 class RemotingCdmController final : public RemotingSourceImpl::Client { |
| 19 public: |
| 20 explicit RemotingCdmController( |
| 21 scoped_refptr<RemotingSourceImpl> remoting_source); |
| 22 ~RemotingCdmController(); |
| 23 |
| 24 // RemotingSourceImpl::Client implementations. |
| 25 void OnStarted(bool success) override; |
| 26 void OnSessionStateChanged() override; |
| 27 |
| 28 // Returns whether we should create remoting CDM via |cb|, which could be run |
| 29 // synchronously or asynchronously, depending on whether the required |
| 30 // information is available now or later. |
| 31 using CdmCheckCallback = base::Callback<void(bool is_remoting)>; |
| 32 void ShouldCreateRemotingCdm(const CdmCheckCallback& cb); |
| 33 |
| 34 RemotingSourceImpl* remoting_source() const { |
| 35 DCHECK(thread_checker_.CalledOnValidThread()); |
| 36 return remoting_source_.get(); |
| 37 } |
| 38 |
| 39 private: |
| 40 const scoped_refptr<RemotingSourceImpl> remoting_source_; |
| 41 |
| 42 // This callback is run once to report whether to create remoting CDM. |
| 43 CdmCheckCallback cdm_check_cb_; |
| 44 |
| 45 // Indicates if the session is in remoting. |
| 46 bool is_remoting_ = false; |
| 47 |
| 48 base::ThreadChecker thread_checker_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(RemotingCdmController); |
| 51 }; |
| 52 |
| 53 } // namespace media |
| 54 |
| 55 #endif // MEDIA_REMOTING_REMOTING_CDM_CONTROLLER_H_ |
OLD | NEW |