35 const qint64 nowMs = _clock();
36 if (_lastSampleMs && (nowMs <= *_lastSampleMs)) {
41 _framesDisplayed += statsCounterGrowth(counters.
framesDisplayed, _last.framesDisplayed);
42 _bytesReceived += statsCounterGrowth(counters.
bytesReceived.value_or(0), _last.bytesReceived.value_or(0));
43 const quint64 framesDropped = statsCounterGrowth(counters.
framesDropped, _last.framesDropped);
44 _framesDropped += framesDropped;
45 quint64 packetsReceived = 0;
46 quint64 packetsLost = 0;
49 packetsReceived = statsCounterGrowth(counters.
rtp->packetsReceived, last.
packetsReceived);
50 packetsLost = statsCounterGrowth(counters.
rtp->packetsLost, last.
packetsLost);
51 _packetsLost += packetsLost;
54 const std::optional<qint64> lastSampleMs = std::exchange(_lastSampleMs, nowMs);
56 _window.push_back({.ms = nowMs, .framesDisplayed = _framesDisplayed, .bytesReceived = _bytesReceived});
64 const double seconds =
static_cast<double>(nowMs - *lastSampleMs) / 1000.0;
65 const RatePoint& oldest = _window.front();
66 const double windowSeconds =
static_cast<double>(nowMs - oldest.ms) / 1000.0;
68 stats.
fps =
static_cast<double>(_framesDisplayed - oldest.framesDisplayed) / windowSeconds;
71 ? (
static_cast<double>(_bytesReceived - oldest.bytesReceived) * 8.0 / 1000.0 / windowSeconds)
74 stats.
droppedFps =
static_cast<double>(framesDropped) / seconds;
76 const quint64 packetsDue = packetsReceived + packetsLost;
77 stats.
packetsLost =
static_cast<qint64
>(_packetsLost);
79 (packetsDue > 0) ? (100.0 *
static_cast<double>(packetsLost) /
static_cast<double>(packetsDue)) : 0.0;