| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 int bandwidth; | 57 int bandwidth; |
| 58 int max_buffers; | 58 int max_buffers; |
| 59 base::TimeDelta latency_average; | 59 base::TimeDelta latency_average; |
| 60 base::TimeDelta latency_stddev; | 60 base::TimeDelta latency_stddev; |
| 61 double out_of_order_rate; | 61 double out_of_order_rate; |
| 62 }; | 62 }; |
| 63 | 63 |
| 64 class FakeCursorShapeStub : public protocol::CursorShapeStub { | 64 class FakeCursorShapeStub : public protocol::CursorShapeStub { |
| 65 public: | 65 public: |
| 66 FakeCursorShapeStub() {} | 66 FakeCursorShapeStub() {} |
| 67 virtual ~FakeCursorShapeStub() {} | 67 ~FakeCursorShapeStub() override {} |
| 68 | 68 |
| 69 // protocol::CursorShapeStub interface. | 69 // protocol::CursorShapeStub interface. |
| 70 virtual void SetCursorShape( | 70 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override{}; |
| 71 const protocol::CursorShapeInfo& cursor_shape) override {}; | |
| 72 }; | 71 }; |
| 73 | 72 |
| 74 class ProtocolPerfTest | 73 class ProtocolPerfTest |
| 75 : public testing::Test, | 74 : public testing::Test, |
| 76 public testing::WithParamInterface<NetworkPerformanceParams>, | 75 public testing::WithParamInterface<NetworkPerformanceParams>, |
| 77 public ClientUserInterface, | 76 public ClientUserInterface, |
| 78 public VideoRenderer, | 77 public VideoRenderer, |
| 79 public HostStatusObserver { | 78 public HostStatusObserver { |
| 80 public: | 79 public: |
| 81 ProtocolPerfTest() | 80 ProtocolPerfTest() |
| 82 : host_thread_("host"), | 81 : host_thread_("host"), |
| 83 capture_thread_("capture"), | 82 capture_thread_("capture"), |
| 84 encode_thread_("encode") { | 83 encode_thread_("encode") { |
| 85 VideoScheduler::EnableTimestampsForTests(); | 84 VideoScheduler::EnableTimestampsForTests(); |
| 86 host_thread_.StartWithOptions( | 85 host_thread_.StartWithOptions( |
| 87 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); | 86 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); |
| 88 capture_thread_.Start(); | 87 capture_thread_.Start(); |
| 89 encode_thread_.Start(); | 88 encode_thread_.Start(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 virtual ~ProtocolPerfTest() { | 91 virtual ~ProtocolPerfTest() { |
| 93 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, host_.release()); | 92 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, host_.release()); |
| 94 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, | 93 host_thread_.message_loop_proxy()->DeleteSoon(FROM_HERE, |
| 95 host_signaling_.release()); | 94 host_signaling_.release()); |
| 96 message_loop_.RunUntilIdle(); | 95 message_loop_.RunUntilIdle(); |
| 97 } | 96 } |
| 98 | 97 |
| 99 // ClientUserInterface interface. | 98 // ClientUserInterface interface. |
| 100 virtual void OnConnectionState(protocol::ConnectionToHost::State state, | 99 void OnConnectionState(protocol::ConnectionToHost::State state, |
| 101 protocol::ErrorCode error) override { | 100 protocol::ErrorCode error) override { |
| 102 if (state == protocol::ConnectionToHost::CONNECTED) { | 101 if (state == protocol::ConnectionToHost::CONNECTED) { |
| 103 client_connected_ = true; | 102 client_connected_ = true; |
| 104 if (host_connected_) | 103 if (host_connected_) |
| 105 connecting_loop_->Quit(); | 104 connecting_loop_->Quit(); |
| 106 } | 105 } |
| 107 } | 106 } |
| 108 virtual void OnConnectionReady(bool ready) override {} | 107 void OnConnectionReady(bool ready) override {} |
| 109 virtual void OnRouteChanged(const std::string& channel_name, | 108 void OnRouteChanged(const std::string& channel_name, |
| 110 const protocol::TransportRoute& route) override { | 109 const protocol::TransportRoute& route) override {} |
| 111 } | 110 void SetCapabilities(const std::string& capabilities) override {} |
| 112 virtual void SetCapabilities(const std::string& capabilities) override {} | 111 void SetPairingResponse( |
| 113 virtual void SetPairingResponse( | |
| 114 const protocol::PairingResponse& pairing_response) override {} | 112 const protocol::PairingResponse& pairing_response) override {} |
| 115 virtual void DeliverHostMessage( | 113 void DeliverHostMessage(const protocol::ExtensionMessage& message) override {} |
| 116 const protocol::ExtensionMessage& message) override {} | 114 protocol::ClipboardStub* GetClipboardStub() override { return NULL; } |
| 117 virtual protocol::ClipboardStub* GetClipboardStub() override { | 115 protocol::CursorShapeStub* GetCursorShapeStub() override { |
| 118 return NULL; | |
| 119 } | |
| 120 virtual protocol::CursorShapeStub* GetCursorShapeStub() override { | |
| 121 return &cursor_shape_stub_; | 116 return &cursor_shape_stub_; |
| 122 } | 117 } |
| 123 | 118 |
| 124 // VideoRenderer interface. | 119 // VideoRenderer interface. |
| 125 virtual void Initialize(const protocol::SessionConfig& config) override {} | 120 void Initialize(const protocol::SessionConfig& config) override {} |
| 126 virtual ChromotingStats* GetStats() override { return NULL; } | 121 ChromotingStats* GetStats() override { return NULL; } |
| 127 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, | 122 void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet, |
| 128 const base::Closure& done) override { | 123 const base::Closure& done) override { |
| 129 if (video_packet->data().empty()) { | 124 if (video_packet->data().empty()) { |
| 130 // Ignore keep-alive packets | 125 // Ignore keep-alive packets |
| 131 done.Run(); | 126 done.Run(); |
| 132 return; | 127 return; |
| 133 } | 128 } |
| 134 | 129 |
| 135 last_video_packet_ = video_packet.Pass(); | 130 last_video_packet_ = video_packet.Pass(); |
| 136 | 131 |
| 137 if (!on_frame_task_.is_null()) | 132 if (!on_frame_task_.is_null()) |
| 138 on_frame_task_.Run(); | 133 on_frame_task_.Run(); |
| 139 | 134 |
| 140 done.Run(); | 135 done.Run(); |
| 141 } | 136 } |
| 142 | 137 |
| 143 // HostStatusObserver interface. | 138 // HostStatusObserver interface. |
| 144 virtual void OnClientConnected(const std::string& jid) override { | 139 void OnClientConnected(const std::string& jid) override { |
| 145 message_loop_.PostTask( | 140 message_loop_.PostTask( |
| 146 FROM_HERE, | 141 FROM_HERE, |
| 147 base::Bind(&ProtocolPerfTest::OnHostConnectedMainThread, | 142 base::Bind(&ProtocolPerfTest::OnHostConnectedMainThread, |
| 148 base::Unretained(this))); | 143 base::Unretained(this))); |
| 149 } | 144 } |
| 150 | 145 |
| 151 protected: | 146 protected: |
| 152 void WaitConnected() { | 147 void WaitConnected() { |
| 153 client_connected_ = false; | 148 client_connected_ = false; |
| 154 host_connected_ = false; | 149 host_connected_ = false; |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 << "ms Encode: " << last_video_packet_->encode_time_ms() | 484 << "ms Encode: " << last_video_packet_->encode_time_ms() |
| 490 << "ms Capture: " << last_video_packet_->capture_time_ms() | 485 << "ms Capture: " << last_video_packet_->capture_time_ms() |
| 491 << "ms"; | 486 << "ms"; |
| 492 sum += latency; | 487 sum += latency; |
| 493 } | 488 } |
| 494 | 489 |
| 495 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); | 490 LOG(INFO) << "Average: " << (sum / kFrames).InMillisecondsF(); |
| 496 } | 491 } |
| 497 | 492 |
| 498 } // namespace remoting | 493 } // namespace remoting |
| OLD | NEW |