QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoStreamStatsSampler.cc
Go to the documentation of this file.
2
3#include <utility>
4
5#include "RecordingPlan.h"
6#include "StreamSupervisor.h"
7
9 : _supervisor(supervisor)
10 , _meter(std::move(clock))
11{}
12
14{
15 _meter.reset();
16 return _publish(VideoStreamStats());
17}
18
20 const RecordingPlan* recording)
21{
22 stats.uptimeMs = _supervisor.uptime().count();
23 stats.reconnects = _supervisor.reconnects();
24 const qint64 recordingMs = recording ? recording->recordingMs() : -1;
25 stats.recordingMs = recordingMs;
26 stats.recordingBytes = (recordingMs >= 0) ? recording->bytesWritten() : -1;
27 if (!_meter.update(counters, stats)) {
28 return false;
29 }
30 return _publish(stats);
31}
32
33bool VideoStreamStatsSampler::_publish(const VideoStreamStats& stats)
34{
35 if (stats == _stats) {
36 return false;
37 }
38 _stats = stats;
39 return true;
40}
What a receiver was asked to record, across the sessions reconnects start and the hours it runs for.
qint64 recordingMs(Clock::time_point now=Clock::now()) const
For VideoStreamStats::recordingMs: since the first part got its first frame; -1 before.
qint64 bytesWritten() const
For VideoStreamStats::recordingBytes: what the parts' files held when they closed,...
The reconnect policy both receivers share: the phase a stream is in, when a failed one connects again...
std::function< qint64()> Clock
Monotonic milliseconds.
bool reset()
A session ended: the rates start over and the stats go invalid. True when that changed them.
bool sample(const VideoStreamStatsMeter::Counters &counters, VideoStreamStats stats, const RecordingPlan *recording)
const VideoStreamStats & stats() const
The stats the last sample() or reset() produced.
VideoStreamStatsSampler(const StreamSupervisor &supervisor, VideoStreamStatsMeter::Clock clock={})