Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 11 | #ifndef VIDEO_QUALITY_SCALER_RESOURCE_H_ |
| 12 | #define VIDEO_QUALITY_SCALER_RESOURCE_H_ |
| 13 | |
| 14 | #include <memory> |
Evan Shrubsole | aa6fbc1 | 2020-02-25 16:26:01 +0100 | [diff] [blame] | 15 | #include <string> |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 16 | |
| 17 | #include "api/video_codecs/video_encoder.h" |
| 18 | #include "call/adaptation/resource.h" |
| 19 | #include "modules/video_coding/utility/quality_scaler.h" |
| 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // Handles interaction with the QualityScaler. |
| 24 | // TODO(hbos): Add unittests specific to this class, it is currently only tested |
| 25 | // indirectly by usage in the OveruseFrameDetectorResourceAdaptationModule |
| 26 | // (which is only tested because of its usage in VideoStreamEncoder); all tests |
| 27 | // are currently in video_stream_encoder_unittest.cc. |
Henrik Boström | efbec9a | 2020-03-06 10:41:25 +0100 | [diff] [blame] | 28 | // TODO(https://crbug.com/webrtc/11222): Move this class to the |
| 29 | // video/adaptation/ subdirectory. |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 30 | class QualityScalerResource : public Resource, |
| 31 | public AdaptationObserverInterface { |
| 32 | public: |
| 33 | QualityScalerResource(); |
| 34 | |
| 35 | bool is_started() const; |
| 36 | |
| 37 | void StartCheckForOveruse(VideoEncoder::QpThresholds qp_thresholds); |
| 38 | void StopCheckForOveruse(); |
| 39 | |
| 40 | void SetQpThresholds(VideoEncoder::QpThresholds qp_thresholds); |
| 41 | bool QpFastFilterLow(); |
| 42 | void OnEncodeCompleted(const EncodedImage& encoded_image, |
| 43 | int64_t time_sent_in_us); |
| 44 | void OnFrameDropped(EncodedImageCallback::DropReason reason); |
| 45 | |
| 46 | // AdaptationObserverInterface implementation. |
| 47 | // TODO(https://crbug.com/webrtc/11222, 11172): This resource also needs to |
| 48 | // signal when its stable to support multi-stream aware modules. |
| 49 | void AdaptUp(AdaptReason reason) override; |
| 50 | bool AdaptDown(AdaptReason reason) override; |
| 51 | |
Evan Shrubsole | aa6fbc1 | 2020-02-25 16:26:01 +0100 | [diff] [blame] | 52 | std::string name() const override { return "QualityScalerResource"; } |
| 53 | |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 54 | private: |
| 55 | std::unique_ptr<QualityScaler> quality_scaler_; |
| 56 | }; |
| 57 | |
| 58 | } // namespace webrtc |
| 59 | |
| 60 | #endif // VIDEO_QUALITY_SCALER_RESOURCE_H_ |