| 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/command_line.h" | |
| 10 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 11 #include "remoting/base/capabilities.h" | 10 #include "remoting/base/capabilities.h" |
| 12 #include "remoting/base/logging.h" | 11 #include "remoting/base/logging.h" |
| 13 #include "remoting/codec/audio_encoder.h" | 12 #include "remoting/codec/audio_encoder.h" |
| 14 #include "remoting/codec/audio_encoder_opus.h" | 13 #include "remoting/codec/audio_encoder_opus.h" |
| 15 #include "remoting/codec/audio_encoder_verbatim.h" | 14 #include "remoting/codec/audio_encoder_verbatim.h" |
| 16 #include "remoting/codec/video_encoder.h" | 15 #include "remoting/codec/video_encoder.h" |
| 17 #include "remoting/codec/video_encoder_verbatim.h" | 16 #include "remoting/codec/video_encoder_verbatim.h" |
| 18 #include "remoting/codec/video_encoder_vpx.h" | 17 #include "remoting/codec/video_encoder_vpx.h" |
| 19 #include "remoting/host/audio_capturer.h" | 18 #include "remoting/host/audio_capturer.h" |
| 20 #include "remoting/host/audio_scheduler.h" | 19 #include "remoting/host/audio_scheduler.h" |
| 21 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
| 22 #include "remoting/host/input_injector.h" | 21 #include "remoting/host/input_injector.h" |
| 23 #include "remoting/host/screen_controls.h" | 22 #include "remoting/host/screen_controls.h" |
| 24 #include "remoting/host/screen_resolution.h" | 23 #include "remoting/host/screen_resolution.h" |
| 25 #include "remoting/host/video_scheduler.h" | 24 #include "remoting/host/video_scheduler.h" |
| 26 #include "remoting/proto/control.pb.h" | 25 #include "remoting/proto/control.pb.h" |
| 27 #include "remoting/proto/event.pb.h" | 26 #include "remoting/proto/event.pb.h" |
| 28 #include "remoting/protocol/client_stub.h" | 27 #include "remoting/protocol/client_stub.h" |
| 29 #include "remoting/protocol/clipboard_thread_proxy.h" | 28 #include "remoting/protocol/clipboard_thread_proxy.h" |
| 30 #include "remoting/protocol/pairing_registry.h" | 29 #include "remoting/protocol/pairing_registry.h" |
| 31 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 30 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 32 | 31 |
| 33 // Default DPI to assume for old clients that use notifyClientDimensions. | 32 // Default DPI to assume for old clients that use notifyClientDimensions. |
| 34 const int kDefaultDPI = 96; | 33 const int kDefaultDPI = 96; |
| 35 | 34 |
| 36 const char kEnableI444SwitchName[] = "enable-i444"; | |
| 37 | |
| 38 namespace remoting { | 35 namespace remoting { |
| 39 | 36 |
| 40 ClientSession::ClientSession( | 37 ClientSession::ClientSession( |
| 41 EventHandler* event_handler, | 38 EventHandler* event_handler, |
| 42 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, | 39 scoped_refptr<base::SingleThreadTaskRunner> audio_task_runner, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 40 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 44 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, | 41 scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
| 45 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, | 42 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner, |
| 46 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, | 43 scoped_refptr<base::SingleThreadTaskRunner> network_task_runner, |
| 47 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, | 44 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 } | 126 } |
| 130 | 127 |
| 131 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { | 128 void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| 132 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
| 133 | 130 |
| 134 if (video_control.has_enable()) { | 131 if (video_control.has_enable()) { |
| 135 VLOG(1) << "Received VideoControl (enable=" | 132 VLOG(1) << "Received VideoControl (enable=" |
| 136 << video_control.enable() << ")"; | 133 << video_control.enable() << ")"; |
| 137 video_scheduler_->Pause(!video_control.enable()); | 134 video_scheduler_->Pause(!video_control.enable()); |
| 138 } | 135 } |
| 136 if (video_control.has_lossless_encode()) { |
| 137 VLOG(1) << "Received VideoControl (lossless_encode=" |
| 138 << video_control.lossless_encode() << ")"; |
| 139 video_scheduler_->SetLosslessEncode(video_control.lossless_encode()); |
| 140 } |
| 141 if (video_control.has_lossless_color()) { |
| 142 VLOG(1) << "Received VideoControl (lossless_color=" |
| 143 << video_control.lossless_color() << ")"; |
| 144 video_scheduler_->SetLosslessColor(video_control.lossless_color()); |
| 145 } |
| 139 } | 146 } |
| 140 | 147 |
| 141 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { | 148 void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| 142 DCHECK(CalledOnValidThread()); | 149 DCHECK(CalledOnValidThread()); |
| 143 | 150 |
| 144 if (audio_control.has_enable()) { | 151 if (audio_control.has_enable()) { |
| 145 VLOG(1) << "Received AudioControl (enable=" | 152 VLOG(1) << "Received AudioControl (enable=" |
| 146 << audio_control.enable() << ")"; | 153 << audio_control.enable() << ")"; |
| 147 if (audio_scheduler_.get()) | 154 if (audio_scheduler_.get()) |
| 148 audio_scheduler_->Pause(!audio_control.enable()); | 155 audio_scheduler_->Pause(!audio_control.enable()); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 | 453 |
| 447 // TODO(sergeyu): Move this to SessionManager? | 454 // TODO(sergeyu): Move this to SessionManager? |
| 448 // static | 455 // static |
| 449 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( | 456 scoped_ptr<VideoEncoder> ClientSession::CreateVideoEncoder( |
| 450 const protocol::SessionConfig& config) { | 457 const protocol::SessionConfig& config) { |
| 451 const protocol::ChannelConfig& video_config = config.video_config(); | 458 const protocol::ChannelConfig& video_config = config.video_config(); |
| 452 | 459 |
| 453 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { | 460 if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) { |
| 454 return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>(); | 461 return remoting::VideoEncoderVpx::CreateForVP8().PassAs<VideoEncoder>(); |
| 455 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { | 462 } else if (video_config.codec == protocol::ChannelConfig::CODEC_VP9) { |
| 456 // Use I444 colour space if specified on the command-line. | 463 return remoting::VideoEncoderVpx::CreateForVP9().PassAs<VideoEncoder>(); |
| 457 if (CommandLine::ForCurrentProcess()->HasSwitch(kEnableI444SwitchName)) { | |
| 458 return | |
| 459 remoting::VideoEncoderVpx::CreateForVP9I444().PassAs<VideoEncoder>(); | |
| 460 } | |
| 461 return remoting::VideoEncoderVpx::CreateForVP9I420().PassAs<VideoEncoder>(); | |
| 462 } | 464 } |
| 463 | 465 |
| 464 NOTREACHED(); | 466 NOTREACHED(); |
| 465 return scoped_ptr<VideoEncoder>(); | 467 return scoped_ptr<VideoEncoder>(); |
| 466 } | 468 } |
| 467 | 469 |
| 468 // static | 470 // static |
| 469 scoped_ptr<AudioEncoder> ClientSession::CreateAudioEncoder( | 471 scoped_ptr<AudioEncoder> ClientSession::CreateAudioEncoder( |
| 470 const protocol::SessionConfig& config) { | 472 const protocol::SessionConfig& config) { |
| 471 const protocol::ChannelConfig& audio_config = config.audio_config(); | 473 const protocol::ChannelConfig& audio_config = config.audio_config(); |
| 472 | 474 |
| 473 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { | 475 if (audio_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) { |
| 474 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); | 476 return scoped_ptr<AudioEncoder>(new AudioEncoderVerbatim()); |
| 475 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { | 477 } else if (audio_config.codec == protocol::ChannelConfig::CODEC_OPUS) { |
| 476 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); | 478 return scoped_ptr<AudioEncoder>(new AudioEncoderOpus()); |
| 477 } | 479 } |
| 478 | 480 |
| 479 NOTREACHED(); | 481 NOTREACHED(); |
| 480 return scoped_ptr<AudioEncoder>(); | 482 return scoped_ptr<AudioEncoder>(); |
| 481 } | 483 } |
| 482 | 484 |
| 483 } // namespace remoting | 485 } // namespace remoting |
| OLD | NEW |