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