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 | 10 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 VideoReceiveStream::Stats stats; | 91 VideoReceiveStream::Stats stats; |
| 92 { | 92 { |
| 93 rtc::CritScope lock(&crit_); | 93 rtc::CritScope lock(&crit_); |
| 94 if (receive_stream_) | 94 if (receive_stream_) |
| 95 stats = receive_stream_->GetStats(); | 95 stats = receive_stream_->GetStats(); |
| 96 } | 96 } |
| 97 if (stats.sync_offset_ms == std::numeric_limits<int>::max()) | 97 if (stats.sync_offset_ms == std::numeric_limits<int>::max()) |
| 98 return; | 98 return; |
| 99 | 99 |
| 100 int64_t now_ms = clock_->TimeInMilliseconds(); | 100 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 101 | |
| 102 sync_offset_ms_list_.push_back(stats.sync_offset_ms); | |
|
stefan-webrtc
2016/06/08 11:02:25
Maybe we should still track this, but track it onl
danilchap
2016/06/08 11:25:16
yes, that make sense (I missed the fact that test
| |
| 103 int64_t time_since_creation = now_ms - creation_time_ms_; | 101 int64_t time_since_creation = now_ms - creation_time_ms_; |
| 104 // During the first couple of seconds audio and video can falsely be | 102 // During the first couple of seconds audio and video can falsely be |
| 105 // estimated as being synchronized. We don't want to trigger on those. | 103 // estimated as being synchronized. We don't want to trigger on those. |
| 106 if (time_since_creation < kStartupTimeMs) | 104 if (time_since_creation < kStartupTimeMs) |
| 107 return; | 105 return; |
| 108 if (std::abs(stats.sync_offset_ms) < kInSyncThresholdMs) { | 106 if (std::abs(stats.sync_offset_ms) < kInSyncThresholdMs) { |
| 109 if (first_time_in_sync_ == -1) { | 107 if (first_time_in_sync_ == -1) { |
| 110 first_time_in_sync_ = now_ms; | 108 first_time_in_sync_ = now_ms; |
| 111 webrtc::test::PrintResult("sync_convergence_time", | 109 webrtc::test::PrintResult("sync_convergence_time", |
| 112 "", | 110 "", |
| 113 "synchronization", | 111 "synchronization", |
| 114 time_since_creation, | 112 time_since_creation, |
| 115 "ms", | 113 "ms", |
| 116 false); | 114 false); |
| 117 } | 115 } |
| 118 if (time_since_creation > kMinRunTimeMs) | 116 if (time_since_creation > kMinRunTimeMs) |
| 119 observation_complete_.Set(); | 117 observation_complete_.Set(); |
| 120 } | 118 } |
| 121 } | 119 } |
| 122 | 120 |
| 123 void set_receive_stream(VideoReceiveStream* receive_stream) { | 121 void set_receive_stream(VideoReceiveStream* receive_stream) { |
| 124 rtc::CritScope lock(&crit_); | 122 rtc::CritScope lock(&crit_); |
| 125 receive_stream_ = receive_stream; | 123 receive_stream_ = receive_stream; |
| 126 } | 124 } |
| 127 | 125 |
| 128 void PrintResults() { | |
| 129 test::PrintResultList("stream_offset", "", "synchronization", | |
| 130 test::ValuesToString(sync_offset_ms_list_), "ms", | |
| 131 false); | |
| 132 } | |
| 133 | |
| 134 private: | 126 private: |
| 135 Clock* const clock_; | 127 Clock* const clock_; |
| 136 const int64_t creation_time_ms_; | 128 const int64_t creation_time_ms_; |
| 137 int64_t first_time_in_sync_; | 129 int64_t first_time_in_sync_; |
| 138 rtc::CriticalSection crit_; | 130 rtc::CriticalSection crit_; |
| 139 VideoReceiveStream* receive_stream_ GUARDED_BY(crit_); | 131 VideoReceiveStream* receive_stream_ GUARDED_BY(crit_); |
| 140 std::vector<int> sync_offset_ms_list_; | |
| 141 }; | 132 }; |
| 142 | 133 |
| 143 void CallPerfTest::TestAudioVideoSync(FecMode fec, | 134 void CallPerfTest::TestAudioVideoSync(FecMode fec, |
| 144 CreateOrder create_first, | 135 CreateOrder create_first, |
| 145 float video_ntp_speed, | 136 float video_ntp_speed, |
| 146 float video_rtp_speed, | 137 float video_rtp_speed, |
| 147 float audio_rtp_speed) { | 138 float audio_rtp_speed) { |
| 148 const char* kSyncGroup = "av_sync"; | 139 const char* kSyncGroup = "av_sync"; |
| 149 const uint32_t kAudioSendSsrc = 1234; | 140 const uint32_t kAudioSendSsrc = 1234; |
| 150 const uint32_t kAudioRecvSsrc = 5678; | 141 const uint32_t kAudioRecvSsrc = 5678; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 | 283 |
| 293 voe_base->DeleteChannel(send_channel_id); | 284 voe_base->DeleteChannel(send_channel_id); |
| 294 voe_base->DeleteChannel(recv_channel_id); | 285 voe_base->DeleteChannel(recv_channel_id); |
| 295 voe_base->Release(); | 286 voe_base->Release(); |
| 296 voe_codec->Release(); | 287 voe_codec->Release(); |
| 297 | 288 |
| 298 DestroyCalls(); | 289 DestroyCalls(); |
| 299 | 290 |
| 300 VoiceEngine::Delete(voice_engine); | 291 VoiceEngine::Delete(voice_engine); |
| 301 | 292 |
| 302 observer.PrintResults(); | |
| 303 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs")); | 293 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs")); |
| 304 } | 294 } |
| 305 | 295 |
| 306 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { | 296 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithVideoNtpDrift) { |
| 307 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, | 297 TestAudioVideoSync(FecMode::kOff, CreateOrder::kAudioFirst, |
| 308 DriftingClock::PercentsFaster(10.0f), | 298 DriftingClock::PercentsFaster(10.0f), |
| 309 DriftingClock::kNoDrift, DriftingClock::kNoDrift); | 299 DriftingClock::kNoDrift, DriftingClock::kNoDrift); |
| 310 } | 300 } |
| 311 | 301 |
| 312 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { | 302 TEST_F(CallPerfTest, PlaysOutAudioAndVideoInSyncWithAudioFasterThanVideoDrift) { |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 694 int encoder_inits_; | 684 int encoder_inits_; |
| 695 uint32_t last_set_bitrate_; | 685 uint32_t last_set_bitrate_; |
| 696 VideoSendStream* send_stream_; | 686 VideoSendStream* send_stream_; |
| 697 VideoEncoderConfig encoder_config_; | 687 VideoEncoderConfig encoder_config_; |
| 698 } test; | 688 } test; |
| 699 | 689 |
| 700 RunBaseTest(&test); | 690 RunBaseTest(&test); |
| 701 } | 691 } |
| 702 | 692 |
| 703 } // namespace webrtc | 693 } // namespace webrtc |
| OLD | NEW |