Home | History | Annotate | Download | only in base
      1 /*
      2  *  Copyright 2004 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_BASE_RATETRACKER_H_
     12 #define WEBRTC_BASE_RATETRACKER_H_
     13 
     14 #include <stdlib.h>
     15 #include "webrtc/base/basictypes.h"
     16 
     17 namespace rtc {
     18 
     19 // Computes instantaneous units per second.
     20 class RateTracker {
     21  public:
     22   RateTracker();
     23   virtual ~RateTracker() {}
     24 
     25   size_t total_units() const;
     26   size_t units_second();
     27   void Update(size_t units);
     28 
     29  protected:
     30   // overrideable for tests
     31   virtual uint32 Time() const;
     32 
     33  private:
     34   size_t total_units_;
     35   size_t units_second_;
     36   uint32 last_units_second_time_;
     37   size_t last_units_second_calc_;
     38 };
     39 
     40 }  // namespace rtc
     41 
     42 #endif  // WEBRTC_BASE_RATETRACKER_H_
     43