QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstQgcCaps.cc
Go to the documentation of this file.
1#include "GstQgcCaps.h"
2
3#include <gst/gst.h>
4
8
9namespace GstQgc {
10
11std::string buildCpuCapsString()
12{
13 return std::string("video/x-raw, format=") + advertisedFormatList();
14}
15
16std::string buildGpuCapsString()
17{
18 const std::string kFormats = advertisedFormatList();
19 std::string capsStr;
20#if defined(QGC_GST_BIN_USE_GLUPLOAD)
21 // texture-target=2D is load-bearing: it forces glcolorconvert to convert amcvideodec's external-OES
22 // Surface textures to GL_TEXTURE_2D; the default ANY target passes external-OES through and the Qt
23 // RHI 2D sink samples it black.
24 // Keep this path single-plane for Qt's GL import. VA H.265 can negotiate NV12 GLMemory here, which
25 // reaches QVideoFrame delivery cleanly but renders as intermittent green frames through Qt's sampler.
26 capsStr = "video/x-raw(memory:GLMemory), texture-target=2D, format={ BGRA, RGBA }";
27#else
28#if defined(QGC_HAS_GST_DMABUF_GPU_PATH)
29#if GST_CHECK_VERSION(1, 24, 0)
30 // Best-effort: advertise the GPU's actually-supported (format, modifier) pairs (EGL query) so modifier-aware
31 // drivers negotiate a tiling QGC's importer can consume. Additive — empty on any query failure (see below).
32 capsStr += GstHw::buildSupportedDmaDrmCaps(kFormats.c_str());
33 // QGC_GST_OFFER_DMA_DRM_LINEAR=1 force-offers LINEAR-modifier (0x0) DMA_DRM as a fallback/override so a driver
34 // that mis-reports modifiers still gets a guaranteed-LINEAR option and iHD can't pick tiled+CCS.
35 if (HwBuffers::hwBufferEnvConfig().offerDmaDrmLinear) {
36 capsStr += GstHw::buildLinearDmaDrmCaps("{ NV12, NV21, I420, P010_10LE, BGRA, RGBA }");
37 }
38#endif
39 // Legacy memory:DMABuf covers v4l2h264dec/Mali/V3D LINEAR. DMA_DRM omitted: gst-va iHD
40 // negotiates tiled+CCS that crashes both paths (system catch-all routes va to GstVaMemory).
41 capsStr += "video/x-raw(memory:DMABuf), format=";
42 capsStr += kFormats;
43 capsStr += "; ";
44#endif
45#if defined(QGC_HAS_GST_D3D11_GPU_PATH)
46 capsStr += "video/x-raw(memory:D3D11Memory), format=";
47 capsStr += kFormats;
48 capsStr += "; ";
49#endif
50#if defined(QGC_HAS_GST_D3D12_GPU_PATH)
51 capsStr += "video/x-raw(memory:D3D12Memory), format=";
52 capsStr += kFormats;
53 capsStr += "; ";
54#endif
55#if defined(QGC_HAS_GST_GLMEMORY_GPU_PATH) && !defined(QGC_GST_BIN_USE_DMABUF)
56 capsStr += "video/x-raw(memory:GLMemory), format=";
57 capsStr += kFormats;
58 capsStr += "; ";
59#endif
60#if defined(QGC_HAS_GST_AHARDWAREBUFFER_GPU_PATH)
61 capsStr += "video/x-raw(memory:AHardwareBuffer), format=";
62 capsStr += kFormats;
63 capsStr += "; ";
64#endif
65 capsStr += "video/x-raw, format=";
66 capsStr += kFormats;
67#endif
68 return capsStr;
69}
70
71} // namespace GstQgc
std::string buildLinearDmaDrmCaps(const char *)
std::string buildSupportedDmaDrmCaps(const char *)
std::string advertisedFormatList()
"{ NV12, NV21, ... }" — the advertised format list for a caps string. Built once at caps setup.
std::string buildGpuCapsString()
Definition GstQgcCaps.cc:16
std::string buildCpuCapsString()
Definition GstQgcCaps.cc:11
const HwBufferEnvConfig & hwBufferEnvConfig() noexcept
Lazily parses + logs the toggle config on first call; thread-safe via static-init guarantees.
Definition HwBuffers.cc:144