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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 221 |
222 // Create the chromoting objects that don't depend on the network connection. | 222 // Create the chromoting objects that don't depend on the network connection. |
223 // RectangleUpdateDecoder runs on a separate thread so for now we wrap | 223 // RectangleUpdateDecoder runs on a separate thread so for now we wrap |
224 // PepperView with a ref-counted proxy object. | 224 // PepperView with a ref-counted proxy object. |
225 scoped_refptr<FrameConsumerProxy> consumer_proxy = | 225 scoped_refptr<FrameConsumerProxy> consumer_proxy = |
226 new FrameConsumerProxy(plugin_message_loop_); | 226 new FrameConsumerProxy(plugin_message_loop_); |
227 rectangle_decoder_ = new RectangleUpdateDecoder( | 227 rectangle_decoder_ = new RectangleUpdateDecoder( |
228 context_.decode_task_runner(), consumer_proxy); | 228 context_.decode_task_runner(), consumer_proxy); |
229 view_.reset(new PepperView(this, &context_, rectangle_decoder_.get())); | 229 view_.reset(new PepperView(this, &context_, rectangle_decoder_.get())); |
230 consumer_proxy->Attach(view_->AsWeakPtr()); | 230 consumer_proxy->Attach(view_->AsWeakPtr()); |
231 audio_player_.reset(new PepperAudioPlayer(this)); | |
232 | 231 |
233 return true; | 232 return true; |
234 } | 233 } |
235 | 234 |
236 void ChromotingInstance::HandleMessage(const pp::Var& message) { | 235 void ChromotingInstance::HandleMessage(const pp::Var& message) { |
237 if (!message.is_string()) { | 236 if (!message.is_string()) { |
238 LOG(ERROR) << "Received a message that is not a string."; | 237 LOG(ERROR) << "Received a message that is not a string."; |
239 return; | 238 return; |
240 } | 239 } |
241 | 240 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 468 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); |
470 PostChromotingMessage("onFirstFrameReceived", data.Pass()); | 469 PostChromotingMessage("onFirstFrameReceived", data.Pass()); |
471 } | 470 } |
472 | 471 |
473 void ChromotingInstance::Connect(const ClientConfig& config) { | 472 void ChromotingInstance::Connect(const ClientConfig& config) { |
474 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); | 473 DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
475 | 474 |
476 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); | 475 jingle_glue::JingleThreadWrapper::EnsureForCurrentThread(); |
477 | 476 |
478 host_connection_.reset(new protocol::ConnectionToHost(true)); | 477 host_connection_.reset(new protocol::ConnectionToHost(true)); |
| 478 audio_player_.reset(new PepperAudioPlayer(this)); |
479 client_.reset(new ChromotingClient(config, context_.main_task_runner(), | 479 client_.reset(new ChromotingClient(config, context_.main_task_runner(), |
480 host_connection_.get(), this, | 480 host_connection_.get(), this, |
481 rectangle_decoder_.get(), | 481 rectangle_decoder_.get(), |
482 audio_player_.get())); | 482 audio_player_.get())); |
483 | 483 |
484 // Construct the input pipeline | 484 // Construct the input pipeline |
485 mouse_input_filter_.reset( | 485 mouse_input_filter_.reset( |
486 new protocol::MouseInputFilter(host_connection_->input_stub())); | 486 new protocol::MouseInputFilter(host_connection_->input_stub())); |
487 mouse_input_filter_->set_input_size(view_->get_view_size()); | 487 mouse_input_filter_->set_input_size(view_->get_view_size()); |
488 input_tracker_.reset( | 488 input_tracker_.reset( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 base::WaitableEvent done_event(true, false); | 534 base::WaitableEvent done_event(true, false); |
535 client_->Stop(base::Bind(&base::WaitableEvent::Signal, | 535 client_->Stop(base::Bind(&base::WaitableEvent::Signal, |
536 base::Unretained(&done_event))); | 536 base::Unretained(&done_event))); |
537 done_event.Wait(); | 537 done_event.Wait(); |
538 client_.reset(); | 538 client_.reset(); |
539 } | 539 } |
540 | 540 |
541 input_handler_.reset(); | 541 input_handler_.reset(); |
542 input_tracker_.reset(); | 542 input_tracker_.reset(); |
543 mouse_input_filter_.reset(); | 543 mouse_input_filter_.reset(); |
| 544 audio_player_.reset(); |
544 host_connection_.reset(); | 545 host_connection_.reset(); |
545 } | 546 } |
546 | 547 |
547 void ChromotingInstance::OnIncomingIq(const std::string& iq) { | 548 void ChromotingInstance::OnIncomingIq(const std::string& iq) { |
548 xmpp_proxy_->OnIq(iq); | 549 xmpp_proxy_->OnIq(iq); |
549 } | 550 } |
550 | 551 |
551 void ChromotingInstance::ReleaseAllKeys() { | 552 void ChromotingInstance::ReleaseAllKeys() { |
552 if (IsConnected()) | 553 if (IsConnected()) |
553 input_tracker_->ReleaseAll(); | 554 input_tracker_->ReleaseAll(); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 PostChromotingMessage("logDebugMessage", data.Pass()); | 752 PostChromotingMessage("logDebugMessage", data.Pass()); |
752 g_logging_to_plugin = false; | 753 g_logging_to_plugin = false; |
753 } | 754 } |
754 | 755 |
755 bool ChromotingInstance::IsConnected() { | 756 bool ChromotingInstance::IsConnected() { |
756 return host_connection_.get() && | 757 return host_connection_.get() && |
757 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); | 758 (host_connection_->state() == protocol::ConnectionToHost::CONNECTED); |
758 } | 759 } |
759 | 760 |
760 } // namespace remoting | 761 } // namespace remoting |
OLD | NEW |