| 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 // This test generate synthetic data. For audio it's a sinusoid waveform with | 5 // This test generate synthetic data. For audio it's a sinusoid waveform with |
| 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern | 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern |
| 7 // that is shifting by one pixel per frame, each pixels neighbors right and down | 7 // that is shifting by one pixel per frame, each pixels neighbors right and down |
| 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap | 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap |
| 9 // frequently within the image. Visually this will create diagonally color bands | 9 // frequently within the image. Visually this will create diagonally color bands |
| 10 // that moves across the screen | 10 // that moves across the screen |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 void Create() { | 477 void Create() { |
| 478 cast_receiver_.reset( | 478 cast_receiver_.reset( |
| 479 CastReceiver::CreateCastReceiver(cast_environment_, | 479 CastReceiver::CreateCastReceiver(cast_environment_, |
| 480 audio_receiver_config_, | 480 audio_receiver_config_, |
| 481 video_receiver_config_, | 481 video_receiver_config_, |
| 482 &receiver_to_sender_)); | 482 &receiver_to_sender_)); |
| 483 transport_sender_.reset(new transport::CastTransportSenderImpl( | 483 transport_sender_.reset(new transport::CastTransportSenderImpl( |
| 484 testing_clock_, | 484 testing_clock_, |
| 485 transport_config_, | 485 transport_config_, |
| 486 base::Bind(&UpdateCastTransportStatus), | 486 base::Bind(&UpdateCastTransportStatus), |
| 487 base::Bind(&End2EndTest::LogRawEvents, base::Unretained(this)), |
| 487 task_runner_, | 488 task_runner_, |
| 488 &sender_to_receiver_)); | 489 &sender_to_receiver_)); |
| 489 | 490 |
| 490 cast_sender_.reset(CastSender::CreateCastSender( | 491 cast_sender_.reset(CastSender::CreateCastSender( |
| 491 cast_environment_, | 492 cast_environment_, |
| 492 &audio_sender_config_, | 493 &audio_sender_config_, |
| 493 &video_sender_config_, | 494 &video_sender_config_, |
| 494 NULL, | 495 NULL, |
| 495 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), | 496 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), |
| 496 transport_sender_.get())); | 497 transport_sender_.get())); |
| 497 | 498 |
| 498 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); | 499 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); |
| 499 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver()); | 500 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver()); |
| 500 | 501 |
| 501 frame_input_ = cast_sender_->frame_input(); | 502 frame_input_ = cast_sender_->frame_input(); |
| 502 frame_receiver_ = cast_receiver_->frame_receiver(); | 503 frame_receiver_ = cast_receiver_->frame_receiver(); |
| 503 | 504 |
| 504 audio_bus_factory_.reset( | 505 audio_bus_factory_.reset( |
| 505 new TestAudioBusFactory(audio_sender_config_.channels, | 506 new TestAudioBusFactory(audio_sender_config_.channels, |
| 506 audio_sender_config_.frequency, | 507 audio_sender_config_.frequency, |
| 507 kSoundFrequency, | 508 kSoundFrequency, |
| 508 kSoundVolume)); | 509 kSoundVolume)); |
| 509 } | 510 } |
| 510 | 511 |
| 511 virtual ~End2EndTest() { | 512 virtual ~End2EndTest() { |
| 512 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); | 513 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); |
| 513 } | 514 } |
| 514 | 515 |
| 515 virtual void TearDown() OVERRIDE { | 516 virtual void TearDown() OVERRIDE { |
| 516 | |
| 517 cast_sender_.reset(); | 517 cast_sender_.reset(); |
| 518 cast_receiver_.reset(); | 518 cast_receiver_.reset(); |
| 519 task_runner_->RunTasks(); | 519 task_runner_->RunTasks(); |
| 520 } | 520 } |
| 521 | 521 |
| 522 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { | 522 void SendVideoFrame(int start_value, const base::TimeTicks& capture_time) { |
| 523 if (start_time_.is_null()) | 523 if (start_time_.is_null()) |
| 524 start_time_ = capture_time; | 524 start_time_ = capture_time; |
| 525 base::TimeDelta time_diff = capture_time - start_time_; | 525 base::TimeDelta time_diff = capture_time - start_time_; |
| 526 gfx::Size size(video_sender_config_.width, video_sender_config_.height); | 526 gfx::Size size(video_sender_config_.width, video_sender_config_.height); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 538 // Call process the timers every 1 ms. | 538 // Call process the timers every 1 ms. |
| 539 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1)); | 539 testing_clock_->Advance(base::TimeDelta::FromMilliseconds(1)); |
| 540 task_runner_->RunTasks(); | 540 task_runner_->RunTasks(); |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 | 543 |
| 544 void InitializationResult(CastInitializationStatus result) { | 544 void InitializationResult(CastInitializationStatus result) { |
| 545 EXPECT_EQ(result, STATUS_INITIALIZED); | 545 EXPECT_EQ(result, STATUS_INITIALIZED); |
| 546 } | 546 } |
| 547 | 547 |
| 548 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { |
| 549 EXPECT_FALSE(packet_events.empty()); |
| 550 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 551 packet_events.begin(); |
| 552 it != packet_events.end(); |
| 553 ++it) { |
| 554 cast_environment_->Logging()->InsertPacketEvent(it->timestamp, |
| 555 it->type, |
| 556 it->rtp_timestamp, |
| 557 it->frame_id, |
| 558 it->packet_id, |
| 559 it->max_packet_id, |
| 560 it->size); |
| 561 } |
| 562 } |
| 563 |
| 548 AudioReceiverConfig audio_receiver_config_; | 564 AudioReceiverConfig audio_receiver_config_; |
| 549 VideoReceiverConfig video_receiver_config_; | 565 VideoReceiverConfig video_receiver_config_; |
| 550 AudioSenderConfig audio_sender_config_; | 566 AudioSenderConfig audio_sender_config_; |
| 551 VideoSenderConfig video_sender_config_; | 567 VideoSenderConfig video_sender_config_; |
| 552 transport::CastTransportConfig transport_config_; | 568 transport::CastTransportConfig transport_config_; |
| 553 | 569 |
| 554 base::TimeTicks start_time_; | 570 base::TimeTicks start_time_; |
| 555 base::SimpleTestTickClock* testing_clock_; | 571 base::SimpleTestTickClock* testing_clock_; |
| 556 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 572 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 557 scoped_refptr<CastEnvironment> cast_environment_; | 573 scoped_refptr<CastEnvironment> cast_environment_; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1300 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
| 1285 } | 1301 } |
| 1286 | 1302 |
| 1287 // TODO(pwestin): Add repeatable packet loss test. | 1303 // TODO(pwestin): Add repeatable packet loss test. |
| 1288 // TODO(pwestin): Add test for misaligned send get calls. | 1304 // TODO(pwestin): Add test for misaligned send get calls. |
| 1289 // TODO(pwestin): Add more tests that does not resample. | 1305 // TODO(pwestin): Add more tests that does not resample. |
| 1290 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1306 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1291 | 1307 |
| 1292 } // namespace cast | 1308 } // namespace cast |
| 1293 } // namespace media | 1309 } // namespace media |
| OLD | NEW |