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(client_context_.get(), this, |
| 408 video_renderer_.get(), |
| 409 audio_player_->GetWeakPtr())); |
406 | 410 |
407 signaling_.reset( | 411 signaling_.reset( |
408 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), | 412 new XmppSignalStrategy(net::ClientSocketFactory::GetDefaultFactory(), |
409 jni_runtime_->url_requester(), xmpp_config_)); | 413 jni_runtime_->url_requester(), xmpp_config_)); |
410 | 414 |
411 scoped_refptr<protocol::TransportContext> transport_context = | 415 scoped_refptr<protocol::TransportContext> transport_context = |
412 new protocol::TransportContext( | 416 new protocol::TransportContext( |
413 signaling_.get(), | 417 signaling_.get(), |
414 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), | 418 base::WrapUnique(new protocol::ChromiumPortAllocatorFactory()), |
415 base::WrapUnique( | 419 base::WrapUnique( |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); | 500 jni_runtime_->logger()->LogStatistics(perf_tracker_.get()); |
497 | 501 |
498 jni_runtime_->network_task_runner()->PostDelayedTask( | 502 jni_runtime_->network_task_runner()->PostDelayedTask( |
499 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, GetWeakPtr()), | 503 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, GetWeakPtr()), |
500 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 504 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
501 } | 505 } |
502 | 506 |
503 void ChromotingJniInstance::ReleaseResources() { | 507 void ChromotingJniInstance::ReleaseResources() { |
504 // |client_| must be torn down before |signaling_|. | 508 // |client_| must be torn down before |signaling_|. |
505 client_.reset(); | 509 client_.reset(); |
| 510 audio_player_.reset(); |
506 video_renderer_.reset(); | 511 video_renderer_.reset(); |
507 view_.reset(); | 512 view_.reset(); |
508 signaling_.reset(); | 513 signaling_.reset(); |
509 perf_tracker_.reset(); | 514 perf_tracker_.reset(); |
510 client_context_.reset(); | 515 client_context_.reset(); |
511 | 516 |
512 weak_factory_.InvalidateWeakPtrs(); | 517 weak_factory_.InvalidateWeakPtrs(); |
513 } | 518 } |
514 | 519 |
515 } // namespace remoting | 520 } // namespace remoting |
OLD | NEW |