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/plugin/chromoting_instance.h" | 5 #include "remoting/client/plugin/chromoting_instance.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 base::LazyInstance<base::Lock>::Leaky | 175 base::LazyInstance<base::Lock>::Leaky |
176 g_logging_lock = LAZY_INSTANCE_INITIALIZER; | 176 g_logging_lock = LAZY_INSTANCE_INITIALIZER; |
177 logging::LogMessageHandlerFunction g_logging_old_handler = NULL; | 177 logging::LogMessageHandlerFunction g_logging_old_handler = NULL; |
178 | 178 |
179 } // namespace | 179 } // namespace |
180 | 180 |
181 // String sent in the "hello" message to the webapp to describe features. | 181 // String sent in the "hello" message to the webapp to describe features. |
182 const char ChromotingInstance::kApiFeatures[] = | 182 const char ChromotingInstance::kApiFeatures[] = |
183 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " | 183 "highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey " |
184 "notifyClientResolution pauseVideo pauseAudio asyncPin thirdPartyAuth " | 184 "notifyClientResolution pauseVideo pauseAudio asyncPin thirdPartyAuth " |
185 "pinlessAuth extensionMessage allowMouseLock mediaSourceRendering"; | 185 "pinlessAuth extensionMessage allowMouseLock mediaSourceRendering " |
| 186 "videoControl"; |
186 | 187 |
187 const char ChromotingInstance::kRequestedCapabilities[] = ""; | 188 const char ChromotingInstance::kRequestedCapabilities[] = ""; |
188 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape"; | 189 const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape"; |
189 | 190 |
190 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, | 191 bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, |
191 ClientConfig* config) { | 192 ClientConfig* config) { |
192 std::vector<std::string> auth_methods; | 193 std::vector<std::string> auth_methods; |
193 base::SplitString(auth_methods_str, ',', &auth_methods); | 194 base::SplitString(auth_methods_str, ',', &auth_methods); |
194 for (std::vector<std::string>::iterator it = auth_methods.begin(); | 195 for (std::vector<std::string>::iterator it = auth_methods.begin(); |
195 it != auth_methods.end(); ++it) { | 196 it != auth_methods.end(); ++it) { |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 } else if (method == "remapKey") { | 341 } else if (method == "remapKey") { |
341 HandleRemapKey(*data); | 342 HandleRemapKey(*data); |
342 } else if (method == "trapKey") { | 343 } else if (method == "trapKey") { |
343 HandleTrapKey(*data); | 344 HandleTrapKey(*data); |
344 } else if (method == "sendClipboardItem") { | 345 } else if (method == "sendClipboardItem") { |
345 HandleSendClipboardItem(*data); | 346 HandleSendClipboardItem(*data); |
346 } else if (method == "notifyClientResolution") { | 347 } else if (method == "notifyClientResolution") { |
347 HandleNotifyClientResolution(*data); | 348 HandleNotifyClientResolution(*data); |
348 } else if (method == "pauseVideo") { | 349 } else if (method == "pauseVideo") { |
349 HandlePauseVideo(*data); | 350 HandlePauseVideo(*data); |
| 351 } else if (method == "videoControl") { |
| 352 HandleVideoControl(*data); |
350 } else if (method == "pauseAudio") { | 353 } else if (method == "pauseAudio") { |
351 HandlePauseAudio(*data); | 354 HandlePauseAudio(*data); |
352 } else if (method == "useAsyncPinDialog") { | 355 } else if (method == "useAsyncPinDialog") { |
353 use_async_pin_dialog_ = true; | 356 use_async_pin_dialog_ = true; |
354 } else if (method == "onPinFetched") { | 357 } else if (method == "onPinFetched") { |
355 HandleOnPinFetched(*data); | 358 HandleOnPinFetched(*data); |
356 } else if (method == "onThirdPartyTokenFetched") { | 359 } else if (method == "onThirdPartyTokenFetched") { |
357 HandleOnThirdPartyTokenFetched(*data); | 360 HandleOnThirdPartyTokenFetched(*data); |
358 } else if (method == "requestPairing") { | 361 } else if (method == "requestPairing") { |
359 HandleRequestPairing(*data); | 362 HandleRequestPairing(*data); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 client_resolution.set_y_dpi(y_dpi); | 867 client_resolution.set_y_dpi(y_dpi); |
865 | 868 |
866 // Include the legacy width & height in DIPs for use by older hosts. | 869 // Include the legacy width & height in DIPs for use by older hosts. |
867 client_resolution.set_dips_width((width * kDefaultDPI) / x_dpi); | 870 client_resolution.set_dips_width((width * kDefaultDPI) / x_dpi); |
868 client_resolution.set_dips_height((height * kDefaultDPI) / y_dpi); | 871 client_resolution.set_dips_height((height * kDefaultDPI) / y_dpi); |
869 | 872 |
870 host_connection_->host_stub()->NotifyClientResolution(client_resolution); | 873 host_connection_->host_stub()->NotifyClientResolution(client_resolution); |
871 } | 874 } |
872 | 875 |
873 void ChromotingInstance::HandlePauseVideo(const base::DictionaryValue& data) { | 876 void ChromotingInstance::HandlePauseVideo(const base::DictionaryValue& data) { |
874 bool pause = false; | 877 if (!data.HasKey("pause")) { |
875 if (!data.GetBoolean("pause", &pause)) { | |
876 LOG(ERROR) << "Invalid pauseVideo."; | 878 LOG(ERROR) << "Invalid pauseVideo."; |
877 return; | 879 return; |
878 } | 880 } |
| 881 HandleVideoControl(data); |
| 882 } |
| 883 |
| 884 void ChromotingInstance::HandleVideoControl(const base::DictionaryValue& data) { |
| 885 protocol::VideoControl video_control; |
| 886 bool pause_video = false; |
| 887 if (data.GetBoolean("pause", &pause_video)) { |
| 888 video_control.set_enable(!pause_video); |
| 889 } |
| 890 bool lossless_encode = false; |
| 891 if (data.GetBoolean("losslessEncode", &lossless_encode)) { |
| 892 video_control.set_lossless_encode(lossless_encode); |
| 893 } |
| 894 bool lossless_color = false; |
| 895 if (data.GetBoolean("losslessColor", &lossless_color)) { |
| 896 video_control.set_lossless_color(lossless_color); |
| 897 } |
879 if (!IsConnected()) { | 898 if (!IsConnected()) { |
880 return; | 899 return; |
881 } | 900 } |
882 protocol::VideoControl video_control; | |
883 video_control.set_enable(!pause); | |
884 host_connection_->host_stub()->ControlVideo(video_control); | 901 host_connection_->host_stub()->ControlVideo(video_control); |
885 } | 902 } |
886 | 903 |
887 void ChromotingInstance::HandlePauseAudio(const base::DictionaryValue& data) { | 904 void ChromotingInstance::HandlePauseAudio(const base::DictionaryValue& data) { |
888 bool pause = false; | 905 bool pause = false; |
889 if (!data.GetBoolean("pause", &pause)) { | 906 if (!data.GetBoolean("pause", &pause)) { |
890 LOG(ERROR) << "Invalid pauseAudio."; | 907 LOG(ERROR) << "Invalid pauseAudio."; |
891 return; | 908 return; |
892 } | 909 } |
893 if (!IsConnected()) { | 910 if (!IsConnected()) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1178 pp::VarArrayBuffer array_buffer(buffer_size); | 1195 pp::VarArrayBuffer array_buffer(buffer_size); |
1179 void* data_ptr = array_buffer.Map(); | 1196 void* data_ptr = array_buffer.Map(); |
1180 memcpy(data_ptr, buffer, buffer_size); | 1197 memcpy(data_ptr, buffer, buffer_size); |
1181 array_buffer.Unmap(); | 1198 array_buffer.Unmap(); |
1182 pp::VarDictionary data_dictionary; | 1199 pp::VarDictionary data_dictionary; |
1183 data_dictionary.Set(pp::Var("buffer"), array_buffer); | 1200 data_dictionary.Set(pp::Var("buffer"), array_buffer); |
1184 PostChromotingMessage("mediaSourceData", data_dictionary); | 1201 PostChromotingMessage("mediaSourceData", data_dictionary); |
1185 } | 1202 } |
1186 | 1203 |
1187 } // namespace remoting | 1204 } // namespace remoting |
OLD | NEW |