| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 UpdateAndMaybeSwitch(); | 53 UpdateAndMaybeSwitch(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void RemotingRendererController::OnExitedFullscreen() { | 56 void RemotingRendererController::OnExitedFullscreen() { |
| 57 DCHECK(thread_checker_.CalledOnValidThread()); | 57 DCHECK(thread_checker_.CalledOnValidThread()); |
| 58 | 58 |
| 59 is_fullscreen_ = false; | 59 is_fullscreen_ = false; |
| 60 UpdateAndMaybeSwitch(); | 60 UpdateAndMaybeSwitch(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void RemotingRendererController::OnStablyFilledMostViewportChanged( |
| 64 bool is_mostly_filling_viewport) { |
| 65 DCHECK(thread_checker_.CalledOnValidThread()); |
| 66 is_mostly_filling_viewport_ = is_mostly_filling_viewport; |
| 67 UpdateAndMaybeSwitch(); |
| 68 } |
| 69 |
| 63 void RemotingRendererController::OnSetCdm(CdmContext* cdm_context) { | 70 void RemotingRendererController::OnSetCdm(CdmContext* cdm_context) { |
| 64 DCHECK(thread_checker_.CalledOnValidThread()); | 71 DCHECK(thread_checker_.CalledOnValidThread()); |
| 65 | 72 |
| 66 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context); | 73 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context); |
| 67 if (!remoting_cdm_context) | 74 if (!remoting_cdm_context) |
| 68 return; | 75 return; |
| 69 | 76 |
| 70 remoting_source_->RemoveClient(this); | 77 remoting_source_->RemoveClient(this); |
| 71 remoting_source_ = remoting_cdm_context->GetRemotingSource(); | 78 remoting_source_ = remoting_cdm_context->GetRemotingSource(); |
| 72 remoting_source_->AddClient(this); // Calls OnSessionStateChanged(). | 79 remoting_source_->AddClient(this); // Calls OnSessionStateChanged(). |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 break; // Media remoting is possible, assuming other requirments are met. | 195 break; // Media remoting is possible, assuming other requirments are met. |
| 189 case SESSION_STOPPING: | 196 case SESSION_STOPPING: |
| 190 case SESSION_PERMANENTLY_STOPPED: | 197 case SESSION_PERMANENTLY_STOPPED: |
| 191 return false; // Use local rendering after stopping remoting. | 198 return false; // Use local rendering after stopping remoting. |
| 192 } | 199 } |
| 193 if ((!has_audio() && !has_video()) || | 200 if ((!has_audio() && !has_video()) || |
| 194 (has_video() && !IsVideoCodecSupported()) || | 201 (has_video() && !IsVideoCodecSupported()) || |
| 195 (has_audio() && !IsAudioCodecSupported())) | 202 (has_audio() && !IsAudioCodecSupported())) |
| 196 return false; | 203 return false; |
| 197 | 204 |
| 198 // Normally, entering fullscreen is the signal that starts remote rendering. | 205 // Normally, entering fullscreen or filling most of the viewport is the signal |
| 199 // However, current technical limitations require encrypted content be remoted | 206 // that starts remote rendering. However, current technical limitations |
| 200 // without waiting for a user signal. | 207 // require encrypted content be remoted without waiting for a user signal. |
| 201 return is_fullscreen_; | 208 return is_fullscreen_ || is_mostly_filling_viewport_; |
| 202 } | 209 } |
| 203 | 210 |
| 204 void RemotingRendererController::UpdateAndMaybeSwitch() { | 211 void RemotingRendererController::UpdateAndMaybeSwitch() { |
| 205 DCHECK(thread_checker_.CalledOnValidThread()); | 212 DCHECK(thread_checker_.CalledOnValidThread()); |
| 206 | 213 |
| 207 bool should_be_remoting = ShouldBeRemoting(); | 214 bool should_be_remoting = ShouldBeRemoting(); |
| 208 | 215 |
| 209 if (remote_rendering_started_ == should_be_remoting) | 216 if (remote_rendering_started_ == should_be_remoting) |
| 210 return; | 217 return; |
| 211 | 218 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 227 // and never back to the local renderer. The RemotingCdmController will | 234 // and never back to the local renderer. The RemotingCdmController will |
| 228 // force-stop the session when remoting has ended; so no need to call | 235 // force-stop the session when remoting has ended; so no need to call |
| 229 // StopRemoting() from here. | 236 // StopRemoting() from here. |
| 230 DCHECK(!is_encrypted_); | 237 DCHECK(!is_encrypted_); |
| 231 switch_renderer_cb_.Run(); | 238 switch_renderer_cb_.Run(); |
| 232 remoting_source_->StopRemoting(this); | 239 remoting_source_->StopRemoting(this); |
| 233 } | 240 } |
| 234 } | 241 } |
| 235 | 242 |
| 236 } // namespace media | 243 } // namespace media |
| OLD | NEW |