8 , _reconnectTimer(this)
10 _reconnectTimer.setSingleShot(
true);
12 _reconnectTimer.setTimerType(Qt::PreciseTimer);
34 return std::max(0, _streamedSessions - 1);
39 return std::chrono::milliseconds(_sinceStreaming.isValid() ? _sinceStreaming.elapsed() : 0);
44 _reconnectTimer.stop();
46 _streamedSessions = 0;
47 _haltedPermanently =
false;
55 _reconnectTimer.stop();
57 _haltedPermanently =
false;
63 _reconnectTimer.stop();
70 if (!_sessionStreamed) {
71 _sessionStreamed =
true;
73 _sinceStreaming.start();
82 _lastFailure = message;
83 if (_sessionStreamed) {
88 if (permanent || !autoReconnect) {
89 _reconnectTimer.stop();
90 _haltedPermanently = permanent;
92 return {.halted =
true};
95 const std::chrono::milliseconds delay = _backoff.next();
96 _reconnectTimer.start(delay);
98 return {.halted =
false, .reconnectDelay = delay};
103 if (!autoReconnect && _reconnectTimer.isActive()) {
104 _reconnectTimer.stop();
105 _haltedPermanently =
false;
109 if (autoReconnect && (_phase ==
Phase::Halted) && !_haltedPermanently) {
118 if (!_reconnectTimer.isActive()) {
121 _reconnectTimer.stop();
126void StreamSupervisor::_setPhase(Phase phase)
128 if (
phase == _phase) {
133 if (
state() != previous) {
138void StreamSupervisor::_endSession()
140 _sessionStreamed =
false;
141 _sinceStreaming.invalidate();
Retry delays that start at an initial value and grow by a factor per attempt, up to a cap.
@ Halted
Turned off while a reconnect was pending: the stream halted.
@ Resumable
Turned on while halted after a failure that wasn't permanent: the halt is lifted.
int reconnects() const
For VideoStreamStats::reconnects: sessions that streamed since startOver(), less the first.
void sessionStreaming()
The session delivers. The first call per session counts it as streamed.
void sessionStarted()
A new session runs.
FailureOutcome sessionFailed(const QString &message, Failure failure, bool autoReconnect)
void reconnectDue()
A failure's backoff has passed, or reconnectNow() cut it short: the receiver starts the next session.
StreamSupervisor(QObject *parent=nullptr, ExponentialBackoff backoff=kDefaultBackoff)
void stop()
The stream isn't wanted (anymore): Idle, without a reconnect.
Failure
Whether another session could fare better than the one that failed.
@ Permanent
It can't: an unsupported stream, a missing plugin.
@ Halted
Given up after a failure, until startOver() or autoReconnect resumes it.
@ Reconnecting
After a failure, until the session that replaces it starts.
@ Streaming
The session delivers.
@ Connecting
A session runs, without data yet.
@ Idle
Not streaming and not about to: not asked to, or before the first session.
std::chrono::milliseconds uptime() const
For VideoStreamStats::uptimeMs: since the current session started streaming; zero while it isn't.
AutoReconnectChange autoReconnectChanged(bool autoReconnect)
The config's autoReconnect became autoReconnect.
VideoReceiver::State state() const
void stateChanged(VideoReceiver::State state)
@ Reconnecting
Waiting out the backoff after a failure.
@ Streaming
Data is arriving.
@ Stopped
Inactive, no URI, or given up after a failure (autoReconnect off).
@ Connecting
Pipeline running, no data yet.