OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/client_session.h" | 5 #include "remoting/host/client_session.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "remoting/base/capabilities.h" | 10 #include "remoting/base/capabilities.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 auth_input_filter_(&disable_input_filter_), | 60 auth_input_filter_(&disable_input_filter_), |
61 auth_clipboard_filter_(&disable_clipboard_filter_), | 61 auth_clipboard_filter_(&disable_clipboard_filter_), |
62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 62 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
63 max_duration_(max_duration), | 63 max_duration_(max_duration), |
64 audio_task_runner_(audio_task_runner), | 64 audio_task_runner_(audio_task_runner), |
65 input_task_runner_(input_task_runner), | 65 input_task_runner_(input_task_runner), |
66 video_capture_task_runner_(video_capture_task_runner), | 66 video_capture_task_runner_(video_capture_task_runner), |
67 video_encode_task_runner_(video_encode_task_runner), | 67 video_encode_task_runner_(video_encode_task_runner), |
68 network_task_runner_(network_task_runner), | 68 network_task_runner_(network_task_runner), |
69 ui_task_runner_(ui_task_runner), | 69 ui_task_runner_(ui_task_runner), |
70 pairing_registry_(pairing_registry) { | 70 pairing_registry_(pairing_registry), |
71 enable_cast_(false) { | |
71 connection_->SetEventHandler(this); | 72 connection_->SetEventHandler(this); |
72 | 73 |
73 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be | 74 // TODO(sergeyu): Currently ConnectionToClient expects stubs to be |
74 // set before channels are connected. Make it possible to set stubs | 75 // set before channels are connected. Make it possible to set stubs |
75 // later and set them only when connection is authenticated. | 76 // later and set them only when connection is authenticated. |
76 connection_->set_clipboard_stub(&auth_clipboard_filter_); | 77 connection_->set_clipboard_stub(&auth_clipboard_filter_); |
77 connection_->set_host_stub(this); | 78 connection_->set_host_stub(this); |
78 connection_->set_input_stub(&auth_input_filter_); | 79 connection_->set_input_stub(&auth_input_filter_); |
79 | 80 |
80 // |auth_*_filter_|'s states reflect whether the session is authenticated. | 81 // |auth_*_filter_|'s states reflect whether the session is authenticated. |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 input_injector_ = desktop_environment_->CreateInputInjector(); | 312 input_injector_ = desktop_environment_->CreateInputInjector(); |
312 | 313 |
313 // Connect the host clipboard and input stubs. | 314 // Connect the host clipboard and input stubs. |
314 host_input_filter_.set_input_stub(input_injector_.get()); | 315 host_input_filter_.set_input_stub(input_injector_.get()); |
315 clipboard_echo_filter_.set_host_stub(input_injector_.get()); | 316 clipboard_echo_filter_.set_host_stub(input_injector_.get()); |
316 | 317 |
317 // Create a VideoEncoder based on the session's video channel configuration. | 318 // Create a VideoEncoder based on the session's video channel configuration. |
318 scoped_ptr<VideoEncoder> video_encoder = | 319 scoped_ptr<VideoEncoder> video_encoder = |
319 CreateVideoEncoder(connection_->session()->config()); | 320 CreateVideoEncoder(connection_->session()->config()); |
320 | 321 |
321 // Create a VideoScheduler to pump frames from the capturer to the client. | |
322 video_scheduler_ = new VideoScheduler( | 322 video_scheduler_ = new VideoScheduler( |
323 video_capture_task_runner_, | 323 video_capture_task_runner_, |
324 video_encode_task_runner_, | 324 video_encode_task_runner_, |
325 network_task_runner_, | 325 network_task_runner_, |
326 desktop_environment_->CreateVideoCapturer(), | 326 desktop_environment_->CreateVideoCapturer(), |
327 video_encoder.Pass(), | 327 video_encoder.Pass(), |
328 connection_->client_stub(), | 328 connection_->client_stub(), |
329 &mouse_clamping_filter_); | 329 &mouse_clamping_filter_); |
330 | 330 |
331 // Create an AudioScheduler if audio is enabled, to pump audio samples. | 331 // Create an AudioScheduler if audio is enabled, to pump audio samples. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 | 474 |
475 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { | 475 scoped_ptr<protocol::ClipboardStub> ClientSession::CreateClipboardProxy() { |
476 DCHECK(CalledOnValidThread()); | 476 DCHECK(CalledOnValidThread()); |
477 | 477 |
478 return scoped_ptr<protocol::ClipboardStub>( | 478 return scoped_ptr<protocol::ClipboardStub>( |
479 new protocol::ClipboardThreadProxy( | 479 new protocol::ClipboardThreadProxy( |
480 client_clipboard_factory_.GetWeakPtr(), | 480 client_clipboard_factory_.GetWeakPtr(), |
481 base::MessageLoopProxy::current())); | 481 base::MessageLoopProxy::current())); |
482 } | 482 } |
483 | 483 |
484 scoped_ptr<webrtc::ScreenCapturer> ClientSession::RequestScreenCapturer() { | |
485 // VideoScheduler must be stopped on one of these threads. | |
486 DCHECK(video_capture_task_runner_->BelongsToCurrentThread() || | |
487 network_task_runner_->BelongsToCurrentThread()); | |
488 | |
489 if(!enable_cast_) { | |
Sergey Ulanov
2014/07/24 19:11:36
I still think you don't need this flag. RequestScr
aiguha
2014/07/28 17:11:56
Acknowledged.
| |
490 LOG(ERROR) << "Cast mode not enabled."; | |
491 return scoped_ptr<webrtc::ScreenCapturer>(); | |
492 } | |
493 | |
494 if (!video_scheduler_.get()) { | |
495 LOG(ERROR) << "Video Scheduler was NULL, but shouldn't have been."; | |
496 return scoped_ptr<webrtc::ScreenCapturer>(); | |
497 } | |
498 | |
499 video_scheduler_->Stop(); | |
500 | |
501 return desktop_environment_->CreateVideoCapturer(); | |
aiguha
2014/07/18 21:30:37
As of now, this method is called on the network th
| |
502 } | |
503 | |
484 // TODO(sergeyu): Move this to SessionManager? | 504 // TODO(sergeyu): Move this to SessionManager? |
485 // static | 505 // static |
486 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( | 506 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( |
487 const protocol::SessionConfig& config) { | 507 const protocol::SessionConfig& config) { |
488 const protocol::ChannelConfig& video_config = config.video_config(); | 508 const protocol::ChannelConfig& video_config = config.video_config(); |
489 | 509 |
490 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 510 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
491 return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>(); | 511 return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>(); |
492 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { | 512 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { |
493 return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>(); | 513 return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>(); |
(...skipping 12 matching lines...) Expand all Loading... | |
506 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); | 526 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); |
507 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 527 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
508 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 528 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
509 } | 529 } |
510 | 530 |
511 NOTREACHED(); | 531 NOTREACHED(); |
512 return scoped_ptr<AudioEncoder>(); | 532 return scoped_ptr<AudioEncoder>(); |
513 } | 533 } |
514 | 534 |
515 } // namespace remoting | 535 } // namespace remoting |
OLD | NEW |