| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 bool result = (status == transport::TRANSPORT_AUDIO_INITIALIZED || | 93 bool result = (status == transport::TRANSPORT_AUDIO_INITIALIZED || |
| 94 status == transport::TRANSPORT_VIDEO_INITIALIZED); | 94 status == transport::TRANSPORT_VIDEO_INITIALIZED); |
| 95 EXPECT_TRUE(result); | 95 EXPECT_TRUE(result); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void AudioInitializationStatus(CastInitializationStatus status) { |
| 99 EXPECT_EQ(STATUS_AUDIO_INITIALIZED, status); |
| 100 } |
| 101 |
| 102 void VideoInitializationStatus(CastInitializationStatus status) { |
| 103 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, status); |
| 104 } |
| 105 |
| 98 // This is wrapped in a struct because it needs to be put into a std::map. | 106 // This is wrapped in a struct because it needs to be put into a std::map. |
| 99 typedef struct { | 107 typedef struct { |
| 100 int counter[kNumOfLoggingEvents]; | 108 int counter[kNumOfLoggingEvents]; |
| 101 } LoggingEventCounts; | 109 } LoggingEventCounts; |
| 102 | 110 |
| 103 // Constructs a map from each frame (RTP timestamp) to counts of each event | 111 // Constructs a map from each frame (RTP timestamp) to counts of each event |
| 104 // type logged for that frame. | 112 // type logged for that frame. |
| 105 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( | 113 std::map<RtpTimestamp, LoggingEventCounts> GetEventCountForFrameEvents( |
| 106 const std::vector<FrameEvent>& frame_events) { | 114 const std::vector<FrameEvent>& frame_events) { |
| 107 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame; | 115 std::map<RtpTimestamp, LoggingEventCounts> event_counter_for_frame; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 }; | 397 }; |
| 390 | 398 |
| 391 // The actual test class, generate synthetic data for both audio and video and | 399 // The actual test class, generate synthetic data for both audio and video and |
| 392 // send those through the sender and receiver and analyzes the result. | 400 // send those through the sender and receiver and analyzes the result. |
| 393 class End2EndTest : public ::testing::Test { | 401 class End2EndTest : public ::testing::Test { |
| 394 protected: | 402 protected: |
| 395 End2EndTest() | 403 End2EndTest() |
| 396 : start_time_(), | 404 : start_time_(), |
| 397 testing_clock_sender_(new base::SimpleTestTickClock()), | 405 testing_clock_sender_(new base::SimpleTestTickClock()), |
| 398 testing_clock_receiver_(new base::SimpleTestTickClock()), | 406 testing_clock_receiver_(new base::SimpleTestTickClock()), |
| 399 task_runner_(new test::FakeSingleThreadTaskRunner( | 407 task_runner_( |
| 400 testing_clock_sender_)), | 408 new test::FakeSingleThreadTaskRunner(testing_clock_sender_)), |
| 401 logging_config_(GetLoggingConfigWithRawEventsAndStatsEnabled()), | 409 logging_config_(GetLoggingConfigWithRawEventsAndStatsEnabled()), |
| 402 cast_environment_sender_(new CastEnvironment( | 410 cast_environment_sender_(new CastEnvironment( |
| 403 scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(), | 411 scoped_ptr<base::TickClock>(testing_clock_sender_).Pass(), |
| 404 task_runner_, | 412 task_runner_, |
| 405 task_runner_, | 413 task_runner_, |
| 406 task_runner_, | 414 task_runner_, |
| 407 task_runner_, | 415 task_runner_, |
| 408 task_runner_, | 416 task_runner_, |
| 409 task_runner_, | 417 task_runner_, |
| 410 logging_config_)), | 418 logging_config_)), |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 transport_audio_config_.codec = audio_sender_config_.codec; | 493 transport_audio_config_.codec = audio_sender_config_.codec; |
| 486 transport_audio_config_.base.rtp_config = audio_sender_config_.rtp_config; | 494 transport_audio_config_.base.rtp_config = audio_sender_config_.rtp_config; |
| 487 transport_audio_config_.frequency = audio_sender_config_.frequency; | 495 transport_audio_config_.frequency = audio_sender_config_.frequency; |
| 488 transport_audio_config_.channels = audio_sender_config_.channels; | 496 transport_audio_config_.channels = audio_sender_config_.channels; |
| 489 transport_video_config_.base.ssrc = video_sender_config_.sender_ssrc; | 497 transport_video_config_.base.ssrc = video_sender_config_.sender_ssrc; |
| 490 transport_video_config_.codec = video_sender_config_.codec; | 498 transport_video_config_.codec = video_sender_config_.codec; |
| 491 transport_video_config_.base.rtp_config = video_sender_config_.rtp_config; | 499 transport_video_config_.base.rtp_config = video_sender_config_.rtp_config; |
| 492 } | 500 } |
| 493 | 501 |
| 494 void Create() { | 502 void Create() { |
| 495 cast_receiver_.reset( | 503 cast_receiver_ = CastReceiver::Create(cast_environment_receiver_, |
| 496 CastReceiver::CreateCastReceiver(cast_environment_receiver_, | 504 audio_receiver_config_, |
| 497 audio_receiver_config_, | 505 video_receiver_config_, |
| 498 video_receiver_config_, | 506 &receiver_to_sender_); |
| 499 &receiver_to_sender_)); | |
| 500 net::IPEndPoint dummy_endpoint; | 507 net::IPEndPoint dummy_endpoint; |
| 501 transport_sender_.reset(new transport::CastTransportSenderImpl( | 508 transport_sender_.reset(new transport::CastTransportSenderImpl( |
| 502 NULL, | 509 NULL, |
| 503 testing_clock_sender_, | 510 testing_clock_sender_, |
| 504 dummy_endpoint, | 511 dummy_endpoint, |
| 505 dummy_endpoint, | 512 dummy_endpoint, |
| 506 logging_config_, | 513 logging_config_, |
| 507 base::Bind(&UpdateCastTransportStatus), | 514 base::Bind(&UpdateCastTransportStatus), |
| 508 base::Bind(&End2EndTest::LogRawEvents, base::Unretained(this)), | 515 base::Bind(&End2EndTest::LogRawEvents, base::Unretained(this)), |
| 509 base::TimeDelta::FromSeconds(1), | 516 base::TimeDelta::FromSeconds(1), |
| 510 task_runner_, | 517 task_runner_, |
| 511 &sender_to_receiver_)); | 518 &sender_to_receiver_)); |
| 512 transport_sender_->InitializeAudio(transport_audio_config_); | 519 transport_sender_->InitializeAudio(transport_audio_config_); |
| 513 transport_sender_->InitializeVideo(transport_video_config_); | 520 transport_sender_->InitializeVideo(transport_video_config_); |
| 514 | 521 |
| 515 cast_sender_.reset(CastSender::CreateCastSender( | 522 cast_sender_ = |
| 516 cast_environment_sender_, | 523 CastSender::Create(cast_environment_sender_, transport_sender_.get()); |
| 517 &audio_sender_config_, | 524 |
| 518 &video_sender_config_, | 525 // Initializing audio and video senders. |
| 519 NULL, | 526 cast_sender_->InitializeAudio(audio_sender_config_, |
| 520 base::Bind(&End2EndTest::InitializationResult, base::Unretained(this)), | 527 base::Bind(&AudioInitializationStatus)); |
| 521 transport_sender_.get())); | 528 cast_sender_->InitializeVideo( |
| 529 video_sender_config_, base::Bind(&VideoInitializationStatus), NULL); |
| 522 | 530 |
| 523 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); | 531 receiver_to_sender_.SetPacketReceiver(cast_sender_->packet_receiver()); |
| 524 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver()); | 532 sender_to_receiver_.SetPacketReceiver(cast_receiver_->packet_receiver()); |
| 525 | 533 |
| 526 frame_input_ = cast_sender_->frame_input(); | 534 audio_frame_input_ = cast_sender_->audio_frame_input(); |
| 535 video_frame_input_ = cast_sender_->video_frame_input(); |
| 536 |
| 527 frame_receiver_ = cast_receiver_->frame_receiver(); | 537 frame_receiver_ = cast_receiver_->frame_receiver(); |
| 528 | 538 |
| 529 audio_bus_factory_.reset( | 539 audio_bus_factory_.reset( |
| 530 new TestAudioBusFactory(audio_sender_config_.channels, | 540 new TestAudioBusFactory(audio_sender_config_.channels, |
| 531 audio_sender_config_.frequency, | 541 audio_sender_config_.frequency, |
| 532 kSoundFrequency, | 542 kSoundFrequency, |
| 533 kSoundVolume)); | 543 kSoundVolume)); |
| 534 } | 544 } |
| 535 | 545 |
| 536 virtual ~End2EndTest() { | 546 virtual ~End2EndTest() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 548 if (start_time_.is_null()) | 558 if (start_time_.is_null()) |
| 549 start_time_ = capture_time; | 559 start_time_ = capture_time; |
| 550 base::TimeDelta time_diff = capture_time - start_time_; | 560 base::TimeDelta time_diff = capture_time - start_time_; |
| 551 gfx::Size size(video_sender_config_.width, video_sender_config_.height); | 561 gfx::Size size(video_sender_config_.width, video_sender_config_.height); |
| 552 EXPECT_TRUE(VideoFrame::IsValidConfig( | 562 EXPECT_TRUE(VideoFrame::IsValidConfig( |
| 553 VideoFrame::I420, size, gfx::Rect(size), size)); | 563 VideoFrame::I420, size, gfx::Rect(size), size)); |
| 554 scoped_refptr<media::VideoFrame> video_frame = | 564 scoped_refptr<media::VideoFrame> video_frame = |
| 555 media::VideoFrame::CreateFrame( | 565 media::VideoFrame::CreateFrame( |
| 556 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); | 566 VideoFrame::I420, size, gfx::Rect(size), size, time_diff); |
| 557 PopulateVideoFrame(video_frame, start_value); | 567 PopulateVideoFrame(video_frame, start_value); |
| 558 frame_input_->InsertRawVideoFrame(video_frame, capture_time); | 568 video_frame_input_->InsertRawVideoFrame(video_frame, capture_time); |
| 559 } | 569 } |
| 560 | 570 |
| 561 void RunTasks(int during_ms) { | 571 void RunTasks(int during_ms) { |
| 562 for (int i = 0; i < during_ms; ++i) { | 572 for (int i = 0; i < during_ms; ++i) { |
| 563 // Call process the timers every 1 ms. | 573 // Call process the timers every 1 ms. |
| 564 testing_clock_sender_->Advance(base::TimeDelta::FromMilliseconds(1)); | 574 testing_clock_sender_->Advance(base::TimeDelta::FromMilliseconds(1)); |
| 565 testing_clock_receiver_->Advance(base::TimeDelta::FromMilliseconds(1)); | 575 testing_clock_receiver_->Advance(base::TimeDelta::FromMilliseconds(1)); |
| 566 task_runner_->RunTasks(); | 576 task_runner_->RunTasks(); |
| 567 } | 577 } |
| 568 } | 578 } |
| 569 | 579 |
| 570 void InitializationResult(CastInitializationStatus result) { | |
| 571 EXPECT_EQ(result, STATUS_INITIALIZED); | |
| 572 } | |
| 573 | |
| 574 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { | 580 void LogRawEvents(const std::vector<PacketEvent>& packet_events) { |
| 575 EXPECT_FALSE(packet_events.empty()); | 581 EXPECT_FALSE(packet_events.empty()); |
| 576 for (std::vector<media::cast::PacketEvent>::const_iterator it = | 582 for (std::vector<media::cast::PacketEvent>::const_iterator it = |
| 577 packet_events.begin(); | 583 packet_events.begin(); |
| 578 it != packet_events.end(); | 584 it != packet_events.end(); |
| 579 ++it) { | 585 ++it) { |
| 580 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp, | 586 cast_environment_sender_->Logging()->InsertPacketEvent(it->timestamp, |
| 581 it->type, | 587 it->type, |
| 582 it->rtp_timestamp, | 588 it->rtp_timestamp, |
| 583 it->frame_id, | 589 it->frame_id, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 601 CastLoggingConfig logging_config_; | 607 CastLoggingConfig logging_config_; |
| 602 scoped_refptr<CastEnvironment> cast_environment_sender_; | 608 scoped_refptr<CastEnvironment> cast_environment_sender_; |
| 603 scoped_refptr<CastEnvironment> cast_environment_receiver_; | 609 scoped_refptr<CastEnvironment> cast_environment_receiver_; |
| 604 | 610 |
| 605 LoopBackTransport receiver_to_sender_; | 611 LoopBackTransport receiver_to_sender_; |
| 606 LoopBackTransport sender_to_receiver_; | 612 LoopBackTransport sender_to_receiver_; |
| 607 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 613 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; |
| 608 | 614 |
| 609 scoped_ptr<CastReceiver> cast_receiver_; | 615 scoped_ptr<CastReceiver> cast_receiver_; |
| 610 scoped_ptr<CastSender> cast_sender_; | 616 scoped_ptr<CastSender> cast_sender_; |
| 611 scoped_refptr<FrameInput> frame_input_; | 617 scoped_refptr<AudioFrameInput> audio_frame_input_; |
| 618 scoped_refptr<VideoFrameInput> video_frame_input_; |
| 612 scoped_refptr<FrameReceiver> frame_receiver_; | 619 scoped_refptr<FrameReceiver> frame_receiver_; |
| 613 | 620 |
| 614 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; | 621 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; |
| 615 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; | 622 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; |
| 616 | 623 |
| 617 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; | 624 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; |
| 618 | 625 |
| 619 SimpleEventSubscriber event_subscriber_sender_; | 626 SimpleEventSubscriber event_subscriber_sender_; |
| 620 std::vector<FrameEvent> frame_events_; | 627 std::vector<FrameEvent> frame_events_; |
| 621 std::vector<PacketEvent> packet_events_; | 628 std::vector<PacketEvent> packet_events_; |
| 622 std::vector<GenericEvent> generic_events_; | 629 std::vector<GenericEvent> generic_events_; |
| 623 | |
| 624 // |transport_sender_| has a RepeatingTimer which needs a MessageLoop. | 630 // |transport_sender_| has a RepeatingTimer which needs a MessageLoop. |
| 625 base::MessageLoop message_loop_; | 631 base::MessageLoop message_loop_; |
| 626 }; | 632 }; |
| 627 | 633 |
| 628 TEST_F(End2EndTest, LoopNoLossPcm16) { | 634 TEST_F(End2EndTest, LoopNoLossPcm16) { |
| 629 SetupConfig(transport::kPcm16, 32000, false, 1); | 635 SetupConfig(transport::kPcm16, 32000, false, 1); |
| 630 // Reduce video resolution to allow processing multiple frames within a | 636 // Reduce video resolution to allow processing multiple frames within a |
| 631 // reasonable time frame. | 637 // reasonable time frame. |
| 632 video_sender_config_.width = kVideoQcifWidth; | 638 video_sender_config_.width = kVideoQcifWidth; |
| 633 video_sender_config_.height = kVideoQcifHeight; | 639 video_sender_config_.height = kVideoQcifHeight; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 650 // first samples will be 0 and then slowly ramp up to its real | 656 // first samples will be 0 and then slowly ramp up to its real |
| 651 // amplitude; | 657 // amplitude; |
| 652 // ignore the first frame. | 658 // ignore the first frame. |
| 653 test_receiver_audio_callback_->AddExpectedResult( | 659 test_receiver_audio_callback_->AddExpectedResult( |
| 654 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 660 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 655 num_10ms_blocks, | 661 num_10ms_blocks, |
| 656 send_time); | 662 send_time); |
| 657 } | 663 } |
| 658 | 664 |
| 659 AudioBus* const audio_bus_ptr = audio_bus.get(); | 665 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 660 frame_input_->InsertAudio( | 666 audio_frame_input_->InsertAudio( |
| 661 audio_bus_ptr, | 667 audio_bus_ptr, |
| 662 send_time, | 668 send_time, |
| 663 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 669 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 664 | 670 |
| 665 test_receiver_video_callback_->AddExpectedResult( | 671 test_receiver_video_callback_->AddExpectedResult( |
| 666 video_start, | 672 video_start, |
| 667 video_sender_config_.width, | 673 video_sender_config_.width, |
| 668 video_sender_config_.height, | 674 video_sender_config_.height, |
| 669 send_time); | 675 send_time); |
| 670 SendVideoFrame(video_start, send_time); | 676 SendVideoFrame(video_start, send_time); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 for (; i < 10; ++i) { | 713 for (; i < 10; ++i) { |
| 708 base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 714 base::TimeTicks send_time = testing_clock_sender_->NowTicks(); |
| 709 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 715 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
| 710 base::TimeDelta::FromMilliseconds(10))); | 716 base::TimeDelta::FromMilliseconds(10))); |
| 711 test_receiver_audio_callback_->AddExpectedResult( | 717 test_receiver_audio_callback_->AddExpectedResult( |
| 712 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 718 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 713 1, | 719 1, |
| 714 send_time); | 720 send_time); |
| 715 | 721 |
| 716 AudioBus* const audio_bus_ptr = audio_bus.get(); | 722 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 717 frame_input_->InsertAudio( | 723 audio_frame_input_->InsertAudio( |
| 718 audio_bus_ptr, | 724 audio_bus_ptr, |
| 719 send_time, | 725 send_time, |
| 720 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 726 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 721 | 727 |
| 722 RunTasks(10); | 728 RunTasks(10); |
| 723 frame_receiver_->GetCodedAudioFrame( | 729 frame_receiver_->GetCodedAudioFrame( |
| 724 base::Bind(&TestReceiverAudioCallback::CheckCodedPcmAudioFrame, | 730 base::Bind(&TestReceiverAudioCallback::CheckCodedPcmAudioFrame, |
| 725 test_receiver_audio_callback_)); | 731 test_receiver_audio_callback_)); |
| 726 } | 732 } |
| 727 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 733 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 742 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 748 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
| 743 | 749 |
| 744 if (i != 0) { | 750 if (i != 0) { |
| 745 test_receiver_audio_callback_->AddExpectedResult( | 751 test_receiver_audio_callback_->AddExpectedResult( |
| 746 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 752 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 747 num_10ms_blocks, | 753 num_10ms_blocks, |
| 748 send_time); | 754 send_time); |
| 749 } | 755 } |
| 750 | 756 |
| 751 AudioBus* const audio_bus_ptr = audio_bus.get(); | 757 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 752 frame_input_->InsertAudio( | 758 audio_frame_input_->InsertAudio( |
| 753 audio_bus_ptr, | 759 audio_bus_ptr, |
| 754 send_time, | 760 send_time, |
| 755 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 761 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 756 | 762 |
| 757 RunTasks(30); | 763 RunTasks(30); |
| 758 | 764 |
| 759 if (i == 0) { | 765 if (i == 0) { |
| 760 frame_receiver_->GetRawAudioFrame( | 766 frame_receiver_->GetRawAudioFrame( |
| 761 num_10ms_blocks, | 767 num_10ms_blocks, |
| 762 audio_sender_config_.frequency, | 768 audio_sender_config_.frequency, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 792 int num_10ms_blocks = audio_diff / 10; | 798 int num_10ms_blocks = audio_diff / 10; |
| 793 audio_diff -= num_10ms_blocks * 10; | 799 audio_diff -= num_10ms_blocks * 10; |
| 794 | 800 |
| 795 base::TimeTicks send_time = testing_clock_sender_->NowTicks(); | 801 base::TimeTicks send_time = testing_clock_sender_->NowTicks(); |
| 796 if (initial_send_time.is_null()) | 802 if (initial_send_time.is_null()) |
| 797 initial_send_time = send_time; | 803 initial_send_time = send_time; |
| 798 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( | 804 scoped_ptr<AudioBus> audio_bus(audio_bus_factory_->NextAudioBus( |
| 799 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 805 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
| 800 | 806 |
| 801 AudioBus* const audio_bus_ptr = audio_bus.get(); | 807 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 802 frame_input_->InsertAudio( | 808 audio_frame_input_->InsertAudio( |
| 803 audio_bus_ptr, | 809 audio_bus_ptr, |
| 804 send_time, | 810 send_time, |
| 805 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 811 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 806 | 812 |
| 807 // Frame will be rendered with 100mS delay, as the transmission is delayed. | 813 // Frame will be rendered with 100mS delay, as the transmission is delayed. |
| 808 // The receiver at this point cannot be synced to the sender's clock, as no | 814 // The receiver at this point cannot be synced to the sender's clock, as no |
| 809 // packets, and specifically no RTCP packets were sent. | 815 // packets, and specifically no RTCP packets were sent. |
| 810 test_receiver_video_callback_->AddExpectedResult( | 816 test_receiver_video_callback_->AddExpectedResult( |
| 811 video_start, | 817 video_start, |
| 812 video_sender_config_.width, | 818 video_sender_config_.width, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 834 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); | 840 base::TimeDelta::FromMilliseconds(10) * num_10ms_blocks)); |
| 835 | 841 |
| 836 if (j >= number_of_audio_frames_to_ignore) { | 842 if (j >= number_of_audio_frames_to_ignore) { |
| 837 test_receiver_audio_callback_->AddExpectedResult( | 843 test_receiver_audio_callback_->AddExpectedResult( |
| 838 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 844 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 839 num_10ms_blocks, | 845 num_10ms_blocks, |
| 840 send_time); | 846 send_time); |
| 841 } | 847 } |
| 842 | 848 |
| 843 AudioBus* const audio_bus_ptr = audio_bus.get(); | 849 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 844 frame_input_->InsertAudio( | 850 audio_frame_input_->InsertAudio( |
| 845 audio_bus_ptr, | 851 audio_bus_ptr, |
| 846 send_time, | 852 send_time, |
| 847 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 853 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 848 | 854 |
| 849 test_receiver_video_callback_->AddExpectedResult( | 855 test_receiver_video_callback_->AddExpectedResult( |
| 850 video_start, | 856 video_start, |
| 851 video_sender_config_.width, | 857 video_sender_config_.width, |
| 852 video_sender_config_.height, | 858 video_sender_config_.height, |
| 853 send_time); | 859 send_time); |
| 854 | 860 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the | 1071 // Due to the re-sampler and NetEq in the webrtc AudioCodingModule the |
| 1066 // first samples will be 0 and then slowly ramp up to its real | 1072 // first samples will be 0 and then slowly ramp up to its real |
| 1067 // amplitude; | 1073 // amplitude; |
| 1068 // ignore the first frame. | 1074 // ignore the first frame. |
| 1069 test_receiver_audio_callback_->AddExpectedResult( | 1075 test_receiver_audio_callback_->AddExpectedResult( |
| 1070 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 1076 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 1071 num_10ms_blocks, | 1077 num_10ms_blocks, |
| 1072 send_time); | 1078 send_time); |
| 1073 } | 1079 } |
| 1074 AudioBus* const audio_bus_ptr = audio_bus.get(); | 1080 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 1075 frame_input_->InsertAudio( | 1081 audio_frame_input_->InsertAudio( |
| 1076 audio_bus_ptr, | 1082 audio_bus_ptr, |
| 1077 send_time, | 1083 send_time, |
| 1078 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 1084 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 1079 | 1085 |
| 1080 RunTasks(num_10ms_blocks * 10); | 1086 RunTasks(num_10ms_blocks * 10); |
| 1081 | 1087 |
| 1082 if (frames_counter == 0) { | 1088 if (frames_counter == 0) { |
| 1083 frame_receiver_->GetRawAudioFrame( | 1089 frame_receiver_->GetRawAudioFrame( |
| 1084 num_10ms_blocks, | 1090 num_10ms_blocks, |
| 1085 32000, | 1091 32000, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 // first samples will be 0 and then slowly ramp up to its real | 1249 // first samples will be 0 and then slowly ramp up to its real |
| 1244 // amplitude; | 1250 // amplitude; |
| 1245 // ignore the first frame. | 1251 // ignore the first frame. |
| 1246 test_receiver_audio_callback_->AddExpectedResult( | 1252 test_receiver_audio_callback_->AddExpectedResult( |
| 1247 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), | 1253 ToPcmAudioFrame(*audio_bus, audio_sender_config_.frequency), |
| 1248 num_10ms_blocks, | 1254 num_10ms_blocks, |
| 1249 send_time); | 1255 send_time); |
| 1250 } | 1256 } |
| 1251 | 1257 |
| 1252 AudioBus* const audio_bus_ptr = audio_bus.get(); | 1258 AudioBus* const audio_bus_ptr = audio_bus.get(); |
| 1253 frame_input_->InsertAudio( | 1259 audio_frame_input_->InsertAudio( |
| 1254 audio_bus_ptr, | 1260 audio_bus_ptr, |
| 1255 send_time, | 1261 send_time, |
| 1256 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); | 1262 base::Bind(&OwnThatAudioBus, base::Passed(&audio_bus))); |
| 1257 | 1263 |
| 1258 RunTasks(kFrameTimerMs); | 1264 RunTasks(kFrameTimerMs); |
| 1259 audio_diff += kFrameTimerMs; | 1265 audio_diff += kFrameTimerMs; |
| 1260 | 1266 |
| 1261 if (i == 0) { | 1267 if (i == 0) { |
| 1262 frame_receiver_->GetRawAudioFrame( | 1268 frame_receiver_->GetRawAudioFrame( |
| 1263 num_10ms_blocks, | 1269 num_10ms_blocks, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1351 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
| 1346 } | 1352 } |
| 1347 | 1353 |
| 1348 // TODO(pwestin): Add repeatable packet loss test. | 1354 // TODO(pwestin): Add repeatable packet loss test. |
| 1349 // TODO(pwestin): Add test for misaligned send get calls. | 1355 // TODO(pwestin): Add test for misaligned send get calls. |
| 1350 // TODO(pwestin): Add more tests that does not resample. | 1356 // TODO(pwestin): Add more tests that does not resample. |
| 1351 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1357 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1352 | 1358 |
| 1353 } // namespace cast | 1359 } // namespace cast |
| 1354 } // namespace media | 1360 } // namespace media |
| OLD | NEW |