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

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

Issue 5298001: Use VP8 over PseudoTCP by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed EventExecutor class. Created 10 years, 1 month 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
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/event_executor.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/chromoting_host.h" 5 #include "remoting/host/chromoting_host.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "remoting/base/constants.h" 10 #include "remoting/base/constants.h"
11 #if defined(OS_WIN)
12 #include "remoting/host/capturer_gdi.h"
13 #include "remoting/host/event_executor_win.h"
14 #elif defined(OS_LINUX)
15 #include "remoting/host/capturer_linux.h"
16 #include "remoting/host/event_executor_linux.h"
17 #elif defined(OS_MACOSX)
18 #include "remoting/host/capturer_mac.h"
19 #include "remoting/host/event_executor_mac.h"
20 #endif
21 #include "remoting/base/encoder.h" 11 #include "remoting/base/encoder.h"
22 #include "remoting/base/encoder_verbatim.h" 12 #include "remoting/base/encoder_verbatim.h"
23 #include "remoting/base/encoder_vp8.h" 13 #include "remoting/base/encoder_vp8.h"
24 #include "remoting/base/encoder_zlib.h" 14 #include "remoting/base/encoder_zlib.h"
15 #include "remoting/host/capturer.h"
25 #include "remoting/host/chromoting_host_context.h" 16 #include "remoting/host/chromoting_host_context.h"
17 #include "remoting/host/event_executor.h"
26 #include "remoting/host/host_config.h" 18 #include "remoting/host/host_config.h"
27 #include "remoting/host/host_stub_fake.h" 19 #include "remoting/host/host_stub_fake.h"
28 #include "remoting/host/session_manager.h" 20 #include "remoting/host/session_manager.h"
29 #include "remoting/protocol/connection_to_client.h" 21 #include "remoting/protocol/connection_to_client.h"
30 #include "remoting/protocol/host_stub.h" 22 #include "remoting/protocol/host_stub.h"
31 #include "remoting/protocol/input_stub.h" 23 #include "remoting/protocol/input_stub.h"
32 #include "remoting/protocol/jingle_session_manager.h" 24 #include "remoting/protocol/jingle_session_manager.h"
33 #include "remoting/protocol/session_config.h" 25 #include "remoting/protocol/session_config.h"
34 26
35 using remoting::protocol::ConnectionToClient; 27 using remoting::protocol::ConnectionToClient;
36 28
37 namespace remoting { 29 namespace remoting {
38 30
39 ChromotingHost::ChromotingHost(ChromotingHostContext* context, 31 // static
40 MutableHostConfig* config) 32 ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
41 : context_(context), 33 MutableHostConfig* config) {
42 config_(config), 34 return Create(context, config,
43 #if defined(OS_WIN) 35 Capturer::Create(context->main_message_loop()));
44 capturer_(new remoting::CapturerGdi( 36 }
45 context->main_message_loop())), 37
46 input_stub_(new remoting::EventExecutorWin( 38 // static
47 context->main_message_loop(), capturer_.get())), 39 ChromotingHost* ChromotingHost::Create(ChromotingHostContext* context,
48 #elif defined(OS_LINUX) 40 MutableHostConfig* config,
49 capturer_(new remoting::CapturerLinux( 41 Capturer* capturer) {
50 context->main_message_loop())), 42 return new ChromotingHost(context, config, capturer);
51 input_stub_(new remoting::EventExecutorLinux(
52 context->main_message_loop(), capturer_.get())),
53 #elif defined(OS_MACOSX)
54 capturer_(new remoting::CapturerMac(
55 context->main_message_loop())),
56 input_stub_(new remoting::EventExecutorMac(
57 context->main_message_loop(), capturer_.get())),
58 #endif
59 host_stub_(new HostStubFake()),
60 state_(kInitial) {
61 } 43 }
62 44
63 ChromotingHost::ChromotingHost(ChromotingHostContext* context, 45 ChromotingHost::ChromotingHost(ChromotingHostContext* context,
64 MutableHostConfig* config, Capturer* capturer) 46 MutableHostConfig* config, Capturer* capturer)
65 : context_(context), 47 : context_(context),
66 config_(config), 48 config_(config),
67 capturer_(capturer), 49 capturer_(capturer),
68 #if defined(OS_WIN) 50 input_stub_(CreateEventExecutor(
69 input_stub_(new remoting::EventExecutorWin(
70 context->main_message_loop(), capturer)), 51 context->main_message_loop(), capturer)),
71 #elif defined(OS_LINUX)
72 input_stub_(new remoting::EventExecutorLinux(
73 context->main_message_loop(), capturer)),
74 #elif defined(OS_MACOSX)
75 input_stub_(new remoting::EventExecutorMac(
76 context->main_message_loop(), capturer)),
77 #endif
78 host_stub_(new HostStubFake()), 52 host_stub_(new HostStubFake()),
79 state_(kInitial) { 53 state_(kInitial),
54 protocol_config_(protocol::CandidateSessionConfig::CreateDefault()) {
80 } 55 }
81 56
57
82 ChromotingHost::~ChromotingHost() { 58 ChromotingHost::~ChromotingHost() {
83 } 59 }
84 60
85 void ChromotingHost::Start(Task* shutdown_task) { 61 void ChromotingHost::Start(Task* shutdown_task) {
86 if (MessageLoop::current() != context_->main_message_loop()) { 62 if (MessageLoop::current() != context_->main_message_loop()) {
87 context_->main_message_loop()->PostTask( 63 context_->main_message_loop()->PostTask(
88 FROM_HERE, 64 FROM_HERE,
89 NewRunnableMethod(this, &ChromotingHost::Start, shutdown_task)); 65 NewRunnableMethod(this, &ChromotingHost::Start, shutdown_task));
90 return; 66 return;
91 } 67 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 *response = protocol::SessionManager::DECLINE; 262 *response = protocol::SessionManager::DECLINE;
287 return; 263 return;
288 } 264 }
289 265
290 // Check that the user has access to the host. 266 // Check that the user has access to the host.
291 if (!access_verifier_.VerifyPermissions(session->jid())) { 267 if (!access_verifier_.VerifyPermissions(session->jid())) {
292 *response = protocol::SessionManager::DECLINE; 268 *response = protocol::SessionManager::DECLINE;
293 return; 269 return;
294 } 270 }
295 271
296 scoped_ptr<protocol::CandidateSessionConfig> 272 *protocol_config_->mutable_initial_resolution() =
297 local_config(protocol::CandidateSessionConfig::CreateDefault()); 273 protocol::ScreenResolution(capturer_->width(), capturer_->height());
298 local_config->SetInitialResolution(
299 protocol::ScreenResolution(capturer_->width(), capturer_->height()));
300 // TODO(sergeyu): Respect resolution requested by the client if supported. 274 // TODO(sergeyu): Respect resolution requested by the client if supported.
301 protocol::SessionConfig* config = local_config->Select( 275 protocol::SessionConfig* config = protocol_config_->Select(
302 session->candidate_config(), true /* force_host_resolution */); 276 session->candidate_config(), true /* force_host_resolution */);
303 277
304 if (!config) { 278 if (!config) {
305 LOG(WARNING) << "Rejecting connection from " << session->jid() 279 LOG(WARNING) << "Rejecting connection from " << session->jid()
306 << " because no compatible configuration has been found."; 280 << " because no compatible configuration has been found.";
307 *response = protocol::SessionManager::INCOMPATIBLE; 281 *response = protocol::SessionManager::INCOMPATIBLE;
308 return; 282 return;
309 } 283 }
310 284
311 session->set_config(config); 285 session->set_config(config);
312 286
313 *response = protocol::SessionManager::ACCEPT; 287 *response = protocol::SessionManager::ACCEPT;
314 288
315 VLOG(1) << "Client connected: " << session->jid(); 289 VLOG(1) << "Client connected: " << session->jid();
316 290
317 // If we accept the connected then create a client object and set the 291 // If we accept the connected then create a client object and set the
318 // callback. 292 // callback.
319 connection_ = new ConnectionToClient(context_->main_message_loop(), 293 connection_ = new ConnectionToClient(context_->main_message_loop(),
320 this, host_stub_.get(), 294 this, host_stub_.get(),
321 input_stub_.get()); 295 input_stub_.get());
322 connection_->Init(session); 296 connection_->Init(session);
323 } 297 }
324 298
299 void ChromotingHost::set_protocol_config(
300 protocol::CandidateSessionConfig* config) {
301 DCHECK(config_.get());
302 DCHECK_EQ(state_, kInitial);
303 protocol_config_.reset(config);
304 }
305
325 void ChromotingHost::OnServerClosed() { 306 void ChromotingHost::OnServerClosed() {
326 // Don't need to do anything here. 307 // Don't need to do anything here.
327 } 308 }
328 309
329 // TODO(sergeyu): Move this to SessionManager? 310 // TODO(sergeyu): Move this to SessionManager?
330 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) { 311 Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) {
331 const protocol::ChannelConfig& video_config = config->video_config(); 312 const protocol::ChannelConfig& video_config = config->video_config();
332 313
333 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { 314 if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
334 return new remoting::EncoderVerbatim(); 315 return new remoting::EncoderVerbatim();
335 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) { 316 } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) {
336 return new remoting::EncoderZlib(); 317 return new remoting::EncoderZlib();
337 } 318 }
338 // TODO(sergeyu): Enable VP8 on ARM builds. 319 // TODO(sergeyu): Enable VP8 on ARM builds.
339 #if !defined(ARCH_CPU_ARM_FAMILY) 320 #if !defined(ARCH_CPU_ARM_FAMILY)
340 else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { 321 else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
341 return new remoting::EncoderVp8(); 322 return new remoting::EncoderVp8();
342 } 323 }
343 #endif 324 #endif
344 325
345 return NULL; 326 return NULL;
346 } 327 }
347 328
348 } // namespace remoting 329 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.h ('k') | remoting/host/event_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698