QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcSinkCounters.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <atomic>
5#include <gst/gst.h>
6
7#include <QtCore/QMutex>
8
10
11namespace GstQgc {
12
16{
17public:
18 void noteInput() { (void) _input.fetch_add(1, std::memory_order_relaxed); }
19
20 void noteDropped() { (void) _dropped.fetch_add(1, std::memory_order_relaxed); }
21
24 quint64 noteDelivered(HwVideoBufferPath path, bool superseded);
26 void noteGpuFallback(bool firstOfEpoch);
27
29 void noteTiledDrop() { (void) _tiledDrops.fetch_add(1, std::memory_order_relaxed); }
30
31 quint64 input() const { return _input.load(std::memory_order_relaxed); }
32
33 quint64 dropped() const { return _dropped.load(std::memory_order_relaxed); }
34
35 quint64 delivered() const { return _delivered.load(std::memory_order_relaxed); }
36
37 quint64 pathFrames(HwVideoBufferPath path) const
38 {
39 return _pathFrames[static_cast<std::size_t>(path)].load(std::memory_order_relaxed);
40 }
41
43 GstStructure* frameStats() const;
44
45private:
46 std::atomic<quint64> _input{0};
47 std::atomic<quint64> _dropped{0};
48 // Per element, so receivers that each have a sink don't see a shared total.
49 std::atomic<quint64> _delivered{0};
50 std::array<std::atomic<quint64>, GstHw::kPathCount> _pathFrames{};
51 std::atomic<quint64> _gpuFallbacks{0};
52 std::atomic<quint64> _streamDemotions{0};
53 std::atomic<quint64> _tiledDrops{0};
54 std::atomic<quint64> _superseded{0};
55 // Held while a delivery and the frame it superseded are counted, and while frameStats() reads them: its readers
56 // count the frames displayed as those delivered less those superseded, which a snapshot seeing one count without
57 // the other would make fall.
58 mutable QMutex _deliveryMutex;
59};
60
61} // namespace GstQgc
HwVideoBufferPath
GPU zero-copy path a frame is imported through; None means the frame takes the CPU path.
Definition GstHwTypes.h:7
qgcqvideosink's frame accounting: what its frames-input, frames-dropped and frames-delivered properti...
quint64 noteDelivered(HwVideoBufferPath path, bool superseded)
void noteGpuFallback(bool firstOfEpoch)
A GPU path was tried for a frame the CPU delivered; firstOfEpoch: the caps epoch's first,...
GstStructure * frameStats() const
The "frame-stats" property value (transfer-full).
void noteTiledDrop()
A frame in a tiled DMA_DRM layout no GPU path imported and the CPU can't read.
quint64 delivered() const
quint64 pathFrames(HwVideoBufferPath path) const
constexpr std::size_t kPathCount
Definition GstHwTypes.h:33
GstVideoSink that pushes decoded frames into a Qt QVideoSink; sole sink in qgcvideosinkbin....