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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 video_sender_config_.number_of_cores = 1; | 459 video_sender_config_.number_of_cores = 1; |
458 | 460 |
459 video_receiver_config_.feedback_ssrc = | 461 video_receiver_config_.feedback_ssrc = |
460 video_sender_config_.incoming_feedback_ssrc; | 462 video_sender_config_.incoming_feedback_ssrc; |
461 video_receiver_config_.incoming_ssrc = video_sender_config_.sender_ssrc; | 463 video_receiver_config_.incoming_ssrc = video_sender_config_.sender_ssrc; |
462 video_receiver_config_.rtp_payload_type = | 464 video_receiver_config_.rtp_payload_type = |
463 video_sender_config_.rtp_config.payload_type; | 465 video_sender_config_.rtp_config.payload_type; |
464 video_receiver_config_.use_external_decoder = false; | 466 video_receiver_config_.use_external_decoder = false; |
465 video_receiver_config_.codec = video_sender_config_.codec; | 467 video_receiver_config_.codec = video_sender_config_.codec; |
466 | 468 |
467 transport_config_.audio_ssrc = audio_sender_config_.sender_ssrc; | 469 transport_audio_config_.base.ssrc = audio_sender_config_.sender_ssrc; |
468 transport_config_.video_ssrc = video_sender_config_.sender_ssrc; | 470 transport_audio_config_.codec = audio_sender_config_.codec; |
469 transport_config_.video_codec = video_sender_config_.codec; | 471 transport_audio_config_.base.rtp_config = audio_sender_config_.rtp_config; |
470 transport_config_.audio_codec = audio_sender_config_.codec; | 472 transport_audio_config_.frequency = audio_sender_config_.frequency; |
471 transport_config_.video_rtp_config = video_sender_config_.rtp_config; | 473 transport_audio_config_.channels = audio_sender_config_.channels; |
472 transport_config_.audio_rtp_config = audio_sender_config_.rtp_config; | 474 transport_video_config_.base.ssrc = video_sender_config_.sender_ssrc; |
473 transport_config_.audio_frequency = audio_sender_config_.frequency; | 475 transport_video_config_.codec = video_sender_config_.codec; |
474 transport_config_.audio_channels = audio_sender_config_.channels; | 476 transport_video_config_.base.rtp_config = video_sender_config_.rtp_config; |
475 } | 477 } |
476 | 478 |
477 void Create() { | 479 void Create() { |
478 cast_receiver_.reset( | 480 cast_receiver_.reset( |
479 CastReceiver::CreateCastReceiver(cast_environment_, | 481 CastReceiver::CreateCastReceiver(cast_environment_, |
480 audio_receiver_config_, | 482 audio_receiver_config_, |
481 video_receiver_config_, | 483 video_receiver_config_, |
482 &receiver_to_sender_)); | 484 &receiver_to_sender_)); |
| 485 net::IPEndPoint dummy_endpoint; |
483 transport_sender_.reset(new transport::CastTransportSenderImpl( | 486 transport_sender_.reset(new transport::CastTransportSenderImpl( |
484 testing_clock_, | 487 testing_clock_, |
485 transport_config_, | 488 dummy_endpoint, |
| 489 dummy_endpoint, |
486 base::Bind(&UpdateCastTransportStatus), | 490 base::Bind(&UpdateCastTransportStatus), |
487 task_runner_, | 491 task_runner_, |
488 &sender_to_receiver_)); | 492 &sender_to_receiver_)); |
| 493 transport_sender_->InitializeAudio(transport_audio_config_); |
| 494 transport_sender_->InitializeVideo(transport_video_config_); |
489 | 495 |
490 cast_sender_.reset(CastSender::CreateCastSender( | 496 cast_sender_.reset(CastSender::CreateCastSender( |
491 cast_environment_, | 497 cast_environment_, |
492 &audio_sender_config_, | 498 &audio_sender_config_, |
493 &video_sender_config_, | 499 &video_sender_config_, |
494 NULL, | 500 NULL, |
495 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), | 501 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), |
496 transport_sender_.get())); | 502 transport_sender_.get())); |
497 | 503 |
498 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); | 504 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 } | 548 } |
543 | 549 |
544 void InitializationResult(CastInitializationStatus result) { | 550 void InitializationResult(CastInitializationStatus result) { |
545 EXPECT_EQ(result, STATUS_INITIALIZED); | 551 EXPECT_EQ(result, STATUS_INITIALIZED); |
546 } | 552 } |
547 | 553 |
548 AudioReceiverConfig audio_receiver_config_; | 554 AudioReceiverConfig audio_receiver_config_; |
549 VideoReceiverConfig video_receiver_config_; | 555 VideoReceiverConfig video_receiver_config_; |
550 AudioSenderConfig audio_sender_config_; | 556 AudioSenderConfig audio_sender_config_; |
551 VideoSenderConfig video_sender_config_; | 557 VideoSenderConfig video_sender_config_; |
552 transport::CastTransportConfig transport_config_; | 558 transport::CastTransportAudioConfig transport_audio_config_; |
| 559 transport::CastTransportVideoConfig transport_video_config_; |
553 | 560 |
554 base::TimeTicks start_time_; | 561 base::TimeTicks start_time_; |
555 base::SimpleTestTickClock* testing_clock_; | 562 base::SimpleTestTickClock* testing_clock_; |
556 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; | 563 scoped_refptr<test::FakeSingleThreadTaskRunner> task_runner_; |
557 scoped_refptr<CastEnvironment> cast_environment_; | 564 scoped_refptr<CastEnvironment> cast_environment_; |
558 | 565 |
559 LoopBackTransport receiver_to_sender_; | 566 LoopBackTransport receiver_to_sender_; |
560 LoopBackTransport sender_to_receiver_; | 567 LoopBackTransport sender_to_receiver_; |
561 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 568 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; |
562 | 569 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 RunTasks(kFrameTimerMs); | 962 RunTasks(kFrameTimerMs); |
956 } | 963 } |
957 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 964 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
958 EXPECT_EQ(frames_counter, | 965 EXPECT_EQ(frames_counter, |
959 test_receiver_video_callback_->number_times_called()); | 966 test_receiver_video_callback_->number_times_called()); |
960 } | 967 } |
961 | 968 |
962 TEST_F(End2EndTest, CryptoVideo) { | 969 TEST_F(End2EndTest, CryptoVideo) { |
963 SetupConfig(transport::kPcm16, 32000, false, 1); | 970 SetupConfig(transport::kPcm16, 32000, false, 1); |
964 | 971 |
965 transport_config_.aes_iv_mask = | 972 transport_video_config_.base.aes_iv_mask = |
966 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); | 973 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); |
967 transport_config_.aes_key = | 974 transport_video_config_.base.aes_key = |
968 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); | 975 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); |
969 | 976 |
970 video_receiver_config_.aes_iv_mask = transport_config_.aes_iv_mask; | 977 video_receiver_config_.aes_iv_mask = transport_video_config_.base.aes_iv_mask; |
971 video_receiver_config_.aes_key = transport_config_.aes_key; | 978 video_receiver_config_.aes_key = transport_video_config_.base.aes_key; |
972 | 979 |
973 Create(); | 980 Create(); |
974 | 981 |
975 int frames_counter = 0; | 982 int frames_counter = 0; |
976 for (; frames_counter < 3; ++frames_counter) { | 983 for (; frames_counter < 3; ++frames_counter) { |
977 const base::TimeTicks send_time = testing_clock_->NowTicks(); | 984 const base::TimeTicks send_time = testing_clock_->NowTicks(); |
978 | 985 |
979 SendVideoFrame(frames_counter, send_time); | 986 SendVideoFrame(frames_counter, send_time); |
980 | 987 |
981 test_receiver_video_callback_->AddExpectedResult( | 988 test_receiver_video_callback_->AddExpectedResult( |
(...skipping 16 matching lines...) Expand all Loading... |
998 | 1005 |
999 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 | 1006 // TODO(mikhal): Crashes on the bots. Re-enable. http://crbug.com/329563 |
1000 #if defined(OS_WIN) | 1007 #if defined(OS_WIN) |
1001 #define MAYBE_CryptoAudio DISABLED_CryptoAudio | 1008 #define MAYBE_CryptoAudio DISABLED_CryptoAudio |
1002 #else | 1009 #else |
1003 #define MAYBE_CryptoAudio CryptoAudio | 1010 #define MAYBE_CryptoAudio CryptoAudio |
1004 #endif | 1011 #endif |
1005 TEST_F(End2EndTest, MAYBE_CryptoAudio) { | 1012 TEST_F(End2EndTest, MAYBE_CryptoAudio) { |
1006 SetupConfig(transport::kPcm16, 32000, false, 1); | 1013 SetupConfig(transport::kPcm16, 32000, false, 1); |
1007 | 1014 |
1008 transport_config_.aes_iv_mask = | 1015 transport_audio_config_.base.aes_iv_mask = |
1009 ConvertFromBase16String("abcdeffedcba12345678900987654321"); | 1016 ConvertFromBase16String("abcdeffedcba12345678900987654321"); |
1010 transport_config_.aes_key = | 1017 transport_audio_config_.base.aes_key = |
1011 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); | 1018 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); |
1012 | 1019 |
1013 audio_receiver_config_.aes_iv_mask = transport_config_.aes_iv_mask; | 1020 audio_receiver_config_.aes_iv_mask = transport_audio_config_.base.aes_iv_mask; |
1014 audio_receiver_config_.aes_key = transport_config_.aes_key; | 1021 audio_receiver_config_.aes_key = transport_audio_config_.base.aes_key; |
1015 | 1022 |
1016 Create(); | 1023 Create(); |
1017 | 1024 |
1018 int frames_counter = 0; | 1025 int frames_counter = 0; |
1019 for (; frames_counter < 3; ++frames_counter) { | 1026 for (; frames_counter < 3; ++frames_counter) { |
1020 int num_10ms_blocks = 2; | 1027 int num_10ms_blocks = 2; |
1021 | 1028 |
1022 const base::TimeTicks send_time = testing_clock_->NowTicks(); | 1029 const base::TimeTicks send_time = testing_clock_->NowTicks(); |
1023 | 1030 |
1024 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 1031 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1291 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
1285 } | 1292 } |
1286 | 1293 |
1287 // TODO(pwestin): Add repeatable packet loss test. | 1294 // TODO(pwestin): Add repeatable packet loss test. |
1288 // TODO(pwestin): Add test for misaligned send get calls. | 1295 // TODO(pwestin): Add test for misaligned send get calls. |
1289 // TODO(pwestin): Add more tests that does not resample. | 1296 // TODO(pwestin): Add more tests that does not resample. |
1290 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1297 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1291 | 1298 |
1292 } // namespace cast | 1299 } // namespace cast |
1293 } // namespace media | 1300 } // namespace media |
OLD | NEW |