Chromium Code Reviews| Index: remoting/host/client_session.cc |
| diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc |
| index 58b49a56dc89d6fb172c4634271b6f0b278e7d94..897a47137e5fa8b9ff7ed79f2bdabcc71f276337 100644 |
| --- a/remoting/host/client_session.cc |
| +++ b/remoting/host/client_session.cc |
| @@ -96,6 +96,8 @@ ClientSession::~ClientSession() { |
| void ClientSession::NotifyClientResolution( |
| const protocol::ClientResolution& resolution) { |
| + DCHECK(CalledOnValidThread()); |
| + |
| if (!resolution.has_dips_width() || !resolution.has_dips_height()) |
| return; |
| @@ -116,6 +118,8 @@ void ClientSession::NotifyClientResolution( |
| } |
| void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| + DCHECK(CalledOnValidThread()); |
| + |
| if (video_control.has_enable()) { |
| VLOG(1) << "Received VideoControl (enable=" |
| << video_control.enable() << ")"; |
| @@ -125,6 +129,8 @@ void ClientSession::ControlVideo(const protocol::VideoControl& video_control) { |
| } |
| void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| + DCHECK(CalledOnValidThread()); |
| + |
| if (audio_control.has_enable()) { |
| VLOG(1) << "Received AudioControl (enable=" |
| << audio_control.enable() << ")"; |
| @@ -133,6 +139,31 @@ void ClientSession::ControlAudio(const protocol::AudioControl& audio_control) { |
| } |
| } |
| +void ClientSession::SetCapabilities( |
| + const protocol::Capabilities& capabilities) { |
| + DCHECK(CalledOnValidThread()); |
| + |
| + // Ignore all the messages but the 1st one. |
| + if (client_capabilities_) { |
| + LOG(WARNING) << "protocol::Capabilities has been received already."; |
| + return; |
| + } |
| + |
| + // Calculate the set of capabilities enabled by both client and host and pass |
| + // it to the desktop environment. |
| + client_capabilities_ = make_scoped_ptr(new Capabilities()); |
| + if (client_capabilities_->FromProtocolMessage(capabilities)) { |
| + 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
|
| + } else { |
| + LOG(ERROR) << "Invalid protocol::Capabilities received."; |
| + } |
| + |
| + 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
|
| + desktop_environment_->SetCapabilities( |
| + client_capabilities_->Intersect(host_capabilities_)); |
| + } |
| +} |
| + |
| void ClientSession::OnConnectionAuthenticated( |
| protocol::ConnectionToClient* connection) { |
| DCHECK(CalledOnValidThread()); |
| @@ -167,6 +198,27 @@ void ClientSession::OnConnectionChannelsConnected( |
| desktop_environment_ = |
| desktop_environment_factory_->Create(control_factory_.GetWeakPtr()); |
| + // Negotiate capabilities with the client. |
| + if (connection_->session()->config().supports_capabilities()) { |
| + host_capabilities_ = desktop_environment_->GetCapabilities(); |
| + VLOG(1) << "Host capabilities: " << host_capabilities_.ToString(); |
| + |
| + connection_->client_stub()->SetCapabilities( |
| + *host_capabilities_.ToProtocolMessage()); |
| + |
| + // |client_capabilities_| could have been received before all channels were |
| + // connected. Process them now. |
| + if (client_capabilities_) { |
| + desktop_environment_->SetCapabilities( |
| + client_capabilities_->Intersect(host_capabilities_)); |
| + } |
| + } else { |
| + VLOG(1) << "The client does not support any capabilities."; |
| + |
| + client_capabilities_ = make_scoped_ptr(new Capabilities()); |
| + desktop_environment_->SetCapabilities(*client_capabilities_); |
| + } |
| + |
| // Create the object that controls the screen resolution. |
| screen_controls_ = desktop_environment_->CreateScreenControls(); |