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 "media/remoting/remoting_source_impl.h" | |
11 | |
12 namespace base { | |
13 class ThreadChecker; | |
14 } | |
15 | |
16 namespace media { | |
17 | |
18 // This class controlls whether to start a remoting session to create CDM. | |
19 // The |remoting_source_| will be passed to the RemotingRendererController when | |
20 // the CDM is attached to a media element. | |
21 class RemotingCdmController final : public RemotingSourceImpl::Client { | |
22 public: | |
23 explicit RemotingCdmController( | |
24 scoped_refptr<RemotingSourceImpl> remoting_source); | |
25 ~RemotingCdmController(); | |
26 | |
27 // RemotingSourceImpl::Client implementations. | |
28 void OnStarted(bool success) override; | |
29 void OnSessionStateChanged() override; | |
30 | |
31 // Query whether to create a Media Remoting CDM. |cb| could be run | |
32 // synchronously or asynchronously, depending on whether the required | |
33 // information is available now or later. | |
34 using CdmCheckCallback = base::Callback<void(bool is_remoting)>; | |
35 void ShouldCreateRemotingCdm(const CdmCheckCallback& cb); | |
36 | |
37 scoped_refptr<RemotingSourceImpl> remoting_source() { | |
38 DCHECK(thread_checker_.CalledOnValidThread()); | |
39 return remoting_source_; | |
40 } | |
41 | |
42 private: | |
43 // This callback is run once to report whether to create remoting CDM. | |
44 CdmCheckCallback cdm_check_cb_; | |
45 | |
46 // Indicates if remoting is started. | |
47 bool is_remoting_ = false; | |
48 | |
49 scoped_refptr<RemotingSourceImpl> remoting_source_; | |
miu
2016/10/25 04:21:25
nit: const (and move up to be the first data membe
xjz
2016/10/26 22:00:25
Done.
| |
50 | |
51 // This is used to check all the methods are called on the current thread in | |
52 // debug builds. | |
53 base::ThreadChecker thread_checker_; | |
54 | |
55 DISALLOW_COPY_AND_ASSIGN(RemotingCdmController); | |
56 }; | |
57 | |
58 } // namespace media | |
59 | |
60 #endif // MEDIA_REMOTING_REMOTING_CDM_CONTROLLER_H_ | |
OLD | NEW |