QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcSinkCounters.cc
Go to the documentation of this file.
2
3#include <QtCore/QMutexLocker>
4
5#include "GstQgcSinkStats.h"
6
7namespace GstQgc {
8
9quint64 SinkCounters::noteDelivered(HwVideoBufferPath path, bool superseded)
10{
11 {
12 const QMutexLocker locker(&_deliveryMutex);
13 (void) _pathFrames[static_cast<std::size_t>(path)].fetch_add(1, std::memory_order_relaxed);
14 if (superseded) {
15 (void) _superseded.fetch_add(1, std::memory_order_relaxed);
16 }
17 }
18 return _delivered.fetch_add(1, std::memory_order_relaxed) + 1;
19}
20
21void SinkCounters::noteGpuFallback(bool firstOfEpoch)
22{
23 (void) _gpuFallbacks.fetch_add(1, std::memory_order_relaxed);
24 if (firstOfEpoch) {
25 (void) _streamDemotions.fetch_add(1, std::memory_order_relaxed);
26 }
27}
28
29GstStructure* SinkCounters::frameStats() const
30{
31 GstStructure* const stats = gst_structure_new_empty("qgc-video-sink-stats");
32 gst_structure_set(stats, kGpuFallbacksField, G_TYPE_UINT64,
33 static_cast<guint64>(_gpuFallbacks.load(std::memory_order_relaxed)), kStreamDemotionsField,
34 G_TYPE_UINT64, static_cast<guint64>(_streamDemotions.load(std::memory_order_relaxed)), nullptr);
35 gst_structure_set(stats, kTiledDropsField, G_TYPE_UINT64,
36 static_cast<guint64>(_tiledDrops.load(std::memory_order_relaxed)), nullptr);
37 {
38 const QMutexLocker locker(&_deliveryMutex);
39 for (std::size_t i = 0; i < GstHw::kPathCount; ++i) {
40 gst_structure_set(stats, sinkFramesField(HwVideoBufferPath(i)), G_TYPE_UINT64,
41 static_cast<guint64>(_pathFrames[i].load(std::memory_order_relaxed)), nullptr);
42 }
43 gst_structure_set(stats, kSupersededFramesField, G_TYPE_UINT64,
44 static_cast<guint64>(_superseded.load(std::memory_order_relaxed)), nullptr);
45 }
46 return stats;
47}
48
49} // namespace GstQgc
HwVideoBufferPath
GPU zero-copy path a frame is imported through; None means the frame takes the CPU path.
Definition GstHwTypes.h:7
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).
constexpr std::size_t kPathCount
Definition GstHwTypes.h:33
GstVideoSink that pushes decoded frames into a Qt QVideoSink; sole sink in qgcvideosinkbin....
const char * sinkFramesField(HwVideoBufferPath path)
constexpr const char * kSupersededFramesField
constexpr const char * kGpuFallbacksField
guint64 "frame-stats" field holding the frames a GPU path was tried for but the CPU delivered.
constexpr const char * kStreamDemotionsField
guint64 "frame-stats" field holding the caps epochs that started on a GPU path and fell back to the C...
constexpr const char * kTiledDropsField