aggregator
TimestampEstimator.hpp
Go to the documentation of this file.
1 #ifndef AGGREGATOR_TIMESTAMP_ESTIMATOR_HPP
2 #define AGGREGATOR_TIMESTAMP_ESTIMATOR_HPP
3 
4 #include <base/Time.hpp>
5 #include <base/CircularBuffer.hpp>
6 #include <vector>
7 
8 #include <aggregator/TimestampEstimatorStatus.hpp>
9 
10 namespace aggregator
11 {
19  {
25  base::Time m_zero;
26 
28  double m_window;
29 
33  boost::circular_buffer<double> m_samples;
34 
40  double m_last;
41 
49  std::vector<long> m_lost;
50 
54  int m_lost_threshold;
55 
57  int m_lost_total;
58 
63  bool m_got_full_window;
64 
65  double getPeriodInternal() const;
66 
73  double m_base_time_reset;
74 
80  double m_base_time_reset_offset;
81 
95  double m_latency;
96 
100  double m_latency_raw;
101 
108  double m_initial_latency;
109 
111  double m_max_jitter;
112 
114  double m_initial_period;
115 
117  int m_missing_samples_total;
118 
120  unsigned int m_missing_samples;
121 
123  int64_t m_last_index;
124 
126  bool m_have_last_index;
127 
129  base::Time m_last_reference;
130 
134  int m_expected_losses;
135 
139  int m_rejected_expected_losses;
140 
144  int m_expected_loss_timeout;
145 
149  void resetBaseTime(double new_value, double reset_time);
150 
155  void internalReset(double window,
156  double initial_period,
157  double min_latency,
158  int lost_threshold = 2);
159 
164  void pushSample(double time);
165 
166  public:
188  TimestampEstimator(base::Time window,
189  base::Time initial_period,
190  base::Time min_latency,
191  int lost_threshold = 2);
192  TimestampEstimator(base::Time window,
193  base::Time initial_period,
194  int lost_threshold = 2);
195  TimestampEstimator(base::Time window = base::Time(),
196  int lost_threshold = 2);
197 
203  void reset();
204 
207  void reset(base::Time window,
208  int lost_threshold = 2);
209 
212  void reset(base::Time window,
213  base::Time initial_period,
214  int lost_threshold = 2);
215 
220  void reset(base::Time window,
221  base::Time initial_period,
222  base::Time min_latency,
223  int lost_threshold = 2);
224 
226  base::Time update(base::Time ts);
227 
231  base::Time update(base::Time ts, int64_t index);
232 
234  void updateLoss();
235 
237  void updateReference(base::Time ts);
238 
241  base::Time getPeriod() const;
242 
247  void shortenSampleList(double current);
248 
250  int getLostSampleCount() const;
251 
253  bool haveEstimate() const;
254 
258  base::Time getLatency() const;
259 
264  base::Time getMaxJitter() const;
265 
272 
275  void dumpInternalState() const;
276  };
277 }
278 
279 #endif
280 
Definition: TimestampEstimator.hpp:18
int getLostSampleCount() const
Definition: TimestampEstimator.cpp:176
void dumpInternalState() const
Definition: TimestampEstimator.cpp:159
base::Time getPeriod() const
Definition: TimestampEstimator.cpp:103
bool haveEstimate() const
Definition: TimestampEstimator.cpp:451
base::Time getLatency() const
Definition: TimestampEstimator.cpp:478
base::Time update(base::Time ts)
Definition: TimestampEstimator.cpp:250
TimestampEstimatorStatus getStatus() const
Definition: TimestampEstimator.cpp:483
void reset()
Definition: TimestampEstimator.cpp:33
base::Time getMaxJitter() const
void updateLoss()
Definition: TimestampEstimator.cpp:423
void shortenSampleList(double current)
Definition: TimestampEstimator.cpp:179
void updateReference(base::Time ts)
Definition: TimestampEstimator.cpp:429
Definition: TimestampEstimatorStatus.hpp:10
Definition: DetermineSampleTimestamp.hpp:8
TimestampEstimator(base::Time window, base::Time initial_period, base::Time min_latency, int lost_threshold=2)
Definition: TimestampEstimator.cpp:12