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

Side by Side Diff: remoting/host/client_session.cc

Issue 13932020: Set the initial resolution of an RDP session to the client screen resolution if it is available. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback #2 Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
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_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "media/video/capture/screen/screen_capturer.h" 10 #include "media/video/capture/screen/screen_capturer.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 DCHECK(!desktop_environment_); 89 DCHECK(!desktop_environment_);
90 DCHECK(!input_injector_); 90 DCHECK(!input_injector_);
91 DCHECK(!screen_controls_); 91 DCHECK(!screen_controls_);
92 DCHECK(!video_scheduler_); 92 DCHECK(!video_scheduler_);
93 93
94 connection_.reset(); 94 connection_.reset();
95 } 95 }
96 96
97 void ClientSession::NotifyClientResolution( 97 void ClientSession::NotifyClientResolution(
98 const protocol::ClientResolution& resolution) { 98 const protocol::ClientResolution& resolution) {
99 DCHECK(CalledOnValidThread());
100
99 if (!resolution.has_dips_width() || !resolution.has_dips_height()) 101 if (!resolution.has_dips_width() || !resolution.has_dips_height())
100 return; 102 return;
101 103
102 VLOG(1) << "Received ClientResolution (dips_width=" 104 VLOG(1) << "Received ClientResolution (dips_width="
103 << resolution.dips_width() << ", dips_height=" 105 << resolution.dips_width() << ", dips_height="
104 << resolution.dips_height() << ")"; 106 << resolution.dips_height() << ")";
105 107
106 if (!screen_controls_) 108 if (!screen_controls_)
107 return; 109 return;
108 110
109 ScreenResolution client_resolution( 111 ScreenResolution client_resolution(
110 SkISize::Make(resolution.dips_width(), resolution.dips_height()), 112 SkISize::Make(resolution.dips_width(), resolution.dips_height()),
111 SkIPoint::Make(kDefaultDPI, kDefaultDPI)); 113 SkIPoint::Make(kDefaultDPI, kDefaultDPI));
112 114
113 // Try to match the client's resolution. 115 // Try to match the client's resolution.
114 if (client_resolution.IsValid()) 116 if (client_resolution.IsValid())
115 screen_controls_->SetScreenResolution(client_resolution); 117 screen_controls_->SetScreenResolution(client_resolution);
116 } 118 }
117 119
118 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { 120 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) {
121 DCHECK(CalledOnValidThread());
122
119 if (video_control.has_enable()) { 123 if (video_control.has_enable()) {
120 VLOG(1) << "Received VideoControl (enable=" 124 VLOG(1) << "Received VideoControl (enable="
121 << video_control.enable() << ")"; 125 << video_control.enable() << ")";
122 if (video_scheduler_) 126 if (video_scheduler_)
123 video_scheduler_->Pause(!video_control.enable()); 127 video_scheduler_->Pause(!video_control.enable());
124 } 128 }
125 } 129 }
126 130
127 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { 131 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) {
132 DCHECK(CalledOnValidThread());
133
128 if (audio_control.has_enable()) { 134 if (audio_control.has_enable()) {
129 VLOG(1) << "Received AudioControl (enable=" 135 VLOG(1) << "Received AudioControl (enable="
130 << audio_control.enable() << ")"; 136 << audio_control.enable() << ")";
131 if (audio_scheduler_) 137 if (audio_scheduler_)
132 audio_scheduler_->Pause(!audio_control.enable()); 138 audio_scheduler_->Pause(!audio_control.enable());
133 } 139 }
134 } 140 }
135 141
142 void ClientSession::SetCapabilities(
143 const protocol::Capabilities& capabilities) {
144 DCHECK(CalledOnValidThread());
145
146 // Ignore all the messages but the 1st one.
147 if (client_capabilities_) {
148 LOG(WARNING) << "protocol::Capabilities has been received already.";
149 return;
150 }
151
152 // Calculate the set of capabilities enabled by both client and host and pass
153 // it to the desktop environment.
154 client_capabilities_ = make_scoped_ptr(new Capabilities());
155 if (client_capabilities_->FromProtocolMessage(capabilities)) {
156 VLOG(1) << "Client capabilities: " << client_capabilities_->ToString();
Sergey Ulanov 2013/04/16 08:38:53 nit: this will convert the capabilities to string
alexeypa (please no reviews) 2013/04/16 22:06:11 It is actually useful. I used it when I tested var
157 } else {
158 LOG(ERROR) << "Invalid protocol::Capabilities received.";
159 }
160
161 if (desktop_environment_) {
Sergey Ulanov 2013/04/16 08:38:53 It sucks that we need to worry about the case when
alexeypa (please no reviews) 2013/04/16 22:06:11 Done.
Sergey Ulanov 2013/04/18 00:34:53 I don't see it in the last patchset.
alexeypa (please no reviews) 2013/04/18 18:56:36 It turned out that |event_handler_->OnSessionAuthe
162 desktop_environment_->SetCapabilities(
163 client_capabilities_->Intersect(host_capabilities_));
164 }
165 }
166
136 void ClientSession::OnConnectionAuthenticated( 167 void ClientSession::OnConnectionAuthenticated(
137 protocol::ConnectionToClient* connection) { 168 protocol::ConnectionToClient* connection) {
138 DCHECK(CalledOnValidThread()); 169 DCHECK(CalledOnValidThread());
139 DCHECK_EQ(connection_.get(), connection); 170 DCHECK_EQ(connection_.get(), connection);
140 171
141 auth_input_filter_.set_enabled(true); 172 auth_input_filter_.set_enabled(true);
142 auth_clipboard_filter_.set_enabled(true); 173 auth_clipboard_filter_.set_enabled(true);
143 174
144 clipboard_echo_filter_.set_client_stub(connection_->client_stub()); 175 clipboard_echo_filter_.set_client_stub(connection_->client_stub());
145 mouse_clamping_filter_.set_video_stub(connection_->video_stub()); 176 mouse_clamping_filter_.set_video_stub(connection_->video_stub());
(...skipping 14 matching lines...) Expand all
160 DCHECK_EQ(connection_.get(), connection); 191 DCHECK_EQ(connection_.get(), connection);
161 DCHECK(!audio_scheduler_); 192 DCHECK(!audio_scheduler_);
162 DCHECK(!desktop_environment_); 193 DCHECK(!desktop_environment_);
163 DCHECK(!input_injector_); 194 DCHECK(!input_injector_);
164 DCHECK(!screen_controls_); 195 DCHECK(!screen_controls_);
165 DCHECK(!video_scheduler_); 196 DCHECK(!video_scheduler_);
166 197
167 desktop_environment_ = 198 desktop_environment_ =
168 desktop_environment_factory_->Create(control_factory_.GetWeakPtr()); 199 desktop_environment_factory_->Create(control_factory_.GetWeakPtr());
169 200
201 // Negotiate capabilities with the client.
202 if (connection_->session()->config().supports_capabilities()) {
203 host_capabilities_ = desktop_environment_->GetCapabilities();
204 VLOG(1) << "Host capabilities: " << host_capabilities_.ToString();
205
206 connection_->client_stub()->SetCapabilities(
207 *host_capabilities_.ToProtocolMessage());
208
209 // |client_capabilities_| could have been received before all channels were
210 // connected. Process them now.
211 if (client_capabilities_) {
212 desktop_environment_->SetCapabilities(
213 client_capabilities_->Intersect(host_capabilities_));
214 }
215 } else {
216 VLOG(1) << "The client does not support any capabilities.";
217
218 client_capabilities_ = make_scoped_ptr(new Capabilities());
219 desktop_environment_->SetCapabilities(*client_capabilities_);
220 }
221
170 // Create the object that controls the screen resolution. 222 // Create the object that controls the screen resolution.
171 screen_controls_ = desktop_environment_->CreateScreenControls(); 223 screen_controls_ = desktop_environment_->CreateScreenControls();
172 224
173 // Create and start the event executor. 225 // Create and start the event executor.
174 input_injector_ = desktop_environment_->CreateInputInjector(); 226 input_injector_ = desktop_environment_->CreateInputInjector();
175 input_injector_->Start(CreateClipboardProxy()); 227 input_injector_->Start(CreateClipboardProxy());
176 228
177 // Connect the host clipboard and input stubs. 229 // Connect the host clipboard and input stubs.
178 host_input_filter_.set_input_stub(input_injector_.get()); 230 host_input_filter_.set_input_stub(input_injector_.get());
179 clipboard_echo_filter_.set_host_stub(input_injector_.get()); 231 clipboard_echo_filter_.set_host_stub(input_injector_.get());
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex()); 391 return scoped_ptr<AudioEncoder>(new AudioEncoderSpeex());
340 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { 392 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) {
341 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); 393 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus());
342 } 394 }
343 395
344 NOTIMPLEMENTED(); 396 NOTIMPLEMENTED();
345 return scoped_ptr<AudioEncoder>(NULL); 397 return scoped_ptr<AudioEncoder>(NULL);
346 } 398 }
347 399
348 } // namespace remoting 400 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698