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 | |
Henrik Boström | 6205762 | 2020-03-10 19:08:05 +0100 | [diff] [blame] | 11 | #ifndef VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_ |
| 12 | #define VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_ |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 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 | |
Evan Shrubsole | ce0a11d | 2020-04-16 11:36:55 +0200 | [diff] [blame^] | 17 | #include "api/video/video_adaptation_reason.h" |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 18 | #include "api/video_codecs/video_encoder.h" |
| 19 | #include "call/adaptation/resource.h" |
| 20 | #include "modules/video_coding/utility/quality_scaler.h" |
| 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Handles interaction with the QualityScaler. |
| 25 | // TODO(hbos): Add unittests specific to this class, it is currently only tested |
Henrik Boström | 6205762 | 2020-03-10 19:08:05 +0100 | [diff] [blame] | 26 | // 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öm | efbec9a | 2020-03-06 10:41:25 +0100 | [diff] [blame] | 29 | // TODO(https://crbug.com/webrtc/11222): Move this class to the |
| 30 | // video/adaptation/ subdirectory. |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 31 | class 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 Shrubsole | ce0a11d | 2020-04-16 11:36:55 +0200 | [diff] [blame^] | 50 | void AdaptUp(VideoAdaptationReason reason) override; |
| 51 | bool AdaptDown(VideoAdaptationReason reason) override; |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 52 | |
Evan Shrubsole | aa6fbc1 | 2020-02-25 16:26:01 +0100 | [diff] [blame] | 53 | std::string name() const override { return "QualityScalerResource"; } |
| 54 | |
Henrik Boström | 0653485 | 2020-02-06 14:27:00 +0100 | [diff] [blame] | 55 | private: |
| 56 | std::unique_ptr<QualityScaler> quality_scaler_; |
| 57 | }; |
| 58 | |
| 59 | } // namespace webrtc |
| 60 | |
Henrik Boström | 6205762 | 2020-03-10 19:08:05 +0100 | [diff] [blame] | 61 | #endif // VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_ |