Piping audio interruption metrics to API layer

Bug: webrtc:10549
Change-Id: Ie6abe5819c5b73dc5f5f89bdc375bad77f44ce97
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/134303
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27788}
This commit is contained in:
Henrik Lundin
2019-04-26 14:41:13 +02:00
committed by Commit Bot
parent c35b6e675a
commit 299c4e6846
14 changed files with 48 additions and 15 deletions

View File

@ -135,31 +135,31 @@ TEST(StatisticsCalculator, InterruptionCounter) {
stats.DecodedOutputPlayed();
stats.EndExpandEvent(fs_hz);
auto lts = stats.GetLifetimeStatistics();
EXPECT_EQ(0u, lts.interruption_count);
EXPECT_EQ(0u, lts.total_interruption_duration_ms);
EXPECT_EQ(0, lts.interruption_count);
EXPECT_EQ(0, lts.total_interruption_duration_ms);
// Add an event that is shorter than 150 ms. Should not be logged.
stats.ExpandedVoiceSamples(10 * fs_khz, false); // 10 ms.
stats.ExpandedNoiseSamples(139 * fs_khz, false); // 139 ms.
stats.EndExpandEvent(fs_hz);
lts = stats.GetLifetimeStatistics();
EXPECT_EQ(0u, lts.interruption_count);
EXPECT_EQ(0, lts.interruption_count);
// Add an event that is longer than 150 ms. Should be logged.
stats.ExpandedVoiceSamples(140 * fs_khz, false); // 140 ms.
stats.ExpandedNoiseSamples(11 * fs_khz, false); // 11 ms.
stats.EndExpandEvent(fs_hz);
lts = stats.GetLifetimeStatistics();
EXPECT_EQ(1u, lts.interruption_count);
EXPECT_EQ(151u, lts.total_interruption_duration_ms);
EXPECT_EQ(1, lts.interruption_count);
EXPECT_EQ(151, lts.total_interruption_duration_ms);
// Add one more long event.
stats.ExpandedVoiceSamples(100 * fs_khz, false); // 100 ms.
stats.ExpandedNoiseSamples(5000 * fs_khz, false); // 5000 ms.
stats.EndExpandEvent(fs_hz);
lts = stats.GetLifetimeStatistics();
EXPECT_EQ(2u, lts.interruption_count);
EXPECT_EQ(5100u + 151u, lts.total_interruption_duration_ms);
EXPECT_EQ(2, lts.interruption_count);
EXPECT_EQ(5100 + 151, lts.total_interruption_duration_ms);
}
TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
@ -172,7 +172,7 @@ TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
stats.ExpandedVoiceSamples(151 * fs_khz, false); // 151 ms.
stats.EndExpandEvent(fs_hz);
auto lts = stats.GetLifetimeStatistics();
EXPECT_EQ(0u, lts.interruption_count);
EXPECT_EQ(0, lts.interruption_count);
// Call DecodedOutputPlayed(). Logging should happen after this.
stats.DecodedOutputPlayed();
@ -181,7 +181,7 @@ TEST(StatisticsCalculator, InterruptionCounterDoNotLogBeforeDecoding) {
stats.ExpandedVoiceSamples(151 * fs_khz, false); // 151 ms.
stats.EndExpandEvent(fs_hz);
lts = stats.GetLifetimeStatistics();
EXPECT_EQ(1u, lts.interruption_count);
EXPECT_EQ(1, lts.interruption_count);
}
} // namespace webrtc