Chromium Code Reviews

Side by Side Diff: webrtc/video/overuse_frame_detector_unittest.cc

Issue 2772033002: Add content type information to encoded images and corresponding rtp extension header (Closed)
Patch Set: Set EncodedImage content_type from vie_encoder Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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...)
91 return ((options_.low_encode_usage_threshold_percent + 91 return ((options_.low_encode_usage_threshold_percent +
92 options_.high_encode_usage_threshold_percent) / 2.0f) + 0.5; 92 options_.high_encode_usage_threshold_percent) / 2.0f) + 0.5;
93 } 93 }
94 94
95 void InsertAndSendFramesWithInterval(int num_frames, 95 void InsertAndSendFramesWithInterval(int num_frames,
96 int interval_us, 96 int interval_us,
97 int width, 97 int width,
98 int height, 98 int height,
99 int delay_us) { 99 int delay_us) {
100 VideoFrame frame(I420Buffer::Create(width, height), 100 VideoFrame frame(I420Buffer::Create(width, height),
101 webrtc::kVideoRotation_0, 0); 101 webrtc::kVideoRotation_0, webrtc::kVideoContent_Default,
102 0);
102 uint32_t timestamp = 0; 103 uint32_t timestamp = 0;
103 while (num_frames-- > 0) { 104 while (num_frames-- > 0) {
104 frame.set_timestamp(timestamp); 105 frame.set_timestamp(timestamp);
105 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros()); 106 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros());
106 clock_.AdvanceTimeMicros(delay_us); 107 clock_.AdvanceTimeMicros(delay_us);
107 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros()); 108 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros());
108 clock_.AdvanceTimeMicros(interval_us - delay_us); 109 clock_.AdvanceTimeMicros(interval_us - delay_us);
109 timestamp += interval_us * 90 / 1000; 110 timestamp += interval_us * 90 / 1000;
110 } 111 }
111 } 112 }
(...skipping 167 matching lines...)
279 ForceUpdate(kWidth, kHeight); 280 ForceUpdate(kWidth, kHeight);
280 EXPECT_EQ(InitialUsage(), UsagePercent()); 281 EXPECT_EQ(InitialUsage(), UsagePercent());
281 } 282 }
282 283
283 TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) { 284 TEST_F(OveruseFrameDetectorTest, MeasuresMultipleConcurrentSamples) {
284 EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) 285 EXPECT_CALL(*(observer_.get()), AdaptDown(reason_))
285 .Times(testing::AtLeast(1)); 286 .Times(testing::AtLeast(1));
286 static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; 287 static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec;
287 static const size_t kNumFramesEncodingDelay = 3; 288 static const size_t kNumFramesEncodingDelay = 3;
288 VideoFrame frame(I420Buffer::Create(kWidth, kHeight), 289 VideoFrame frame(I420Buffer::Create(kWidth, kHeight),
289 webrtc::kVideoRotation_0, 0); 290 webrtc::kVideoRotation_0, webrtc::kVideoContent_Default, 0);
290 for (size_t i = 0; i < 1000; ++i) { 291 for (size_t i = 0; i < 1000; ++i) {
291 // Unique timestamps. 292 // Unique timestamps.
292 frame.set_timestamp(static_cast<uint32_t>(i)); 293 frame.set_timestamp(static_cast<uint32_t>(i));
293 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros()); 294 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros());
294 clock_.AdvanceTimeMicros(kIntervalUs); 295 clock_.AdvanceTimeMicros(kIntervalUs);
295 if (i > kNumFramesEncodingDelay) { 296 if (i > kNumFramesEncodingDelay) {
296 overuse_detector_->FrameSent( 297 overuse_detector_->FrameSent(
297 static_cast<uint32_t>(i - kNumFramesEncodingDelay), 298 static_cast<uint32_t>(i - kNumFramesEncodingDelay),
298 rtc::TimeMicros()); 299 rtc::TimeMicros());
299 } 300 }
300 overuse_detector_->CheckForOveruse(); 301 overuse_detector_->CheckForOveruse();
301 } 302 }
302 } 303 }
303 304
304 TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) { 305 TEST_F(OveruseFrameDetectorTest, UpdatesExistingSamples) {
305 // >85% encoding time should trigger overuse. 306 // >85% encoding time should trigger overuse.
306 EXPECT_CALL(*(observer_.get()), AdaptDown(reason_)) 307 EXPECT_CALL(*(observer_.get()), AdaptDown(reason_))
307 .Times(testing::AtLeast(1)); 308 .Times(testing::AtLeast(1));
308 static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec; 309 static const int kIntervalUs = 33 * rtc::kNumMicrosecsPerMillisec;
309 static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec; 310 static const int kDelayUs = 30 * rtc::kNumMicrosecsPerMillisec;
310 VideoFrame frame(I420Buffer::Create(kWidth, kHeight), 311 VideoFrame frame(I420Buffer::Create(kWidth, kHeight),
311 webrtc::kVideoRotation_0, 0); 312 webrtc::kVideoRotation_0, webrtc::kVideoContent_Default, 0);
312 uint32_t timestamp = 0; 313 uint32_t timestamp = 0;
313 for (size_t i = 0; i < 1000; ++i) { 314 for (size_t i = 0; i < 1000; ++i) {
314 frame.set_timestamp(timestamp); 315 frame.set_timestamp(timestamp);
315 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros()); 316 overuse_detector_->FrameCaptured(frame, rtc::TimeMicros());
316 // Encode and send first parts almost instantly. 317 // Encode and send first parts almost instantly.
317 clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerMillisec); 318 clock_.AdvanceTimeMicros(rtc::kNumMicrosecsPerMillisec);
318 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros()); 319 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros());
319 // Encode heavier part, resulting in >85% usage total. 320 // Encode heavier part, resulting in >85% usage total.
320 clock_.AdvanceTimeMicros(kDelayUs - rtc::kNumMicrosecsPerMillisec); 321 clock_.AdvanceTimeMicros(kDelayUs - rtc::kNumMicrosecsPerMillisec);
321 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros()); 322 overuse_detector_->FrameSent(timestamp, rtc::TimeMicros());
(...skipping 27 matching lines...)
349 InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight, 350 InsertAndSendFramesWithInterval(1300, kFrameIntervalUs, kWidth, kHeight,
350 kDelayUs1); 351 kDelayUs1);
351 InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight, 352 InsertAndSendFramesWithInterval(1, kFrameIntervalUs, kWidth, kHeight,
352 kDelayUs2); 353 kDelayUs2);
353 }); 354 });
354 355
355 EXPECT_TRUE(event.Wait(10000)); 356 EXPECT_TRUE(event.Wait(10000));
356 } 357 }
357 358
358 } // namespace webrtc 359 } // namespace webrtc
OLDNEW

Powered by Google App Engine