QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgc Namespace Reference

GstVideoSink that pushes decoded frames into a Qt QVideoSink; sole sink in qgcvideosinkbin. Streaming-thread vfuncs MUST NOT touch QObject members directly (thread-affinity asserts) — hand off via QMetaObject::invokeMethod / bus messages. More...

Classes

class  BinChain
struct  SinkCapsPolicy
 Everything qgcqvideosink's caps depend on. More...
class  FrameDelivery
 qgcqvideosink's latest-frame-only hand-off to a QVideoSink, on the QVideoSink's thread. More...
struct  GpuBinPreference
 The GPU bin asked for, before the render target is known. More...
class  PathSession
 What qgcqvideosink keeps about the path its frames take through one caps epoch, from set_caps to the next set_caps or stop: the GPU path it resolved, and what is once per epoch, a stream demotion and the tiled-drop warning. Also decides what becomes of a frame that fails to map: dropped, or after a sustained run of failures, an error that ends the stream. More...
struct  RenderTarget
class  SinkCounters
 qgcqvideosink's frame accounting: what its frames-input, frames-dropped and frames-delivered properties report, and the "frame-stats" structure GstQgcSinkStats.h reads. Thread-safe. More...
struct  PathStats
 Formatted per-path frame counts + the total delivered through GPU paths. More...
struct  VideoFormatEntry

Enumerations

enum class  GpuBinMode { Passthrough , GlUpload , DirectDmaBuf , D3D12Convert }
enum class  RenderBackend {
  Unknown , Null , OpenGL , Direct3D11 ,
  Direct3D12 , Metal , Vulkan
}
 Graphics API Qt Quick renders the video with, which decides the GPU memory qgcqvideosink can import. More...

Functions

bool populateAllocationQuery (GstQuery *query)
std::string buildSinkCaps (const SinkCapsPolicy &policy)
GpuBinPreference parseGpuBinPreference (QByteArrayView value)
GpuBinPreference gpuBinPreference ()
 parseGpuBinPreference() of QGC_GST_GPU_BIN, read and logged on the first call.
GpuBinMode selectGpuBin (GpuBinPreference preference, const RenderTarget &target) noexcept
const char * gpuBinName (GpuBinMode mode) noexcept
bool converterSuitsRenderTarget (const char *pluginName, const char *factoryName, const RenderTarget &target) noexcept
void configureSinkCaps (GstElement *sink, GpuBinMode gpuBin, bool squarePixels)
RenderTarget currentRenderTarget ()
const char * toString (RenderBackend backend) noexcept
const char * zeroCopyPathName (RenderBackend backend) noexcept
const char * sinkFramesField (HwVideoBufferPath path)
GStreamer::GstStructurePtr frameStats (GstElement *sinkOrBin)
 The "frame-stats" of sinkOrBin, a qgcqvideosink or the qgcvideosinkbin around one; null for other elements.
PathStats formatSinkStats (const GstStructure *stats, const GstStructure *since)
quint64 frameStatsField (const GstStructure *stats, const char *field) noexcept
 The guint64 field of stats, a "frame-stats" or any other structure; 0 without the structure or the field.
quint64 frameStatsGrowth (const GstStructure *stats, const GstStructure *since, const char *field) noexcept
 How far the guint64 field grew from since to stats, two "frame-stats" values of the same sink.
std::vector< GstVideoFormat > advertisedFormats (unsigned requiredOffers=0)
 The advertised formats carrying every flag in requiredOffers, in table order.
std::string advertisedFormatList (unsigned requiredOffers=0)

Variables

constexpr const char * kSupersededFramesField = "superseded-frames"
constexpr const char * kGpuFallbacksField = "gpu-fallbacks"
 guint64 "frame-stats" field holding the frames a GPU path was tried for but the CPU delivered.
constexpr const char * kStreamDemotionsField = "stream-demotions"
 guint64 "frame-stats" field holding the caps epochs that started on a GPU path and fell back to the CPU.
constexpr const char * kTiledDropsField = "tiled-drops"
constexpr unsigned kOfferGlUpload = 1u << 0
constexpr unsigned kOfferDmaDrm = 1u << 1
 The EGL-derived DMA_DRM caps: formats the DMABuf importer takes with an explicit modifier.
constexpr VideoFormatEntry kVideoFormatTable []

Detailed Description

GstVideoSink that pushes decoded frames into a Qt QVideoSink; sole sink in qgcvideosinkbin. Streaming-thread vfuncs MUST NOT touch QObject members directly (thread-affinity asserts) — hand off via QMetaObject::invokeMethod / bus messages.

Enumeration Type Documentation

◆ GpuBinMode

enum class GstQgc::GpuBinMode
strong

Head of qgcvideosinkbin's GPU branch. Linux builds with both gst-gl and DMABuf compile GlUpload and DirectDmaBuf; every other build compiles exactly one.

Enumerator
Passthrough 

Every compiled native memory straight into qgcqvideosink (Windows, Apple, ...).

GlUpload 

glupload → glcolorconvert → GLMemory 2D; gst-gl imports LINEAR and vendor-tiled DMABuf.

DirectDmaBuf 

memory:DMABuf and DMA_DRM into QGC's own importer (LINEAR only), skipping gst-gl's copy.

D3D12Convert 

d3d12upload → d3d12convert → single-plane D3D12Memory RGBA/BGRA: Qt's D3D12 QRhi has no plane views, so it can't sample NV12/P010 resources. The only variant for a Direct3D12 render target.

Definition at line 11 of file GstQgcGpuBin.h.

◆ RenderBackend

enum class GstQgc::RenderBackend
strong

Graphics API Qt Quick renders the video with, which decides the GPU memory qgcqvideosink can import.

Enumerator
Unknown 

No scene graph yet, and the GUI thread hasn't recorded the requested API either.

Null 

QRhi's Null backend or the software renderer: no GPU import.

OpenGL 
Direct3D11 
Direct3D12 
Metal 
Vulkan 

Definition at line 6 of file GstQgcRenderTarget.h.

Function Documentation

◆ advertisedFormatList()

std::string GstQgc::advertisedFormatList ( unsigned requiredOffers = 0)
inline

"{ NV12, NV21, ... }" — the advertised formats carrying every flag in requiredOffers, in table order, for a caps string. Built once at caps setup.

Definition at line 72 of file GstQgcVideoFormats.h.

References kVideoFormatTable.

◆ advertisedFormats()

std::vector< GstVideoFormat > GstQgc::advertisedFormats ( unsigned requiredOffers = 0)
inline

The advertised formats carrying every flag in requiredOffers, in table order.

Definition at line 59 of file GstQgcVideoFormats.h.

References kVideoFormatTable.

◆ buildSinkCaps()

std::string GstQgc::buildSinkCaps ( const SinkCapsPolicy & policy)

The caps qgcqvideosink accepts under policy, most preferred first, all in the Qt-renderable formats of kVideoFormatTable. The glupload variant takes GLMemory only, as glcolorconvert outputs it. Otherwise, with gpu-zerocopy, the GPU memory policy's render target imports comes first: EGL-importable DMA_DRM and DMABuf on OpenGL over EGL while the DMABuf import works; GLMemory, unless the direct DMABuf variant, wherever gst-gl shares Qt's OpenGL context (EGL or GLX); AHardwareBuffer on OpenGL over EGL (Android); on Direct3D11 NV12 and P010 D3D12Memory, where Qt's device opens it, then D3D11Memory; the DMA_DRM layouts Qt's device imports on Vulkan; none elsewhere. GLMemory always carries texture-target=2D, the only target the GL path samples. System memory always closes the list. Every entry asks for square pixels when policy does. DMABuf builds query EGL for importable DMA_DRM modifiers.

Definition at line 142 of file GstQgcCaps.cc.

References GstQgc::SinkCapsPolicy::squarePixels.

◆ configureSinkCaps()

void GstQgc::configureSinkCaps ( GstElement * sink,
GpuBinMode gpuBin,
bool squarePixels )

For qgcvideosinkbin, before it links sink: the GPU variant in front of the sink, and whether the sink asks for square pixels in system memory. Both shape the caps the sink offers.

Definition at line 660 of file gstqgcqvideosink.cc.

Referenced by gst_qgc_video_sink_bin_setup().

◆ converterSuitsRenderTarget()

bool GstQgc::converterSuitsRenderTarget ( const char * pluginName,
const char * factoryName,
const RenderTarget & target )
noexcept

Whether the element factoryName of GStreamer's plugin pluginName may be the bin's converter under target. Under Direct3D 11 a pipeline's d3d11 elements share the device Qt renders with (GstD3D11ContextBridge), and with it the immediate context, whose state Qt caches. Decoders, the uploader and the downloader only copy there. The plugin's other filters (d3d11convert, d3d11scale, d3d11deinterlace, d3d11overlay) draw, which sets that state behind Qt's back.

Definition at line 103 of file GstQgcGpuBin.cc.

References converterSuitsRenderTarget(), and Direct3D11.

Referenced by converterSuitsRenderTarget(), and gst_qgc_video_sink_bin_make_conversion_element().

◆ currentRenderTarget()

RenderTarget GstQgc::currentRenderTarget ( )

What qgcqvideosink renders into now; callable from any thread. The backend of QGC's scene graph once it runs (QGCRhiCapture); before that, the API Qt Quick was asked to use, as last read on the GUI thread.

Definition at line 70 of file GstQgcRenderTarget.cc.

References GstQgc::RenderTarget::backend, QGCRhiCapture::deviceSnapshot(), GstQgc::RenderTarget::egl, OpenGL, and QGCRhiCapture::qtEglDisplay().

Referenced by gst_qgc_video_sink_bin_make_conversion_element(), GStreamer::onMainWindowReady(), GstQgc::RenderTarget::operator==, and select_gpu_bin().

◆ formatSinkStats()

PathStats GstQgc::formatSinkStats ( const GstStructure * stats,
const GstStructure * since = nullptr )

One qgcqvideosink's frame accounting, from its "frame-stats" structure: the per-path counts it has delivered, plus its GPU fallbacks and demotions. With since (an earlier "frame-stats" value of the same sink), only what changed since.

Definition at line 40 of file GstQgcSinkStats.cc.

References frameStatsGrowth(), kGpuFallbacksField, GstHw::kPathCount, kStreamDemotionsField, kTiledDropsField, GstQgc::PathStats::line, None, sinkFramesField(), GstHw::toString(), and GstQgc::PathStats::totalDelivered.

Referenced by DecodingBranch::sinkPathStats().

◆ frameStats()

GStreamer::GstStructurePtr GstQgc::frameStats ( GstElement * sinkOrBin)

The "frame-stats" of sinkOrBin, a qgcqvideosink or the qgcvideosinkbin around one; null for other elements.

Definition at line 25 of file GstQgcSinkStats.cc.

References GStreamer::adoptElement(), GStreamer::adoptStructure(), and gst_qgc_video_sink_bin_get_qvideosink().

Referenced by DecodingBranch::sampleStats(), DecodingBranch::setVideoSink(), and DecodingBranch::sinkPathStats().

◆ frameStatsField()

quint64 GstQgc::frameStatsField ( const GstStructure * stats,
const char * field )
inlinenoexcept

The guint64 field of stats, a "frame-stats" or any other structure; 0 without the structure or the field.

Definition at line 34 of file GstQgcSinkStats.h.

Referenced by frameStatsGrowth(), DecodingBranch::sampleStats(), and DecodingBranch::setVideoSink().

◆ frameStatsGrowth()

quint64 GstQgc::frameStatsGrowth ( const GstStructure * stats,
const GstStructure * since,
const char * field )
inlinenoexcept

How far the guint64 field grew from since to stats, two "frame-stats" values of the same sink.

Definition at line 44 of file GstQgcSinkStats.h.

References frameStatsField().

Referenced by formatSinkStats().

◆ gpuBinName()

const char * GstQgc::gpuBinName ( GpuBinMode mode)
noexcept

◆ gpuBinPreference()

GpuBinPreference GstQgc::gpuBinPreference ( )

parseGpuBinPreference() of QGC_GST_GPU_BIN, read and logged on the first call.

Definition at line 48 of file GstQgcGpuBin.cc.

References GstQgc::GpuBinPreference::explicitChoice, gpuBinName(), gpuBinPreference(), GstQgc::GpuBinPreference::mode, and parseGpuBinPreference().

Referenced by gpuBinPreference(), and select_gpu_bin().

◆ parseGpuBinPreference()

GpuBinPreference GstQgc::parseGpuBinPreference ( QByteArrayView value)

value of QGC_GST_GPU_BIN ("glupload" or "dmabuf", case-insensitive) against the compiled bins. Empty keeps the default, GlUpload; an unknown value warns and keeps it too. With one compiled bin the value is ignored.

Definition at line 21 of file GstQgcGpuBin.cc.

References DirectDmaBuf, GlUpload, and parseGpuBinPreference().

Referenced by gpuBinPreference(), and parseGpuBinPreference().

◆ populateAllocationQuery()

bool GstQgc::populateAllocationQuery ( GstQuery * query)
nodiscard

Populate an ALLOCATION query with qgcqvideosink's consumed metas and its pool entry: the buffers the sink holds at once, with a pool when the query needs one. False, with the query untouched, when it has no caps that describe video. Called from the sink's propose_allocation vmethod.

Definition at line 69 of file GstQgcAllocation.cc.

References GstHw::dmaDrmAwareVideoInfo(), and HwBuffers::proposeDeviceBoundPool().

Referenced by gst_qgc_q_video_sink_propose_allocation().

◆ selectGpuBin()

GpuBinMode GstQgc::selectGpuBin ( GpuBinPreference preference,
const RenderTarget & target )
noexcept

The bin for preference under target. glupload hands GLMemory to Qt through the GL share group, so it needs Qt on OpenGL that gst-gl shares (EGL or GLX); direct DMABuf hands EGLImages to Qt, so it needs OpenGL on EGL. A preference the target doesn't suit falls back to passthrough unless it is explicit.

Definition at line 64 of file GstQgcGpuBin.cc.

References D3D12Convert, Direct3D12, DirectDmaBuf, GlUpload, Passthrough, and selectGpuBin().

Referenced by select_gpu_bin(), and selectGpuBin().

◆ sinkFramesField()

const char * GstQgc::sinkFramesField ( HwVideoBufferPath path)

guint64 "frame-stats" field holding the frames path delivered: "frames-" plus the lower-cased GstHw::toString(path).

Definition at line 12 of file GstQgcSinkStats.cc.

References GstHw::toString().

Referenced by formatSinkStats(), GstQgc::SinkCounters::frameStats(), DecodingBranch::sampleStats(), and DecodingBranch::setVideoSink().

◆ toString()

◆ zeroCopyPathName()

const char * GstQgc::zeroCopyPathName ( RenderBackend backend)
noexcept

The zero-copy buffer family qgcqvideosink imports under backend in this build, or "CPU" when none is compiled for it. For logs.

Definition at line 123 of file GstQgcRenderTarget.cc.

References Direct3D11, Direct3D12, Metal, OpenGL, and Vulkan.

Referenced by GStreamer::onMainWindowReady(), and GstQgc::RenderTarget::operator==.

Variable Documentation

◆ kGpuFallbacksField

const char* GstQgc::kGpuFallbacksField = "gpu-fallbacks"
inlineconstexpr

guint64 "frame-stats" field holding the frames a GPU path was tried for but the CPU delivered.

Definition at line 21 of file GstQgcSinkStats.h.

Referenced by formatSinkStats(), and GstQgc::SinkCounters::frameStats().

◆ kOfferDmaDrm

unsigned GstQgc::kOfferDmaDrm = 1u << 1
inlineconstexpr

The EGL-derived DMA_DRM caps: formats the DMABuf importer takes with an explicit modifier.

Definition at line 16 of file GstQgcVideoFormats.h.

◆ kOfferGlUpload

unsigned GstQgc::kOfferGlUpload = 1u << 0
inlineconstexpr

VideoFormatEntry::offers flags: extra caps an advertised format appears in besides system and native GPU memory. glupload's GLMemory caps: single-plane RGB only, because Qt's GL import samples multi-plane GLMemory (e.g. the NV12 that VA H.265 negotiates there) as intermittent green frames.

Definition at line 14 of file GstQgcVideoFormats.h.

◆ kStreamDemotionsField

const char* GstQgc::kStreamDemotionsField = "stream-demotions"
inlineconstexpr

guint64 "frame-stats" field holding the caps epochs that started on a GPU path and fell back to the CPU.

Definition at line 24 of file GstQgcSinkStats.h.

Referenced by formatSinkStats(), and GstQgc::SinkCounters::frameStats().

◆ kSupersededFramesField

const char* GstQgc::kSupersededFramesField = "superseded-frames"
inlineconstexpr

guint64 "frame-stats" field holding the delivered frames a newer frame replaced before the QVideoSink took them, which were never shown.

Definition at line 18 of file GstQgcSinkStats.h.

Referenced by GstQgc::SinkCounters::frameStats().

◆ kTiledDropsField

const char* GstQgc::kTiledDropsField = "tiled-drops"
inlineconstexpr

guint64 "frame-stats" field holding the frames dropped because no GPU path imported them and the CPU can't read their tiled DMA_DRM layout.

Definition at line 28 of file GstQgcSinkStats.h.

Referenced by formatSinkStats(), and GstQgc::SinkCounters::frameStats().

◆ kVideoFormatTable

VideoFormatEntry GstQgc::kVideoFormatTable[]
inlineconstexpr
Initial value:
= {
{GST_VIDEO_FORMAT_NV12, QVideoFrameFormat::Format_NV12, "NV12", kOfferDmaDrm},
{GST_VIDEO_FORMAT_NV21, QVideoFrameFormat::Format_NV21, "NV21", kOfferDmaDrm},
{GST_VIDEO_FORMAT_I420, QVideoFrameFormat::Format_YUV420P, "I420", kOfferDmaDrm},
{GST_VIDEO_FORMAT_YV12, QVideoFrameFormat::Format_YV12, "YV12", kOfferDmaDrm},
{GST_VIDEO_FORMAT_Y42B, QVideoFrameFormat::Format_YUV422P, "Y42B"},
{GST_VIDEO_FORMAT_P010_10LE, QVideoFrameFormat::Format_P010, "P010_10LE", kOfferDmaDrm},
{GST_VIDEO_FORMAT_I420_10LE, QVideoFrameFormat::Format_YUV420P10, "I420_10LE"},
{GST_VIDEO_FORMAT_AYUV, QVideoFrameFormat::Format_AYUV, "AYUV"},
{GST_VIDEO_FORMAT_YUY2, QVideoFrameFormat::Format_YUYV, "YUY2"},
{GST_VIDEO_FORMAT_UYVY, QVideoFrameFormat::Format_UYVY, "UYVY"},
{GST_VIDEO_FORMAT_GRAY8, QVideoFrameFormat::Format_Y8, "GRAY8"},
{GST_VIDEO_FORMAT_GRAY16_LE, QVideoFrameFormat::Format_Y16, "GRAY16_LE"},
{GST_VIDEO_FORMAT_BGRA, QVideoFrameFormat::Format_BGRA8888, "BGRA", kOfferGlUpload | kOfferDmaDrm},
{GST_VIDEO_FORMAT_RGBA, QVideoFrameFormat::Format_RGBA8888, "RGBA", kOfferGlUpload | kOfferDmaDrm},
{GST_VIDEO_FORMAT_BGRx, QVideoFrameFormat::Format_BGRX8888, nullptr},
{GST_VIDEO_FORMAT_RGBx, QVideoFrameFormat::Format_RGBX8888, nullptr},
{GST_VIDEO_FORMAT_ARGB, QVideoFrameFormat::Format_ARGB8888, nullptr},
{GST_VIDEO_FORMAT_xRGB, QVideoFrameFormat::Format_XRGB8888, nullptr},
{GST_VIDEO_FORMAT_P016_LE, QVideoFrameFormat::Format_P016, nullptr},
}
constexpr unsigned kOfferDmaDrm
The EGL-derived DMA_DRM caps: formats the DMABuf importer takes with an explicit modifier.
constexpr unsigned kOfferGlUpload

Definition at line 30 of file GstQgcVideoFormats.h.

Referenced by advertisedFormatList(), advertisedFormats(), and toQtPixelFormat().