| 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 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "jingle/glue/thread_wrapper.h" | 11 #include "jingle/glue/thread_wrapper.h" |
| 12 #include "net/socket/client_socket_factory.h" | 12 #include "net/socket/client_socket_factory.h" |
| 13 #include "remoting/base/service_urls.h" | 13 #include "remoting/base/service_urls.h" |
| 14 #include "remoting/client/audio_player.h" | 14 #include "remoting/client/audio_player.h" |
| 15 #include "remoting/client/client_status_logger.h" |
| 15 #include "remoting/client/jni/android_keymap.h" | 16 #include "remoting/client/jni/android_keymap.h" |
| 16 #include "remoting/client/jni/chromoting_jni_runtime.h" | 17 #include "remoting/client/jni/chromoting_jni_runtime.h" |
| 17 #include "remoting/client/log_to_server.h" | |
| 18 #include "remoting/client/software_video_renderer.h" | 18 #include "remoting/client/software_video_renderer.h" |
| 19 #include "remoting/client/token_fetcher_proxy.h" | 19 #include "remoting/client/token_fetcher_proxy.h" |
| 20 #include "remoting/jingle_glue/chromium_port_allocator.h" | 20 #include "remoting/jingle_glue/chromium_port_allocator.h" |
| 21 #include "remoting/jingle_glue/chromium_socket_factory.h" | 21 #include "remoting/jingle_glue/chromium_socket_factory.h" |
| 22 #include "remoting/jingle_glue/network_settings.h" | 22 #include "remoting/jingle_glue/network_settings.h" |
| 23 #include "remoting/jingle_glue/server_log_entry.h" | 23 #include "remoting/jingle_glue/server_log_entry.h" |
| 24 #include "remoting/protocol/host_stub.h" | 24 #include "remoting/protocol/host_stub.h" |
| 25 #include "remoting/protocol/libjingle_transport_factory.h" | 25 #include "remoting/protocol/libjingle_transport_factory.h" |
| 26 | 26 |
| 27 namespace remoting { | 27 namespace remoting { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 video_renderer_->GetStats()->video_paint_ms()->Record(paint_time_ms); | 247 video_renderer_->GetStats()->video_paint_ms()->Record(paint_time_ms); |
| 248 } | 248 } |
| 249 | 249 |
| 250 void ChromotingJniInstance::OnConnectionState( | 250 void ChromotingJniInstance::OnConnectionState( |
| 251 protocol::ConnectionToHost::State state, | 251 protocol::ConnectionToHost::State state, |
| 252 protocol::ErrorCode error) { | 252 protocol::ErrorCode error) { |
| 253 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); | 253 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); |
| 254 | 254 |
| 255 EnableStatsLogging(state == protocol::ConnectionToHost::CONNECTED); | 255 EnableStatsLogging(state == protocol::ConnectionToHost::CONNECTED); |
| 256 | 256 |
| 257 log_to_server_->LogSessionStateChange(state, error); | 257 client_status_logger_->LogSessionStateChange(state, error); |
| 258 | 258 |
| 259 if (create_pairing_ && state == protocol::ConnectionToHost::CONNECTED) { | 259 if (create_pairing_ && state == protocol::ConnectionToHost::CONNECTED) { |
| 260 protocol::PairingRequest request; | 260 protocol::PairingRequest request; |
| 261 DCHECK(!device_name_.empty()); | 261 DCHECK(!device_name_.empty()); |
| 262 request.set_client_name(device_name_); | 262 request.set_client_name(device_name_); |
| 263 connection_->host_stub()->RequestPairing(request); | 263 connection_->host_stub()->RequestPairing(request); |
| 264 } | 264 } |
| 265 | 265 |
| 266 jni_runtime_->ui_task_runner()->PostTask( | 266 jni_runtime_->ui_task_runner()->PostTask( |
| 267 FROM_HERE, | 267 FROM_HERE, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 371 |
| 372 client_.reset(new ChromotingClient( | 372 client_.reset(new ChromotingClient( |
| 373 client_config_, client_context_.get(), connection_.get(), | 373 client_config_, client_context_.get(), connection_.get(), |
| 374 this, video_renderer_.get(), scoped_ptr<AudioPlayer>())); | 374 this, video_renderer_.get(), scoped_ptr<AudioPlayer>())); |
| 375 | 375 |
| 376 | 376 |
| 377 signaling_.reset(new XmppSignalStrategy( | 377 signaling_.reset(new XmppSignalStrategy( |
| 378 net::ClientSocketFactory::GetDefaultFactory(), | 378 net::ClientSocketFactory::GetDefaultFactory(), |
| 379 jni_runtime_->url_requester(), xmpp_config_)); | 379 jni_runtime_->url_requester(), xmpp_config_)); |
| 380 | 380 |
| 381 log_to_server_.reset( | 381 client_status_logger_.reset( |
| 382 new client::LogToServer(ServerLogEntry::ME2ME, | 382 new ClientStatusLogger(ServerLogEntry::ME2ME, |
| 383 signaling_.get(), | 383 signaling_.get(), |
| 384 ServiceUrls::GetInstance()->directory_bot_jid())); | 384 ServiceUrls::GetInstance()->directory_bot_jid())); |
| 385 | 385 |
| 386 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_FULL); | 386 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_FULL); |
| 387 | 387 |
| 388 // Use Chrome's network stack to allocate ports for peer-to-peer channels. | 388 // Use Chrome's network stack to allocate ports for peer-to-peer channels. |
| 389 scoped_ptr<ChromiumPortAllocator> port_allocator( | 389 scoped_ptr<ChromiumPortAllocator> port_allocator( |
| 390 ChromiumPortAllocator::Create(jni_runtime_->url_requester(), | 390 ChromiumPortAllocator::Create(jni_runtime_->url_requester(), |
| 391 network_settings)); | 391 network_settings)); |
| 392 | 392 |
| 393 scoped_ptr<protocol::TransportFactory> transport_factory( | 393 scoped_ptr<protocol::TransportFactory> transport_factory( |
| 394 new protocol::LibjingleTransportFactory( | 394 new protocol::LibjingleTransportFactory( |
| 395 signaling_.get(), | 395 signaling_.get(), |
| 396 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(), | 396 port_allocator.PassAs<cricket::HttpPortAllocatorBase>(), |
| 397 network_settings)); | 397 network_settings)); |
| 398 | 398 |
| 399 client_->Start(signaling_.get(), transport_factory.Pass()); | 399 client_->Start(signaling_.get(), transport_factory.Pass()); |
| 400 } | 400 } |
| 401 | 401 |
| 402 void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() { | 402 void ChromotingJniInstance::DisconnectFromHostOnNetworkThread() { |
| 403 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); | 403 DCHECK(jni_runtime_->network_task_runner()->BelongsToCurrentThread()); |
| 404 | 404 |
| 405 host_id_.clear(); | 405 host_id_.clear(); |
| 406 | 406 |
| 407 stats_logging_enabled_ = false; | 407 stats_logging_enabled_ = false; |
| 408 | 408 |
| 409 // |client_| must be torn down before |signaling_|. | 409 // |client_| must be torn down before |signaling_|. |
| 410 connection_.reset(); | 410 connection_.reset(); |
| 411 client_.reset(); | 411 client_.reset(); |
| 412 log_to_server_.reset(); | 412 client_status_logger_.reset(); |
| 413 } | 413 } |
| 414 | 414 |
| 415 void ChromotingJniInstance::FetchSecret( | 415 void ChromotingJniInstance::FetchSecret( |
| 416 bool pairable, | 416 bool pairable, |
| 417 const protocol::SecretFetchedCallback& callback) { | 417 const protocol::SecretFetchedCallback& callback) { |
| 418 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { | 418 if (!jni_runtime_->ui_task_runner()->BelongsToCurrentThread()) { |
| 419 jni_runtime_->ui_task_runner()->PostTask( | 419 jni_runtime_->ui_task_runner()->PostTask( |
| 420 FROM_HERE, base::Bind(&ChromotingJniInstance::FetchSecret, | 420 FROM_HERE, base::Bind(&ChromotingJniInstance::FetchSecret, |
| 421 this, pairable, callback)); | 421 this, pairable, callback)); |
| 422 return; | 422 return; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 "Bandwidth:%.0f FrameRate:%.1f Capture:%.1f Encode:%.1f " | 481 "Bandwidth:%.0f FrameRate:%.1f Capture:%.1f Encode:%.1f " |
| 482 "Decode:%.1f Render:%.1f Latency:%.0f", | 482 "Decode:%.1f Render:%.1f Latency:%.0f", |
| 483 stats->video_bandwidth()->Rate(), | 483 stats->video_bandwidth()->Rate(), |
| 484 stats->video_frame_rate()->Rate(), | 484 stats->video_frame_rate()->Rate(), |
| 485 stats->video_capture_ms()->Average(), | 485 stats->video_capture_ms()->Average(), |
| 486 stats->video_encode_ms()->Average(), | 486 stats->video_encode_ms()->Average(), |
| 487 stats->video_decode_ms()->Average(), | 487 stats->video_decode_ms()->Average(), |
| 488 stats->video_paint_ms()->Average(), | 488 stats->video_paint_ms()->Average(), |
| 489 stats->round_trip_ms()->Average()); | 489 stats->round_trip_ms()->Average()); |
| 490 | 490 |
| 491 log_to_server_->LogStatistics(stats); | 491 client_status_logger_->LogStatistics(stats); |
| 492 | 492 |
| 493 jni_runtime_->network_task_runner()->PostDelayedTask( | 493 jni_runtime_->network_task_runner()->PostDelayedTask( |
| 494 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), | 494 FROM_HERE, base::Bind(&ChromotingJniInstance::LogPerfStats, this), |
| 495 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); | 495 base::TimeDelta::FromMilliseconds(kPerfStatsIntervalMs)); |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace remoting | 498 } // namespace remoting |
| OLD | NEW |