libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
st2110vrxmonitor.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
13#include <cstdint>
14#include <promeki/duration.h>
15#include <promeki/namespace.h>
16#include <promeki/timestamp.h>
17
18PROMEKI_NAMESPACE_BEGIN
19
71class St2110VrxMonitor {
72 public:
78 St2110VrxMonitor() = default;
79
114 void configure(uint64_t drainRateBytesPerSec, int64_t vrxFullBytes,
115 int cmaxPackets,
116 const Duration &burstWindow = Duration::fromMicroseconds(5));
117
122 void reset();
123
145 void observePacket(int64_t timestamp, int sizeBytes);
146
148 bool isConfigured() const { return _drainRateBytesPerSec > 0; }
149
151 uint64_t drainRateBytesPerSec() const { return _drainRateBytesPerSec; }
152
154 int64_t vrxFullBytes() const { return _vrxFullBytes; }
155
157 int cmaxPackets() const { return _cmaxPackets; }
158
160 int64_t occupancyBytes() const { return _occupancyBytes; }
161
164 int64_t peakOccupancyBytes() const { return _peakOccupancyBytes; }
165
168 int peakBurstPackets() const { return _peakBurstPackets; }
169
173 int64_t vrxViolations() const { return _vrxViolations; }
174
178 int64_t cmaxViolations() const { return _cmaxViolations; }
179
182 int64_t observedPackets() const { return _observedPackets; }
183
186 int64_t observedBytes() const { return _observedBytes; }
187
195 bool isConformant() const { return _vrxViolations == 0 && _cmaxViolations == 0; }
196
197 private:
198 uint64_t _drainRateBytesPerSec = 0;
199 int64_t _vrxFullBytes = 0;
200 int _cmaxPackets = 0;
201 int64_t _burstWindowNs = 5'000;
202
203 int64_t _occupancyBytes = 0;
204 int64_t _peakOccupancyBytes = 0;
205 int _currentBurstPackets = 0;
206 int _peakBurstPackets = 0;
207 int64_t _vrxViolations = 0;
208 int64_t _cmaxViolations = 0;
209 int64_t _observedPackets = 0;
210 int64_t _observedBytes = 0;
211 int64_t _lastTimestampNs = -1;
212};
213
214PROMEKI_NAMESPACE_END
215
216#endif // PROMEKI_ENABLE_NETWORK