Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: media/remoting/renderer_controller.cc

Issue 2951523002: Media Remoting: Add mojo interfaces between browser and extension. (Closed)
Patch Set: Addressed comments. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer_controller.h" 5 #include "media/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 "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // in OnEnteredFullscreen() and OnExitedFullscreen(), and changes to it here 111 // in OnEnteredFullscreen() and OnExitedFullscreen(), and changes to it here
112 // are ignored while in fullscreen. 112 // are ignored while in fullscreen.
113 if (is_fullscreen_) 113 if (is_fullscreen_)
114 return; 114 return;
115 115
116 is_dominant_content_ = is_dominant; 116 is_dominant_content_ = is_dominant;
117 UpdateAndMaybeSwitch(BECAME_DOMINANT_CONTENT, BECAME_AUXILIARY_CONTENT); 117 UpdateAndMaybeSwitch(BECAME_DOMINANT_CONTENT, BECAME_AUXILIARY_CONTENT);
118 } 118 }
119 119
120 void RendererController::OnSetCdm(CdmContext* cdm_context) { 120 void RendererController::OnSetCdm(CdmContext* cdm_context) {
121 VLOG(2) << __func__;
121 DCHECK(thread_checker_.CalledOnValidThread()); 122 DCHECK(thread_checker_.CalledOnValidThread());
122 123
123 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context); 124 auto* remoting_cdm_context = RemotingCdmContext::From(cdm_context);
124 if (!remoting_cdm_context) 125 if (!remoting_cdm_context)
125 return; 126 return;
126 127
127 session_->RemoveClient(this); 128 session_->RemoveClient(this);
128 session_ = remoting_cdm_context->GetSharedSession(); 129 session_ = remoting_cdm_context->GetSharedSession();
129 session_->AddClient(this); 130 session_->AddClient(this);
130 UpdateFromSessionState(CDM_READY, DECRYPTION_ERROR); 131 UpdateFromSessionState(CDM_READY, DECRYPTION_ERROR);
131 } 132 }
132 133
133 void RendererController::OnRemotePlaybackDisabled(bool disabled) { 134 void RendererController::OnRemotePlaybackDisabled(bool disabled) {
135 VLOG(2) << __func__ << ": disabled = " << disabled;
134 DCHECK(thread_checker_.CalledOnValidThread()); 136 DCHECK(thread_checker_.CalledOnValidThread());
135 137
136 is_remote_playback_disabled_ = disabled; 138 is_remote_playback_disabled_ = disabled;
137 metrics_recorder_.OnRemotePlaybackDisabled(disabled); 139 metrics_recorder_.OnRemotePlaybackDisabled(disabled);
138 UpdateAndMaybeSwitch(ENABLED_BY_PAGE, DISABLED_BY_PAGE); 140 UpdateAndMaybeSwitch(ENABLED_BY_PAGE, DISABLED_BY_PAGE);
139 } 141 }
140 142
141 base::WeakPtr<RpcBroker> RendererController::GetRpcBroker() const { 143 base::WeakPtr<RpcBroker> RendererController::GetRpcBroker() const {
142 DCHECK(thread_checker_.CalledOnValidThread()); 144 DCHECK(thread_checker_.CalledOnValidThread());
143 145
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 case SharedSession::SESSION_PERMANENTLY_STOPPED: 285 case SharedSession::SESSION_PERMANENTLY_STOPPED:
284 return false; // Use local rendering after stopping remoting. 286 return false; // Use local rendering after stopping remoting.
285 } 287 }
286 288
287 switch (session_->sink_capabilities()) { 289 switch (session_->sink_capabilities()) {
288 case mojom::RemotingSinkCapabilities::NONE: 290 case mojom::RemotingSinkCapabilities::NONE:
289 return false; 291 return false;
290 case mojom::RemotingSinkCapabilities::RENDERING_ONLY: 292 case mojom::RemotingSinkCapabilities::RENDERING_ONLY:
291 case mojom::RemotingSinkCapabilities::CONTENT_DECRYPTION_AND_RENDERING: 293 case mojom::RemotingSinkCapabilities::CONTENT_DECRYPTION_AND_RENDERING:
292 break; // The sink is capable of remote rendering. 294 break; // The sink is capable of remote rendering.
295 default:
296 // TODO(xjz): Will be changed in a coming CL that passes the receiver's
297 // capabilities.
298 NOTREACHED();
293 } 299 }
294 300
295 if ((!has_audio() && !has_video()) || 301 if ((!has_audio() && !has_video()) ||
296 (has_video() && !IsVideoCodecSupported()) || 302 (has_video() && !IsVideoCodecSupported()) ||
297 (has_audio() && !IsAudioCodecSupported())) { 303 (has_audio() && !IsAudioCodecSupported())) {
298 return false; 304 return false;
299 } 305 }
300 306
301 if (is_remote_playback_disabled_) 307 if (is_remote_playback_disabled_)
302 return false; 308 return false;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // StopRemoting() from here. 351 // StopRemoting() from here.
346 DCHECK(!is_encrypted_); 352 DCHECK(!is_encrypted_);
347 DCHECK_NE(stop_trigger, UNKNOWN_STOP_TRIGGER); 353 DCHECK_NE(stop_trigger, UNKNOWN_STOP_TRIGGER);
348 metrics_recorder_.WillStopSession(stop_trigger); 354 metrics_recorder_.WillStopSession(stop_trigger);
349 client_->SwitchRenderer(false); 355 client_->SwitchRenderer(false);
350 session_->StopRemoting(this); 356 session_->StopRemoting(this);
351 } 357 }
352 } 358 }
353 359
354 void RendererController::OnRendererFatalError(StopTrigger stop_trigger) { 360 void RendererController::OnRendererFatalError(StopTrigger stop_trigger) {
361 VLOG(2) << __func__ << ": stop_trigger= " << stop_trigger;
355 DCHECK(thread_checker_.CalledOnValidThread()); 362 DCHECK(thread_checker_.CalledOnValidThread());
356 363
357 // Do not act on errors caused by things like Mojo pipes being closed during 364 // Do not act on errors caused by things like Mojo pipes being closed during
358 // shutdown. 365 // shutdown.
359 if (!remote_rendering_started_) 366 if (!remote_rendering_started_)
360 return; 367 return;
361 368
362 encountered_renderer_fatal_error_ = true; 369 encountered_renderer_fatal_error_ = true;
363 UpdateAndMaybeSwitch(UNKNOWN_START_TRIGGER, stop_trigger); 370 UpdateAndMaybeSwitch(UNKNOWN_START_TRIGGER, stop_trigger);
364 } 371 }
365 372
366 void RendererController::SetClient(MediaObserverClient* client) { 373 void RendererController::SetClient(MediaObserverClient* client) {
367 DCHECK(thread_checker_.CalledOnValidThread()); 374 DCHECK(thread_checker_.CalledOnValidThread());
368 DCHECK(client); 375 DCHECK(client);
369 DCHECK(!client_); 376 DCHECK(!client_);
370 377
371 client_ = client; 378 client_ = client;
372 client_->ActivateViewportIntersectionMonitoring(IsRemoteSinkAvailable()); 379 client_->ActivateViewportIntersectionMonitoring(IsRemoteSinkAvailable());
373 } 380 }
374 381
375 } // namespace remoting 382 } // namespace remoting
376 } // namespace media 383 } // namespace media
OLDNEW
« media/mojo/interfaces/remoting.mojom ('K') | « media/mojo/interfaces/remoting_common.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698