| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 compressed.assign(reinterpret_cast<const char*>(&v[0]), v.size()); | 84 compressed.assign(reinterpret_cast<const char*>(&v[0]), v.size()); |
| 85 return compressed; | 85 return compressed; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Dummy callback function that does nothing except to accept ownership of | 88 // Dummy callback function that does nothing except to accept ownership of |
| 89 // |audio_bus| for destruction. | 89 // |audio_bus| for destruction. |
| 90 void OwnThatAudioBus(scoped_ptr<AudioBus> audio_bus) {} | 90 void OwnThatAudioBus(scoped_ptr<AudioBus> audio_bus) {} |
| 91 | 91 |
| 92 void UpdateCastTransportStatus(transport::CastTransportStatus status) { | 92 void UpdateCastTransportStatus(transport::CastTransportStatus status) { |
| 93 EXPECT_EQ(status, transport::TRANSPORT_INITIALIZED); | 93 bool result = (status == transport::TRANSPORT_AUDIO_INITIALIZED || |
| 94 status == transport::TRANSPORT_VIDEO_INITIALIZED); |
| 95 EXPECT_TRUE(result); |
| 94 } | 96 } |
| 95 | 97 |
| 96 // This is wrapped in a struct because it needs to be put into a std::map. | 98 // This is wrapped in a struct because it needs to be put into a std::map. |
| 97 typedef struct { | 99 typedef struct { |
| 98 int counter[kNumOfLoggingEvents]; | 100 int counter[kNumOfLoggingEvents]; |
| 99 } LoggingEventCounts; | 101 } LoggingEventCounts; |
| 100 | 102 |
| 101 // Constructs a map from each frame (RTP timestamp) to counts of each event | 103 // Constructs a map from each frame (RTP timestamp) to counts of each event |
| 102 // type logged for that frame. | 104 // type logged for that frame. |
| 103 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( | 105 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 video_sender_config_.number_of_cores = 1; | 473 video_sender_config_.number_of_cores = 1; |
| 472 | 474 |
| 473 video_receiver_config_.feedback_ssrc = | 475 video_receiver_config_.feedback_ssrc = |
| 474 video_sender_config_.incoming_feedback_ssrc; | 476 video_sender_config_.incoming_feedback_ssrc; |
| 475 video_receiver_config_.incoming_ssrc = video_sender_config_.sender_ssrc; | 477 video_receiver_config_.incoming_ssrc = video_sender_config_.sender_ssrc; |
| 476 video_receiver_config_.rtp_payload_type = | 478 video_receiver_config_.rtp_payload_type = |
| 477 video_sender_config_.rtp_config.payload_type; | 479 video_sender_config_.rtp_config.payload_type; |
| 478 video_receiver_config_.use_external_decoder = false; | 480 video_receiver_config_.use_external_decoder = false; |
| 479 video_receiver_config_.codec = video_sender_config_.codec; | 481 video_receiver_config_.codec = video_sender_config_.codec; |
| 480 | 482 |
| 481 transport_config_.audio_ssrc = audio_sender_config_.sender_ssrc; | 483 transport_audio_config_.base.ssrc = audio_sender_config_.sender_ssrc; |
| 482 transport_config_.video_ssrc = video_sender_config_.sender_ssrc; | 484 transport_audio_config_.codec = audio_sender_config_.codec; |
| 483 transport_config_.video_codec = video_sender_config_.codec; | 485 transport_audio_config_.base.rtp_config = audio_sender_config_.rtp_config; |
| 484 transport_config_.audio_codec = audio_sender_config_.codec; | 486 transport_audio_config_.frequency = audio_sender_config_.frequency; |
| 485 transport_config_.video_rtp_config = video_sender_config_.rtp_config; | 487 transport_audio_config_.channels = audio_sender_config_.channels; |
| 486 transport_config_.audio_rtp_config = audio_sender_config_.rtp_config; | 488 transport_video_config_.base.ssrc = video_sender_config_.sender_ssrc; |
| 487 transport_config_.audio_frequency = audio_sender_config_.frequency; | 489 transport_video_config_.codec = video_sender_config_.codec; |
| 488 transport_config_.audio_channels = audio_sender_config_.channels; | 490 transport_video_config_.base.rtp_config = video_sender_config_.rtp_config; |
| 489 } | 491 } |
| 490 | 492 |
| 491 void Create() { | 493 void Create() { |
| 492 cast_receiver_.reset( | 494 cast_receiver_.reset( |
| 493 CastReceiver::CreateCastReceiver(cast_environment_receiver_, | 495 CastReceiver::CreateCastReceiver(cast_environment_receiver_, |
| 494 audio_receiver_config_, | 496 audio_receiver_config_, |
| 495 video_receiver_config_, | 497 video_receiver_config_, |
| 496 &receiver_to_sender_)); | 498 &receiver_to_sender_)); |
| 499 net::IPEndPoint dummy_endpoint; |
| 497 transport_sender_.reset(new transport::CastTransportSenderImpl( | 500 transport_sender_.reset(new transport::CastTransportSenderImpl( |
| 498 NULL, | 501 NULL, |
| 499 testing_clock_sender_, | 502 testing_clock_sender_, |
| 500 transport_config_, | 503 dummy_endpoint, |
| 504 dummy_endpoint, |
| 501 base::Bind(&UpdateCastTransportStatus), | 505 base::Bind(&UpdateCastTransportStatus), |
| 502 task_runner_, | 506 task_runner_, |
| 503 &sender_to_receiver_)); | 507 &sender_to_receiver_)); |
| 508 transport_sender_->InitializeAudio(transport_audio_config_); |
| 509 transport_sender_->InitializeVideo(transport_video_config_); |
| 504 | 510 |
| 505 cast_sender_.reset(CastSender::CreateCastSender( | 511 cast_sender_.reset(CastSender::CreateCastSender( |
| 506 cast_environment_sender_, | 512 cast_environment_sender_, |
| 507 &audio_sender_config_, | 513 &audio_sender_config_, |
| 508 &video_sender_config_, | 514 &video_sender_config_, |
| 509 NULL, | 515 NULL, |
| 510 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), | 516 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), |
| 511 transport_sender_.get())); | 517 transport_sender_.get())); |
| 512 | 518 |
| 513 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); | 519 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 } | 564 } |
| 559 | 565 |
| 560 void InitializationResult(CastInitializationStatus result) { | 566 void InitializationResult(CastInitializationStatus result) { |
| 561 EXPECT_EQ(result, STATUS_INITIALIZED); | 567 EXPECT_EQ(result, STATUS_INITIALIZED); |
| 562 } | 568 } |
| 563 | 569 |
| 564 AudioReceiverConfig audio_receiver_config_; | 570 AudioReceiverConfig audio_receiver_config_; |
| 565 VideoReceiverConfig video_receiver_config_; | 571 VideoReceiverConfig video_receiver_config_; |
| 566 AudioSenderConfig audio_sender_config_; | 572 AudioSenderConfig audio_sender_config_; |
| 567 VideoSenderConfig video_sender_config_; | 573 VideoSenderConfig video_sender_config_; |
| 568 transport::CastTransportConfig transport_config_; | 574 transport::CastTransportAudioConfig transport_audio_config_; |
| 575 transport::CastTransportVideoConfig transport_video_config_; |
| 569 | 576 |
| 570 base::TimeTicks start_time_; | 577 base::TimeTicks start_time_; |
| 571 base::SimpleTestTickClock* testing_clock_sender_; | 578 base::SimpleTestTickClock* testing_clock_sender_; |
| 572 base::SimpleTestTickClock* testing_clock_receiver_; | 579 base::SimpleTestTickClock* testing_clock_receiver_; |
| 573 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 580 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
| 574 scoped_refptr<CastEnvironment> cast_environment_sender_; | 581 scoped_refptr<CastEnvironment> cast_environment_sender_; |
| 575 scoped_refptr<CastEnvironment> cast_environment_receiver_; | 582 scoped_refptr<CastEnvironment> cast_environment_receiver_; |
| 576 | 583 |
| 577 LoopBackTransport receiver_to_sender_; | 584 LoopBackTransport receiver_to_sender_; |
| 578 LoopBackTransport sender_to_receiver_; | 585 LoopBackTransport sender_to_receiver_; |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 RunTasks(kFrameTimerMs); | 974 RunTasks(kFrameTimerMs); |
| 968 } | 975 } |
| 969 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 976 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 970 EXPECT_EQ(frames_counter, | 977 EXPECT_EQ(frames_counter, |
| 971 test_receiver_video_callback_->number_times_called()); | 978 test_receiver_video_callback_->number_times_called()); |
| 972 } | 979 } |
| 973 | 980 |
| 974 TEST_F(End2EndTest, CryptoVideo) { | 981 TEST_F(End2EndTest, CryptoVideo) { |
| 975 SetupConfig(transport::kPcm16, 32000, false, 1); | 982 SetupConfig(transport::kPcm16, 32000, false, 1); |
| 976 | 983 |
| 977 transport_config_.aes_iv_mask = | 984 transport_video_config_.base.aes_iv_mask = |
| 978 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); | 985 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); |
| 979 transport_config_.aes_key = | 986 transport_video_config_.base.aes_key = |
| 980 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); | 987 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); |
| 981 | 988 |
| 982 video_receiver_config_.aes_iv_mask = transport_config_.aes_iv_mask; | 989 video_receiver_config_.aes_iv_mask = transport_video_config_.base.aes_iv_mask; |
| 983 video_receiver_config_.aes_key = transport_config_.aes_key; | 990 video_receiver_config_.aes_key = transport_video_config_.base.aes_key; |
| 984 | 991 |
| 985 Create(); | 992 Create(); |
| 986 | 993 |
| 987 int frames_counter = 0; | 994 int frames_counter = 0; |
| 988 for (; frames_counter < 3; ++frames_counter) { | 995 for (; frames_counter < 3; ++frames_counter) { |
| 989 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 996 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); |
| 990 | 997 |
| 991 SendVideoFrame(frames_counter, send_time); | 998 SendVideoFrame(frames_counter, send_time); |
| 992 | 999 |
| 993 test_receiver_video_callback_->AddExpectedResult( | 1000 test_receiver_video_callback_->AddExpectedResult( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1004 RunTasks(kFrameTimerMs); | 1011 RunTasks(kFrameTimerMs); |
| 1005 } | 1012 } |
| 1006 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1013 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1007 EXPECT_EQ(frames_counter, | 1014 EXPECT_EQ(frames_counter, |
| 1008 test_receiver_video_callback_->number_times_called()); | 1015 test_receiver_video_callback_->number_times_called()); |
| 1009 } | 1016 } |
| 1010 | 1017 |
| 1011 TEST_F(End2EndTest, CryptoAudio) { | 1018 TEST_F(End2EndTest, CryptoAudio) { |
| 1012 SetupConfig(transport::kPcm16, 32000, false, 1); | 1019 SetupConfig(transport::kPcm16, 32000, false, 1); |
| 1013 | 1020 |
| 1014 transport_config_.aes_iv_mask = | 1021 transport_audio_config_.base.aes_iv_mask = |
| 1015 ConvertFromBase16String("abcdeffedcba12345678900987654321"); | 1022 ConvertFromBase16String("abcdeffedcba12345678900987654321"); |
| 1016 transport_config_.aes_key = | 1023 transport_audio_config_.base.aes_key = |
| 1017 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); | 1024 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); |
| 1018 | 1025 |
| 1019 audio_receiver_config_.aes_iv_mask = transport_config_.aes_iv_mask; | 1026 audio_receiver_config_.aes_iv_mask = transport_audio_config_.base.aes_iv_mask; |
| 1020 audio_receiver_config_.aes_key = transport_config_.aes_key; | 1027 audio_receiver_config_.aes_key = transport_audio_config_.base.aes_key; |
| 1021 | 1028 |
| 1022 Create(); | 1029 Create(); |
| 1023 | 1030 |
| 1024 int frames_counter = 0; | 1031 int frames_counter = 0; |
| 1025 for (; frames_counter < 3; ++frames_counter) { | 1032 for (; frames_counter < 3; ++frames_counter) { |
| 1026 int num_10ms_blocks = 2; | 1033 int num_10ms_blocks = 2; |
| 1027 | 1034 |
| 1028 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 1035 const base::TimeTicks send_time = testing_clock_sender_->NowTicks(); |
| 1029 | 1036 |
| 1030 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 1037 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1321 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
| 1315 } | 1322 } |
| 1316 | 1323 |
| 1317 // TODO(pwestin): Add repeatable packet loss test. | 1324 // TODO(pwestin): Add repeatable packet loss test. |
| 1318 // TODO(pwestin): Add test for misaligned send get calls. | 1325 // TODO(pwestin): Add test for misaligned send get calls. |
| 1319 // TODO(pwestin): Add more tests that does not resample. | 1326 // TODO(pwestin): Add more tests that does not resample. |
| 1320 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1327 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1321 | 1328 |
| 1322 } // namespace cast | 1329 } // namespace cast |
| 1323 } // namespace media | 1330 } // namespace media |
| OLD | NEW |