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 #include "media/remoting/remoting_renderer_controller.h" | 5 #include "media/remoting/remoting_renderer_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/threading/thread_checker.h" | 9 #include "base/threading/thread_checker.h" |
10 #include "media/remoting/remoting_cdm_context.h" | 10 #include "media/remoting/remoting_cdm_context.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 } else { | 36 } else { |
37 VLOG(1) << "Failed to start remoting."; | 37 VLOG(1) << "Failed to start remoting."; |
38 remote_rendering_started_ = false; | 38 remote_rendering_started_ = false; |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 void RemotingRendererController::OnSessionStateChanged() { | 42 void RemotingRendererController::OnSessionStateChanged() { |
43 DCHECK(thread_checker_.CalledOnValidThread()); | 43 DCHECK(thread_checker_.CalledOnValidThread()); |
44 | 44 |
45 VLOG(1) << "OnSessionStateChanged: " << remoting_source_->state(); | 45 VLOG(1) << "OnSessionStateChanged: " << remoting_source_->state(); |
46 if (!sink_available_changed_cb_.is_null()) | |
47 sink_available_changed_cb_.Run(IsRemoteSinkAvailable()); | |
48 | |
46 UpdateAndMaybeSwitch(); | 49 UpdateAndMaybeSwitch(); |
47 } | 50 } |
48 | 51 |
52 bool RemotingRendererController::IsRemoteSinkAvailable() { | |
53 DCHECK(thread_checker_.CalledOnValidThread()); | |
54 | |
55 switch (remoting_source_->state()) { | |
56 case SESSION_CAN_START: | |
57 case SESSION_STARTING: | |
58 case SESSION_STARTED: | |
59 return true; | |
60 case SESSION_UNAVAILABLE: | |
61 case SESSION_STOPPING: | |
62 case SESSION_PERMANENTLY_STOPPED: | |
63 return false; | |
64 } | |
65 } | |
66 | |
49 void RemotingRendererController::OnEnteredFullscreen() { | 67 void RemotingRendererController::OnEnteredFullscreen() { |
50 DCHECK(thread_checker_.CalledOnValidThread()); | 68 DCHECK(thread_checker_.CalledOnValidThread()); |
51 | 69 |
52 is_fullscreen_ = true; | 70 is_fullscreen_ = true; |
53 UpdateAndMaybeSwitch(); | 71 UpdateAndMaybeSwitch(); |
54 } | 72 } |
55 | 73 |
56 void RemotingRendererController::OnExitedFullscreen() { | 74 void RemotingRendererController::OnExitedFullscreen() { |
57 DCHECK(thread_checker_.CalledOnValidThread()); | 75 DCHECK(thread_checker_.CalledOnValidThread()); |
58 | 76 |
(...skipping 30 matching lines...) Expand all Loading... | |
89 | 107 |
90 void RemotingRendererController::SetSwitchRendererCallback( | 108 void RemotingRendererController::SetSwitchRendererCallback( |
91 const base::Closure& cb) { | 109 const base::Closure& cb) { |
92 DCHECK(thread_checker_.CalledOnValidThread()); | 110 DCHECK(thread_checker_.CalledOnValidThread()); |
93 DCHECK(!cb.is_null()); | 111 DCHECK(!cb.is_null()); |
94 | 112 |
95 switch_renderer_cb_ = cb; | 113 switch_renderer_cb_ = cb; |
96 UpdateAndMaybeSwitch(); | 114 UpdateAndMaybeSwitch(); |
97 } | 115 } |
98 | 116 |
117 void RemotingRendererController::SetRemoteSinkAvailableChangedCallback( | |
118 const base::Callback<void(bool)>& cb) { | |
119 DCHECK(thread_checker_.CalledOnValidThread()); | |
120 DCHECK(!cb.is_null()); | |
miu
2016/12/10 02:18:37
nit: It's probably okay for this to be a null call
xjz
2016/12/12 18:58:45
Done.
| |
121 | |
122 sink_available_changed_cb_ = cb; | |
123 sink_available_changed_cb_.Run(IsRemoteSinkAvailable()); | |
124 } | |
125 | |
99 base::WeakPtr<remoting::RpcBroker> RemotingRendererController::GetRpcBroker() | 126 base::WeakPtr<remoting::RpcBroker> RemotingRendererController::GetRpcBroker() |
100 const { | 127 const { |
101 DCHECK(thread_checker_.CalledOnValidThread()); | 128 DCHECK(thread_checker_.CalledOnValidThread()); |
102 | 129 |
103 return remoting_source_->GetRpcBroker()->GetWeakPtr(); | 130 return remoting_source_->GetRpcBroker()->GetWeakPtr(); |
104 } | 131 } |
105 | 132 |
106 void RemotingRendererController::StartDataPipe( | 133 void RemotingRendererController::StartDataPipe( |
107 std::unique_ptr<mojo::DataPipe> audio_data_pipe, | 134 std::unique_ptr<mojo::DataPipe> audio_data_pipe, |
108 std::unique_ptr<mojo::DataPipe> video_data_pipe, | 135 std::unique_ptr<mojo::DataPipe> video_data_pipe, |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 // and never back to the local renderer. The RemotingCdmController will | 281 // and never back to the local renderer. The RemotingCdmController will |
255 // force-stop the session when remoting has ended; so no need to call | 282 // force-stop the session when remoting has ended; so no need to call |
256 // StopRemoting() from here. | 283 // StopRemoting() from here. |
257 DCHECK(!is_encrypted_); | 284 DCHECK(!is_encrypted_); |
258 switch_renderer_cb_.Run(); | 285 switch_renderer_cb_.Run(); |
259 remoting_source_->StopRemoting(this); | 286 remoting_source_->StopRemoting(this); |
260 } | 287 } |
261 } | 288 } |
262 | 289 |
263 } // namespace media | 290 } // namespace media |
OLD | NEW |