OLD | NEW |
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp); | 54 layers_->PopulateCodecSpecific(base_sync, vp8_info, timestamp); |
55 ASSERT_NE(-1, frame_size_); | 55 ASSERT_NE(-1, frame_size_); |
56 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); | 56 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); |
57 } | 57 } |
58 | 58 |
59 void ConfigureBitrates() { | 59 void ConfigureBitrates() { |
60 vpx_codec_enc_cfg_t vpx_cfg; | 60 vpx_codec_enc_cfg_t vpx_cfg; |
61 memset(&vpx_cfg, 0, sizeof(vpx_codec_enc_cfg_t)); | 61 memset(&vpx_cfg, 0, sizeof(vpx_codec_enc_cfg_t)); |
62 vpx_cfg.rc_min_quantizer = min_qp_; | 62 vpx_cfg.rc_min_quantizer = min_qp_; |
63 vpx_cfg.rc_max_quantizer = max_qp_; | 63 vpx_cfg.rc_max_quantizer = max_qp_; |
64 EXPECT_TRUE(layers_->ConfigureBitrates( | 64 layers_->OnRatesUpdated(kDefaultTl0BitrateKbps, kDefaultTl1BitrateKbps, |
65 kDefaultTl0BitrateKbps, kDefaultTl1BitrateKbps, kFrameRate, &vpx_cfg)); | 65 kFrameRate); |
| 66 layers_->UpdateConfiguration(&vpx_cfg); |
66 frame_size_ = ((vpx_cfg.rc_target_bitrate * 1000) / 8) / kFrameRate; | 67 frame_size_ = ((vpx_cfg.rc_target_bitrate * 1000) / 8) / kFrameRate; |
67 } | 68 } |
68 | 69 |
69 void WithQpLimits(int min_qp, int max_qp) { | 70 void WithQpLimits(int min_qp, int max_qp) { |
70 min_qp_ = min_qp; | 71 min_qp_ = min_qp; |
71 max_qp_ = max_qp; | 72 max_qp_ = max_qp; |
72 } | 73 } |
73 | 74 |
74 int RunGracePeriod() { | 75 int RunGracePeriod() { |
75 int flags = 0; | 76 int flags = 0; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 } | 367 } |
367 } | 368 } |
368 } | 369 } |
369 | 370 |
370 EXPECT_EQ(50, tl0_frames + tl1_frames); | 371 EXPECT_EQ(50, tl0_frames + tl1_frames); |
371 EXPECT_EQ(50, dropped_frames); | 372 EXPECT_EQ(50, dropped_frames); |
372 } | 373 } |
373 | 374 |
374 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL0) { | 375 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL0) { |
375 vpx_codec_enc_cfg_t cfg = GetConfig(); | 376 vpx_codec_enc_cfg_t cfg = GetConfig(); |
376 layers_->ConfigureBitrates(100, 1000, 5, &cfg); | 377 layers_->OnRatesUpdated(100, 1000, 5); |
| 378 layers_->UpdateConfiguration(&cfg); |
377 | 379 |
378 EXPECT_EQ(static_cast<unsigned int>( | 380 EXPECT_EQ(static_cast<unsigned int>( |
379 ScreenshareLayers::kMaxTL0FpsReduction * 100 + 0.5), | 381 ScreenshareLayers::kMaxTL0FpsReduction * 100 + 0.5), |
380 cfg.rc_target_bitrate); | 382 cfg.rc_target_bitrate); |
381 } | 383 } |
382 | 384 |
383 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL1) { | 385 TEST_F(ScreenshareLayerTest, TargetBitrateCappedByTL1) { |
384 vpx_codec_enc_cfg_t cfg = GetConfig(); | 386 vpx_codec_enc_cfg_t cfg = GetConfig(); |
385 layers_->ConfigureBitrates(100, 450, 5, &cfg); | 387 layers_->OnRatesUpdated(100, 450, 5); |
| 388 layers_->UpdateConfiguration(&cfg); |
386 | 389 |
387 EXPECT_EQ(static_cast<unsigned int>( | 390 EXPECT_EQ(static_cast<unsigned int>( |
388 450 / ScreenshareLayers::kAcceptableTargetOvershoot), | 391 450 / ScreenshareLayers::kAcceptableTargetOvershoot), |
389 cfg.rc_target_bitrate); | 392 cfg.rc_target_bitrate); |
390 } | 393 } |
391 | 394 |
392 TEST_F(ScreenshareLayerTest, TargetBitrateBelowTL0) { | 395 TEST_F(ScreenshareLayerTest, TargetBitrateBelowTL0) { |
393 vpx_codec_enc_cfg_t cfg = GetConfig(); | 396 vpx_codec_enc_cfg_t cfg = GetConfig(); |
394 layers_->ConfigureBitrates(100, 100, 5, &cfg); | 397 layers_->OnRatesUpdated(100, 100, 5); |
| 398 layers_->UpdateConfiguration(&cfg); |
395 | 399 |
396 EXPECT_EQ(100U, cfg.rc_target_bitrate); | 400 EXPECT_EQ(100U, cfg.rc_target_bitrate); |
397 } | 401 } |
398 | 402 |
399 TEST_F(ScreenshareLayerTest, EncoderDrop) { | 403 TEST_F(ScreenshareLayerTest, EncoderDrop) { |
400 ConfigureBitrates(); | 404 ConfigureBitrates(); |
401 CodecSpecificInfoVP8 vp8_info; | 405 CodecSpecificInfoVP8 vp8_info; |
402 vpx_codec_enc_cfg_t cfg = GetConfig(); | 406 vpx_codec_enc_cfg_t cfg = GetConfig(); |
403 | 407 |
404 uint32_t timestamp = RunGracePeriod(); | 408 uint32_t timestamp = RunGracePeriod(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp)); | 450 EXPECT_EQ(cfg.rc_max_quantizer, static_cast<unsigned int>(kDefaultQp)); |
447 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); | 451 layers_->FrameEncoded(frame_size_, timestamp, kDefaultQp); |
448 } | 452 } |
449 | 453 |
450 TEST_F(ScreenshareLayerTest, RespectsMaxIntervalBetweenFrames) { | 454 TEST_F(ScreenshareLayerTest, RespectsMaxIntervalBetweenFrames) { |
451 const int kLowBitrateKbps = 50; | 455 const int kLowBitrateKbps = 50; |
452 const int kLargeFrameSizeBytes = 100000; | 456 const int kLargeFrameSizeBytes = 100000; |
453 const uint32_t kStartTimestamp = 1234; | 457 const uint32_t kStartTimestamp = 1234; |
454 | 458 |
455 vpx_codec_enc_cfg_t cfg = GetConfig(); | 459 vpx_codec_enc_cfg_t cfg = GetConfig(); |
456 layers_->ConfigureBitrates(kLowBitrateKbps, kLowBitrateKbps, 5, &cfg); | 460 layers_->OnRatesUpdated(kLowBitrateKbps, kLowBitrateKbps, 5); |
| 461 layers_->UpdateConfiguration(&cfg); |
457 | 462 |
458 EXPECT_EQ(ScreenshareLayers::kTl0Flags, | 463 EXPECT_EQ(ScreenshareLayers::kTl0Flags, |
459 layers_->EncodeFlags(kStartTimestamp)); | 464 layers_->EncodeFlags(kStartTimestamp)); |
460 layers_->FrameEncoded(kLargeFrameSizeBytes, kStartTimestamp, kDefaultQp); | 465 layers_->FrameEncoded(kLargeFrameSizeBytes, kStartTimestamp, kDefaultQp); |
461 | 466 |
462 const uint32_t kTwoSecondsLater = | 467 const uint32_t kTwoSecondsLater = |
463 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90); | 468 kStartTimestamp + (ScreenshareLayers::kMaxFrameIntervalMs * 90); |
464 | 469 |
465 // Sanity check, repayment time should exceed kMaxFrameIntervalMs. | 470 // Sanity check, repayment time should exceed kMaxFrameIntervalMs. |
466 ASSERT_GT(kStartTimestamp + 90 * (kLargeFrameSizeBytes * 8) / kLowBitrateKbps, | 471 ASSERT_GT(kStartTimestamp + 90 * (kLargeFrameSizeBytes * 8) / kLowBitrateKbps, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.Qp", kTl1Qp)); | 550 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.Qp", kTl1Qp)); |
546 EXPECT_EQ(1, | 551 EXPECT_EQ(1, |
547 metrics::NumEvents("WebRTC.Video.Screenshare.Layer0.TargetBitrate", | 552 metrics::NumEvents("WebRTC.Video.Screenshare.Layer0.TargetBitrate", |
548 kDefaultTl0BitrateKbps)); | 553 kDefaultTl0BitrateKbps)); |
549 EXPECT_EQ(1, | 554 EXPECT_EQ(1, |
550 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.TargetBitrate", | 555 metrics::NumEvents("WebRTC.Video.Screenshare.Layer1.TargetBitrate", |
551 kDefaultTl1BitrateKbps)); | 556 kDefaultTl1BitrateKbps)); |
552 } | 557 } |
553 | 558 |
554 } // namespace webrtc | 559 } // namespace webrtc |
OLD | NEW |