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 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "remoting/base/capabilities.h" | 14 #include "remoting/base/capabilities.h" |
15 #include "remoting/base/logging.h" | 15 #include "remoting/base/logging.h" |
16 #include "remoting/codec/audio_encoder.h" | 16 #include "remoting/codec/audio_encoder.h" |
17 #include "remoting/codec/audio_encoder_opus.h" | 17 #include "remoting/codec/audio_encoder_opus.h" |
18 #include "remoting/codec/audio_encoder_verbatim.h" | 18 #include "remoting/codec/audio_encoder_verbatim.h" |
19 #include "remoting/host/audio_capturer.h" | 19 #include "remoting/host/audio_capturer.h" |
20 #include "remoting/host/audio_pump.h" | 20 #include "remoting/host/audio_pump.h" |
21 #include "remoting/host/desktop_capturer_proxy.h" | |
22 #include "remoting/host/desktop_environment.h" | 21 #include "remoting/host/desktop_environment.h" |
23 #include "remoting/host/host_extension_session.h" | 22 #include "remoting/host/host_extension_session.h" |
24 #include "remoting/host/input_injector.h" | 23 #include "remoting/host/input_injector.h" |
25 #include "remoting/host/mouse_cursor_monitor_proxy.h" | |
26 #include "remoting/host/mouse_shape_pump.h" | 24 #include "remoting/host/mouse_shape_pump.h" |
27 #include "remoting/host/screen_controls.h" | 25 #include "remoting/host/screen_controls.h" |
28 #include "remoting/host/screen_resolution.h" | 26 #include "remoting/host/screen_resolution.h" |
29 #include "remoting/proto/control.pb.h" | 27 #include "remoting/proto/control.pb.h" |
30 #include "remoting/proto/event.pb.h" | 28 #include "remoting/proto/event.pb.h" |
31 #include "remoting/protocol/client_stub.h" | 29 #include "remoting/protocol/client_stub.h" |
32 #include "remoting/protocol/clipboard_thread_proxy.h" | 30 #include "remoting/protocol/clipboard_thread_proxy.h" |
33 #include "remoting/protocol/pairing_registry.h" | 31 #include "remoting/protocol/pairing_registry.h" |
34 #include "remoting/protocol/session.h" | 32 #include "remoting/protocol/session.h" |
35 #include "remoting/protocol/session_config.h" | 33 #include "remoting/protocol/session_config.h" |
(...skipping 22 matching lines...) Expand all Loading... |
58 | 56 |
59 NOTREACHED(); | 57 NOTREACHED(); |
60 return nullptr; | 58 return nullptr; |
61 } | 59 } |
62 | 60 |
63 } // namespace | 61 } // namespace |
64 | 62 |
65 ClientSession::ClientSession( | 63 ClientSession::ClientSession( |
66 EventHandler* event_handler, | 64 EventHandler* event_handler, |
67 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 65 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
68 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | |
69 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | |
70 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | |
71 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | |
72 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | |
73 scoped_ptr<protocol::ConnectionToClient> connection, | 66 scoped_ptr<protocol::ConnectionToClient> connection, |
74 DesktopEnvironmentFactory* desktop_environment_factory, | 67 DesktopEnvironmentFactory* desktop_environment_factory, |
75 const base::TimeDelta& max_duration, | 68 const base::TimeDelta& max_duration, |
76 scoped_refptr<protocol::PairingRegistry> pairing_registry, | 69 scoped_refptr<protocol::PairingRegistry> pairing_registry, |
77 const std::vector<HostExtension*>& extensions) | 70 const std::vector<HostExtension*>& extensions) |
78 : event_handler_(event_handler), | 71 : event_handler_(event_handler), |
79 connection_(std::move(connection)), | 72 connection_(std::move(connection)), |
80 client_jid_(connection_->session()->jid()), | 73 client_jid_(connection_->session()->jid()), |
81 desktop_environment_factory_(desktop_environment_factory), | 74 desktop_environment_factory_(desktop_environment_factory), |
82 input_tracker_(&host_input_filter_), | 75 input_tracker_(&host_input_filter_), |
83 remote_input_filter_(&input_tracker_), | 76 remote_input_filter_(&input_tracker_), |
84 mouse_clamping_filter_(&remote_input_filter_), | 77 mouse_clamping_filter_(&remote_input_filter_), |
85 disable_input_filter_(&mouse_clamping_filter_), | 78 disable_input_filter_(&mouse_clamping_filter_), |
86 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), | 79 disable_clipboard_filter_(clipboard_echo_filter_.host_filter()), |
87 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), | 80 client_clipboard_factory_(clipboard_echo_filter_.client_filter()), |
88 max_duration_(max_duration), | 81 max_duration_(max_duration), |
89 audio_task_runner_(audio_task_runner), | 82 audio_task_runner_(audio_task_runner), |
90 input_task_runner_(input_task_runner), | |
91 video_capture_task_runner_(video_capture_task_runner), | |
92 video_encode_task_runner_(video_encode_task_runner), | |
93 network_task_runner_(network_task_runner), | |
94 ui_task_runner_(ui_task_runner), | |
95 pairing_registry_(pairing_registry), | 83 pairing_registry_(pairing_registry), |
96 is_authenticated_(false), | 84 is_authenticated_(false), |
97 pause_video_(false), | 85 pause_video_(false), |
98 lossless_video_encode_(false), | 86 lossless_video_encode_(false), |
99 // Note that |lossless_video_color_| defaults to true, but actually only | 87 // Note that |lossless_video_color_| defaults to true, but actually only |
100 // controls VP9 video stream color quality. | 88 // controls VP9 video stream color quality. |
101 lossless_video_color_(!base::CommandLine::ForCurrentProcess()->HasSwitch( | 89 lossless_video_color_(!base::CommandLine::ForCurrentProcess()->HasSwitch( |
102 kDisableI444SwitchName)), | 90 kDisableI444SwitchName)), |
103 weak_factory_(this) { | 91 weak_factory_(this) { |
104 connection_->SetEventHandler(this); | 92 connection_->SetEventHandler(this); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 scoped_ptr<webrtc::DesktopCapturer> video_capturer = | 436 scoped_ptr<webrtc::DesktopCapturer> video_capturer = |
449 desktop_environment_->CreateVideoCapturer(); | 437 desktop_environment_->CreateVideoCapturer(); |
450 extension_manager_->OnCreateVideoCapturer(&video_capturer); | 438 extension_manager_->OnCreateVideoCapturer(&video_capturer); |
451 | 439 |
452 // Don't start the video stream if the extension took ownership of the | 440 // Don't start the video stream if the extension took ownership of the |
453 // capturer. | 441 // capturer. |
454 if (!video_capturer) | 442 if (!video_capturer) |
455 return; | 443 return; |
456 | 444 |
457 // Create MouseShapePump to send mouse cursor shape. | 445 // Create MouseShapePump to send mouse cursor shape. |
458 // TODO(sergeyu): Move MouseCursorMonitorProxy creation to DesktopEnvironment. | |
459 // When using IpcDesktopCapturer the capture thread is not useful. | |
460 mouse_shape_pump_.reset( | 446 mouse_shape_pump_.reset( |
461 new MouseShapePump(make_scoped_ptr(new MouseCursorMonitorProxy( | 447 new MouseShapePump(desktop_environment_->CreateMouseCursorMonitor(), |
462 video_capture_task_runner_, | |
463 desktop_environment_->CreateMouseCursorMonitor())), | |
464 connection_->client_stub())); | 448 connection_->client_stub())); |
465 | 449 |
466 // Create a VideoStream to pump frames from the capturer to the client. | 450 // Create a VideoStream to pump frames from the capturer to the client. |
467 // TODO(sergeyu): Move DesktopCapturerProxy creation to DesktopEnvironment. | 451 video_stream_ = connection_->StartVideoStream(std::move(video_capturer)); |
468 // When using IpcDesktopCapturer the capture thread is not useful. | |
469 scoped_ptr<webrtc::DesktopCapturer> capturer_proxy(new DesktopCapturerProxy( | |
470 video_capture_task_runner_, std::move(video_capturer))); | |
471 | 452 |
472 video_stream_ = connection_->StartVideoStream(std::move(capturer_proxy)); | |
473 video_stream_->SetSizeCallback( | 453 video_stream_->SetSizeCallback( |
474 base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this))); | 454 base::Bind(&ClientSession::OnScreenSizeChanged, base::Unretained(this))); |
475 | 455 |
476 // Apply video-control parameters to the new stream. | 456 // Apply video-control parameters to the new stream. |
477 video_stream_->SetLosslessEncode(lossless_video_encode_); | 457 video_stream_->SetLosslessEncode(lossless_video_encode_); |
478 video_stream_->SetLosslessColor(lossless_video_color_); | 458 video_stream_->SetLosslessColor(lossless_video_color_); |
479 | 459 |
480 // Pause capturing if necessary. | 460 // Pause capturing if necessary. |
481 video_stream_->Pause(pause_video_); | 461 video_stream_->Pause(pause_video_); |
482 } | 462 } |
(...skipping 12 matching lines...) Expand all Loading... |
495 base::ThreadTaskRunnerHandle::Get())); | 475 base::ThreadTaskRunnerHandle::Get())); |
496 } | 476 } |
497 | 477 |
498 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) { | 478 void ClientSession::OnScreenSizeChanged(const webrtc::DesktopSize& size) { |
499 DCHECK(CalledOnValidThread()); | 479 DCHECK(CalledOnValidThread()); |
500 mouse_clamping_filter_.set_input_size(size); | 480 mouse_clamping_filter_.set_input_size(size); |
501 mouse_clamping_filter_.set_output_size(size); | 481 mouse_clamping_filter_.set_output_size(size); |
502 } | 482 } |
503 | 483 |
504 } // namespace remoting | 484 } // namespace remoting |
OLD | NEW |