| 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 11 matching lines...) Expand all Loading... |
| 22 #include "base/sys_byteorder.h" | 22 #include "base/sys_byteorder.h" |
| 23 #include "base/test/simple_test_tick_clock.h" | 23 #include "base/test/simple_test_tick_clock.h" |
| 24 #include "base/time/tick_clock.h" | 24 #include "base/time/tick_clock.h" |
| 25 #include "media/base/audio_bus.h" | 25 #include "media/base/audio_bus.h" |
| 26 #include "media/base/video_frame.h" | 26 #include "media/base/video_frame.h" |
| 27 #include "media/cast/cast_config.h" | 27 #include "media/cast/cast_config.h" |
| 28 #include "media/cast/cast_environment.h" | 28 #include "media/cast/cast_environment.h" |
| 29 #include "media/cast/cast_receiver.h" | 29 #include "media/cast/cast_receiver.h" |
| 30 #include "media/cast/cast_sender.h" | 30 #include "media/cast/cast_sender.h" |
| 31 #include "media/cast/logging/simple_event_subscriber.h" | 31 #include "media/cast/logging/simple_event_subscriber.h" |
| 32 #include "media/cast/net/cast_transport_config.h" |
| 33 #include "media/cast/net/cast_transport_defines.h" |
| 34 #include "media/cast/net/cast_transport_sender.h" |
| 35 #include "media/cast/net/cast_transport_sender_impl.h" |
| 32 #include "media/cast/test/fake_single_thread_task_runner.h" | 36 #include "media/cast/test/fake_single_thread_task_runner.h" |
| 33 #include "media/cast/test/skewed_single_thread_task_runner.h" | 37 #include "media/cast/test/skewed_single_thread_task_runner.h" |
| 34 #include "media/cast/test/skewed_tick_clock.h" | 38 #include "media/cast/test/skewed_tick_clock.h" |
| 35 #include "media/cast/test/utility/audio_utility.h" | 39 #include "media/cast/test/utility/audio_utility.h" |
| 36 #include "media/cast/test/utility/default_config.h" | 40 #include "media/cast/test/utility/default_config.h" |
| 37 #include "media/cast/test/utility/udp_proxy.h" | 41 #include "media/cast/test/utility/udp_proxy.h" |
| 38 #include "media/cast/test/utility/video_utility.h" | 42 #include "media/cast/test/utility/video_utility.h" |
| 39 #include "media/cast/transport/cast_transport_config.h" | |
| 40 #include "media/cast/transport/cast_transport_defines.h" | |
| 41 #include "media/cast/transport/cast_transport_sender.h" | |
| 42 #include "media/cast/transport/cast_transport_sender_impl.h" | |
| 43 #include "testing/gtest/include/gtest/gtest.h" | 43 #include "testing/gtest/include/gtest/gtest.h" |
| 44 | 44 |
| 45 namespace media { | 45 namespace media { |
| 46 namespace cast { | 46 namespace cast { |
| 47 | 47 |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 static const int64 kStartMillisecond = INT64_C(1245); | 50 static const int64 kStartMillisecond = INT64_C(1245); |
| 51 static const int kAudioChannels = 2; | 51 static const int kAudioChannels = 2; |
| 52 static const double kSoundFrequency = 314.15926535897; // Freq of sine wave. | 52 static const double kSoundFrequency = 314.15926535897; // Freq of sine wave. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 compressed.reserve(base_16.size() / 2); | 90 compressed.reserve(base_16.size() / 2); |
| 91 | 91 |
| 92 std::vector<uint8> v; | 92 std::vector<uint8> v; |
| 93 if (!base::HexStringToBytes(base_16, &v)) { | 93 if (!base::HexStringToBytes(base_16, &v)) { |
| 94 NOTREACHED(); | 94 NOTREACHED(); |
| 95 } | 95 } |
| 96 compressed.assign(reinterpret_cast<const char*>(&v[0]), v.size()); | 96 compressed.assign(reinterpret_cast<const char*>(&v[0]), v.size()); |
| 97 return compressed; | 97 return compressed; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void UpdateCastTransportStatus(transport::CastTransportStatus status) { | 100 void UpdateCastTransportStatus(CastTransportStatus status) { |
| 101 bool result = (status == transport::TRANSPORT_AUDIO_INITIALIZED || | 101 bool result = (status == TRANSPORT_AUDIO_INITIALIZED || |
| 102 status == transport::TRANSPORT_VIDEO_INITIALIZED); | 102 status == TRANSPORT_VIDEO_INITIALIZED); |
| 103 EXPECT_TRUE(result); | 103 EXPECT_TRUE(result); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void AudioInitializationStatus(CastInitializationStatus status) { | 106 void AudioInitializationStatus(CastInitializationStatus status) { |
| 107 EXPECT_EQ(STATUS_AUDIO_INITIALIZED, status); | 107 EXPECT_EQ(STATUS_AUDIO_INITIALIZED, status); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void VideoInitializationStatus(CastInitializationStatus status) { | 110 void VideoInitializationStatus(CastInitializationStatus status) { |
| 111 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, status); | 111 EXPECT_EQ(STATUS_VIDEO_INITIALIZED, status); |
| 112 } | 112 } |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 } | 161 } |
| 162 return event_counter_for_packet; | 162 return event_counter_for_packet; |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace | 165 } // namespace |
| 166 | 166 |
| 167 // Shim that turns forwards packets from a test::PacketPipe to a | 167 // Shim that turns forwards packets from a test::PacketPipe to a |
| 168 // PacketReceiverCallback. | 168 // PacketReceiverCallback. |
| 169 class LoopBackPacketPipe : public test::PacketPipe { | 169 class LoopBackPacketPipe : public test::PacketPipe { |
| 170 public: | 170 public: |
| 171 LoopBackPacketPipe(const transport::PacketReceiverCallback& packet_receiver) | 171 LoopBackPacketPipe(const PacketReceiverCallback& packet_receiver) |
| 172 : packet_receiver_(packet_receiver) {} | 172 : packet_receiver_(packet_receiver) {} |
| 173 | 173 |
| 174 virtual ~LoopBackPacketPipe() {} | 174 virtual ~LoopBackPacketPipe() {} |
| 175 | 175 |
| 176 // PacketPipe implementations. | 176 // PacketPipe implementations. |
| 177 virtual void Send(scoped_ptr<transport::Packet> packet) OVERRIDE { | 177 virtual void Send(scoped_ptr<Packet> packet) OVERRIDE { |
| 178 packet_receiver_.Run(packet.Pass()); | 178 packet_receiver_.Run(packet.Pass()); |
| 179 } | 179 } |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 transport::PacketReceiverCallback packet_receiver_; | 182 PacketReceiverCallback packet_receiver_; |
| 183 }; | 183 }; |
| 184 | 184 |
| 185 // Class that sends the packet direct from sender into the receiver with the | 185 // Class that sends the packet direct from sender into the receiver with the |
| 186 // ability to drop packets between the two. | 186 // ability to drop packets between the two. |
| 187 class LoopBackTransport : public transport::PacketSender { | 187 class LoopBackTransport : public PacketSender { |
| 188 public: | 188 public: |
| 189 explicit LoopBackTransport(scoped_refptr<CastEnvironment> cast_environment) | 189 explicit LoopBackTransport(scoped_refptr<CastEnvironment> cast_environment) |
| 190 : send_packets_(true), | 190 : send_packets_(true), |
| 191 drop_packets_belonging_to_odd_frames_(false), | 191 drop_packets_belonging_to_odd_frames_(false), |
| 192 cast_environment_(cast_environment) {} | 192 cast_environment_(cast_environment) {} |
| 193 | 193 |
| 194 void SetPacketReceiver( | 194 void SetPacketReceiver( |
| 195 const transport::PacketReceiverCallback& packet_receiver, | 195 const PacketReceiverCallback& packet_receiver, |
| 196 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 196 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 197 base::TickClock* clock) { | 197 base::TickClock* clock) { |
| 198 scoped_ptr<test::PacketPipe> loopback_pipe( | 198 scoped_ptr<test::PacketPipe> loopback_pipe( |
| 199 new LoopBackPacketPipe(packet_receiver)); | 199 new LoopBackPacketPipe(packet_receiver)); |
| 200 if (packet_pipe_) { | 200 if (packet_pipe_) { |
| 201 packet_pipe_->AppendToPipe(loopback_pipe.Pass()); | 201 packet_pipe_->AppendToPipe(loopback_pipe.Pass()); |
| 202 } else { | 202 } else { |
| 203 packet_pipe_ = loopback_pipe.Pass(); | 203 packet_pipe_ = loopback_pipe.Pass(); |
| 204 } | 204 } |
| 205 packet_pipe_->InitOnIOThread(task_runner, clock); | 205 packet_pipe_->InitOnIOThread(task_runner, clock); |
| 206 } | 206 } |
| 207 | 207 |
| 208 virtual bool SendPacket(transport::PacketRef packet, | 208 virtual bool SendPacket(PacketRef packet, |
| 209 const base::Closure& cb) OVERRIDE { | 209 const base::Closure& cb) OVERRIDE { |
| 210 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 210 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 211 if (!send_packets_) | 211 if (!send_packets_) |
| 212 return false; | 212 return false; |
| 213 | 213 |
| 214 if (drop_packets_belonging_to_odd_frames_) { | 214 if (drop_packets_belonging_to_odd_frames_) { |
| 215 uint32 frame_id = packet->data[13]; | 215 uint32 frame_id = packet->data[13]; |
| 216 if (frame_id % 2 == 1) | 216 if (frame_id % 2 == 1) |
| 217 return true; | 217 return true; |
| 218 } | 218 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 0.0, | 300 0.0, |
| 301 kMaxAllowedPlayoutErrorMs); | 301 kMaxAllowedPlayoutErrorMs); |
| 302 VLOG_IF(1, !last_playout_time_.is_null()) | 302 VLOG_IF(1, !last_playout_time_.is_null()) |
| 303 << "Audio frame playout time delta (compared to last frame) is " | 303 << "Audio frame playout time delta (compared to last frame) is " |
| 304 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; | 304 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; |
| 305 last_playout_time_ = playout_time; | 305 last_playout_time_ = playout_time; |
| 306 | 306 |
| 307 EXPECT_TRUE(is_continuous); | 307 EXPECT_TRUE(is_continuous); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void CheckCodedAudioFrame(scoped_ptr<transport::EncodedFrame> audio_frame) { | 310 void CheckCodedAudioFrame(scoped_ptr<EncodedFrame> audio_frame) { |
| 311 ASSERT_TRUE(!!audio_frame); | 311 ASSERT_TRUE(!!audio_frame); |
| 312 ASSERT_FALSE(expected_frames_.empty()); | 312 ASSERT_FALSE(expected_frames_.empty()); |
| 313 const ExpectedAudioFrame& expected_audio_frame = | 313 const ExpectedAudioFrame& expected_audio_frame = |
| 314 *(expected_frames_.front()); | 314 *(expected_frames_.front()); |
| 315 // Note: Just peeking here. Will delegate to CheckAudioFrame() to pop. | 315 // Note: Just peeking here. Will delegate to CheckAudioFrame() to pop. |
| 316 | 316 |
| 317 // We need to "decode" the encoded audio frame. The codec is simply to | 317 // We need to "decode" the encoded audio frame. The codec is simply to |
| 318 // swizzle the bytes of each int16 from host-->network-->host order to get | 318 // swizzle the bytes of each int16 from host-->network-->host order to get |
| 319 // interleaved int16 PCM. Then, make an AudioBus out of that. | 319 // interleaved int16 PCM. Then, make an AudioBus out of that. |
| 320 const int num_elements = audio_frame->data.size() / sizeof(int16); | 320 const int num_elements = audio_frame->data.size() / sizeof(int16); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 receiver_to_sender_(cast_environment_receiver_), | 451 receiver_to_sender_(cast_environment_receiver_), |
| 452 sender_to_receiver_(cast_environment_sender_), | 452 sender_to_receiver_(cast_environment_sender_), |
| 453 test_receiver_audio_callback_(new TestReceiverAudioCallback()), | 453 test_receiver_audio_callback_(new TestReceiverAudioCallback()), |
| 454 test_receiver_video_callback_(new TestReceiverVideoCallback()) { | 454 test_receiver_video_callback_(new TestReceiverVideoCallback()) { |
| 455 testing_clock_.Advance( | 455 testing_clock_.Advance( |
| 456 base::TimeDelta::FromMilliseconds(kStartMillisecond)); | 456 base::TimeDelta::FromMilliseconds(kStartMillisecond)); |
| 457 cast_environment_sender_->Logging()->AddRawEventSubscriber( | 457 cast_environment_sender_->Logging()->AddRawEventSubscriber( |
| 458 &event_subscriber_sender_); | 458 &event_subscriber_sender_); |
| 459 } | 459 } |
| 460 | 460 |
| 461 void Configure(transport::Codec video_codec, | 461 void Configure(Codec video_codec, |
| 462 transport::Codec audio_codec, | 462 Codec audio_codec, |
| 463 int audio_sampling_frequency, | 463 int audio_sampling_frequency, |
| 464 int max_number_of_video_buffers_used) { | 464 int max_number_of_video_buffers_used) { |
| 465 audio_sender_config_.ssrc = 1; | 465 audio_sender_config_.ssrc = 1; |
| 466 audio_sender_config_.incoming_feedback_ssrc = 2; | 466 audio_sender_config_.incoming_feedback_ssrc = 2; |
| 467 audio_sender_config_.target_playout_delay = | 467 audio_sender_config_.target_playout_delay = |
| 468 base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs); | 468 base::TimeDelta::FromMilliseconds(kTargetPlayoutDelayMs); |
| 469 audio_sender_config_.rtp_payload_type = 96; | 469 audio_sender_config_.rtp_payload_type = 96; |
| 470 audio_sender_config_.use_external_encoder = false; | 470 audio_sender_config_.use_external_encoder = false; |
| 471 audio_sender_config_.frequency = audio_sampling_frequency; | 471 audio_sender_config_.frequency = audio_sampling_frequency; |
| 472 audio_sender_config_.channels = kAudioChannels; | 472 audio_sender_config_.channels = kAudioChannels; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 | 577 |
| 578 void Create() { | 578 void Create() { |
| 579 cast_receiver_ = CastReceiver::Create(cast_environment_receiver_, | 579 cast_receiver_ = CastReceiver::Create(cast_environment_receiver_, |
| 580 audio_receiver_config_, | 580 audio_receiver_config_, |
| 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 transport::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::FromSeconds(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_ = |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 base::TimeDelta max_video_playout_curvature_; | 755 base::TimeDelta max_video_playout_curvature_; |
| 756 base::TimeTicks last_video_playout_time_; | 756 base::TimeTicks last_video_playout_time_; |
| 757 base::TimeDelta last_video_playout_delta_; | 757 base::TimeDelta last_video_playout_delta_; |
| 758 base::TimeTicks last_audio_playout_time_; | 758 base::TimeTicks last_audio_playout_time_; |
| 759 | 759 |
| 760 scoped_refptr<CastEnvironment> cast_environment_sender_; | 760 scoped_refptr<CastEnvironment> cast_environment_sender_; |
| 761 scoped_refptr<CastEnvironment> cast_environment_receiver_; | 761 scoped_refptr<CastEnvironment> cast_environment_receiver_; |
| 762 | 762 |
| 763 LoopBackTransport receiver_to_sender_; | 763 LoopBackTransport receiver_to_sender_; |
| 764 LoopBackTransport sender_to_receiver_; | 764 LoopBackTransport sender_to_receiver_; |
| 765 scoped_ptr<transport::CastTransportSenderImpl> transport_sender_; | 765 scoped_ptr<CastTransportSenderImpl> transport_sender_; |
| 766 | 766 |
| 767 scoped_ptr<CastReceiver> cast_receiver_; | 767 scoped_ptr<CastReceiver> cast_receiver_; |
| 768 scoped_ptr<CastSender> cast_sender_; | 768 scoped_ptr<CastSender> cast_sender_; |
| 769 scoped_refptr<AudioFrameInput> audio_frame_input_; | 769 scoped_refptr<AudioFrameInput> audio_frame_input_; |
| 770 scoped_refptr<VideoFrameInput> video_frame_input_; | 770 scoped_refptr<VideoFrameInput> video_frame_input_; |
| 771 | 771 |
| 772 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; | 772 scoped_refptr<TestReceiverAudioCallback> test_receiver_audio_callback_; |
| 773 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; | 773 scoped_refptr<TestReceiverVideoCallback> test_receiver_video_callback_; |
| 774 | 774 |
| 775 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; | 775 scoped_ptr<TestAudioBusFactory> audio_bus_factory_; |
| 776 | 776 |
| 777 SimpleEventSubscriber event_subscriber_sender_; | 777 SimpleEventSubscriber event_subscriber_sender_; |
| 778 std::vector<FrameEvent> frame_events_; | 778 std::vector<FrameEvent> frame_events_; |
| 779 std::vector<PacketEvent> packet_events_; | 779 std::vector<PacketEvent> packet_events_; |
| 780 std::vector<std::pair<base::TimeTicks, base::TimeTicks> > audio_ticks_; | 780 std::vector<std::pair<base::TimeTicks, base::TimeTicks> > audio_ticks_; |
| 781 std::vector<std::pair<base::TimeTicks, base::TimeTicks> > video_ticks_; | 781 std::vector<std::pair<base::TimeTicks, base::TimeTicks> > video_ticks_; |
| 782 // |transport_sender_| has a RepeatingTimer which needs a MessageLoop. | 782 // |transport_sender_| has a RepeatingTimer which needs a MessageLoop. |
| 783 base::MessageLoop message_loop_; | 783 base::MessageLoop message_loop_; |
| 784 }; | 784 }; |
| 785 | 785 |
| 786 TEST_F(End2EndTest, LoopNoLossPcm16) { | 786 TEST_F(End2EndTest, LoopNoLossPcm16) { |
| 787 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 787 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 788 // Reduce video resolution to allow processing multiple frames within a | 788 // Reduce video resolution to allow processing multiple frames within a |
| 789 // reasonable time frame. | 789 // reasonable time frame. |
| 790 video_sender_config_.width = kVideoQcifWidth; | 790 video_sender_config_.width = kVideoQcifWidth; |
| 791 video_sender_config_.height = kVideoQcifHeight; | 791 video_sender_config_.height = kVideoQcifHeight; |
| 792 Create(); | 792 Create(); |
| 793 | 793 |
| 794 const int kNumIterations = 50; | 794 const int kNumIterations = 50; |
| 795 int video_start = kVideoStart; | 795 int video_start = kVideoStart; |
| 796 int audio_diff = kFrameTimerMs; | 796 int audio_diff = kFrameTimerMs; |
| 797 int num_audio_frames_requested = 0; | 797 int num_audio_frames_requested = 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 831 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 832 EXPECT_EQ(num_audio_frames_requested, | 832 EXPECT_EQ(num_audio_frames_requested, |
| 833 test_receiver_audio_callback_->number_times_called()); | 833 test_receiver_audio_callback_->number_times_called()); |
| 834 EXPECT_EQ(kNumIterations, | 834 EXPECT_EQ(kNumIterations, |
| 835 test_receiver_video_callback_->number_times_called()); | 835 test_receiver_video_callback_->number_times_called()); |
| 836 } | 836 } |
| 837 | 837 |
| 838 // This tests our external decoder interface for Audio. | 838 // This tests our external decoder interface for Audio. |
| 839 // Audio test without packet loss using raw PCM 16 audio "codec"; | 839 // Audio test without packet loss using raw PCM 16 audio "codec"; |
| 840 TEST_F(End2EndTest, LoopNoLossPcm16ExternalDecoder) { | 840 TEST_F(End2EndTest, LoopNoLossPcm16ExternalDecoder) { |
| 841 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 841 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 842 Create(); | 842 Create(); |
| 843 | 843 |
| 844 const int kNumIterations = 10; | 844 const int kNumIterations = 10; |
| 845 for (int i = 0; i < kNumIterations; ++i) { | 845 for (int i = 0; i < kNumIterations; ++i) { |
| 846 FeedAudioFrames(1, true); | 846 FeedAudioFrames(1, true); |
| 847 RunTasks(kAudioFrameDurationMs); | 847 RunTasks(kAudioFrameDurationMs); |
| 848 cast_receiver_->RequestEncodedAudioFrame( | 848 cast_receiver_->RequestEncodedAudioFrame( |
| 849 base::Bind(&TestReceiverAudioCallback::CheckCodedAudioFrame, | 849 base::Bind(&TestReceiverAudioCallback::CheckCodedAudioFrame, |
| 850 test_receiver_audio_callback_)); | 850 test_receiver_audio_callback_)); |
| 851 } | 851 } |
| 852 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 852 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 853 EXPECT_EQ(kNumIterations, | 853 EXPECT_EQ(kNumIterations, |
| 854 test_receiver_audio_callback_->number_times_called()); | 854 test_receiver_audio_callback_->number_times_called()); |
| 855 } | 855 } |
| 856 | 856 |
| 857 // This tests our Opus audio codec without video. | 857 // This tests our Opus audio codec without video. |
| 858 TEST_F(End2EndTest, LoopNoLossOpus) { | 858 TEST_F(End2EndTest, LoopNoLossOpus) { |
| 859 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_OPUS, | 859 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS, |
| 860 kDefaultAudioSamplingRate, 1); | 860 kDefaultAudioSamplingRate, 1); |
| 861 Create(); | 861 Create(); |
| 862 | 862 |
| 863 const int kNumIterations = 300; | 863 const int kNumIterations = 300; |
| 864 for (int i = 0; i < kNumIterations; ++i) { | 864 for (int i = 0; i < kNumIterations; ++i) { |
| 865 // Opus introduces a tiny delay before the sinewave starts; so don't examine | 865 // Opus introduces a tiny delay before the sinewave starts; so don't examine |
| 866 // the first frame. | 866 // the first frame. |
| 867 const bool examine_audio_data = i > 0; | 867 const bool examine_audio_data = i > 0; |
| 868 FeedAudioFrames(1, examine_audio_data); | 868 FeedAudioFrames(1, examine_audio_data); |
| 869 RunTasks(kAudioFrameDurationMs); | 869 RunTasks(kAudioFrameDurationMs); |
| 870 RequestAudioFrames(1, examine_audio_data); | 870 RequestAudioFrames(1, examine_audio_data); |
| 871 } | 871 } |
| 872 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 872 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 873 EXPECT_EQ(kNumIterations, | 873 EXPECT_EQ(kNumIterations, |
| 874 test_receiver_audio_callback_->number_times_called()); | 874 test_receiver_audio_callback_->number_times_called()); |
| 875 } | 875 } |
| 876 | 876 |
| 877 // This tests start sending audio and video at start-up time before the receiver | 877 // This tests start sending audio and video at start-up time before the receiver |
| 878 // is ready; it sends 2 frames before the receiver comes online. | 878 // is ready; it sends 2 frames before the receiver comes online. |
| 879 // | 879 // |
| 880 // Test disabled due to flakiness: It appears that the RTCP synchronization | 880 // Test disabled due to flakiness: It appears that the RTCP synchronization |
| 881 // sometimes kicks in, and sometimes doesn't. When it does, there's a sharp | 881 // sometimes kicks in, and sometimes doesn't. When it does, there's a sharp |
| 882 // discontinuity in the timeline, throwing off the test expectations. See TODOs | 882 // discontinuity in the timeline, throwing off the test expectations. See TODOs |
| 883 // in audio_receiver.cc for likely cause(s) of this bug. | 883 // in audio_receiver.cc for likely cause(s) of this bug. |
| 884 // http://crbug.com/356942 | 884 // http://crbug.com/356942 |
| 885 TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) { | 885 TEST_F(End2EndTest, DISABLED_StartSenderBeforeReceiver) { |
| 886 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, | 886 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, |
| 887 kDefaultAudioSamplingRate, 1); | 887 kDefaultAudioSamplingRate, 1); |
| 888 Create(); | 888 Create(); |
| 889 | 889 |
| 890 int video_start = kVideoStart; | 890 int video_start = kVideoStart; |
| 891 int audio_diff = kFrameTimerMs; | 891 int audio_diff = kFrameTimerMs; |
| 892 | 892 |
| 893 sender_to_receiver_.SetSendPackets(false); | 893 sender_to_receiver_.SetSendPackets(false); |
| 894 | 894 |
| 895 const int test_delay_ms = 100; | 895 const int test_delay_ms = 100; |
| 896 | 896 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 } | 965 } |
| 966 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 966 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 967 EXPECT_EQ(num_audio_frames_requested, | 967 EXPECT_EQ(num_audio_frames_requested, |
| 968 test_receiver_audio_callback_->number_times_called()); | 968 test_receiver_audio_callback_->number_times_called()); |
| 969 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called()); | 969 EXPECT_EQ(10, test_receiver_video_callback_->number_times_called()); |
| 970 } | 970 } |
| 971 | 971 |
| 972 // This tests a network glitch lasting for 10 video frames. | 972 // This tests a network glitch lasting for 10 video frames. |
| 973 // Flaky. See crbug.com/351596. | 973 // Flaky. See crbug.com/351596. |
| 974 TEST_F(End2EndTest, DISABLED_GlitchWith3Buffers) { | 974 TEST_F(End2EndTest, DISABLED_GlitchWith3Buffers) { |
| 975 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_OPUS, | 975 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS, |
| 976 kDefaultAudioSamplingRate, 3); | 976 kDefaultAudioSamplingRate, 3); |
| 977 video_sender_config_.target_playout_delay = | 977 video_sender_config_.target_playout_delay = |
| 978 base::TimeDelta::FromMilliseconds(67); | 978 base::TimeDelta::FromMilliseconds(67); |
| 979 video_receiver_config_.rtp_max_delay_ms = 67; | 979 video_receiver_config_.rtp_max_delay_ms = 67; |
| 980 Create(); | 980 Create(); |
| 981 | 981 |
| 982 int video_start = kVideoStart; | 982 int video_start = kVideoStart; |
| 983 base::TimeTicks capture_time; | 983 base::TimeTicks capture_time; |
| 984 // Frames will rendered on completion until the render time stabilizes, i.e. | 984 // Frames will rendered on completion until the render time stabilizes, i.e. |
| 985 // we got enough data. | 985 // we got enough data. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 1030 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
| 1031 test_receiver_video_callback_)); | 1031 test_receiver_video_callback_)); |
| 1032 | 1032 |
| 1033 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. | 1033 RunTasks(2 * kFrameTimerMs + 1); // Empty the receiver pipeline. |
| 1034 EXPECT_EQ(frames_before_glitch + 1, | 1034 EXPECT_EQ(frames_before_glitch + 1, |
| 1035 test_receiver_video_callback_->number_times_called()); | 1035 test_receiver_video_callback_->number_times_called()); |
| 1036 } | 1036 } |
| 1037 | 1037 |
| 1038 // Disabled due to flakiness and crashiness. http://crbug.com/360951 | 1038 // Disabled due to flakiness and crashiness. http://crbug.com/360951 |
| 1039 TEST_F(End2EndTest, DISABLED_DropEveryOtherFrame3Buffers) { | 1039 TEST_F(End2EndTest, DISABLED_DropEveryOtherFrame3Buffers) { |
| 1040 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_OPUS, | 1040 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_OPUS, |
| 1041 kDefaultAudioSamplingRate, 3); | 1041 kDefaultAudioSamplingRate, 3); |
| 1042 video_sender_config_.target_playout_delay = | 1042 video_sender_config_.target_playout_delay = |
| 1043 base::TimeDelta::FromMilliseconds(67); | 1043 base::TimeDelta::FromMilliseconds(67); |
| 1044 video_receiver_config_.rtp_max_delay_ms = 67; | 1044 video_receiver_config_.rtp_max_delay_ms = 67; |
| 1045 Create(); | 1045 Create(); |
| 1046 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); | 1046 sender_to_receiver_.DropAllPacketsBelongingToOddFrames(); |
| 1047 | 1047 |
| 1048 int video_start = kVideoStart; | 1048 int video_start = kVideoStart; |
| 1049 base::TimeTicks capture_time; | 1049 base::TimeTicks capture_time; |
| 1050 | 1050 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1070 } | 1070 } |
| 1071 RunTasks(kFrameTimerMs); | 1071 RunTasks(kFrameTimerMs); |
| 1072 video_start++; | 1072 video_start++; |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1075 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1076 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called()); | 1076 EXPECT_EQ(i / 2, test_receiver_video_callback_->number_times_called()); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 TEST_F(End2EndTest, CryptoVideo) { | 1079 TEST_F(End2EndTest, CryptoVideo) { |
| 1080 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 1080 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 1081 | 1081 |
| 1082 video_sender_config_.aes_iv_mask = | 1082 video_sender_config_.aes_iv_mask = |
| 1083 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); | 1083 ConvertFromBase16String("1234567890abcdeffedcba0987654321"); |
| 1084 video_sender_config_.aes_key = | 1084 video_sender_config_.aes_key = |
| 1085 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); | 1085 ConvertFromBase16String("deadbeefcafeb0b0b0b0cafedeadbeef"); |
| 1086 | 1086 |
| 1087 video_receiver_config_.aes_iv_mask = | 1087 video_receiver_config_.aes_iv_mask = |
| 1088 video_sender_config_.aes_iv_mask; | 1088 video_sender_config_.aes_iv_mask; |
| 1089 video_receiver_config_.aes_key = | 1089 video_receiver_config_.aes_key = |
| 1090 video_sender_config_.aes_key; | 1090 video_sender_config_.aes_key; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1108 cast_receiver_->RequestDecodedVideoFrame( | 1108 cast_receiver_->RequestDecodedVideoFrame( |
| 1109 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, | 1109 base::Bind(&TestReceiverVideoCallback::CheckVideoFrame, |
| 1110 test_receiver_video_callback_)); | 1110 test_receiver_video_callback_)); |
| 1111 } | 1111 } |
| 1112 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1112 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1113 EXPECT_EQ(frames_counter, | 1113 EXPECT_EQ(frames_counter, |
| 1114 test_receiver_video_callback_->number_times_called()); | 1114 test_receiver_video_callback_->number_times_called()); |
| 1115 } | 1115 } |
| 1116 | 1116 |
| 1117 TEST_F(End2EndTest, CryptoAudio) { | 1117 TEST_F(End2EndTest, CryptoAudio) { |
| 1118 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 1118 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 1119 | 1119 |
| 1120 audio_sender_config_.aes_iv_mask = | 1120 audio_sender_config_.aes_iv_mask = |
| 1121 ConvertFromBase16String("abcdeffedcba12345678900987654321"); | 1121 ConvertFromBase16String("abcdeffedcba12345678900987654321"); |
| 1122 audio_sender_config_.aes_key = | 1122 audio_sender_config_.aes_key = |
| 1123 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); | 1123 ConvertFromBase16String("deadbeefcafecafedeadbeefb0b0b0b0"); |
| 1124 | 1124 |
| 1125 audio_receiver_config_.aes_iv_mask = | 1125 audio_receiver_config_.aes_iv_mask = |
| 1126 audio_sender_config_.aes_iv_mask; | 1126 audio_sender_config_.aes_iv_mask; |
| 1127 audio_receiver_config_.aes_key = | 1127 audio_receiver_config_.aes_key = |
| 1128 audio_sender_config_.aes_key; | 1128 audio_sender_config_.aes_key; |
| 1129 | 1129 |
| 1130 Create(); | 1130 Create(); |
| 1131 | 1131 |
| 1132 const int kNumIterations = 3; | 1132 const int kNumIterations = 3; |
| 1133 const int kNumAudioFramesPerIteration = 2; | 1133 const int kNumAudioFramesPerIteration = 2; |
| 1134 for (int i = 0; i < kNumIterations; ++i) { | 1134 for (int i = 0; i < kNumIterations; ++i) { |
| 1135 FeedAudioFrames(kNumAudioFramesPerIteration, true); | 1135 FeedAudioFrames(kNumAudioFramesPerIteration, true); |
| 1136 RunTasks(kNumAudioFramesPerIteration * kAudioFrameDurationMs); | 1136 RunTasks(kNumAudioFramesPerIteration * kAudioFrameDurationMs); |
| 1137 RequestAudioFrames(kNumAudioFramesPerIteration, true); | 1137 RequestAudioFrames(kNumAudioFramesPerIteration, true); |
| 1138 } | 1138 } |
| 1139 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1139 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1140 EXPECT_EQ(kNumIterations * kNumAudioFramesPerIteration, | 1140 EXPECT_EQ(kNumIterations * kNumAudioFramesPerIteration, |
| 1141 test_receiver_audio_callback_->number_times_called()); | 1141 test_receiver_audio_callback_->number_times_called()); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 // Video test without packet loss - tests the logging aspects of the end2end, | 1144 // Video test without packet loss - tests the logging aspects of the end2end, |
| 1145 // but is basically equivalent to LoopNoLossPcm16. | 1145 // but is basically equivalent to LoopNoLossPcm16. |
| 1146 TEST_F(End2EndTest, VideoLogging) { | 1146 TEST_F(End2EndTest, VideoLogging) { |
| 1147 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 1147 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 1148 Create(); | 1148 Create(); |
| 1149 | 1149 |
| 1150 int video_start = kVideoStart; | 1150 int video_start = kVideoStart; |
| 1151 const int num_frames = 5; | 1151 const int num_frames = 5; |
| 1152 for (int i = 0; i < num_frames; ++i) { | 1152 for (int i = 0; i < num_frames; ++i) { |
| 1153 base::TimeTicks capture_time = testing_clock_sender_->NowTicks(); | 1153 base::TimeTicks capture_time = testing_clock_sender_->NowTicks(); |
| 1154 test_receiver_video_callback_->AddExpectedResult( | 1154 test_receiver_video_callback_->AddExpectedResult( |
| 1155 video_start, | 1155 video_start, |
| 1156 video_sender_config_.width, | 1156 video_sender_config_.width, |
| 1157 video_sender_config_.height, | 1157 video_sender_config_.height, |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 | 1261 |
| 1262 // Verify that there were no other events logged with respect to this | 1262 // Verify that there were no other events logged with respect to this |
| 1263 // packet. (i.e. Total event count = expected event count) | 1263 // packet. (i.e. Total event count = expected event count) |
| 1264 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); | 1264 EXPECT_EQ(total_event_count_for_packet, expected_event_count_for_packet); |
| 1265 } | 1265 } |
| 1266 } | 1266 } |
| 1267 | 1267 |
| 1268 // Audio test without packet loss - tests the logging aspects of the end2end, | 1268 // Audio test without packet loss - tests the logging aspects of the end2end, |
| 1269 // but is basically equivalent to LoopNoLossPcm16. | 1269 // but is basically equivalent to LoopNoLossPcm16. |
| 1270 TEST_F(End2EndTest, AudioLogging) { | 1270 TEST_F(End2EndTest, AudioLogging) { |
| 1271 Configure(transport::CODEC_VIDEO_VP8, transport::CODEC_AUDIO_PCM16, 32000, 1); | 1271 Configure(CODEC_VIDEO_VP8, CODEC_AUDIO_PCM16, 32000, 1); |
| 1272 Create(); | 1272 Create(); |
| 1273 | 1273 |
| 1274 int audio_diff = kFrameTimerMs; | 1274 int audio_diff = kFrameTimerMs; |
| 1275 const int kNumVideoFrames = 10; | 1275 const int kNumVideoFrames = 10; |
| 1276 int num_audio_frames_requested = 0; | 1276 int num_audio_frames_requested = 0; |
| 1277 for (int i = 0; i < kNumVideoFrames; ++i) { | 1277 for (int i = 0; i < kNumVideoFrames; ++i) { |
| 1278 const int num_audio_frames = audio_diff / kAudioFrameDurationMs; | 1278 const int num_audio_frames = audio_diff / kAudioFrameDurationMs; |
| 1279 audio_diff -= num_audio_frames * kAudioFrameDurationMs; | 1279 audio_diff -= num_audio_frames * kAudioFrameDurationMs; |
| 1280 | 1280 |
| 1281 FeedAudioFrames(num_audio_frames, true); | 1281 FeedAudioFrames(num_audio_frames, true); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1342 expected_event_count_for_frame += | 1342 expected_event_count_for_frame += |
| 1343 map_it->second.counter[FRAME_ACK_RECEIVED]; | 1343 map_it->second.counter[FRAME_ACK_RECEIVED]; |
| 1344 | 1344 |
| 1345 // Verify that there were no other events logged with respect to this frame. | 1345 // Verify that there were no other events logged with respect to this frame. |
| 1346 // (i.e. Total event count = expected event count) | 1346 // (i.e. Total event count = expected event count) |
| 1347 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); | 1347 EXPECT_EQ(total_event_count_for_frame, expected_event_count_for_frame); |
| 1348 } | 1348 } |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 TEST_F(End2EndTest, BasicFakeSoftwareVideo) { | 1351 TEST_F(End2EndTest, BasicFakeSoftwareVideo) { |
| 1352 Configure(transport::CODEC_VIDEO_FAKE, transport::CODEC_AUDIO_PCM16, 32000, | 1352 Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, |
| 1353 1); | 1353 1); |
| 1354 Create(); | 1354 Create(); |
| 1355 StartBasicPlayer(); | 1355 StartBasicPlayer(); |
| 1356 SetReceiverSkew(1.0, base::TimeDelta::FromMilliseconds(1)); | 1356 SetReceiverSkew(1.0, base::TimeDelta::FromMilliseconds(1)); |
| 1357 | 1357 |
| 1358 // Expect very smooth playout when there is no clock skew. | 1358 // Expect very smooth playout when there is no clock skew. |
| 1359 SetExpectedVideoPlayoutSmoothness( | 1359 SetExpectedVideoPlayoutSmoothness( |
| 1360 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 99 / 100, | 1360 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 99 / 100, |
| 1361 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 101 / 100, | 1361 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 101 / 100, |
| 1362 base::TimeDelta::FromMilliseconds(kFrameTimerMs) / 100); | 1362 base::TimeDelta::FromMilliseconds(kFrameTimerMs) / 100); |
| 1363 | 1363 |
| 1364 int frames_counter = 0; | 1364 int frames_counter = 0; |
| 1365 for (; frames_counter < 1000; ++frames_counter) { | 1365 for (; frames_counter < 1000; ++frames_counter) { |
| 1366 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); | 1366 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); |
| 1367 RunTasks(kFrameTimerMs); | 1367 RunTasks(kFrameTimerMs); |
| 1368 } | 1368 } |
| 1369 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1369 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1370 EXPECT_EQ(1000ul, video_ticks_.size()); | 1370 EXPECT_EQ(1000ul, video_ticks_.size()); |
| 1371 } | 1371 } |
| 1372 | 1372 |
| 1373 TEST_F(End2EndTest, ReceiverClockFast) { | 1373 TEST_F(End2EndTest, ReceiverClockFast) { |
| 1374 Configure(transport::CODEC_VIDEO_FAKE, transport::CODEC_AUDIO_PCM16, 32000, | 1374 Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, |
| 1375 1); | 1375 1); |
| 1376 Create(); | 1376 Create(); |
| 1377 StartBasicPlayer(); | 1377 StartBasicPlayer(); |
| 1378 SetReceiverSkew(2.0, base::TimeDelta::FromMicroseconds(1234567)); | 1378 SetReceiverSkew(2.0, base::TimeDelta::FromMicroseconds(1234567)); |
| 1379 | 1379 |
| 1380 int frames_counter = 0; | 1380 int frames_counter = 0; |
| 1381 for (; frames_counter < 10000; ++frames_counter) { | 1381 for (; frames_counter < 10000; ++frames_counter) { |
| 1382 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); | 1382 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); |
| 1383 RunTasks(kFrameTimerMs); | 1383 RunTasks(kFrameTimerMs); |
| 1384 } | 1384 } |
| 1385 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1385 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1386 EXPECT_EQ(10000ul, video_ticks_.size()); | 1386 EXPECT_EQ(10000ul, video_ticks_.size()); |
| 1387 } | 1387 } |
| 1388 | 1388 |
| 1389 TEST_F(End2EndTest, ReceiverClockSlow) { | 1389 TEST_F(End2EndTest, ReceiverClockSlow) { |
| 1390 Configure(transport::CODEC_VIDEO_FAKE, transport::CODEC_AUDIO_PCM16, 32000, | 1390 Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, |
| 1391 1); | 1391 1); |
| 1392 Create(); | 1392 Create(); |
| 1393 StartBasicPlayer(); | 1393 StartBasicPlayer(); |
| 1394 SetReceiverSkew(0.5, base::TimeDelta::FromMicroseconds(-765432)); | 1394 SetReceiverSkew(0.5, base::TimeDelta::FromMicroseconds(-765432)); |
| 1395 | 1395 |
| 1396 int frames_counter = 0; | 1396 int frames_counter = 0; |
| 1397 for (; frames_counter < 10000; ++frames_counter) { | 1397 for (; frames_counter < 10000; ++frames_counter) { |
| 1398 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); | 1398 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); |
| 1399 RunTasks(kFrameTimerMs); | 1399 RunTasks(kFrameTimerMs); |
| 1400 } | 1400 } |
| 1401 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1401 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1402 EXPECT_EQ(10000ul, video_ticks_.size()); | 1402 EXPECT_EQ(10000ul, video_ticks_.size()); |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 TEST_F(End2EndTest, SmoothPlayoutWithFivePercentClockRateSkew) { | 1405 TEST_F(End2EndTest, SmoothPlayoutWithFivePercentClockRateSkew) { |
| 1406 Configure(transport::CODEC_VIDEO_FAKE, transport::CODEC_AUDIO_PCM16, 32000, | 1406 Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, |
| 1407 1); | 1407 1); |
| 1408 Create(); | 1408 Create(); |
| 1409 StartBasicPlayer(); | 1409 StartBasicPlayer(); |
| 1410 SetReceiverSkew(1.05, base::TimeDelta::FromMilliseconds(-42)); | 1410 SetReceiverSkew(1.05, base::TimeDelta::FromMilliseconds(-42)); |
| 1411 | 1411 |
| 1412 // Expect smooth playout when there is 5% skew. | 1412 // Expect smooth playout when there is 5% skew. |
| 1413 SetExpectedVideoPlayoutSmoothness( | 1413 SetExpectedVideoPlayoutSmoothness( |
| 1414 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 90 / 100, | 1414 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 90 / 100, |
| 1415 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 110 / 100, | 1415 base::TimeDelta::FromMilliseconds(kFrameTimerMs) * 110 / 100, |
| 1416 base::TimeDelta::FromMilliseconds(kFrameTimerMs) / 10); | 1416 base::TimeDelta::FromMilliseconds(kFrameTimerMs) / 10); |
| 1417 | 1417 |
| 1418 int frames_counter = 0; | 1418 int frames_counter = 0; |
| 1419 for (; frames_counter < 10000; ++frames_counter) { | 1419 for (; frames_counter < 10000; ++frames_counter) { |
| 1420 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); | 1420 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); |
| 1421 RunTasks(kFrameTimerMs); | 1421 RunTasks(kFrameTimerMs); |
| 1422 } | 1422 } |
| 1423 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. | 1423 RunTasks(2 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1424 EXPECT_EQ(10000ul, video_ticks_.size()); | 1424 EXPECT_EQ(10000ul, video_ticks_.size()); |
| 1425 } | 1425 } |
| 1426 | 1426 |
| 1427 TEST_F(End2EndTest, EvilNetwork) { | 1427 TEST_F(End2EndTest, EvilNetwork) { |
| 1428 Configure(transport::CODEC_VIDEO_FAKE, transport::CODEC_AUDIO_PCM16, 32000, | 1428 Configure(CODEC_VIDEO_FAKE, CODEC_AUDIO_PCM16, 32000, |
| 1429 1); | 1429 1); |
| 1430 receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass()); | 1430 receiver_to_sender_.SetPacketPipe(test::EvilNetwork().Pass()); |
| 1431 sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass()); | 1431 sender_to_receiver_.SetPacketPipe(test::EvilNetwork().Pass()); |
| 1432 Create(); | 1432 Create(); |
| 1433 StartBasicPlayer(); | 1433 StartBasicPlayer(); |
| 1434 | 1434 |
| 1435 int frames_counter = 0; | 1435 int frames_counter = 0; |
| 1436 for (; frames_counter < 10000; ++frames_counter) { | 1436 for (; frames_counter < 10000; ++frames_counter) { |
| 1437 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); | 1437 SendFakeVideoFrame(testing_clock_sender_->NowTicks()); |
| 1438 RunTasks(kFrameTimerMs); | 1438 RunTasks(kFrameTimerMs); |
| 1439 } | 1439 } |
| 1440 base::TimeTicks test_end = testing_clock_receiver_->NowTicks(); | 1440 base::TimeTicks test_end = testing_clock_receiver_->NowTicks(); |
| 1441 RunTasks(100 * kFrameTimerMs + 1); // Empty the pipeline. | 1441 RunTasks(100 * kFrameTimerMs + 1); // Empty the pipeline. |
| 1442 EXPECT_GT(video_ticks_.size(), 100ul); | 1442 EXPECT_GT(video_ticks_.size(), 100ul); |
| 1443 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000); | 1443 EXPECT_LT((video_ticks_.back().second - test_end).InMilliseconds(), 1000); |
| 1444 } | 1444 } |
| 1445 | 1445 |
| 1446 // TODO(pwestin): Add repeatable packet loss test. | 1446 // TODO(pwestin): Add repeatable packet loss test. |
| 1447 // TODO(pwestin): Add test for misaligned send get calls. | 1447 // TODO(pwestin): Add test for misaligned send get calls. |
| 1448 // TODO(pwestin): Add more tests that does not resample. | 1448 // TODO(pwestin): Add more tests that does not resample. |
| 1449 // TODO(pwestin): Add test when we have starvation for our RunTask. | 1449 // TODO(pwestin): Add test when we have starvation for our RunTask. |
| 1450 | 1450 |
| 1451 } // namespace cast | 1451 } // namespace cast |
| 1452 } // namespace media | 1452 } // namespace media |
| OLD | NEW |