| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/jni/chromoting_jni_instance.h" | 5 #include "remoting/client/jni/chromoting_jni_instance.h" |
| 6 | 6 |
| 7 #include <android/log.h> | 7 #include <android/log.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 namespace { | 39 namespace { |
| 40 | 40 |
| 41 // TODO(solb) Move into location shared with client plugin. | 41 // TODO(solb) Move into location shared with client plugin. |
| 42 const char* const kXmppServer = "talk.google.com"; | 42 const char* const kXmppServer = "talk.google.com"; |
| 43 const int kXmppPort = 5222; | 43 const int kXmppPort = 5222; |
| 44 const bool kXmppUseTls = true; | 44 const bool kXmppUseTls = true; |
| 45 | 45 |
| 46 // Interval at which to log performance statistics, if enabled. | 46 // Interval at which to log performance statistics, if enabled. |
| 47 const int kPerfStatsIntervalMs = 60000; | 47 const int kPerfStatsIntervalMs = 60000; |
| 48 | 48 |
| 49 } | 49 } // namespace |
| 50 | 50 |
| 51 ChromotingJniInstance::ChromotingJniInstance( | 51 ChromotingJniInstance::ChromotingJniInstance( |
| 52 ChromotingJniRuntime* jni_runtime, | 52 ChromotingJniRuntime* jni_runtime, |
| 53 base::WeakPtr<JniClient> jni_client, | 53 base::WeakPtr<JniClient> jni_client, |
| 54 base::WeakPtr<JniDisplayHandler> display, | 54 base::WeakPtr<JniDisplayHandler> display, |
| 55 base::WeakPtr<JniPairingSecretFetcher> secret_fetcher, | 55 base::WeakPtr<JniPairingSecretFetcher> secret_fetcher, |
| 56 const std::string& username, | 56 const std::string& username, |
| 57 const std::string& auth_token, | 57 const std::string& auth_token, |
| 58 const std::string& host_jid, | 58 const std::string& host_jid, |
| 59 const std::string& host_id, | 59 const std::string& host_id, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 393 |
| 394 client_context_.reset(new ClientContext(jni_runtime_->network_task_runner())); | 394 client_context_.reset(new ClientContext(jni_runtime_->network_task_runner())); |
| 395 client_context_->Start(); | 395 client_context_->Start(); |
| 396 | 396 |
| 397 perf_tracker_.reset(new protocol::PerformanceTracker()); | 397 perf_tracker_.reset(new protocol::PerformanceTracker()); |
| 398 | 398 |
| 399 view_.reset(new JniFrameConsumer(jni_runtime_, display_handler_)); | 399 view_.reset(new JniFrameConsumer(jni_runtime_, display_handler_)); |
| 400 video_renderer_.reset(new SoftwareVideoRenderer( | 400 video_renderer_.reset(new SoftwareVideoRenderer( |
| 401 client_context_->decode_task_runner(), view_.get(), perf_tracker_.get())); | 401 client_context_->decode_task_runner(), view_.get(), perf_tracker_.get())); |
| 402 | 402 |
| 403 client_.reset( | 403 if (!audio_player_) { |
| 404 new ChromotingClient(client_context_.get(), this, video_renderer_.get(), | 404 audio_player_.reset(new AudioPlayerAndroid()); |
| 405 base::WrapUnique(new AudioPlayerAndroid()))); | 405 } |
| 406 |
| 407 client_.reset(new ChromotingClient( |
| 408 client_context_.get(), this, video_renderer_.get(), audio_player_.get())); |
| 406 | 409 |
| 407 signaling_.reset( | 410 signaling_.reset( |
| 408 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), | 411 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), |
| 409 jni_runtime_->url_requester(), xmpp_config_)); | 412 jni_runtime_->url_requester(), xmpp_config_)); |
| 410 | 413 |
| 411 scoped_refptr<protocol::TransportContext> transport_context = | 414 scoped_refptr<protocol::TransportContext> transport_context = |
| 412 new protocol::TransportContext( | 415 new protocol::TransportContext( |
| 413 signaling_.get(), | 416 signaling_.get(), |
| 414 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), | 417 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), |
| 415 base::WrapUnique( | 418 base::WrapUnique( |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); | 499 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); |
| 497 | 500 |
| 498 jni_runtime_->network_task_runner()->PostDelayedTask( | 501 jni_runtime_->network_task_runner()->PostDelayedTask( |
| 499 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, GetWeakPtr()), | 502 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, GetWeakPtr()), |
| 500 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 503 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
| 501 } | 504 } |
| 502 | 505 |
| 503 void ChromotingJniInstance::ReleaseResources() { | 506 void ChromotingJniInstance::ReleaseResources() { |
| 504 // |client_| must be torn down before |signaling_|. | 507 // |client_| must be torn down before |signaling_|. |
| 505 client_.reset(); | 508 client_.reset(); |
| 509 audio_player_.reset(); |
| 506 video_renderer_.reset(); | 510 video_renderer_.reset(); |
| 507 view_.reset(); | 511 view_.reset(); |
| 508 signaling_.reset(); | 512 signaling_.reset(); |
| 509 perf_tracker_.reset(); | 513 perf_tracker_.reset(); |
| 510 client_context_.reset(); | 514 client_context_.reset(); |
| 511 | 515 |
| 512 weak_factory_.InvalidateWeakPtrs(); | 516 weak_factory_.InvalidateWeakPtrs(); |
| 513 } | 517 } |
| 514 | 518 |
| 515 } // namespace remoting | 519 } // namespace remoting |
| OLD | NEW |