blob: 77bb60690f0d644bc90c6dfa1db30099afc1316c [file] [log] [blame]
Henrik Boström06534852020-02-06 14:27:00 +01001/*
2 * Copyright 2020 The WebRTC Project Authors. All rights reserved.
3 *
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
Henrik Boström62057622020-03-10 19:08:05 +010011#ifndef VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_
12#define VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_
Henrik Boström06534852020-02-06 14:27:00 +010013
14#include <memory>
Evan Shrubsoleaa6fbc12020-02-25 16:26:01 +010015#include <string>
Henrik Boström06534852020-02-06 14:27:00 +010016
Evan Shrubsolece0a11d2020-04-16 11:36:55 +020017#include "api/video/video_adaptation_reason.h"
Henrik Boström06534852020-02-06 14:27:00 +010018#include "api/video_codecs/video_encoder.h"
19#include "call/adaptation/resource.h"
20#include "modules/video_coding/utility/quality_scaler.h"
21
22namespace webrtc {
23
24// Handles interaction with the QualityScaler.
25// TODO(hbos): Add unittests specific to this class, it is currently only tested
Henrik Boström62057622020-03-10 19:08:05 +010026// indirectly by usage in the ResourceAdaptationProcessor (which is only tested
27// because of its usage in VideoStreamEncoder); all tests are currently in
28// video_stream_encoder_unittest.cc.
Henrik Boströmefbec9a2020-03-06 10:41:25 +010029// TODO(https://crbug.com/webrtc/11222): Move this class to the
30// video/adaptation/ subdirectory.
Henrik Boström06534852020-02-06 14:27:00 +010031class QualityScalerResource : public Resource,
32 public AdaptationObserverInterface {
33 public:
34 QualityScalerResource();
35
36 bool is_started() const;
37
38 void StartCheckForOveruse(VideoEncoder::QpThresholds qp_thresholds);
39 void StopCheckForOveruse();
40
41 void SetQpThresholds(VideoEncoder::QpThresholds qp_thresholds);
42 bool QpFastFilterLow();
43 void OnEncodeCompleted(const EncodedImage& encoded_image,
44 int64_t time_sent_in_us);
45 void OnFrameDropped(EncodedImageCallback::DropReason reason);
46
47 // AdaptationObserverInterface implementation.
48 // TODO(https://crbug.com/webrtc/11222, 11172): This resource also needs to
49 // signal when its stable to support multi-stream aware modules.
Evan Shrubsolece0a11d2020-04-16 11:36:55 +020050 void AdaptUp(VideoAdaptationReason reason) override;
51 bool AdaptDown(VideoAdaptationReason reason) override;
Henrik Boström06534852020-02-06 14:27:00 +010052
Evan Shrubsoleaa6fbc12020-02-25 16:26:01 +010053 std::string name() const override { return "QualityScalerResource"; }
54
Henrik Boström06534852020-02-06 14:27:00 +010055 private:
56 std::unique_ptr<QualityScaler> quality_scaler_;
57};
58
59} // namespace webrtc
60
Henrik Boström62057622020-03-10 19:08:05 +010061#endif // VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_