QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoStreamStatsMeter.h
Go to the documentation of this file.
1#pragma once
2
3#include <deque>
4#include <functional>
5#include <optional>
6
7#include <QtCore/QtTypes>
8
10
20{
21public:
22 static constexpr int kRateWindowIntervals = 3;
23
25 using Clock = std::function<qint64()>;
26
28 {
29 quint64 packetsReceived = 0;
30 quint64 packetsLost = 0;
31 };
32
33 struct Counters
34 {
35 quint64 framesDisplayed = 0;
37 std::optional<quint64> bytesReceived;
38 quint64 framesDropped = 0;
40 std::optional<RtpCounters> rtp;
41 };
42
44 explicit VideoStreamStatsMeter(Clock clock = {});
45
47 void reset();
48
52 bool update(const Counters& counters, VideoStreamStats& stats);
53
54private:
56 struct RatePoint
57 {
58 qint64 ms = 0;
59 quint64 framesDisplayed = 0;
60 quint64 bytesReceived = 0;
61 };
62
63 Clock _clock;
64 std::optional<qint64> _lastSampleMs;
65 Counters _last;
66 quint64 _framesDisplayed = 0;
67 quint64 _bytesReceived = 0;
68 quint64 _framesDropped = 0;
69 quint64 _packetsLost = 0;
71 std::deque<RatePoint> _window;
72};
void reset()
A new stream starts: its counters start from zero, and the next update() only sets the baseline for r...
VideoStreamStatsMeter(Clock clock={})
clock defaults to the steady clock.
static constexpr int kRateWindowIntervals
bool update(const Counters &counters, VideoStreamStats &stats)
std::function< qint64()> Clock
Monotonic milliseconds.
std::optional< quint64 > bytesReceived
Only for a backend that counts the bytes it receives: bitrateKbps is -1 without.
std::optional< RtpCounters > rtp
Only for an RTP stream whose packets the backend counts.