Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/modules/video_coding/codecs/vp8/screenshare_layers_unittest.cc

Issue 2578993002: Add frame rate throttling to vp8 screenshare_layers. (Closed)
Patch Set: Don't throttle if target framerate is 0 Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 EXPECT_EQ(1, 570 EXPECT_EQ(1,
571 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.TargetBitrate", 571 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.TargetBitrate",
572 kDefaultTl1BitrateKbps)); 572 kDefaultTl1BitrateKbps));
573 } 573 }
574 574
575 TEST_F(ScreenshareLayerTest, AllowsUpdateConfigBeforeSetRates) { 575 TEST_F(ScreenshareLayerTest, AllowsUpdateConfigBeforeSetRates) {
576 vpx_codec_enc_cfg_t cfg = GetConfig(); 576 vpx_codec_enc_cfg_t cfg = GetConfig();
577 EXPECT_FALSE(layers_->UpdateConfiguration(&cfg)); 577 EXPECT_FALSE(layers_->UpdateConfiguration(&cfg));
578 } 578 }
579 579
580 TEST_F(ScreenshareLayerTest, RespectsConfiguredFramerate) {
581 ConfigureBitrates();
582
583 int64_t kTestSpanMs = 2000;
584 int64_t kFrameIntervalsMs = 1000 / kFrameRate;
585
586 uint32_t timestamp = 1234;
587 int num_input_frames = 0;
588 int num_discarded_frames = 0;
589
590 // Send at regular rate - no drops expected.
591 for (int64_t i = 0; i < kTestSpanMs; i += kFrameIntervalsMs) {
592 if (layers_->EncodeFlags(timestamp) == -1) {
593 ++num_discarded_frames;
594 } else {
595 size_t frame_size_bytes = kDefaultTl0BitrateKbps * kFrameIntervalsMs / 8;
596 layers_->FrameEncoded(frame_size_bytes, timestamp, kDefaultQp);
597 }
598 timestamp += kFrameIntervalsMs * 90;
599 clock_.AdvanceTimeMilliseconds(kFrameIntervalsMs);
600 ++num_input_frames;
601 }
602 EXPECT_EQ(0, num_discarded_frames);
603
604 // Send at twice the configured rate - drop every other frame.
605 num_input_frames = 0;
606 num_discarded_frames = 0;
607 for (int64_t i = 0; i < kTestSpanMs; i += kFrameIntervalsMs / 2) {
608 if (layers_->EncodeFlags(timestamp) == -1) {
609 ++num_discarded_frames;
610 } else {
611 size_t frame_size_bytes = kDefaultTl0BitrateKbps * kFrameIntervalsMs / 8;
612 layers_->FrameEncoded(frame_size_bytes, timestamp, kDefaultQp);
613 }
614 timestamp += kFrameIntervalsMs * 90 / 2;
615 clock_.AdvanceTimeMilliseconds(kFrameIntervalsMs / 2);
616 ++num_input_frames;
617 }
618
619 // Allow for some rounding errors in the measurements.
620 EXPECT_NEAR(num_discarded_frames, num_input_frames / 2, 2);
621 }
580 } // namespace webrtc 622 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698