| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
| 13 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
| 14 #include "base/synchronization/waitable_event.h" | 15 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/task_runner_util.h" | 16 #include "base/task_runner_util.h" |
| 16 #include "base/thread_task_runner_handle.h" | 17 #include "base/thread_task_runner_handle.h" |
| 17 #include "jingle/glue/thread_wrapper.h" | 18 #include "jingle/glue/thread_wrapper.h" |
| 18 #include "net/base/test_data_directory.h" | 19 #include "net/base/test_data_directory.h" |
| 19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 class FakeCursorShapeStub : public protocol::CursorShapeStub { | 79 class FakeCursorShapeStub : public protocol::CursorShapeStub { |
| 79 public: | 80 public: |
| 80 FakeCursorShapeStub() {} | 81 FakeCursorShapeStub() {} |
| 81 ~FakeCursorShapeStub() override {} | 82 ~FakeCursorShapeStub() override {} |
| 82 | 83 |
| 83 // protocol::CursorShapeStub interface. | 84 // protocol::CursorShapeStub interface. |
| 84 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override{}; | 85 void SetCursorShape(const protocol::CursorShapeInfo& cursor_shape) override{}; |
| 85 }; | 86 }; |
| 86 | 87 |
| 87 scoped_ptr<webrtc::DesktopFrame> DoDecodeFrame( | 88 std::unique_ptr<webrtc::DesktopFrame> DoDecodeFrame( |
| 88 VideoDecoder* decoder, | 89 VideoDecoder* decoder, |
| 89 VideoPacket* packet, | 90 VideoPacket* packet, |
| 90 scoped_ptr<webrtc::DesktopFrame> frame) { | 91 std::unique_ptr<webrtc::DesktopFrame> frame) { |
| 91 if (!decoder->DecodePacket(*packet, frame.get())) | 92 if (!decoder->DecodePacket(*packet, frame.get())) |
| 92 frame.reset(); | 93 frame.reset(); |
| 93 return frame; | 94 return frame; |
| 94 } | 95 } |
| 95 | 96 |
| 96 } // namespace | 97 } // namespace |
| 97 | 98 |
| 98 class ProtocolPerfTest | 99 class ProtocolPerfTest |
| 99 : public testing::Test, | 100 : public testing::Test, |
| 100 public testing::WithParamInterface<NetworkPerformanceParams>, | 101 public testing::WithParamInterface<NetworkPerformanceParams>, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 protocol::CursorShapeStub* GetCursorShapeStub() override { | 147 protocol::CursorShapeStub* GetCursorShapeStub() override { |
| 147 return &cursor_shape_stub_; | 148 return &cursor_shape_stub_; |
| 148 } | 149 } |
| 149 | 150 |
| 150 // VideoRenderer interface. | 151 // VideoRenderer interface. |
| 151 void OnSessionConfig(const protocol::SessionConfig& config) override {} | 152 void OnSessionConfig(const protocol::SessionConfig& config) override {} |
| 152 protocol::VideoStub* GetVideoStub() override { return this; } | 153 protocol::VideoStub* GetVideoStub() override { return this; } |
| 153 protocol::FrameConsumer* GetFrameConsumer() override { return this; } | 154 protocol::FrameConsumer* GetFrameConsumer() override { return this; } |
| 154 | 155 |
| 155 // protocol::VideoStub interface. | 156 // protocol::VideoStub interface. |
| 156 void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, | 157 void ProcessVideoPacket(std::unique_ptr<VideoPacket> packet, |
| 157 const base::Closure& done) override { | 158 const base::Closure& done) override { |
| 158 if (packet->data().empty()) { | 159 if (packet->data().empty()) { |
| 159 // Ignore keep-alive packets | 160 // Ignore keep-alive packets |
| 160 done.Run(); | 161 done.Run(); |
| 161 return; | 162 return; |
| 162 } | 163 } |
| 163 | 164 |
| 164 if (packet->format().has_screen_width() && | 165 if (packet->format().has_screen_width() && |
| 165 packet->format().has_screen_height()) { | 166 packet->format().has_screen_height()) { |
| 166 frame_size_.set(packet->format().screen_width(), | 167 frame_size_.set(packet->format().screen_width(), |
| 167 packet->format().screen_height()); | 168 packet->format().screen_height()); |
| 168 } | 169 } |
| 169 | 170 |
| 170 scoped_ptr<webrtc::DesktopFrame> frame( | 171 std::unique_ptr<webrtc::DesktopFrame> frame( |
| 171 new webrtc::BasicDesktopFrame(frame_size_)); | 172 new webrtc::BasicDesktopFrame(frame_size_)); |
| 172 base::PostTaskAndReplyWithResult( | 173 base::PostTaskAndReplyWithResult( |
| 173 decode_thread_.task_runner().get(), FROM_HERE, | 174 decode_thread_.task_runner().get(), FROM_HERE, |
| 174 base::Bind(&DoDecodeFrame, video_decoder_.get(), packet.get(), | 175 base::Bind(&DoDecodeFrame, video_decoder_.get(), packet.get(), |
| 175 base::Passed(&frame)), | 176 base::Passed(&frame)), |
| 176 base::Bind(&ProtocolPerfTest::OnFrameDecoded, base::Unretained(this), | 177 base::Bind(&ProtocolPerfTest::OnFrameDecoded, base::Unretained(this), |
| 177 base::Passed(&packet), done)); | 178 base::Passed(&packet), done)); |
| 178 } | 179 } |
| 179 | 180 |
| 180 void OnFrameDecoded(scoped_ptr<VideoPacket> packet, | 181 void OnFrameDecoded(std::unique_ptr<VideoPacket> packet, |
| 181 const base::Closure& done, | 182 const base::Closure& done, |
| 182 scoped_ptr<webrtc::DesktopFrame> frame) { | 183 std::unique_ptr<webrtc::DesktopFrame> frame) { |
| 183 last_video_packet_ = std::move(packet); | 184 last_video_packet_ = std::move(packet); |
| 184 DrawFrame(std::move(frame), done); | 185 DrawFrame(std::move(frame), done); |
| 185 } | 186 } |
| 186 | 187 |
| 187 // protocol::FrameConsumer interface. | 188 // protocol::FrameConsumer interface. |
| 188 scoped_ptr<webrtc::DesktopFrame> AllocateFrame( | 189 std::unique_ptr<webrtc::DesktopFrame> AllocateFrame( |
| 189 const webrtc::DesktopSize& size) override { | 190 const webrtc::DesktopSize& size) override { |
| 190 return make_scoped_ptr(new webrtc::BasicDesktopFrame(size)); | 191 return base::WrapUnique(new webrtc::BasicDesktopFrame(size)); |
| 191 } | 192 } |
| 192 | 193 |
| 193 void DrawFrame(scoped_ptr<webrtc::DesktopFrame> frame, | 194 void DrawFrame(std::unique_ptr<webrtc::DesktopFrame> frame, |
| 194 const base::Closure& done) override { | 195 const base::Closure& done) override { |
| 195 last_video_frame_ = std::move(frame); | 196 last_video_frame_ = std::move(frame); |
| 196 if (!on_frame_task_.is_null()) | 197 if (!on_frame_task_.is_null()) |
| 197 on_frame_task_.Run(); | 198 on_frame_task_.Run(); |
| 198 if (!done.is_null()) | 199 if (!done.is_null()) |
| 199 done.Run(); | 200 done.Run(); |
| 200 } | 201 } |
| 201 | 202 |
| 202 protocol::FrameConsumer::PixelFormat GetPixelFormat() override { | 203 protocol::FrameConsumer::PixelFormat GetPixelFormat() override { |
| 203 return FORMAT_BGRA; | 204 return FORMAT_BGRA; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 221 | 222 |
| 222 ASSERT_TRUE(client_connected_ && host_connected_); | 223 ASSERT_TRUE(client_connected_ && host_connected_); |
| 223 } | 224 } |
| 224 | 225 |
| 225 void OnHostConnectedMainThread() { | 226 void OnHostConnectedMainThread() { |
| 226 host_connected_ = true; | 227 host_connected_ = true; |
| 227 if (client_connected_) | 228 if (client_connected_) |
| 228 connecting_loop_->Quit(); | 229 connecting_loop_->Quit(); |
| 229 } | 230 } |
| 230 | 231 |
| 231 scoped_ptr<webrtc::DesktopFrame> ReceiveFrame() { | 232 std::unique_ptr<webrtc::DesktopFrame> ReceiveFrame() { |
| 232 last_video_frame_.reset(); | 233 last_video_frame_.reset(); |
| 233 | 234 |
| 234 waiting_frames_loop_.reset(new base::RunLoop()); | 235 waiting_frames_loop_.reset(new base::RunLoop()); |
| 235 on_frame_task_ = waiting_frames_loop_->QuitClosure(); | 236 on_frame_task_ = waiting_frames_loop_->QuitClosure(); |
| 236 waiting_frames_loop_->Run(); | 237 waiting_frames_loop_->Run(); |
| 237 | 238 |
| 238 EXPECT_TRUE(last_video_frame_); | 239 EXPECT_TRUE(last_video_frame_); |
| 239 return std::move(last_video_frame_); | 240 return std::move(last_video_frame_); |
| 240 } | 241 } |
| 241 | 242 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 DCHECK(host_thread_.task_runner()->BelongsToCurrentThread()); | 309 DCHECK(host_thread_.task_runner()->BelongsToCurrentThread()); |
| 309 | 310 |
| 310 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); | 311 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); |
| 311 | 312 |
| 312 host_signaling_.reset(new FakeSignalStrategy(kHostJid)); | 313 host_signaling_.reset(new FakeSignalStrategy(kHostJid)); |
| 313 host_signaling_->ConnectTo(client_signaling_.get()); | 314 host_signaling_->ConnectTo(client_signaling_.get()); |
| 314 | 315 |
| 315 protocol::NetworkSettings network_settings( | 316 protocol::NetworkSettings network_settings( |
| 316 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING); | 317 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING); |
| 317 | 318 |
| 318 scoped_ptr<FakePortAllocatorFactory> port_allocator_factory( | 319 std::unique_ptr<FakePortAllocatorFactory> port_allocator_factory( |
| 319 new FakePortAllocatorFactory(fake_network_dispatcher_)); | 320 new FakePortAllocatorFactory(fake_network_dispatcher_)); |
| 320 port_allocator_factory->socket_factory()->SetBandwidth( | 321 port_allocator_factory->socket_factory()->SetBandwidth( |
| 321 GetParam().bandwidth, GetParam().max_buffers); | 322 GetParam().bandwidth, GetParam().max_buffers); |
| 322 port_allocator_factory->socket_factory()->SetLatency( | 323 port_allocator_factory->socket_factory()->SetLatency( |
| 323 GetParam().latency_average, GetParam().latency_stddev); | 324 GetParam().latency_average, GetParam().latency_stddev); |
| 324 port_allocator_factory->socket_factory()->set_out_of_order_rate( | 325 port_allocator_factory->socket_factory()->set_out_of_order_rate( |
| 325 GetParam().out_of_order_rate); | 326 GetParam().out_of_order_rate); |
| 326 scoped_refptr<protocol::TransportContext> transport_context( | 327 scoped_refptr<protocol::TransportContext> transport_context( |
| 327 new protocol::TransportContext( | 328 new protocol::TransportContext( |
| 328 host_signaling_.get(), std::move(port_allocator_factory), nullptr, | 329 host_signaling_.get(), std::move(port_allocator_factory), nullptr, |
| 329 network_settings, protocol::TransportRole::SERVER)); | 330 network_settings, protocol::TransportRole::SERVER)); |
| 330 scoped_ptr<protocol::SessionManager> session_manager( | 331 std::unique_ptr<protocol::SessionManager> session_manager( |
| 331 new protocol::JingleSessionManager(host_signaling_.get())); | 332 new protocol::JingleSessionManager(host_signaling_.get())); |
| 332 session_manager->set_protocol_config(protocol_config_->Clone()); | 333 session_manager->set_protocol_config(protocol_config_->Clone()); |
| 333 | 334 |
| 334 // Encoder runs on a separate thread, main thread is used for everything | 335 // Encoder runs on a separate thread, main thread is used for everything |
| 335 // else. | 336 // else. |
| 336 host_.reset(new ChromotingHost( | 337 host_.reset(new ChromotingHost( |
| 337 &desktop_environment_factory_, std::move(session_manager), | 338 &desktop_environment_factory_, std::move(session_manager), |
| 338 transport_context, host_thread_.task_runner(), | 339 transport_context, host_thread_.task_runner(), |
| 339 encode_thread_.task_runner())); | 340 encode_thread_.task_runner())); |
| 340 | 341 |
| 341 base::FilePath certs_dir(net::GetTestCertsDirectory()); | 342 base::FilePath certs_dir(net::GetTestCertsDirectory()); |
| 342 | 343 |
| 343 std::string host_cert; | 344 std::string host_cert; |
| 344 ASSERT_TRUE(base::ReadFileToString( | 345 ASSERT_TRUE(base::ReadFileToString( |
| 345 certs_dir.AppendASCII("unittest.selfsigned.der"), &host_cert)); | 346 certs_dir.AppendASCII("unittest.selfsigned.der"), &host_cert)); |
| 346 | 347 |
| 347 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 348 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
| 348 std::string key_string; | 349 std::string key_string; |
| 349 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); | 350 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); |
| 350 std::string key_base64; | 351 std::string key_base64; |
| 351 base::Base64Encode(key_string, &key_base64); | 352 base::Base64Encode(key_string, &key_base64); |
| 352 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); | 353 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); |
| 353 ASSERT_TRUE(key_pair.get()); | 354 ASSERT_TRUE(key_pair.get()); |
| 354 | 355 |
| 355 std::string host_pin_hash = | 356 std::string host_pin_hash = |
| 356 protocol::GetSharedSecretHash(kHostId, kHostPin); | 357 protocol::GetSharedSecretHash(kHostId, kHostPin); |
| 357 scoped_ptr<protocol::AuthenticatorFactory> auth_factory = | 358 std::unique_ptr<protocol::AuthenticatorFactory> auth_factory = |
| 358 protocol::Me2MeHostAuthenticatorFactory::CreateWithPin( | 359 protocol::Me2MeHostAuthenticatorFactory::CreateWithPin( |
| 359 true, kHostOwner, host_cert, key_pair, "", host_pin_hash, nullptr); | 360 true, kHostOwner, host_cert, key_pair, "", host_pin_hash, nullptr); |
| 360 host_->SetAuthenticatorFactory(std::move(auth_factory)); | 361 host_->SetAuthenticatorFactory(std::move(auth_factory)); |
| 361 | 362 |
| 362 host_->AddStatusObserver(this); | 363 host_->AddStatusObserver(this); |
| 363 host_->Start(kHostOwner); | 364 host_->Start(kHostOwner); |
| 364 | 365 |
| 365 message_loop_.PostTask(FROM_HERE, | 366 message_loop_.PostTask(FROM_HERE, |
| 366 base::Bind(&ProtocolPerfTest::StartClientAfterHost, | 367 base::Bind(&ProtocolPerfTest::StartClientAfterHost, |
| 367 base::Unretained(this))); | 368 base::Unretained(this))); |
| 368 } | 369 } |
| 369 | 370 |
| 370 void StartClientAfterHost() { | 371 void StartClientAfterHost() { |
| 371 client_signaling_->ConnectTo(host_signaling_.get()); | 372 client_signaling_->ConnectTo(host_signaling_.get()); |
| 372 | 373 |
| 373 protocol::NetworkSettings network_settings( | 374 protocol::NetworkSettings network_settings( |
| 374 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING); | 375 protocol::NetworkSettings::NAT_TRAVERSAL_OUTGOING); |
| 375 | 376 |
| 376 // Initialize client. | 377 // Initialize client. |
| 377 client_context_.reset( | 378 client_context_.reset( |
| 378 new ClientContext(base::ThreadTaskRunnerHandle::Get())); | 379 new ClientContext(base::ThreadTaskRunnerHandle::Get())); |
| 379 | 380 |
| 380 scoped_ptr<FakePortAllocatorFactory> port_allocator_factory( | 381 std::unique_ptr<FakePortAllocatorFactory> port_allocator_factory( |
| 381 new FakePortAllocatorFactory(fake_network_dispatcher_)); | 382 new FakePortAllocatorFactory(fake_network_dispatcher_)); |
| 382 port_allocator_factory->socket_factory()->SetBandwidth( | 383 port_allocator_factory->socket_factory()->SetBandwidth( |
| 383 GetParam().bandwidth, GetParam().max_buffers); | 384 GetParam().bandwidth, GetParam().max_buffers); |
| 384 port_allocator_factory->socket_factory()->SetLatency( | 385 port_allocator_factory->socket_factory()->SetLatency( |
| 385 GetParam().latency_average, GetParam().latency_stddev); | 386 GetParam().latency_average, GetParam().latency_stddev); |
| 386 port_allocator_factory->socket_factory()->set_out_of_order_rate( | 387 port_allocator_factory->socket_factory()->set_out_of_order_rate( |
| 387 GetParam().out_of_order_rate); | 388 GetParam().out_of_order_rate); |
| 388 scoped_refptr<protocol::TransportContext> transport_context( | 389 scoped_refptr<protocol::TransportContext> transport_context( |
| 389 new protocol::TransportContext( | 390 new protocol::TransportContext( |
| 390 host_signaling_.get(), std::move(port_allocator_factory), nullptr, | 391 host_signaling_.get(), std::move(port_allocator_factory), nullptr, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 419 StartHostAndClient(webrtc, protocol::ChannelConfig::CODEC_VP8); | 420 StartHostAndClient(webrtc, protocol::ChannelConfig::CODEC_VP8); |
| 420 ASSERT_NO_FATAL_FAILURE(WaitConnected()); | 421 ASSERT_NO_FATAL_FAILURE(WaitConnected()); |
| 421 | 422 |
| 422 base::TimeDelta total_latency_big_frames; | 423 base::TimeDelta total_latency_big_frames; |
| 423 int big_frame_count = 0; | 424 int big_frame_count = 0; |
| 424 base::TimeDelta total_latency_small_frames; | 425 base::TimeDelta total_latency_small_frames; |
| 425 int small_frame_count = 0; | 426 int small_frame_count = 0; |
| 426 | 427 |
| 427 int last_frame_id = -1; | 428 int last_frame_id = -1; |
| 428 for (int i = 0; i < 30; ++i) { | 429 for (int i = 0; i < 30; ++i) { |
| 429 scoped_ptr<webrtc::DesktopFrame> frame = ReceiveFrame(); | 430 std::unique_ptr<webrtc::DesktopFrame> frame = ReceiveFrame(); |
| 430 test::CyclicFrameGenerator::FrameInfo frame_info = | 431 test::CyclicFrameGenerator::FrameInfo frame_info = |
| 431 frame_generator->IdentifyFrame(frame.get()); | 432 frame_generator->IdentifyFrame(frame.get()); |
| 432 base::TimeDelta latency = base::TimeTicks::Now() - frame_info.timestamp; | 433 base::TimeDelta latency = base::TimeTicks::Now() - frame_info.timestamp; |
| 433 | 434 |
| 434 if (frame_info.frame_id > last_frame_id) { | 435 if (frame_info.frame_id > last_frame_id) { |
| 435 last_frame_id = frame_info.frame_id; | 436 last_frame_id = frame_info.frame_id; |
| 436 | 437 |
| 437 switch (frame_info.type) { | 438 switch (frame_info.type) { |
| 438 case test::CyclicFrameGenerator::FrameType::EMPTY: | 439 case test::CyclicFrameGenerator::FrameType::EMPTY: |
| 439 NOTREACHED(); | 440 NOTREACHED(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 468 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher_; | 469 scoped_refptr<FakeNetworkDispatcher> fake_network_dispatcher_; |
| 469 | 470 |
| 470 base::Thread host_thread_; | 471 base::Thread host_thread_; |
| 471 base::Thread capture_thread_; | 472 base::Thread capture_thread_; |
| 472 base::Thread encode_thread_; | 473 base::Thread encode_thread_; |
| 473 base::Thread decode_thread_; | 474 base::Thread decode_thread_; |
| 474 FakeDesktopEnvironmentFactory desktop_environment_factory_; | 475 FakeDesktopEnvironmentFactory desktop_environment_factory_; |
| 475 | 476 |
| 476 FakeCursorShapeStub cursor_shape_stub_; | 477 FakeCursorShapeStub cursor_shape_stub_; |
| 477 | 478 |
| 478 scoped_ptr<protocol::CandidateSessionConfig> protocol_config_; | 479 std::unique_ptr<protocol::CandidateSessionConfig> protocol_config_; |
| 479 | 480 |
| 480 scoped_ptr<FakeSignalStrategy> host_signaling_; | 481 std::unique_ptr<FakeSignalStrategy> host_signaling_; |
| 481 scoped_ptr<FakeSignalStrategy> client_signaling_; | 482 std::unique_ptr<FakeSignalStrategy> client_signaling_; |
| 482 | 483 |
| 483 scoped_ptr<ChromotingHost> host_; | 484 std::unique_ptr<ChromotingHost> host_; |
| 484 scoped_ptr<ClientContext> client_context_; | 485 std::unique_ptr<ClientContext> client_context_; |
| 485 scoped_ptr<ChromotingClient> client_; | 486 std::unique_ptr<ChromotingClient> client_; |
| 486 webrtc::DesktopSize frame_size_; | 487 webrtc::DesktopSize frame_size_; |
| 487 scoped_ptr<VideoDecoder> video_decoder_; | 488 std::unique_ptr<VideoDecoder> video_decoder_; |
| 488 | 489 |
| 489 scoped_ptr<base::RunLoop> connecting_loop_; | 490 std::unique_ptr<base::RunLoop> connecting_loop_; |
| 490 scoped_ptr<base::RunLoop> waiting_frames_loop_; | 491 std::unique_ptr<base::RunLoop> waiting_frames_loop_; |
| 491 | 492 |
| 492 bool client_connected_; | 493 bool client_connected_; |
| 493 bool host_connected_; | 494 bool host_connected_; |
| 494 | 495 |
| 495 base::Closure on_frame_task_; | 496 base::Closure on_frame_task_; |
| 496 | 497 |
| 497 scoped_ptr<VideoPacket> last_video_packet_; | 498 std::unique_ptr<VideoPacket> last_video_packet_; |
| 498 scoped_ptr<webrtc::DesktopFrame> last_video_frame_; | 499 std::unique_ptr<webrtc::DesktopFrame> last_video_frame_; |
| 499 | 500 |
| 500 private: | 501 private: |
| 501 DISALLOW_COPY_AND_ASSIGN(ProtocolPerfTest); | 502 DISALLOW_COPY_AND_ASSIGN(ProtocolPerfTest); |
| 502 }; | 503 }; |
| 503 | 504 |
| 504 INSTANTIATE_TEST_CASE_P( | 505 INSTANTIATE_TEST_CASE_P( |
| 505 NoDelay, | 506 NoDelay, |
| 506 ProtocolPerfTest, | 507 ProtocolPerfTest, |
| 507 ::testing::Values(NetworkPerformanceParams(0, 0, 0, 0, 0.0))); | 508 ::testing::Values(NetworkPerformanceParams(0, 0, 0, 0, 0.0))); |
| 508 | 509 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 | 556 |
| 556 // Frame generator that rewrites the whole screen every 60th frame. Should only | 557 // Frame generator that rewrites the whole screen every 60th frame. Should only |
| 557 // be used with the VERBATIM codec as the allocated frame may contain arbitrary | 558 // be used with the VERBATIM codec as the allocated frame may contain arbitrary |
| 558 // data. | 559 // data. |
| 559 class IntermittentChangeFrameGenerator | 560 class IntermittentChangeFrameGenerator |
| 560 : public base::RefCountedThreadSafe<IntermittentChangeFrameGenerator> { | 561 : public base::RefCountedThreadSafe<IntermittentChangeFrameGenerator> { |
| 561 public: | 562 public: |
| 562 IntermittentChangeFrameGenerator() | 563 IntermittentChangeFrameGenerator() |
| 563 : frame_index_(0) {} | 564 : frame_index_(0) {} |
| 564 | 565 |
| 565 scoped_ptr<webrtc::DesktopFrame> GenerateFrame( | 566 std::unique_ptr<webrtc::DesktopFrame> GenerateFrame( |
| 566 webrtc::SharedMemoryFactory* shared_memory_factory) { | 567 webrtc::SharedMemoryFactory* shared_memory_factory) { |
| 567 const int kWidth = 1000; | 568 const int kWidth = 1000; |
| 568 const int kHeight = kIntermittentFrameSize / kWidth / 4; | 569 const int kHeight = kIntermittentFrameSize / kWidth / 4; |
| 569 | 570 |
| 570 bool fresh_frame = false; | 571 bool fresh_frame = false; |
| 571 if (frame_index_ % 60 == 0 || !current_frame_) { | 572 if (frame_index_ % 60 == 0 || !current_frame_) { |
| 572 current_frame_.reset(webrtc::SharedDesktopFrame::Wrap( | 573 current_frame_.reset(webrtc::SharedDesktopFrame::Wrap( |
| 573 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kWidth, kHeight)))); | 574 new webrtc::BasicDesktopFrame(webrtc::DesktopSize(kWidth, kHeight)))); |
| 574 fresh_frame = true; | 575 fresh_frame = true; |
| 575 } | 576 } |
| 576 ++frame_index_; | 577 ++frame_index_; |
| 577 | 578 |
| 578 scoped_ptr<webrtc::DesktopFrame> result(current_frame_->Share()); | 579 std::unique_ptr<webrtc::DesktopFrame> result(current_frame_->Share()); |
| 579 result->mutable_updated_region()->Clear(); | 580 result->mutable_updated_region()->Clear(); |
| 580 if (fresh_frame) { | 581 if (fresh_frame) { |
| 581 result->mutable_updated_region()->AddRect( | 582 result->mutable_updated_region()->AddRect( |
| 582 webrtc::DesktopRect::MakeXYWH(0, 0, kWidth, kHeight)); | 583 webrtc::DesktopRect::MakeXYWH(0, 0, kWidth, kHeight)); |
| 583 } | 584 } |
| 584 return result; | 585 return result; |
| 585 } | 586 } |
| 586 | 587 |
| 587 private: | 588 private: |
| 588 ~IntermittentChangeFrameGenerator() {} | 589 ~IntermittentChangeFrameGenerator() {} |
| 589 friend class base::RefCountedThreadSafe<IntermittentChangeFrameGenerator>; | 590 friend class base::RefCountedThreadSafe<IntermittentChangeFrameGenerator>; |
| 590 | 591 |
| 591 int frame_index_; | 592 int frame_index_; |
| 592 scoped_ptr<webrtc::SharedDesktopFrame> current_frame_; | 593 std::unique_ptr<webrtc::SharedDesktopFrame> current_frame_; |
| 593 | 594 |
| 594 DISALLOW_COPY_AND_ASSIGN(IntermittentChangeFrameGenerator); | 595 DISALLOW_COPY_AND_ASSIGN(IntermittentChangeFrameGenerator); |
| 595 }; | 596 }; |
| 596 | 597 |
| 597 TEST_P(ProtocolPerfTest, IntermittentChanges) { | 598 TEST_P(ProtocolPerfTest, IntermittentChanges) { |
| 598 desktop_environment_factory_.set_frame_generator( | 599 desktop_environment_factory_.set_frame_generator( |
| 599 base::Bind(&IntermittentChangeFrameGenerator::GenerateFrame, | 600 base::Bind(&IntermittentChangeFrameGenerator::GenerateFrame, |
| 600 new IntermittentChangeFrameGenerator())); | 601 new IntermittentChangeFrameGenerator())); |
| 601 | 602 |
| 602 StartHostAndClient(false, protocol::ChannelConfig::CODEC_VERBATIM); | 603 StartHostAndClient(false, protocol::ChannelConfig::CODEC_VERBATIM); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 629 | 630 |
| 630 TEST_P(ProtocolPerfTest, TotalLatencyIce) { | 631 TEST_P(ProtocolPerfTest, TotalLatencyIce) { |
| 631 MeasureTotalLatency(false); | 632 MeasureTotalLatency(false); |
| 632 } | 633 } |
| 633 | 634 |
| 634 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { | 635 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { |
| 635 MeasureTotalLatency(true); | 636 MeasureTotalLatency(true); |
| 636 } | 637 } |
| 637 | 638 |
| 638 } // namespace remoting | 639 } // namespace remoting |
| OLD | NEW |