@@ -36,7 +36,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
36
36
timing.set_render_delay (0 );
37
37
uint32_t wait_time_ms = timing.MaxWaitingTime (
38
38
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
39
- clock.TimeInMilliseconds ());
39
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
40
40
// First update initializes the render time. Since we have no decode delay
41
41
// we get wait_time_ms = renderTime - now - renderDelay = jitter.
42
42
EXPECT_EQ (jitter_delay_ms, wait_time_ms);
@@ -48,7 +48,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
48
48
timing.UpdateCurrentDelay (timestamp);
49
49
wait_time_ms = timing.MaxWaitingTime (
50
50
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
51
- clock.TimeInMilliseconds ());
51
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
52
52
// Since we gradually increase the delay we only get 100 ms every second.
53
53
EXPECT_EQ (jitter_delay_ms - 10 , wait_time_ms);
54
54
@@ -57,7 +57,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
57
57
timing.UpdateCurrentDelay (timestamp);
58
58
wait_time_ms = timing.MaxWaitingTime (
59
59
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
60
- clock.TimeInMilliseconds ());
60
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
61
61
EXPECT_EQ (jitter_delay_ms, wait_time_ms);
62
62
63
63
// Insert frames without jitter, verify that this gives the exact wait time.
@@ -70,7 +70,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
70
70
timing.UpdateCurrentDelay (timestamp);
71
71
wait_time_ms = timing.MaxWaitingTime (
72
72
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
73
- clock.TimeInMilliseconds ());
73
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
74
74
EXPECT_EQ (jitter_delay_ms, wait_time_ms);
75
75
76
76
// Add decode time estimates for 1 second.
@@ -85,7 +85,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
85
85
timing.UpdateCurrentDelay (timestamp);
86
86
wait_time_ms = timing.MaxWaitingTime (
87
87
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
88
- clock.TimeInMilliseconds ());
88
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
89
89
EXPECT_EQ (jitter_delay_ms, wait_time_ms);
90
90
91
91
const int kMinTotalDelayMs = 200 ;
@@ -97,7 +97,7 @@ TEST(ReceiverTimingTest, JitterDelay) {
97
97
timing.set_render_delay (kRenderDelayMs );
98
98
wait_time_ms = timing.MaxWaitingTime (
99
99
timing.RenderTimeMs (timestamp, clock.TimeInMilliseconds ()),
100
- clock.TimeInMilliseconds ());
100
+ clock.TimeInMilliseconds (), /* too_many_frames_queued= */ false );
101
101
// We should at least have kMinTotalDelayMs - decodeTime (10) - renderTime
102
102
// (10) to wait.
103
103
EXPECT_EQ (kMinTotalDelayMs - kDecodeTimeMs - kRenderDelayMs , wait_time_ms);
@@ -140,16 +140,26 @@ TEST(ReceiverTimingTest, MaxWaitingTimeIsZeroForZeroRenderTime) {
140
140
for (int i = 0 ; i < 10 ; ++i) {
141
141
clock.AdvanceTimeMilliseconds (kTimeDeltaMs );
142
142
int64_t now_ms = clock.TimeInMilliseconds ();
143
- EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
143
+ EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
144
+ /* too_many_frames_queued=*/ false ),
145
+ 0 );
144
146
}
145
147
// Another frame submitted at the same time also returns a negative max
146
148
// waiting time.
147
149
int64_t now_ms = clock.TimeInMilliseconds ();
148
- EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
150
+ EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
151
+ /* too_many_frames_queued=*/ false ),
152
+ 0 );
149
153
// MaxWaitingTime should be less than zero even if there's a burst of frames.
150
- EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
151
- EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
152
- EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
154
+ EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
155
+ /* too_many_frames_queued=*/ false ),
156
+ 0 );
157
+ EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
158
+ /* too_many_frames_queued=*/ false ),
159
+ 0 );
160
+ EXPECT_LT (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
161
+ /* too_many_frames_queued=*/ false ),
162
+ 0 );
153
163
}
154
164
155
165
TEST (ReceiverTimingTest, MaxWaitingTimeZeroDelayPacingExperiment) {
@@ -168,27 +178,38 @@ TEST(ReceiverTimingTest, MaxWaitingTimeZeroDelayPacingExperiment) {
168
178
for (int i = 0 ; i < 10 ; ++i) {
169
179
clock.AdvanceTimeMilliseconds (kTimeDeltaMs );
170
180
int64_t now_ms = clock.TimeInMilliseconds ();
171
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), 0 );
181
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
182
+ /* too_many_frames_queued=*/ false ),
183
+ 0 );
172
184
timing.SetLastDecodeScheduledTimestamp (now_ms);
173
185
}
174
186
// Another frame submitted at the same time is paced according to the field
175
187
// trial setting.
176
188
int64_t now_ms = clock.TimeInMilliseconds ();
177
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), kMinPacingMs );
189
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
190
+ /* too_many_frames_queued=*/ false ),
191
+ kMinPacingMs );
178
192
// If there's a burst of frames, the wait time is calculated based on next
179
193
// decode time.
180
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), kMinPacingMs );
181
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), kMinPacingMs );
194
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
195
+ /* too_many_frames_queued=*/ false ),
196
+ kMinPacingMs );
197
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
198
+ /* too_many_frames_queued=*/ false ),
199
+ kMinPacingMs );
182
200
// Allow a few ms to pass, this should be subtracted from the MaxWaitingTime.
183
201
constexpr int64_t kTwoMs = 2 ;
184
202
clock.AdvanceTimeMilliseconds (kTwoMs );
185
203
now_ms = clock.TimeInMilliseconds ();
186
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms),
204
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
205
+ /* too_many_frames_queued=*/ false ),
187
206
kMinPacingMs - kTwoMs );
188
207
// A frame is decoded at the current time, the wait time should be restored to
189
208
// pacing delay.
190
209
timing.SetLastDecodeScheduledTimestamp (now_ms);
191
- EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms), kMinPacingMs );
210
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
211
+ /* too_many_frames_queued=*/ false ),
212
+ kMinPacingMs );
192
213
}
193
214
194
215
TEST (ReceiverTimingTest, DefaultMaxWaitingTimeUnaffectedByPacingExperiment) {
@@ -206,16 +227,56 @@ TEST(ReceiverTimingTest, DefaultMaxWaitingTimeUnaffectedByPacingExperiment) {
206
227
int64_t render_time_ms = now_ms + 30 ;
207
228
// Estimate the internal processing delay from the first frame.
208
229
int64_t estimated_processing_delay =
209
- (render_time_ms - now_ms) - timing.MaxWaitingTime (render_time_ms, now_ms);
230
+ (render_time_ms - now_ms) -
231
+ timing.MaxWaitingTime (render_time_ms, now_ms,
232
+ /* too_many_frames_queued=*/ false );
210
233
EXPECT_GT (estimated_processing_delay, 0 );
211
234
212
235
// Any other frame submitted at the same time should be scheduled according to
213
236
// its render time.
214
237
for (int i = 0 ; i < 5 ; ++i) {
215
238
render_time_ms += kTimeDeltaMs ;
216
- EXPECT_EQ (timing.MaxWaitingTime (render_time_ms, now_ms),
239
+ EXPECT_EQ (timing.MaxWaitingTime (render_time_ms, now_ms,
240
+ /* too_many_frames_queued=*/ false ),
217
241
render_time_ms - now_ms - estimated_processing_delay);
218
242
}
219
243
}
220
244
245
+ TEST (ReceiverTiminTest, MaxWaitingTimeReturnsZeroIfTooManyFramesQueuedIsTrue) {
246
+ // The minimum pacing is enabled by a field trial and active if the RTP
247
+ // playout delay header extension is set to min==0.
248
+ constexpr int64_t kMinPacingMs = 3 ;
249
+ test::ScopedFieldTrials override_field_trials (
250
+ " WebRTC-ZeroPlayoutDelay/min_pacing:3ms/" );
251
+ constexpr int64_t kStartTimeUs = 3.15e13 ; // About one year in us.
252
+ constexpr int64_t kTimeDeltaMs = 1000.0 / 60.0 ;
253
+ constexpr int64_t kZeroRenderTimeMs = 0 ;
254
+ SimulatedClock clock (kStartTimeUs );
255
+ VCMTiming timing (&clock);
256
+ timing.Reset ();
257
+ // MaxWaitingTime() returns zero for evenly spaced video frames.
258
+ for (int i = 0 ; i < 10 ; ++i) {
259
+ clock.AdvanceTimeMilliseconds (kTimeDeltaMs );
260
+ int64_t now_ms = clock.TimeInMilliseconds ();
261
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
262
+ /* too_many_frames_queued=*/ false ),
263
+ 0 );
264
+ timing.SetLastDecodeScheduledTimestamp (now_ms);
265
+ }
266
+ // Another frame submitted at the same time is paced according to the field
267
+ // trial setting.
268
+ int64_t now_ms = clock.TimeInMilliseconds ();
269
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
270
+ /* too_many_frames_queued=*/ false ),
271
+ kMinPacingMs );
272
+ // MaxWaitingTime returns 0 even if there's a burst of frames if
273
+ // too_many_frames_queued is set to true.
274
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
275
+ /* too_many_frames_queued=*/ true ),
276
+ 0 );
277
+ EXPECT_EQ (timing.MaxWaitingTime (kZeroRenderTimeMs , now_ms,
278
+ /* too_many_frames_queued=*/ true ),
279
+ 0 );
280
+ }
281
+
221
282
} // namespace webrtc
0 commit comments