LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/modules/video_coding/utility - quality_scaler.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 2 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 3 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  *  Copyright (c) 2014 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 WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
      12             : #define WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_
      13             : 
      14             : #include <utility>
      15             : 
      16             : #include "webrtc/common_types.h"
      17             : #include "webrtc/video_encoder.h"
      18             : #include "webrtc/base/optional.h"
      19             : #include "webrtc/base/sequenced_task_checker.h"
      20             : #include "webrtc/modules/video_coding/utility/moving_average.h"
      21             : 
      22             : namespace webrtc {
      23             : 
      24             : // An interface for a class that receives scale up/down requests.
      25           0 : class ScalingObserverInterface {
      26             :  public:
      27             :   enum ScaleReason : size_t { kQuality = 0, kCpu = 1 };
      28             :   static const size_t kScaleReasonSize = 2;
      29             :   // Called to signal that we can handle larger frames.
      30             :   virtual void ScaleUp(ScaleReason reason) = 0;
      31             :   // Called to signal that encoder to scale down.
      32             :   virtual void ScaleDown(ScaleReason reason) = 0;
      33             : 
      34             :  protected:
      35           0 :   virtual ~ScalingObserverInterface() {}
      36             : };
      37             : 
      38             : // QualityScaler runs asynchronously and monitors QP values of encoded frames.
      39             : // It holds a reference to a ScalingObserverInterface implementation to signal
      40             : // an intent to scale up or down.
      41             : class QualityScaler {
      42             :  public:
      43             :   // Construct a QualityScaler with a given |observer|.
      44             :   // This starts the quality scaler periodically checking what the average QP
      45             :   // has been recently.
      46             :   QualityScaler(ScalingObserverInterface* observer, VideoCodecType codec_type);
      47             :   // If specific thresholds are desired these can be supplied as |thresholds|.
      48             :   QualityScaler(ScalingObserverInterface* observer,
      49             :                 VideoEncoder::QpThresholds thresholds);
      50             :   virtual ~QualityScaler();
      51             :   // Should be called each time the encoder drops a frame
      52             :   void ReportDroppedFrame();
      53             :   // Inform the QualityScaler of the last seen QP.
      54             :   void ReportQP(int qp);
      55             : 
      56             :   // The following members declared protected for testing purposes
      57             :  protected:
      58             :   QualityScaler(ScalingObserverInterface* observer,
      59             :                 VideoEncoder::QpThresholds thresholds,
      60             :                 int64_t sampling_period);
      61             : 
      62             :  private:
      63             :   class CheckQPTask;
      64             :   void CheckQP();
      65             :   void ClearSamples();
      66             :   void ReportQPLow();
      67             :   void ReportQPHigh();
      68             :   int64_t GetSamplingPeriodMs() const;
      69             : 
      70             :   CheckQPTask* check_qp_task_ GUARDED_BY(&task_checker_);
      71             :   ScalingObserverInterface* const observer_ GUARDED_BY(&task_checker_);
      72             :   rtc::SequencedTaskChecker task_checker_;
      73             : 
      74             :   const int64_t sampling_period_ms_;
      75             :   bool fast_rampup_ GUARDED_BY(&task_checker_);
      76             :   MovingAverage average_qp_ GUARDED_BY(&task_checker_);
      77             :   MovingAverage framedrop_percent_ GUARDED_BY(&task_checker_);
      78             : 
      79             :   VideoEncoder::QpThresholds thresholds_ GUARDED_BY(&task_checker_);
      80             : };
      81             : }  // namespace webrtc
      82             : 
      83             : #endif  // WEBRTC_MODULES_VIDEO_CODING_UTILITY_QUALITY_SCALER_H_

Generated by: LCOV version 1.13