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 24 matching lines...) Expand all Loading... |
35 #include "ppapi/cpp/rect.h" | 35 #include "ppapi/cpp/rect.h" |
36 #include "ppapi/cpp/var_array_buffer.h" | 36 #include "ppapi/cpp/var_array_buffer.h" |
37 #include "ppapi/cpp/var_dictionary.h" | 37 #include "ppapi/cpp/var_dictionary.h" |
38 #include "remoting/base/constants.h" | 38 #include "remoting/base/constants.h" |
39 #include "remoting/base/util.h" | 39 #include "remoting/base/util.h" |
40 #include "remoting/client/chromoting_client.h" | 40 #include "remoting/client/chromoting_client.h" |
41 #include "remoting/client/client_config.h" | 41 #include "remoting/client/client_config.h" |
42 #include "remoting/client/frame_consumer_proxy.h" | 42 #include "remoting/client/frame_consumer_proxy.h" |
43 #include "remoting/client/plugin/delegating_signal_strategy.h" | 43 #include "remoting/client/plugin/delegating_signal_strategy.h" |
44 #include "remoting/client/plugin/media_source_video_renderer.h" | 44 #include "remoting/client/plugin/media_source_video_renderer.h" |
| 45 #include "remoting/client/plugin/normalizing_input_filter_cros.h" |
| 46 #include "remoting/client/plugin/normalizing_input_filter_mac.h" |
45 #include "remoting/client/plugin/pepper_audio_player.h" | 47 #include "remoting/client/plugin/pepper_audio_player.h" |
46 #include "remoting/client/plugin/pepper_input_handler.h" | 48 #include "remoting/client/plugin/pepper_input_handler.h" |
47 #include "remoting/client/plugin/pepper_port_allocator.h" | 49 #include "remoting/client/plugin/pepper_port_allocator.h" |
48 #include "remoting/client/plugin/pepper_token_fetcher.h" | 50 #include "remoting/client/plugin/pepper_token_fetcher.h" |
49 #include "remoting/client/plugin/pepper_view.h" | 51 #include "remoting/client/plugin/pepper_view.h" |
50 #include "remoting/client/software_video_renderer.h" | 52 #include "remoting/client/software_video_renderer.h" |
51 #include "remoting/protocol/connection_to_host.h" | 53 #include "remoting/protocol/connection_to_host.h" |
52 #include "remoting/protocol/host_stub.h" | 54 #include "remoting/protocol/host_stub.h" |
53 #include "remoting/protocol/libjingle_transport_factory.h" | 55 #include "remoting/protocol/libjingle_transport_factory.h" |
54 #include "third_party/libjingle/source/talk/base/helpers.h" | 56 #include "third_party/libjingle/source/talk/base/helpers.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 return true; | 205 return true; |
204 } | 206 } |
205 | 207 |
206 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) | 208 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) |
207 : pp::Instance(pp_instance), | 209 : pp::Instance(pp_instance), |
208 initialized_(false), | 210 initialized_(false), |
209 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)), | 211 plugin_task_runner_(new PluginThreadTaskRunner(&plugin_thread_delegate_)), |
210 context_(plugin_task_runner_.get()), | 212 context_(plugin_task_runner_.get()), |
211 input_tracker_(&mouse_input_filter_), | 213 input_tracker_(&mouse_input_filter_), |
212 key_mapper_(&input_tracker_), | 214 key_mapper_(&input_tracker_), |
213 normalizing_input_filter_(CreateNormalizingInputFilter(&key_mapper_)), | 215 input_handler_(this), |
214 input_handler_(this, normalizing_input_filter_.get()), | |
215 use_async_pin_dialog_(false), | 216 use_async_pin_dialog_(false), |
216 use_media_source_rendering_(false), | 217 use_media_source_rendering_(false), |
217 weak_factory_(this) { | 218 weak_factory_(this) { |
218 #if defined(OS_NACL) | 219 #if defined(OS_NACL) |
219 // In NaCl global resources need to be initialized differently because they | 220 // In NaCl global resources need to be initialized differently because they |
220 // are not shared with Chrome. | 221 // are not shared with Chrome. |
221 thread_task_runner_handle_.reset( | 222 thread_task_runner_handle_.reset( |
222 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); | 223 new base::ThreadTaskRunnerHandle(plugin_task_runner_)); |
223 thread_wrapper_.reset( | 224 thread_wrapper_.reset( |
224 new jingle_glue::JingleThreadWrapper(plugin_task_runner_)); | 225 new jingle_glue::JingleThreadWrapper(plugin_task_runner_)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 637 } |
637 | 638 |
638 // Read the list of capabilities, if any. | 639 // Read the list of capabilities, if any. |
639 if (data.HasKey("capabilities")) { | 640 if (data.HasKey("capabilities")) { |
640 if (!data.GetString("capabilities", &config.capabilities)) { | 641 if (!data.GetString("capabilities", &config.capabilities)) { |
641 LOG(ERROR) << "Invalid connect() data."; | 642 LOG(ERROR) << "Invalid connect() data."; |
642 return; | 643 return; |
643 } | 644 } |
644 } | 645 } |
645 | 646 |
| 647 #if defined(OS_NACL) |
| 648 std::string key_filter; |
| 649 if (!data.GetString("keyFilter", &key_filter)) { |
| 650 NOTREACHED(); |
| 651 normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); |
| 652 } else if (key_filter == "mac") { |
| 653 normalizing_input_filter_.reset( |
| 654 new NormalizingInputFilterMac(&key_mapper_)); |
| 655 } else if (key_filter == "cros") { |
| 656 normalizing_input_filter_.reset( |
| 657 new NormalizingInputFilterCros(&key_mapper_)); |
| 658 } else { |
| 659 DCHECK(key_filter.empty()); |
| 660 normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); |
| 661 } |
| 662 #elif defined(OS_MACOSX) |
| 663 normalizing_input_filter_.reset(new NormalizingInputFilterMac(&key_mapper_)); |
| 664 #elif defined(OS_CHROMEOS) |
| 665 normalizing_input_filter_.reset(new NormalizingInputFilterCros(&key_mapper_)); |
| 666 #else |
| 667 normalizing_input_filter_.reset(new protocol::InputFilter(&key_mapper_)); |
| 668 #endif |
| 669 input_handler_.set_input_stub(normalizing_input_filter_.get()); |
| 670 |
646 ConnectWithConfig(config, local_jid); | 671 ConnectWithConfig(config, local_jid); |
647 } | 672 } |
648 | 673 |
649 void ChromotingInstance::ConnectWithConfig(const ClientConfig& config, | 674 void ChromotingInstance::ConnectWithConfig(const ClientConfig& config, |
650 const std::string& local_jid) { | 675 const std::string& local_jid) { |
651 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); | 676 DCHECK(plugin_task_runner_->BelongsToCurrentThread()); |
652 | 677 |
653 if (use_media_source_rendering_) { | 678 if (use_media_source_rendering_) { |
654 video_renderer_.reset(new MediaSourceVideoRenderer(this)); | 679 video_renderer_.reset(new MediaSourceVideoRenderer(this)); |
655 } else { | 680 } else { |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 pp::VarArrayBuffer array_buffer(buffer_size); | 1169 pp::VarArrayBuffer array_buffer(buffer_size); |
1145 void* data_ptr = array_buffer.Map(); | 1170 void* data_ptr = array_buffer.Map(); |
1146 memcpy(data_ptr, buffer, buffer_size); | 1171 memcpy(data_ptr, buffer, buffer_size); |
1147 array_buffer.Unmap(); | 1172 array_buffer.Unmap(); |
1148 pp::VarDictionary data_dictionary; | 1173 pp::VarDictionary data_dictionary; |
1149 data_dictionary.Set(pp::Var("buffer"), array_buffer); | 1174 data_dictionary.Set(pp::Var("buffer"), array_buffer); |
1150 PostChromotingMessage("mediaSourceData", data_dictionary); | 1175 PostChromotingMessage("mediaSourceData", data_dictionary); |
1151 } | 1176 } |
1152 | 1177 |
1153 } // namespace remoting | 1178 } // namespace remoting |
OLD | NEW |