From 01581da71145d4b9504d12cfad0c988d1fc68654 Mon Sep 17 00:00:00 2001 From: "stefan@webrtc.org" Date: Thu, 4 Sep 2014 06:48:14 +0000 Subject: [PATCH] Fix audio/video sync when FEC is enabled. Also improves the tests by adding a test case for FEC, and running the a/v sync tests with NACK and simulated packet loss. BUG=crbug/374104 R=mflodman@webrtc.org, pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/19209004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7053 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/test/call_test.cc | 2 ++ webrtc/test/call_test.h | 2 ++ webrtc/video/call_perf_tests.cc | 21 ++++++++++++++++++++- webrtc/video/end_to_end_tests.cc | 2 -- webrtc/video/video_send_stream_tests.cc | 4 ---- webrtc/video_engine/vie_receiver.cc | 3 ++- 6 files changed, 26 insertions(+), 8 deletions(-) diff --git a/webrtc/test/call_test.cc b/webrtc/test/call_test.cc index e29b8de9e..ccad7551d 100644 --- a/webrtc/test/call_test.cc +++ b/webrtc/test/call_test.cc @@ -159,6 +159,8 @@ const unsigned int CallTest::kLongTimeoutMs = 120 * 1000; const uint8_t CallTest::kSendPayloadType = 100; const uint8_t CallTest::kFakeSendPayloadType = 125; const uint8_t CallTest::kSendRtxPayloadType = 98; +const uint8_t CallTest::kRedPayloadType = 118; +const uint8_t CallTest::kUlpfecPayloadType = 119; const uint32_t CallTest::kSendRtxSsrcs[kNumSsrcs] = {0xBADCAFD, 0xBADCAFE, 0xBADCAFF}; const uint32_t CallTest::kSendSsrcs[kNumSsrcs] = {0xC0FFED, 0xC0FFEE, 0xC0FFEF}; diff --git a/webrtc/test/call_test.h b/webrtc/test/call_test.h index b390329ef..a03c3bbef 100644 --- a/webrtc/test/call_test.h +++ b/webrtc/test/call_test.h @@ -36,6 +36,8 @@ class CallTest : public ::testing::Test { static const uint8_t kSendPayloadType; static const uint8_t kSendRtxPayloadType; static const uint8_t kFakeSendPayloadType; + static const uint8_t kRedPayloadType; + static const uint8_t kUlpfecPayloadType; static const uint32_t kSendRtxSsrcs[kNumSsrcs]; static const uint32_t kSendSsrcs[kNumSsrcs]; static const uint32_t kReceiverLocalSsrc; diff --git a/webrtc/video/call_perf_tests.cc b/webrtc/video/call_perf_tests.cc index 0eaf310cb..3d1bf7f54 100644 --- a/webrtc/video/call_perf_tests.cc +++ b/webrtc/video/call_perf_tests.cc @@ -48,6 +48,8 @@ namespace webrtc { class CallPerfTest : public test::CallTest { protected: + void TestAudioVideoSync(bool fec); + void TestMinTransmitBitrate(bool pad_to_min_bitrate); void TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, @@ -188,7 +190,7 @@ class VideoRtcpAndSyncObserver : public SyncRtcpObserver, public VideoRenderer { int64_t first_time_in_sync_; }; -TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { +void CallPerfTest::TestAudioVideoSync(bool fec) { class AudioPacketReceiver : public PacketReceiver { public: AudioPacketReceiver(int channel, VoENetwork* voe_network) @@ -229,6 +231,7 @@ TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { FakeNetworkPipe::Config net_config; net_config.queue_delay_ms = 500; + net_config.loss_percent = 5; SyncRtcpObserver audio_observer(net_config); VideoRtcpAndSyncObserver observer(Clock::GetRealTimeClock(), channel, @@ -257,6 +260,14 @@ TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { CreateSendConfig(1); CreateMatchingReceiveConfigs(); + send_config_.rtp.nack.rtp_history_ms = kNackRtpHistoryMs; + if (fec) { + send_config_.rtp.fec.red_payload_type = kRedPayloadType; + send_config_.rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; + receive_configs_[0].rtp.fec.red_payload_type = kRedPayloadType; + receive_configs_[0].rtp.fec.ulpfec_payload_type = kUlpfecPayloadType; + } + receive_configs_[0].rtp.nack.rtp_history_ms = 1000; receive_configs_[0].renderer = &observer; receive_configs_[0].audio_channel_id = channel; @@ -294,6 +305,14 @@ TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { VoiceEngine::Delete(voice_engine); } +TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSync) { + TestAudioVideoSync(false); +} + +TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithFec) { + TestAudioVideoSync(true); +} + void CallPerfTest::TestCaptureNtpTime(const FakeNetworkPipe::Config& net_config, int threshold_ms, int start_time_ms, diff --git a/webrtc/video/end_to_end_tests.cc b/webrtc/video/end_to_end_tests.cc index 11ce64252..114ab65b2 100644 --- a/webrtc/video/end_to_end_tests.cc +++ b/webrtc/video/end_to_end_tests.cc @@ -44,8 +44,6 @@ namespace webrtc { static const unsigned long kSilenceTimeoutMs = 2000; -static const int kRedPayloadType = 118; -static const int kUlpfecPayloadType = 119; class EndToEndTest : public test::CallTest { public: diff --git a/webrtc/video/video_send_stream_tests.cc b/webrtc/video/video_send_stream_tests.cc index 76e9f0f45..b628312a3 100644 --- a/webrtc/video/video_send_stream_tests.cc +++ b/webrtc/video/video_send_stream_tests.cc @@ -311,8 +311,6 @@ TEST_F(VideoSendStreamTest, SwapsI420VideoFrames) { } TEST_F(VideoSendStreamTest, SupportsFec) { - static const int kRedPayloadType = 118; - static const int kUlpfecPayloadType = 119; class FecObserver : public test::SendTest { public: FecObserver() @@ -486,8 +484,6 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format, static const uint32_t start = 90; static const uint32_t stop = 290; - static const int kRedPayloadType = 118; - static const int kUlpfecPayloadType = 119; // Observer that verifies that the expected number of packets and bytes // arrive for each frame size, from start_size to stop_size. class FrameFragmentationTest : public test::SendTest, diff --git a/webrtc/video_engine/vie_receiver.cc b/webrtc/video_engine/vie_receiver.cc index 5d90ac678..a19c4b05e 100644 --- a/webrtc/video_engine/vie_receiver.cc +++ b/webrtc/video_engine/vie_receiver.cc @@ -193,7 +193,8 @@ bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, return false; } header.payload_type_frequency = kVideoPayloadTypeFrequency; - return ReceivePacket(rtp_packet, rtp_packet_length, header, false); + bool in_order = IsPacketInOrder(header); + return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); } void ViEReceiver::ReceivedBWEPacket(