libcyberradio  22.01.24
Throttle.hpp
1 #ifndef LCR_STREAM_THROTTLE_H
2 #define LCR_STREAM_THROTTLE_H
3 
4 #include <iostream>
5 #include <unistd.h>
6 #include <chrono>
7 
8 class Throttle {
9 
10 private:
11  unsigned long long sample_rate;
12  double MB_sent;
13  double seconds_elapsed;
14  double target_rate;
15  std::chrono::system_clock clock;
16  std::chrono::time_point<std::chrono::system_clock,std::chrono::nanoseconds> start_time;
17 
18 public:
19  Throttle(double);
20  void throttle(unsigned int bytes_sent);
21 };
22 
23 #endif