QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
StreamWatchdog.h
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <chrono>
5#include <cstdint>
6#include <optional>
7
8#include <QtCore/QtTypes>
9
15{
16public:
17 enum class Stall
18 {
22 };
23
24 struct Result
25 {
27 qint64 silentMs = 0;
28 };
29
30 static qint64 now();
31
34 void start(std::chrono::seconds timeout,
35 std::optional<std::chrono::milliseconds> firstFrameGrace = std::chrono::milliseconds{0});
36
38 quint64 noteSourceFrame(qint64 nowMs);
40 bool noteSinkFrame(qint64 nowMs);
41
44 void noteFrameWithheld(qint64 nowMs);
45
47 void startSinkClock(qint64 nowMs);
48
51 Result check(qint64 nowMs, bool displaying);
52
53private:
54 qint64 _timeoutMs = 0;
56 std::optional<qint64> _firstFrameGraceMs = 0;
57 std::atomic<quint64> _sourceFrames = 0;
58 std::atomic<qint64> _lastSourceFrameMs = 0;
59 std::atomic<qint64> _lastSinkFrameMs = 0;
60 std::atomic<bool> _sinkFrameSeen = false;
61};
bool noteSinkFrame(qint64 nowMs)
Returns true for the first sink frame since startSinkClock().
void start(std::chrono::seconds timeout, std::optional< std::chrono::milliseconds > firstFrameGrace=std::chrono::milliseconds{0})
Result check(qint64 nowMs, bool displaying)
void startSinkClock(qint64 nowMs)
A decoder starts displaying at nowMs: its silence counts from here until the first sink frame.
void noteFrameWithheld(qint64 nowMs)
quint64 noteSourceFrame(qint64 nowMs)
Returns the number of source frames since start().
static qint64 now()
@ Decoder
Displaying, but no frame reached the video sink within twice the timeout.
@ Source
No frame reached the tee within the timeout.
qint64 silentMs
How long the stalled side has gone without a frame.