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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 video_receiver_config_, | 581 video_receiver_config_, |
582 &receiver_to_sender_); | 582 &receiver_to_sender_); |
583 | 583 |
584 net::IPEndPoint dummy_endpoint; | 584 net::IPEndPoint dummy_endpoint; |
585 transport_sender_.reset(new CastTransportSenderImpl( | 585 transport_sender_.reset(new CastTransportSenderImpl( |
586 NULL, | 586 NULL, |
587 testing_clock_sender_, | 587 testing_clock_sender_, |
588 dummy_endpoint, | 588 dummy_endpoint, |
589 base::Bind(&UpdateCastTransportStatus), | 589 base::Bind(&UpdateCastTransportStatus), |
590 base::Bind(&End2EndTest::LogRawEvents, base::Unretained(this)), | 590 base::Bind(&End2EndTest::LogRawEvents, base::Unretained(this)), |
591 base::TimeDelta::FromSeconds(1), | 591 base::TimeDelta::FromMilliseconds(1), |
592 task_runner_sender_, | 592 task_runner_sender_, |
593 &sender_to_receiver_)); | 593 &sender_to_receiver_)); |
594 | 594 |
595 cast_sender_ = | 595 cast_sender_ = |
596 CastSender::Create(cast_environment_sender_, transport_sender_.get()); | 596 CastSender::Create(cast_environment_sender_, transport_sender_.get()); |
597 | 597 |
598 // Initializing audio and video senders. | 598 // Initializing audio and video senders. |
599 cast_sender_->InitializeAudio(audio_sender_config_, | 599 cast_sender_->InitializeAudio(audio_sender_config_, |
600 base::Bind(&AudioInitializationStatus)); | 600 base::Bind(&AudioInitializationStatus)); |
601 cast_sender_->InitializeVideo(video_sender_config_, | 601 cast_sender_->InitializeVideo(video_sender_config_, |
602 base::Bind(&VideoInitializationStatus), | 602 base::Bind(&VideoInitializationStatus), |
603 CreateDefaultVideoEncodeAcceleratorCallback(), | 603 CreateDefaultVideoEncodeAcceleratorCallback(), |
604 CreateDefaultVideoEncodeMemoryCallback()); | 604 CreateDefaultVideoEncodeMemoryCallback()); |
605 | 605 |
606 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver(), | 606 receiver_to_sender_.SetPacketReceiver( |
607 task_runner_, | 607 transport_sender_->PacketReceiverForTesting(), |
608 &testing_clock_); | 608 task_runner_, |
| 609 &testing_clock_); |
609 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver(), | 610 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver(), |
610 task_runner_, | 611 task_runner_, |
611 &testing_clock_); | 612 &testing_clock_); |
612 | 613 |
613 audio_frame_input_ = cast_sender_->audio_frame_input(); | 614 audio_frame_input_ = cast_sender_->audio_frame_input(); |
614 video_frame_input_ = cast_sender_->video_frame_input(); | 615 video_frame_input_ = cast_sender_->video_frame_input(); |
615 | 616 |
616 audio_bus_factory_.reset( | 617 audio_bus_factory_.reset( |
617 new TestAudioBusFactory(audio_sender_config_.channels, | 618 new TestAudioBusFactory(audio_sender_config_.channels, |
618 audio_sender_config_.frequency, | 619 audio_sender_config_.frequency, |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 | 709 |
709 void StartBasicPlayer() { | 710 void StartBasicPlayer() { |
710 cast_receiver_->RequestDecodedVideoFrame( | 711 cast_receiver_->RequestDecodedVideoFrame( |
711 base::Bind(&End2EndTest::BasicPlayerGotVideoFrame, | 712 base::Bind(&End2EndTest::BasicPlayerGotVideoFrame, |
712 base::Unretained(this))); | 713 base::Unretained(this))); |
713 cast_receiver_->RequestDecodedAudioFrame( | 714 cast_receiver_->RequestDecodedAudioFrame( |
714 base::Bind(&End2EndTest::BasicPlayerGotAudioFrame, | 715 base::Bind(&End2EndTest::BasicPlayerGotAudioFrame, |
715 base::Unretained(this))); | 716 base::Unretained(this))); |
716 } | 717 } |
717 | 718 |
718 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { | 719 void LogRawEvents(const std::vector<PacketEvent>& packet_events, |
719 EXPECT_FALSE(packet_events.empty()); | 720 const std::vector<FrameEvent>& frame_events) { |
720 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 721 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
721 packet_events.begin(); | 722 packet_events.begin(); |
722 it != packet_events.end(); | 723 it != packet_events.end(); |
723 ++it) { | 724 ++it) { |
724 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp, | 725 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp, |
725 it->type, | 726 it->type, |
726 it->media_type, | 727 it->media_type, |
727 it->rtp_timestamp, | 728 it->rtp_timestamp, |
728 it->frame_id, | 729 it->frame_id, |
729 it->packet_id, | 730 it->packet_id, |
730 it->max_packet_id, | 731 it->max_packet_id, |
731 it->size); | 732 it->size); |
732 } | 733 } |
| 734 for (std::vector<media::cast::FrameEvent>::const_iterator it = |
| 735 frame_events.begin(); |
| 736 it != frame_events.end(); |
| 737 ++it) { |
| 738 cast_environment_sender_->Logging()->InsertFrameEvent(it->timestamp, |
| 739 it->type, |
| 740 it->media_type, |
| 741 it->rtp_timestamp, |
| 742 it->frame_id); |
| 743 } |
733 } | 744 } |
734 | 745 |
735 FrameReceiverConfig audio_receiver_config_; | 746 FrameReceiverConfig audio_receiver_config_; |
736 FrameReceiverConfig video_receiver_config_; | 747 FrameReceiverConfig video_receiver_config_; |
737 AudioSenderConfig audio_sender_config_; | 748 AudioSenderConfig audio_sender_config_; |
738 VideoSenderConfig video_sender_config_; | 749 VideoSenderConfig video_sender_config_; |
739 | 750 |
740 base::TimeTicks start_time_; | 751 base::TimeTicks start_time_; |
741 | 752 |
742 // These run in "test time" | 753 // These run in "test time" |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 // Verify that each packet have the expected types of events logged. | 1258 // Verify that each packet have the expected types of events logged. |
1248 for (std::map<uint16, LoggingEventCounts>::iterator map_it = | 1259 for (std::map<uint16, LoggingEventCounts>::iterator map_it = |
1249 event_count_for_packet.begin(); | 1260 event_count_for_packet.begin(); |
1250 map_it != event_count_for_packet.end(); | 1261 map_it != event_count_for_packet.end(); |
1251 ++map_it) { | 1262 ++map_it) { |
1252 int total_event_count_for_packet = 0; | 1263 int total_event_count_for_packet = 0; |
1253 for (int i = 0; i <= kNumOfLoggingEvents; ++i) { | 1264 for (int i = 0; i <= kNumOfLoggingEvents; ++i) { |
1254 total_event_count_for_packet += map_it->second.counter[i]; | 1265 total_event_count_for_packet += map_it->second.counter[i]; |
1255 } | 1266 } |
1256 | 1267 |
1257 int expected_event_count_for_packet = 0; | |
1258 EXPECT_GT(map_it->second.counter[PACKET_RECEIVED], 0); | 1268 EXPECT_GT(map_it->second.counter[PACKET_RECEIVED], 0); |
1259 expected_event_count_for_packet += | 1269 int packets_received = map_it->second.counter[PACKET_RECEIVED]; |
1260 map_it->second.counter[PACKET_RECEIVED]; | 1270 int packets_sent = map_it->second.counter[PACKET_SENT_TO_NETWORK]; |
| 1271 EXPECT_EQ(packets_sent, packets_received); |
1261 | 1272 |
1262 // Verify that there were no other events logged with respect to this | 1273 // Verify that there were no other events logged with respect to this |
1263 // packet. (i.e. Total event count = expected event count) | 1274 // packet. (i.e. Total event count = packets sent + packets received) |
1264 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); | 1275 EXPECT_EQ(packets_received + packets_sent, total_event_count_for_packet); |
1265 } | 1276 } |
1266 } | 1277 } |
1267 | 1278 |
1268 // Audio test without packet loss - tests the logging aspects of the end2end, | 1279 // Audio test without packet loss - tests the logging aspects of the end2end, |
1269 // but is basically equivalent to LoopNoLossPcm16. | 1280 // but is basically equivalent to LoopNoLossPcm16. |
1270 TEST_F(End2EndTest, AudioLogging) { | 1281 TEST_F(End2EndTest, AudioLogging) { |
1271 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); | 1282 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
1272 Create(); | 1283 Create(); |
1273 | 1284 |
1274 int audio_diff = kFrameTimerMs; | 1285 int audio_diff = kFrameTimerMs; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000); | 1454 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000); |
1444 } | 1455 } |
1445 | 1456 |
1446 // TODO(pwestin): Add repeatable packet loss test. | 1457 // TODO(pwestin): Add repeatable packet loss test. |
1447 // TODO(pwestin): Add test for misaligned send get calls. | 1458 // TODO(pwestin): Add test for misaligned send get calls. |
1448 // TODO(pwestin): Add more tests that does not resample. | 1459 // TODO(pwestin): Add more tests that does not resample. |
1449 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1460 // TODO(pwestin): Add test when we have starvation for our RunTask. |
1450 | 1461 |
1451 } // namespace cast | 1462 } // namespace cast |
1452 } // namespace media | 1463 } // namespace media |
OLD | NEW |