Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "webrtc/system_wrappers/include/rtp_to_ntp.h" | 26 #include "webrtc/system_wrappers/include/rtp_to_ntp.h" |
| 27 #include "webrtc/test/call_test.h" | 27 #include "webrtc/test/call_test.h" |
| 28 #include "webrtc/test/direct_transport.h" | 28 #include "webrtc/test/direct_transport.h" |
| 29 #include "webrtc/test/drifting_clock.h" | 29 #include "webrtc/test/drifting_clock.h" |
| 30 #include "webrtc/test/encoder_settings.h" | 30 #include "webrtc/test/encoder_settings.h" |
| 31 #include "webrtc/test/fake_audio_device.h" | 31 #include "webrtc/test/fake_audio_device.h" |
| 32 #include "webrtc/test/fake_decoder.h" | 32 #include "webrtc/test/fake_decoder.h" |
| 33 #include "webrtc/test/fake_encoder.h" | 33 #include "webrtc/test/fake_encoder.h" |
| 34 #include "webrtc/test/frame_generator.h" | 34 #include "webrtc/test/frame_generator.h" |
| 35 #include "webrtc/test/frame_generator_capturer.h" | 35 #include "webrtc/test/frame_generator_capturer.h" |
| 36 #include "webrtc/test/histogram.h" | |
| 36 #include "webrtc/test/rtp_rtcp_observer.h" | 37 #include "webrtc/test/rtp_rtcp_observer.h" |
| 37 #include "webrtc/test/testsupport/fileutils.h" | 38 #include "webrtc/test/testsupport/fileutils.h" |
| 38 #include "webrtc/test/testsupport/perf_test.h" | 39 #include "webrtc/test/testsupport/perf_test.h" |
| 39 #include "webrtc/voice_engine/include/voe_base.h" | 40 #include "webrtc/voice_engine/include/voe_base.h" |
| 40 #include "webrtc/voice_engine/include/voe_codec.h" | 41 #include "webrtc/voice_engine/include/voe_codec.h" |
| 41 #include "webrtc/voice_engine/include/voe_network.h" | 42 #include "webrtc/voice_engine/include/voe_network.h" |
| 42 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 43 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 43 #include "webrtc/voice_engine/include/voe_video_sync.h" | 44 #include "webrtc/voice_engine/include/voe_video_sync.h" |
| 44 | 45 |
| 45 using webrtc::test::DriftingClock; | 46 using webrtc::test::DriftingClock; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 if (voe_sync_->GetPlayoutTimestamp(voe_channel_, playout_timestamp) != 0) | 156 if (voe_sync_->GetPlayoutTimestamp(voe_channel_, playout_timestamp) != 0) |
| 156 return; | 157 return; |
| 157 int64_t latest_audio_ntp = | 158 int64_t latest_audio_ntp = |
| 158 audio_observer_->RtpTimestampToNtp(playout_timestamp); | 159 audio_observer_->RtpTimestampToNtp(playout_timestamp); |
| 159 int64_t latest_video_ntp = RtpTimestampToNtp(video_frame.timestamp()); | 160 int64_t latest_video_ntp = RtpTimestampToNtp(video_frame.timestamp()); |
| 160 if (latest_audio_ntp < 0 || latest_video_ntp < 0) | 161 if (latest_audio_ntp < 0 || latest_video_ntp < 0) |
| 161 return; | 162 return; |
| 162 int time_until_render_ms = | 163 int time_until_render_ms = |
| 163 std::max(0, static_cast<int>(video_frame.render_time_ms() - now_ms)); | 164 std::max(0, static_cast<int>(video_frame.render_time_ms() - now_ms)); |
| 164 latest_video_ntp += time_until_render_ms; | 165 latest_video_ntp += time_until_render_ms; |
| 165 int64_t stream_offset = latest_audio_ntp - latest_video_ntp; | 166 int64_t stream_offset = latest_audio_ntp - latest_video_ntp; |
|
stefan-webrtc
2016/03/04 14:32:17
If you also wire this new metric up to GetStats()
åsapersson
2016/03/09 15:44:35
Done.
| |
| 166 std::stringstream ss; | 167 std::stringstream ss; |
| 167 ss << stream_offset; | 168 ss << stream_offset; |
| 168 webrtc::test::PrintResult("stream_offset", | 169 webrtc::test::PrintResult("stream_offset", |
| 169 "", | 170 "", |
| 170 "synchronization", | 171 "synchronization", |
| 171 ss.str(), | 172 ss.str(), |
| 172 "ms", | 173 "ms", |
| 173 false); | 174 false); |
| 174 int64_t time_since_creation = now_ms - creation_time_ms_; | 175 int64_t time_since_creation = now_ms - creation_time_ms_; |
| 175 // During the first couple of seconds audio and video can falsely be | 176 // During the first couple of seconds audio and video can falsely be |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } | 232 } |
| 232 return ret == 0 ? DELIVERY_OK : DELIVERY_PACKET_ERROR; | 233 return ret == 0 ? DELIVERY_OK : DELIVERY_PACKET_ERROR; |
| 233 } | 234 } |
| 234 | 235 |
| 235 private: | 236 private: |
| 236 int channel_; | 237 int channel_; |
| 237 VoENetwork* voe_network_; | 238 VoENetwork* voe_network_; |
| 238 rtc::scoped_ptr<RtpHeaderParser> parser_; | 239 rtc::scoped_ptr<RtpHeaderParser> parser_; |
| 239 }; | 240 }; |
| 240 | 241 |
| 242 test::ClearHistograms(); | |
| 241 VoiceEngine* voice_engine = VoiceEngine::Create(); | 243 VoiceEngine* voice_engine = VoiceEngine::Create(); |
| 242 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); | 244 VoEBase* voe_base = VoEBase::GetInterface(voice_engine); |
| 243 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); | 245 VoECodec* voe_codec = VoECodec::GetInterface(voice_engine); |
| 244 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); | 246 VoENetwork* voe_network = VoENetwork::GetInterface(voice_engine); |
| 245 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); | 247 VoEVideoSync* voe_sync = VoEVideoSync::GetInterface(voice_engine); |
| 246 const std::string audio_filename = | 248 const std::string audio_filename = |
| 247 test::ResourcePath("voice_engine/audio_long16", "pcm"); | 249 test::ResourcePath("voice_engine/audio_long16", "pcm"); |
| 248 ASSERT_STRNE("", audio_filename.c_str()); | 250 ASSERT_STRNE("", audio_filename.c_str()); |
| 249 FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), audio_filename, | 251 FakeAudioDevice fake_audio_device(Clock::GetRealTimeClock(), audio_filename, |
| 250 audio_rtp_speed); | 252 audio_rtp_speed); |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 voe_base->DeleteChannel(send_channel_id); | 376 voe_base->DeleteChannel(send_channel_id); |
| 375 voe_base->DeleteChannel(recv_channel_id); | 377 voe_base->DeleteChannel(recv_channel_id); |
| 376 voe_base->Release(); | 378 voe_base->Release(); |
| 377 voe_codec->Release(); | 379 voe_codec->Release(); |
| 378 voe_network->Release(); | 380 voe_network->Release(); |
| 379 voe_sync->Release(); | 381 voe_sync->Release(); |
| 380 | 382 |
| 381 DestroyCalls(); | 383 DestroyCalls(); |
| 382 | 384 |
| 383 VoiceEngine::Delete(voice_engine); | 385 VoiceEngine::Delete(voice_engine); |
| 386 | |
| 387 EXPECT_EQ(1, test::NumHistogramSamples("WebRTC.Video.AVSyncOffsetInMs")); | |
|
stefan-webrtc
2016/03/04 14:32:17
Can we also check that the sync offset is reasonab
åsapersson
2016/03/09 15:44:35
Wired up to and tested through GetStats().
stefan-webrtc
2016/03/09 15:59:30
Thanks a lot!
| |
| 384 } | 388 } |
| 385 | 389 |
| 386 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { | 390 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { |
| 387 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, | 391 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, |
| 388 DriftingClock::PercentsFaster(10.0f), | 392 DriftingClock::PercentsFaster(10.0f), |
| 389 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | 393 DriftingClock::kNoDrift, DriftingClock::kNoDrift); |
| 390 } | 394 } |
| 391 | 395 |
| 392 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { | 396 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { |
| 393 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, | 397 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 776 int encoder_inits_; | 780 int encoder_inits_; |
| 777 uint32_t last_set_bitrate_; | 781 uint32_t last_set_bitrate_; |
| 778 VideoSendStream* send_stream_; | 782 VideoSendStream* send_stream_; |
| 779 VideoEncoderConfig encoder_config_; | 783 VideoEncoderConfig encoder_config_; |
| 780 } test; | 784 } test; |
| 781 | 785 |
| 782 RunBaseTest(&test); | 786 RunBaseTest(&test); |
| 783 } | 787 } |
| 784 | 788 |
| 785 } // namespace webrtc | 789 } // namespace webrtc |
| OLD | NEW |