| 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/client/chromoting_client.h" | 5 #include "remoting/client/chromoting_client.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "remoting/base/capabilities.h" | 9 #include "remoting/base/capabilities.h" |
| 10 #include "remoting/base/constants.h" |
| 10 #include "remoting/client/audio_decode_scheduler.h" | 11 #include "remoting/client/audio_decode_scheduler.h" |
| 11 #include "remoting/client/audio_player.h" | 12 #include "remoting/client/audio_player.h" |
| 12 #include "remoting/client/client_context.h" | 13 #include "remoting/client/client_context.h" |
| 13 #include "remoting/client/client_user_interface.h" | 14 #include "remoting/client/client_user_interface.h" |
| 14 #include "remoting/protocol/authenticator.h" | 15 #include "remoting/protocol/authenticator.h" |
| 15 #include "remoting/protocol/connection_to_host.h" | 16 #include "remoting/protocol/connection_to_host.h" |
| 16 #include "remoting/protocol/host_stub.h" | 17 #include "remoting/protocol/host_stub.h" |
| 17 #include "remoting/protocol/ice_connection_to_host.h" | 18 #include "remoting/protocol/ice_connection_to_host.h" |
| 18 #include "remoting/protocol/jingle_session_manager.h" | 19 #include "remoting/protocol/jingle_session_manager.h" |
| 19 #include "remoting/protocol/negotiating_client_authenticator.h" | 20 #include "remoting/protocol/negotiating_client_authenticator.h" |
| 20 #include "remoting/protocol/session_config.h" | 21 #include "remoting/protocol/session_config.h" |
| 21 #include "remoting/protocol/transport_context.h" | 22 #include "remoting/protocol/transport_context.h" |
| 22 #include "remoting/protocol/video_renderer.h" | 23 #include "remoting/protocol/video_renderer.h" |
| 23 #include "remoting/protocol/webrtc_connection_to_host.h" | 24 #include "remoting/protocol/webrtc_connection_to_host.h" |
| 24 #include "remoting/signaling/jid_util.h" | 25 #include "remoting/signaling/jid_util.h" |
| 26 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 25 | 27 |
| 26 namespace remoting { | 28 namespace remoting { |
| 27 | 29 |
| 28 ChromotingClient::ChromotingClient(ClientContext* client_context, | 30 ChromotingClient::ChromotingClient(ClientContext* client_context, |
| 29 ClientUserInterface* user_interface, | 31 ClientUserInterface* user_interface, |
| 30 protocol::VideoRenderer* video_renderer, | 32 protocol::VideoRenderer* video_renderer, |
| 31 scoped_ptr<AudioPlayer> audio_player) | 33 scoped_ptr<AudioPlayer> audio_player) |
| 32 : user_interface_(user_interface), video_renderer_(video_renderer) { | 34 : user_interface_(user_interface), video_renderer_(video_renderer) { |
| 33 DCHECK(client_context->main_task_runner()->BelongsToCurrentThread()); | 35 DCHECK(client_context->main_task_runner()->BelongsToCurrentThread()); |
| 34 if (audio_player) { | 36 if (audio_player) { |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 user_interface_->SetPairingResponse(pairing_response); | 142 user_interface_->SetPairingResponse(pairing_response); |
| 141 } | 143 } |
| 142 | 144 |
| 143 void ChromotingClient::DeliverHostMessage( | 145 void ChromotingClient::DeliverHostMessage( |
| 144 const protocol::ExtensionMessage& message) { | 146 const protocol::ExtensionMessage& message) { |
| 145 DCHECK(thread_checker_.CalledOnValidThread()); | 147 DCHECK(thread_checker_.CalledOnValidThread()); |
| 146 | 148 |
| 147 user_interface_->DeliverHostMessage(message); | 149 user_interface_->DeliverHostMessage(message); |
| 148 } | 150 } |
| 149 | 151 |
| 152 void ChromotingClient::SetVideoLayout(const protocol::VideoLayout& layout) { |
| 153 int num_video_tracks = layout.video_track_size(); |
| 154 if (num_video_tracks < 1) { |
| 155 LOG(ERROR) << "Received VideoLayout message with 0 tracks."; |
| 156 return; |
| 157 } |
| 158 |
| 159 if (num_video_tracks > 2) { |
| 160 LOG(WARNING) << "Received VideoLayout message with " << num_video_tracks |
| 161 << " tracks. Only one track is supported."; |
| 162 } |
| 163 |
| 164 const protocol::VideoTrackLayout& track_layout = layout.video_track(0); |
| 165 int x_dpi = track_layout.has_x_dpi() ? track_layout.x_dpi() : kDefaultDpi; |
| 166 int y_dpi = track_layout.has_y_dpi() ? track_layout.y_dpi() : kDefaultDpi; |
| 167 user_interface_->SetDesktopSize( |
| 168 webrtc::DesktopSize(track_layout.width() * x_dpi / kDefaultDpi, |
| 169 track_layout.height() * y_dpi / kDefaultDpi), |
| 170 webrtc::DesktopVector(x_dpi, y_dpi)); |
| 171 } |
| 172 |
| 150 void ChromotingClient::InjectClipboardEvent( | 173 void ChromotingClient::InjectClipboardEvent( |
| 151 const protocol::ClipboardEvent& event) { | 174 const protocol::ClipboardEvent& event) { |
| 152 DCHECK(thread_checker_.CalledOnValidThread()); | 175 DCHECK(thread_checker_.CalledOnValidThread()); |
| 153 | 176 |
| 154 user_interface_->GetClipboardStub()->InjectClipboardEvent(event); | 177 user_interface_->GetClipboardStub()->InjectClipboardEvent(event); |
| 155 } | 178 } |
| 156 | 179 |
| 157 void ChromotingClient::SetCursorShape( | 180 void ChromotingClient::SetCursorShape( |
| 158 const protocol::CursorShapeInfo& cursor_shape) { | 181 const protocol::CursorShapeInfo& cursor_shape) { |
| 159 DCHECK(thread_checker_.CalledOnValidThread()); | 182 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 258 |
| 236 // Negotiate capabilities with the host. | 259 // Negotiate capabilities with the host. |
| 237 VLOG(1) << "Client capabilities: " << local_capabilities_; | 260 VLOG(1) << "Client capabilities: " << local_capabilities_; |
| 238 | 261 |
| 239 protocol::Capabilities capabilities; | 262 protocol::Capabilities capabilities; |
| 240 capabilities.set_capabilities(local_capabilities_); | 263 capabilities.set_capabilities(local_capabilities_); |
| 241 connection_->host_stub()->SetCapabilities(capabilities); | 264 connection_->host_stub()->SetCapabilities(capabilities); |
| 242 } | 265 } |
| 243 | 266 |
| 244 } // namespace remoting | 267 } // namespace remoting |
| OLD | NEW |