OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 11 matching lines...) Expand all Loading... |
22 #include "webrtc/system_wrappers/include/trace.h" | 22 #include "webrtc/system_wrappers/include/trace.h" |
23 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
24 | 24 |
25 namespace webrtc { | 25 namespace webrtc { |
26 | 26 |
27 TEST(ReceiverTiming, Tests) { | 27 TEST(ReceiverTiming, Tests) { |
28 SimulatedClock clock(0); | 28 SimulatedClock clock(0); |
29 VCMTiming timing(&clock); | 29 VCMTiming timing(&clock); |
30 uint32_t waitTime = 0; | 30 uint32_t waitTime = 0; |
31 uint32_t jitterDelayMs = 0; | 31 uint32_t jitterDelayMs = 0; |
32 uint32_t maxDecodeTimeMs = 0; | 32 uint32_t requiredDecodeTimeMs = 0; |
33 uint32_t timeStamp = 0; | 33 uint32_t timeStamp = 0; |
34 | 34 |
35 timing.Reset(); | 35 timing.Reset(); |
36 | 36 |
37 timing.UpdateCurrentDelay(timeStamp); | 37 timing.UpdateCurrentDelay(timeStamp); |
38 | 38 |
39 timing.Reset(); | 39 timing.Reset(); |
40 | 40 |
41 timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds()); | 41 timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds()); |
42 jitterDelayMs = 20; | 42 jitterDelayMs = 20; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 int64_t startTimeMs = clock.TimeInMilliseconds(); | 87 int64_t startTimeMs = clock.TimeInMilliseconds(); |
88 clock.AdvanceTimeMilliseconds(10); | 88 clock.AdvanceTimeMilliseconds(10); |
89 timing.StopDecodeTimer( | 89 timing.StopDecodeTimer( |
90 timeStamp, clock.TimeInMilliseconds() - startTimeMs, | 90 timeStamp, clock.TimeInMilliseconds() - startTimeMs, |
91 clock.TimeInMilliseconds(), | 91 clock.TimeInMilliseconds(), |
92 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds())); | 92 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds())); |
93 timeStamp += 90000 / 25; | 93 timeStamp += 90000 / 25; |
94 clock.AdvanceTimeMilliseconds(1000 / 25 - 10); | 94 clock.AdvanceTimeMilliseconds(1000 / 25 - 10); |
95 timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds()); | 95 timing.IncomingTimestamp(timeStamp, clock.TimeInMilliseconds()); |
96 } | 96 } |
97 maxDecodeTimeMs = 10; | 97 requiredDecodeTimeMs = 10; |
98 timing.SetJitterDelay(jitterDelayMs); | 98 timing.SetJitterDelay(jitterDelayMs); |
99 clock.AdvanceTimeMilliseconds(1000); | 99 clock.AdvanceTimeMilliseconds(1000); |
100 timeStamp += 90000; | 100 timeStamp += 90000; |
101 timing.UpdateCurrentDelay(timeStamp); | 101 timing.UpdateCurrentDelay(timeStamp); |
102 waitTime = timing.MaxWaitingTime( | 102 waitTime = timing.MaxWaitingTime( |
103 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()), | 103 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()), |
104 clock.TimeInMilliseconds()); | 104 clock.TimeInMilliseconds()); |
105 EXPECT_EQ(waitTime, jitterDelayMs); | 105 EXPECT_EQ(waitTime, jitterDelayMs); |
106 | 106 |
107 uint32_t minTotalDelayMs = 200; | 107 uint32_t minTotalDelayMs = 200; |
108 timing.set_min_playout_delay(minTotalDelayMs); | 108 timing.set_min_playout_delay(minTotalDelayMs); |
109 clock.AdvanceTimeMilliseconds(5000); | 109 clock.AdvanceTimeMilliseconds(5000); |
110 timeStamp += 5 * 90000; | 110 timeStamp += 5 * 90000; |
111 timing.UpdateCurrentDelay(timeStamp); | 111 timing.UpdateCurrentDelay(timeStamp); |
112 const int kRenderDelayMs = 10; | 112 const int kRenderDelayMs = 10; |
113 timing.set_render_delay(kRenderDelayMs); | 113 timing.set_render_delay(kRenderDelayMs); |
114 waitTime = timing.MaxWaitingTime( | 114 waitTime = timing.MaxWaitingTime( |
115 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()), | 115 timing.RenderTimeMs(timeStamp, clock.TimeInMilliseconds()), |
116 clock.TimeInMilliseconds()); | 116 clock.TimeInMilliseconds()); |
117 // We should at least have minTotalDelayMs - decodeTime (10) - renderTime | 117 // We should at least have minTotalDelayMs - decodeTime (10) - renderTime |
118 // (10) to wait. | 118 // (10) to wait. |
119 EXPECT_EQ(waitTime, minTotalDelayMs - maxDecodeTimeMs - kRenderDelayMs); | 119 EXPECT_EQ(waitTime, minTotalDelayMs - requiredDecodeTimeMs - kRenderDelayMs); |
120 // The total video delay should be equal to the min total delay. | 120 // The total video delay should be equal to the min total delay. |
121 EXPECT_EQ(minTotalDelayMs, timing.TargetVideoDelay()); | 121 EXPECT_EQ(minTotalDelayMs, timing.TargetVideoDelay()); |
122 | 122 |
123 // Reset playout delay. | 123 // Reset playout delay. |
124 timing.set_min_playout_delay(0); | 124 timing.set_min_playout_delay(0); |
125 clock.AdvanceTimeMilliseconds(5000); | 125 clock.AdvanceTimeMilliseconds(5000); |
126 timeStamp += 5 * 90000; | 126 timeStamp += 5 * 90000; |
127 timing.UpdateCurrentDelay(timeStamp); | 127 timing.UpdateCurrentDelay(timeStamp); |
128 } | 128 } |
129 | 129 |
(...skipping 10 matching lines...) Expand all Loading... |
140 int64_t render_time = | 140 int64_t render_time = |
141 timing.RenderTimeMs(0xFFFFFFFFu, clock.TimeInMilliseconds()); | 141 timing.RenderTimeMs(0xFFFFFFFFu, clock.TimeInMilliseconds()); |
142 EXPECT_EQ(3 * 1000 / kFramerate, render_time); | 142 EXPECT_EQ(3 * 1000 / kFramerate, render_time); |
143 render_time = timing.RenderTimeMs(89u, // One second later in 90 kHz. | 143 render_time = timing.RenderTimeMs(89u, // One second later in 90 kHz. |
144 clock.TimeInMilliseconds()); | 144 clock.TimeInMilliseconds()); |
145 EXPECT_EQ(3 * 1000 / kFramerate + 1, render_time); | 145 EXPECT_EQ(3 * 1000 / kFramerate + 1, render_time); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 } // namespace webrtc | 149 } // namespace webrtc |
OLD | NEW |