QualityConvergenceController is a layer between VideoStreamEncoder and QualityConvergenceMonitor that takes care of the simulcast logic. Bug: chromium:328598314 Change-Id: Iad8a9d9138e69a60fd508a7ef038220947888f0a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/356420 Commit-Queue: Johannes Kron <kron@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42642}
67 lines
2.7 KiB
C++
67 lines
2.7 KiB
C++
|
|
/*
|
|
* Copyright (c) 2024 The WebRTC project authors. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license
|
|
* that can be found in the LICENSE file in the root of the source
|
|
* tree. An additional intellectual property rights grant can be found
|
|
* in the file PATENTS. All contributing project authors may
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
#include "video/quality_convergence_controller.h"
|
|
|
|
#include "test/gtest.h"
|
|
#include "test/scoped_key_value_config.h"
|
|
|
|
namespace webrtc {
|
|
namespace {
|
|
constexpr int kStaticQpThreshold = 15;
|
|
|
|
TEST(QualityConvergenceController, Singlecast) {
|
|
test::ScopedKeyValueConfig field_trials;
|
|
QualityConvergenceController controller;
|
|
controller.Initialize(1, kStaticQpThreshold, kVideoCodecVP8, field_trials);
|
|
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/0, kStaticQpThreshold + 1, /*is_refresh_frame=*/false));
|
|
EXPECT_TRUE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/0, kStaticQpThreshold, /*is_refresh_frame=*/false));
|
|
}
|
|
|
|
TEST(QualityConvergenceController, Simulcast) {
|
|
test::ScopedKeyValueConfig field_trials;
|
|
QualityConvergenceController controller;
|
|
controller.Initialize(2, kStaticQpThreshold, kVideoCodecVP8, field_trials);
|
|
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/0, kStaticQpThreshold + 1, /*is_refresh_frame=*/false));
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/1, kStaticQpThreshold + 1, /*is_refresh_frame=*/false));
|
|
|
|
// Layer 0 reaches target quality.
|
|
EXPECT_TRUE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/0, kStaticQpThreshold, /*is_refresh_frame=*/false));
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/1, kStaticQpThreshold + 1, /*is_refresh_frame=*/false));
|
|
|
|
// Frames are repeated for both layers. Layer 0 still at target quality.
|
|
EXPECT_TRUE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/0, kStaticQpThreshold, /*is_refresh_frame=*/true));
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/1, kStaticQpThreshold + 1, /*is_refresh_frame=*/true));
|
|
}
|
|
|
|
TEST(QualityConvergenceController, InvalidLayerIndex) {
|
|
test::ScopedKeyValueConfig field_trials;
|
|
QualityConvergenceController controller;
|
|
controller.Initialize(2, kStaticQpThreshold, kVideoCodecVP8, field_trials);
|
|
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/-1, kStaticQpThreshold, /*is_refresh_frame=*/false));
|
|
EXPECT_FALSE(controller.AddSampleAndCheckTargetQuality(
|
|
/*layer_index=*/3, kStaticQpThreshold, /*is_refresh_frame=*/false));
|
|
}
|
|
|
|
} // namespace
|
|
} // namespace webrtc
|