QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoStreamStatsMeter Class Reference

#include <VideoStreamStatsMeter.h>

Classes

struct  RtpCounters
struct  Counters

Public Types

using Clock = std::function<qint64()>
 Monotonic milliseconds.

Public Member Functions

 VideoStreamStatsMeter (Clock clock={})
 clock defaults to the steady clock.
void reset ()
 A new stream starts: its counters start from zero, and the next update() only sets the baseline for rates.
bool update (const Counters &counters, VideoStreamStats &stats)

Static Public Attributes

static constexpr int kRateWindowIntervals = 3

Detailed Description

Turns a stream's cumulative counters, sampled about once a second, into the rates and totals of VideoStreamStats.

Counters count from the start of the stream. A counter below its previous value (the element counting it was replaced) has restarted from zero, so totals keep growing and rates never go negative.

fps and bitrateKbps average over the last kRateWindowIntervals intervals: frames and packets arrive in bursts, so a one-second count of a steady 15 fps stream reads anywhere from 12 to 18. droppedFps and lossPercent cover the last interval only, as they tell whether the stream degrades now.

Definition at line 19 of file VideoStreamStatsMeter.h.

Member Typedef Documentation

◆ Clock

using VideoStreamStatsMeter::Clock = std::function<qint64()>

Monotonic milliseconds.

Definition at line 25 of file VideoStreamStatsMeter.h.

Constructor & Destructor Documentation

◆ VideoStreamStatsMeter()

VideoStreamStatsMeter::VideoStreamStatsMeter ( Clock clock = {})
explicit

clock defaults to the steady clock.

Definition at line 18 of file VideoStreamStatsMeter.cc.

Member Function Documentation

◆ reset()

void VideoStreamStatsMeter::reset ( )

A new stream starts: its counters start from zero, and the next update() only sets the baseline for rates.

Definition at line 22 of file VideoStreamStatsMeter.cc.

◆ update()

bool VideoStreamStatsMeter::update ( const Counters & counters,
VideoStreamStats & stats )

Fills the fields of stats that counters measure: valid, fps, bitrateKbps (-1 without a byte count), framesDropped, droppedFps, packetsLost and lossPercent (-1 without RTP counters). Returns false, leaving stats alone, for the first sample after reset() and for a sample taken no later than the previous one.

Definition at line 33 of file VideoStreamStatsMeter.cc.

References VideoStreamStats::bitrateKbps, VideoStreamStatsMeter::Counters::bytesReceived, VideoStreamStats::droppedFps, VideoStreamStats::fps, VideoStreamStatsMeter::Counters::framesDisplayed, VideoStreamStats::framesDropped, VideoStreamStatsMeter::Counters::framesDropped, kRateWindowIntervals, VideoStreamStats::lossPercent, VideoStreamStats::packetsLost, VideoStreamStatsMeter::RtpCounters::packetsLost, VideoStreamStatsMeter::RtpCounters::packetsReceived, VideoStreamStatsMeter::Counters::rtp, and VideoStreamStats::valid.

Member Data Documentation

◆ kRateWindowIntervals

int VideoStreamStatsMeter::kRateWindowIntervals = 3
staticconstexpr

Definition at line 22 of file VideoStreamStatsMeter.h.

Referenced by update().


The documentation for this class was generated from the following files: