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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "remoting/base/capabilities.h" | |
8 #include "remoting/client/audio_decode_scheduler.h" | 9 #include "remoting/client/audio_decode_scheduler.h" |
9 #include "remoting/client/audio_player.h" | 10 #include "remoting/client/audio_player.h" |
10 #include "remoting/client/client_context.h" | 11 #include "remoting/client/client_context.h" |
11 #include "remoting/client/client_user_interface.h" | 12 #include "remoting/client/client_user_interface.h" |
12 #include "remoting/client/rectangle_update_decoder.h" | 13 #include "remoting/client/rectangle_update_decoder.h" |
13 #include "remoting/proto/audio.pb.h" | 14 #include "remoting/proto/audio.pb.h" |
14 #include "remoting/proto/video.pb.h" | 15 #include "remoting/proto/video.pb.h" |
15 #include "remoting/protocol/authentication_method.h" | 16 #include "remoting/protocol/authentication_method.h" |
16 #include "remoting/protocol/connection_to_host.h" | 17 #include "remoting/protocol/connection_to_host.h" |
18 #include "remoting/protocol/host_stub.h" | |
17 #include "remoting/protocol/negotiating_client_authenticator.h" | 19 #include "remoting/protocol/negotiating_client_authenticator.h" |
18 #include "remoting/protocol/session_config.h" | 20 #include "remoting/protocol/session_config.h" |
19 #include "remoting/protocol/transport.h" | 21 #include "remoting/protocol/transport.h" |
20 | 22 |
21 namespace remoting { | 23 namespace remoting { |
22 | 24 |
23 using protocol::AuthenticationMethod; | 25 using protocol::AuthenticationMethod; |
24 | 26 |
25 ChromotingClient::ChromotingClient( | 27 ChromotingClient::ChromotingClient( |
26 const ClientConfig& config, | 28 const ClientConfig& config, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 | 83 |
82 void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { | 84 void ChromotingClient::OnDisconnected(const base::Closure& shutdown_task) { |
83 shutdown_task.Run(); | 85 shutdown_task.Run(); |
84 } | 86 } |
85 | 87 |
86 ChromotingStats* ChromotingClient::GetStats() { | 88 ChromotingStats* ChromotingClient::GetStats() { |
87 DCHECK(task_runner_->BelongsToCurrentThread()); | 89 DCHECK(task_runner_->BelongsToCurrentThread()); |
88 return rectangle_decoder_->GetStats(); | 90 return rectangle_decoder_->GetStats(); |
89 } | 91 } |
90 | 92 |
93 void ChromotingClient::SetCapabilities( | |
94 const protocol::Capabilities& capabilities) { | |
95 DCHECK(task_runner_->BelongsToCurrentThread()); | |
96 | |
97 // Only accept the first |protocol::Capabilities| message. | |
98 if (host_capabilities_) { | |
99 LOG(WARNING) << "protocol::Capabilities has been received already."; | |
100 return; | |
101 } | |
102 | |
103 host_capabilities_ = make_scoped_ptr(new std::string()); | |
Sergey Ulanov
2013/04/18 00:34:53
host_capabilities_ is never used except to check t
alexeypa (please no reviews)
2013/04/18 18:56:36
Done.
| |
104 if (capabilities.has_capabilities()) | |
105 *host_capabilities_ = capabilities.capabilities(); | |
106 | |
107 VLOG(1) << "Host capabilities: " << *host_capabilities_; | |
108 | |
109 // Calculate the set of capabilities enabled by both client and host and pass | |
110 // it to the webapp. | |
111 user_interface_->SetCapabilities( | |
112 IntersectCapabilities(config_.capabilities, *host_capabilities_)); | |
113 } | |
114 | |
91 void ChromotingClient::InjectClipboardEvent( | 115 void ChromotingClient::InjectClipboardEvent( |
92 const protocol::ClipboardEvent& event) { | 116 const protocol::ClipboardEvent& event) { |
93 DCHECK(task_runner_->BelongsToCurrentThread()); | 117 DCHECK(task_runner_->BelongsToCurrentThread()); |
118 | |
94 user_interface_->GetClipboardStub()->InjectClipboardEvent(event); | 119 user_interface_->GetClipboardStub()->InjectClipboardEvent(event); |
95 } | 120 } |
96 | 121 |
97 void ChromotingClient::SetCursorShape( | 122 void ChromotingClient::SetCursorShape( |
98 const protocol::CursorShapeInfo& cursor_shape) { | 123 const protocol::CursorShapeInfo& cursor_shape) { |
124 DCHECK(task_runner_->BelongsToCurrentThread()); | |
125 | |
99 user_interface_->GetCursorShapeStub()->SetCursorShape(cursor_shape); | 126 user_interface_->GetCursorShapeStub()->SetCursorShape(cursor_shape); |
100 } | 127 } |
101 | 128 |
102 void ChromotingClient::OnConnectionState( | 129 void ChromotingClient::OnConnectionState( |
103 protocol::ConnectionToHost::State state, | 130 protocol::ConnectionToHost::State state, |
104 protocol::ErrorCode error) { | 131 protocol::ErrorCode error) { |
105 DCHECK(task_runner_->BelongsToCurrentThread()); | 132 DCHECK(task_runner_->BelongsToCurrentThread()); |
106 VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")"; | 133 VLOG(1) << "ChromotingClient::OnConnectionState(" << state << ")"; |
107 if (state == protocol::ConnectionToHost::CONNECTED) | 134 if (state == protocol::ConnectionToHost::CONNECTED) |
108 Initialize(); | 135 Initialize(); |
109 user_interface_->OnConnectionState(state, error); | 136 user_interface_->OnConnectionState(state, error); |
110 } | 137 } |
111 | 138 |
112 void ChromotingClient::OnConnectionReady(bool ready) { | 139 void ChromotingClient::OnConnectionReady(bool ready) { |
113 VLOG(1) << "ChromotingClient::OnConnectionReady(" << ready << ")"; | 140 VLOG(1) << "ChromotingClient::OnConnectionReady(" << ready << ")"; |
114 user_interface_->OnConnectionReady(ready); | 141 user_interface_->OnConnectionReady(ready); |
115 } | 142 } |
116 | 143 |
117 void ChromotingClient::Initialize() { | 144 void ChromotingClient::Initialize() { |
118 DCHECK(task_runner_->BelongsToCurrentThread()); | 145 DCHECK(task_runner_->BelongsToCurrentThread()); |
119 | 146 |
120 // Initialize the decoder. | 147 // Initialize the decoder. |
121 rectangle_decoder_->Initialize(connection_->config()); | 148 rectangle_decoder_->Initialize(connection_->config()); |
122 if (connection_->config().is_audio_enabled()) | 149 if (connection_->config().is_audio_enabled()) |
123 audio_decode_scheduler_->Initialize(connection_->config()); | 150 audio_decode_scheduler_->Initialize(connection_->config()); |
151 | |
152 // Negotiate capabilities with the host. | |
153 if (connection_->config().SupportsCapabilities()) { | |
154 VLOG(1) << "Client capabilities: " << config_.capabilities; | |
155 | |
156 protocol::Capabilities capabilities; | |
157 capabilities.set_capabilities(config_.capabilities); | |
158 connection_->host_stub()->SetCapabilities(capabilities); | |
159 } else { | |
160 VLOG(1) << "The host does not support any capabilities."; | |
161 | |
162 host_capabilities_ = make_scoped_ptr(new std::string()); | |
163 user_interface_->SetCapabilities(*host_capabilities_); | |
164 } | |
124 } | 165 } |
125 | 166 |
126 } // namespace remoting | 167 } // namespace remoting |
OLD | NEW |