Remove unused functions in VCMTiming.
Remove VCMTiming::EnoughTimeToDecode, VCMTiming::ResetDecodeTime.
Make VCMTiming::StopDecodeTimer void (always returning zero).
Update ReceiverTiming.WrapAround test to insert timestamp that wraps.
Bug: none
Change-Id: I85a8bfd6be18371810b638284b4af73a46894be7
Reviewed-on: https://webrtc-review.googlesource.com/36060
Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
Commit-Queue: Åsa Persson <asapersson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21660}
diff --git a/modules/video_coding/timing_unittest.cc b/modules/video_coding/timing_unittest.cc
index 40c9f1f..b9397ea 100644
--- a/modules/video_coding/timing_unittest.cc
+++ b/modules/video_coding/timing_unittest.cc
@@ -8,138 +8,123 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "modules/video_coding/include/video_coding.h"
-#include "modules/video_coding/internal_defines.h"
#include "modules/video_coding/timing.h"
#include "system_wrappers/include/clock.h"
#include "test/gtest.h"
-#include "test/testsupport/fileutils.h"
namespace webrtc {
+namespace {
+const int kFps = 25;
+} // namespace
TEST(ReceiverTiming, Tests) {
SimulatedClock clock(0);
VCMTiming timing(&clock);
- uint32_t waitTime = 0;
- uint32_t jitterDelayMs = 0;
- uint32_t requiredDecodeTimeMs = 0;
- uint32_t timeStamp = 0;
+ timing.Reset();
+
+ uint32_t timestamp = 0;
+ timing.UpdateCurrentDelay(timestamp);
timing.Reset();
- timing.UpdateCurrentDelay(timeStamp);
-
- timing.Reset();
-
- timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds());
- jitterDelayMs = 20;
- timing.SetJitterDelay(jitterDelayMs);
- timing.UpdateCurrentDelay(timeStamp);
+ timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds());
+ uint32_t jitter_delay_ms = 20;
+ timing.SetJitterDelay(jitter_delay_ms);
+ timing.UpdateCurrentDelay(timestamp);
timing.set_render_delay(0);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ uint32_t wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
// First update initializes the render time. Since we have no decode delay
- // we get waitTime = renderTime - now - renderDelay = jitter.
- EXPECT_EQ(jitterDelayMs, waitTime);
+ // we get wait_time_ms = renderTime - now - renderDelay = jitter.
+ EXPECT_EQ(jitter_delay_ms, wait_time_ms);
- jitterDelayMs += VCMTiming::kDelayMaxChangeMsPerS + 10;
- timeStamp += 90000;
+ jitter_delay_ms += VCMTiming::kDelayMaxChangeMsPerS + 10;
+ timestamp += 90000;
clock.AdvanceTimeMilliseconds(1000);
- timing.SetJitterDelay(jitterDelayMs);
- timing.UpdateCurrentDelay(timeStamp);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ timing.SetJitterDelay(jitter_delay_ms);
+ timing.UpdateCurrentDelay(timestamp);
+ wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
// Since we gradually increase the delay we only get 100 ms every second.
- EXPECT_EQ(jitterDelayMs - 10, waitTime);
+ EXPECT_EQ(jitter_delay_ms - 10, wait_time_ms);
- timeStamp += 90000;
+ timestamp += 90000;
clock.AdvanceTimeMilliseconds(1000);
- timing.UpdateCurrentDelay(timeStamp);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ timing.UpdateCurrentDelay(timestamp);
+ wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
- EXPECT_EQ(waitTime, jitterDelayMs);
+ EXPECT_EQ(jitter_delay_ms, wait_time_ms);
- // 300 incoming frames without jitter, verify that this gives the exact wait
- // time.
- for (int i = 0; i < 300; i++) {
- clock.AdvanceTimeMilliseconds(1000 / 25);
- timeStamp += 90000 / 25;
- timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds());
+ // Insert frames without jitter, verify that this gives the exact wait time.
+ const int kNumFrames = 300;
+ for (int i = 0; i < kNumFrames; i++) {
+ clock.AdvanceTimeMilliseconds(1000 / kFps);
+ timestamp += 90000 / kFps;
+ timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds());
}
- timing.UpdateCurrentDelay(timeStamp);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ timing.UpdateCurrentDelay(timestamp);
+ wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
- EXPECT_EQ(waitTime, jitterDelayMs);
+ EXPECT_EQ(jitter_delay_ms, wait_time_ms);
- // Add decode time estimates.
- for (int i = 0; i < 10; i++) {
- int64_t startTimeMs = clock.TimeInMilliseconds();
- clock.AdvanceTimeMilliseconds(10);
+ // Add decode time estimates for 1 second.
+ const uint32_t kDecodeTimeMs = 10;
+ for (int i = 0; i < kFps; i++) {
+ clock.AdvanceTimeMilliseconds(kDecodeTimeMs);
timing.StopDecodeTimer(
- timeStamp, clock.TimeInMilliseconds() - startTimeMs,
- clock.TimeInMilliseconds(),
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()));
- timeStamp += 90000 / 25;
- clock.AdvanceTimeMilliseconds(1000 / 25 - 10);
- timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds());
+ timestamp, kDecodeTimeMs, clock.TimeInMilliseconds(),
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()));
+ timestamp += 90000 / kFps;
+ clock.AdvanceTimeMilliseconds(1000 / kFps - kDecodeTimeMs);
+ timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds());
}
- requiredDecodeTimeMs = 10;
- timing.SetJitterDelay(jitterDelayMs);
- clock.AdvanceTimeMilliseconds(1000);
- timeStamp += 90000;
- timing.UpdateCurrentDelay(timeStamp);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ timing.UpdateCurrentDelay(timestamp);
+ wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
- EXPECT_EQ(waitTime, jitterDelayMs);
+ EXPECT_EQ(jitter_delay_ms, wait_time_ms);
- int minTotalDelayMs = 200;
- timing.set_min_playout_delay(minTotalDelayMs);
+ const int kMinTotalDelayMs = 200;
+ timing.set_min_playout_delay(kMinTotalDelayMs);
clock.AdvanceTimeMilliseconds(5000);
- timeStamp += 5 * 90000;
- timing.UpdateCurrentDelay(timeStamp);
+ timestamp += 5 * 90000;
+ timing.UpdateCurrentDelay(timestamp);
const int kRenderDelayMs = 10;
timing.set_render_delay(kRenderDelayMs);
- waitTime = timing.MaxWaitingTime(
- timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()),
+ wait_time_ms = timing.MaxWaitingTime(
+ timing.RenderTimeMs(timestamp, clock.TimeInMilliseconds()),
clock.TimeInMilliseconds());
- // We should at least have minTotalDelayMs - decodeTime (10) - renderTime
+ // We should at least have kMinTotalDelayMs - decodeTime (10) - renderTime
// (10) to wait.
- EXPECT_EQ(waitTime, minTotalDelayMs - requiredDecodeTimeMs - kRenderDelayMs);
+ EXPECT_EQ(kMinTotalDelayMs - kDecodeTimeMs - kRenderDelayMs, wait_time_ms);
// The total video delay should be equal to the min total delay.
- EXPECT_EQ(minTotalDelayMs, timing.TargetVideoDelay());
+ EXPECT_EQ(kMinTotalDelayMs, timing.TargetVideoDelay());
// Reset playout delay.
timing.set_min_playout_delay(0);
clock.AdvanceTimeMilliseconds(5000);
- timeStamp += 5 * 90000;
- timing.UpdateCurrentDelay(timeStamp);
+ timestamp += 5 * 90000;
+ timing.UpdateCurrentDelay(timestamp);
}
TEST(ReceiverTiming, WrapAround) {
- const int kFramerate = 25;
SimulatedClock clock(0);
VCMTiming timing(&clock);
- // Provoke a wrap-around. The forth frame will have wrapped at 25 fps.
- uint32_t timestamp = 0xFFFFFFFFu - 3 * 90000 / kFramerate;
- for (int i = 0; i < 4; ++i) {
+ // Provoke a wrap-around. The fifth frame will have wrapped at 25 fps.
+ uint32_t timestamp = 0xFFFFFFFFu - 3 * 90000 / kFps;
+ for (int i = 0; i < 5; ++i) {
timing.IncomingTimestamp(timestamp, clock.TimeInMilliseconds());
- clock.AdvanceTimeMilliseconds(1000 / kFramerate);
- timestamp += 90000 / kFramerate;
- int64_t render_time =
- timing.RenderTimeMs(0xFFFFFFFFu, clock.TimeInMilliseconds());
- EXPECT_EQ(3 * 1000 / kFramerate, render_time);
- render_time = timing.RenderTimeMs(89u, // One second later in 90 kHz.
- clock.TimeInMilliseconds());
- EXPECT_EQ(3 * 1000 / kFramerate + 1, render_time);
+ clock.AdvanceTimeMilliseconds(1000 / kFps);
+ timestamp += 90000 / kFps;
+ EXPECT_EQ(3 * 1000 / kFps,
+ timing.RenderTimeMs(0xFFFFFFFFu, clock.TimeInMilliseconds()));
+ EXPECT_EQ(3 * 1000 / kFps + 1,
+ timing.RenderTimeMs(89u, // One ms later in 90 kHz.
+ clock.TimeInMilliseconds()));
}
}