| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/base64.h" | 5 #include "base/base64.h" |
| 6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 connecting_loop_->Quit(); | 104 connecting_loop_->Quit(); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 void OnConnectionReady(bool ready) override {} | 107 void OnConnectionReady(bool ready) override {} |
| 108 void OnRouteChanged(const std::string& channel_name, | 108 void OnRouteChanged(const std::string& channel_name, |
| 109 const protocol::TransportRoute& route) override {} | 109 const protocol::TransportRoute& route) override {} |
| 110 void SetCapabilities(const std::string& capabilities) override {} | 110 void SetCapabilities(const std::string& capabilities) override {} |
| 111 void SetPairingResponse( | 111 void SetPairingResponse( |
| 112 const protocol::PairingResponse& pairing_response) override {} | 112 const protocol::PairingResponse& pairing_response) override {} |
| 113 void DeliverHostMessage(const protocol::ExtensionMessage& message) override {} | 113 void DeliverHostMessage(const protocol::ExtensionMessage& message) override {} |
| 114 protocol::ClipboardStub* GetClipboardStub() override { return NULL; } | 114 protocol::ClipboardStub* GetClipboardStub() override { return nullptr; } |
| 115 protocol::CursorShapeStub* GetCursorShapeStub() override { | 115 protocol::CursorShapeStub* GetCursorShapeStub() override { |
| 116 return &cursor_shape_stub_; | 116 return &cursor_shape_stub_; |
| 117 } | 117 } |
| 118 | 118 |
| 119 // VideoRenderer interface. | 119 // VideoRenderer interface. |
| 120 void OnSessionConfig(const protocol::SessionConfig& config) override {} | 120 void OnSessionConfig(const protocol::SessionConfig& config) override {} |
| 121 ChromotingStats* GetStats() override { return NULL; } | 121 ChromotingStats* GetStats() override { return nullptr; } |
| 122 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 122 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 123 const base::Closure& done) override { | 123 const base::Closure& done) override { |
| 124 if (video_packet->data().empty()) { | 124 if (video_packet->data().empty()) { |
| 125 // Ignore keep-alive packets | 125 // Ignore keep-alive packets |
| 126 done.Run(); | 126 done.Run(); |
| 127 return; | 127 return; |
| 128 } | 128 } |
| 129 | 129 |
| 130 last_video_packet_ = video_packet.Pass(); | 130 last_video_packet_ = video_packet.Pass(); |
| 131 | 131 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 base::Base64Encode(key_string, &key_base64); | 263 base::Base64Encode(key_string, &key_base64); |
| 264 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); | 264 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); |
| 265 ASSERT_TRUE(key_pair.get()); | 265 ASSERT_TRUE(key_pair.get()); |
| 266 | 266 |
| 267 | 267 |
| 268 protocol::SharedSecretHash host_secret; | 268 protocol::SharedSecretHash host_secret; |
| 269 host_secret.hash_function = protocol::AuthenticationMethod::NONE; | 269 host_secret.hash_function = protocol::AuthenticationMethod::NONE; |
| 270 host_secret.value = "123456"; | 270 host_secret.value = "123456"; |
| 271 scoped_ptr<protocol::AuthenticatorFactory> auth_factory = | 271 scoped_ptr<protocol::AuthenticatorFactory> auth_factory = |
| 272 protocol::Me2MeHostAuthenticatorFactory::CreateWithSharedSecret( | 272 protocol::Me2MeHostAuthenticatorFactory::CreateWithSharedSecret( |
| 273 true, kHostOwner, host_cert, key_pair, host_secret, NULL); | 273 true, kHostOwner, host_cert, key_pair, host_secret, nullptr); |
| 274 host_->SetAuthenticatorFactory(auth_factory.Pass()); | 274 host_->SetAuthenticatorFactory(auth_factory.Pass()); |
| 275 | 275 |
| 276 host_->AddStatusObserver(this); | 276 host_->AddStatusObserver(this); |
| 277 host_->set_protocol_config(protocol_config_->Clone()); | 277 host_->set_protocol_config(protocol_config_->Clone()); |
| 278 host_->Start(kHostOwner); | 278 host_->Start(kHostOwner); |
| 279 | 279 |
| 280 message_loop_.PostTask(FROM_HERE, | 280 message_loop_.PostTask(FROM_HERE, |
| 281 base::Bind(&ProtocolPerfTest::StartClientAfterHost, | 281 base::Bind(&ProtocolPerfTest::StartClientAfterHost, |
| 282 base::Unretained(this))); | 282 base::Unretained(this))); |
| 283 } | 283 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 NetworkPerformanceParams(100000, 200000, 130, 5, 0.01))); | 398 NetworkPerformanceParams(100000, 200000, 130, 5, 0.01))); |
| 399 | 399 |
| 400 TEST_P(ProtocolPerfTest, StreamFrameRate) { | 400 TEST_P(ProtocolPerfTest, StreamFrameRate) { |
| 401 StartHostAndClient(protocol::ChannelConfig::CODEC_VP8); | 401 StartHostAndClient(protocol::ChannelConfig::CODEC_VP8); |
| 402 ASSERT_NO_FATAL_FAILURE(WaitConnected()); | 402 ASSERT_NO_FATAL_FAILURE(WaitConnected()); |
| 403 | 403 |
| 404 base::TimeDelta latency; | 404 base::TimeDelta latency; |
| 405 | 405 |
| 406 ReceiveFrame(&latency); | 406 ReceiveFrame(&latency); |
| 407 LOG(INFO) << "First frame latency: " << latency.InMillisecondsF() << "ms"; | 407 LOG(INFO) << "First frame latency: " << latency.InMillisecondsF() << "ms"; |
| 408 ReceiveFrames(20, NULL); | 408 ReceiveFrames(20, nullptr); |
| 409 | 409 |
| 410 base::TimeTicks started = base::TimeTicks::Now(); | 410 base::TimeTicks started = base::TimeTicks::Now(); |
| 411 ReceiveFrames(40, &latency); | 411 ReceiveFrames(40, &latency); |
| 412 base::TimeDelta elapsed = base::TimeTicks::Now() - started; | 412 base::TimeDelta elapsed = base::TimeTicks::Now() - started; |
| 413 LOG(INFO) << "Frame rate: " << (40.0 / elapsed.InSecondsF()); | 413 LOG(INFO) << "Frame rate: " << (40.0 / elapsed.InSecondsF()); |
| 414 LOG(INFO) << "Maximum latency: " << latency.InMillisecondsF() << "ms"; | 414 LOG(INFO) << "Maximum latency: " << latency.InMillisecondsF() << "ms"; |
| 415 } | 415 } |
| 416 | 416 |
| 417 const int kIntermittentFrameSize = 100 * 1000; | 417 const int kIntermittentFrameSize = 100 * 1000; |
| 418 | 418 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 }; | 458 }; |
| 459 | 459 |
| 460 TEST_P(ProtocolPerfTest, IntermittentChanges) { | 460 TEST_P(ProtocolPerfTest, IntermittentChanges) { |
| 461 desktop_environment_factory_.set_frame_generator( | 461 desktop_environment_factory_.set_frame_generator( |
| 462 base::Bind(&IntermittentChangeFrameGenerator::GenerateFrame, | 462 base::Bind(&IntermittentChangeFrameGenerator::GenerateFrame, |
| 463 new IntermittentChangeFrameGenerator())); | 463 new IntermittentChangeFrameGenerator())); |
| 464 | 464 |
| 465 StartHostAndClient(protocol::ChannelConfig::CODEC_VERBATIM); | 465 StartHostAndClient(protocol::ChannelConfig::CODEC_VERBATIM); |
| 466 ASSERT_NO_FATAL_FAILURE(WaitConnected()); | 466 ASSERT_NO_FATAL_FAILURE(WaitConnected()); |
| 467 | 467 |
| 468 ReceiveFrame(NULL); | 468 ReceiveFrame(nullptr); |
| 469 | 469 |
| 470 base::TimeDelta expected = GetParam().latency_average; | 470 base::TimeDelta expected = GetParam().latency_average; |
| 471 if (GetParam().bandwidth > 0) { | 471 if (GetParam().bandwidth > 0) { |
| 472 expected += base::TimeDelta::FromSecondsD(kIntermittentFrameSize / | 472 expected += base::TimeDelta::FromSecondsD(kIntermittentFrameSize / |
| 473 GetParam().bandwidth); | 473 GetParam().bandwidth); |
| 474 } | 474 } |
| 475 LOG(INFO) << "Expected: " << expected.InMillisecondsF() << "ms"; | 475 LOG(INFO) << "Expected: " << expected.InMillisecondsF() << "ms"; |
| 476 | 476 |
| 477 base::TimeDelta sum; | 477 base::TimeDelta sum; |
| 478 | 478 |
| 479 const int kFrames = 5; | 479 const int kFrames = 5; |
| 480 for (int i = 0; i < kFrames; ++i) { | 480 for (int i = 0; i < kFrames; ++i) { |
| 481 base::TimeDelta latency; | 481 base::TimeDelta latency; |
| 482 ReceiveFrame(&latency); | 482 ReceiveFrame(&latency); |
| 483 LOG(INFO) << "Latency: " << latency.InMillisecondsF() | 483 LOG(INFO) << "Latency: " << latency.InMillisecondsF() |
| 484 << "ms Encode: " << last_video_packet_->encode_time_ms() | 484 << "ms Encode: " << last_video_packet_->encode_time_ms() |
| 485 << "ms Capture: " << last_video_packet_->capture_time_ms() | 485 << "ms Capture: " << last_video_packet_->capture_time_ms() |
| 486 << "ms"; | 486 << "ms"; |
| 487 sum += latency; | 487 sum += latency; |
| 488 } | 488 } |
| 489 | 489 |
| 490 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); | 490 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace remoting | 493 } // namespace remoting |
| OLD | NEW |