webrtc_m130/video/quality_convergence_controller.h
Johannes Kron f6a804826c Add QualityConvergenceController to VideoStreamEncoder
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}
2024-07-16 10:20:27 +00:00

49 lines
1.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.
*/
#ifndef VIDEO_QUALITY_CONVERGENCE_CONTROLLER_H_
#define VIDEO_QUALITY_CONVERGENCE_CONTROLLER_H_
#include <memory>
#include <vector>
#include "absl/types/optional.h"
#include "api/field_trials_view.h"
#include "api/video/video_codec_type.h"
#include "video/quality_convergence_monitor.h"
namespace webrtc {
class QualityConvergenceController {
public:
void Initialize(int number_of_layers,
absl::optional<int> static_qp_threshold,
VideoCodecType codec,
const FieldTrialsView& trials);
// Add the supplied `qp` value to the detection window for specified layer.
// `is_refresh_frame` must only be `true` if the corresponding
// video frame is a refresh frame that is used to improve the visual quality.
// Returns `true` if the algorithm has determined that the supplied QP values
// have converged and reached the target quality for this layer.
bool AddSampleAndCheckTargetQuality(int layer_index,
int qp,
bool is_refresh_frame);
private:
bool initialized_ = false;
int number_of_layers_ = 0;
std::vector<std::unique_ptr<QualityConvergenceMonitor>> convergence_monitors_;
};
} // namespace webrtc
#endif // VIDEO_QUALITY_CONVERGENCE_CONTROLLER_H_