quality_scaler_resource.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #ifndef VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_
  11. #define VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_
  12. #include <memory>
  13. #include <queue>
  14. #include <string>
  15. #include "absl/types/optional.h"
  16. #include "api/scoped_refptr.h"
  17. #include "api/video/video_adaptation_reason.h"
  18. #include "api/video_codecs/video_encoder.h"
  19. #include "call/adaptation/degradation_preference_provider.h"
  20. #include "call/adaptation/resource_adaptation_processor_interface.h"
  21. #include "modules/video_coding/utility/quality_scaler.h"
  22. #include "rtc_base/ref_counted_object.h"
  23. #include "rtc_base/task_queue.h"
  24. #include "video/adaptation/video_stream_encoder_resource.h"
  25. namespace webrtc {
  26. // Handles interaction with the QualityScaler.
  27. class QualityScalerResource : public VideoStreamEncoderResource,
  28. public QualityScalerQpUsageHandlerInterface {
  29. public:
  30. static rtc::scoped_refptr<QualityScalerResource> Create();
  31. QualityScalerResource();
  32. ~QualityScalerResource() override;
  33. bool is_started() const;
  34. void StartCheckForOveruse(VideoEncoder::QpThresholds qp_thresholds);
  35. void StopCheckForOveruse();
  36. void SetQpThresholds(VideoEncoder::QpThresholds qp_thresholds);
  37. bool QpFastFilterLow();
  38. void OnEncodeCompleted(const EncodedImage& encoded_image,
  39. int64_t time_sent_in_us);
  40. void OnFrameDropped(EncodedImageCallback::DropReason reason);
  41. // QualityScalerQpUsageHandlerInterface implementation.
  42. void OnReportQpUsageHigh() override;
  43. void OnReportQpUsageLow() override;
  44. private:
  45. std::unique_ptr<QualityScaler> quality_scaler_
  46. RTC_GUARDED_BY(encoder_queue());
  47. };
  48. } // namespace webrtc
  49. #endif // VIDEO_ADAPTATION_QUALITY_SCALER_RESOURCE_H_