QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstDmaBufVideoBuffer.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/qglobal.h>
4
5#if defined(QGC_HAS_GST_DMABUF_GPU_PATH)
6
7#include "GstHwVideoBuffer.h"
8#include <EGL/egl.h>
9#include <EGL/eglext.h>
10
11class QRhi;
12
17class GstDmaBufVideoBuffer final : public GstHwVideoBuffer
18{
19public:
21 GstDmaBufVideoBuffer(GstSample* sample, const GstVideoInfo& videoInfo, const QVideoFrameFormat& format,
22 EGLDisplay eglDisplay);
23
26 static EGLDisplay eglDisplayFor(const HwVideoBufferContext& context);
27
30 static bool isDmaBufFd(int fd) noexcept;
31
32 bool isDmaBuf() const override { return true; }
33
34 MapData map(QVideoFrame::MapMode mode) override;
35 QVideoFrameTexturesUPtr mapTextures(QRhi& rhi, QVideoFrameTexturesUPtr& oldTextures) override;
36 bool validatePlaneHandles() const override;
37
39 static constexpr int kMaxConsecutiveImportFailures = 30;
40
42 enum class ImportOutcome
43 {
44 Imported,
45 NotImportable,
46 Rejected,
47 Unrecoverable,
48 };
49
51 static bool importDisabled() noexcept;
52 static void resetCachedState() noexcept;
53
54#ifdef QGC_UNITTEST_BUILD
56 static void recordImportFailureForTest(bool unrecoverable);
58 void noteImportOutcomeForTest(ImportOutcome outcome) const;
60 static bool waitForProducerWritesForTest(GstBuffer* buffer);
63 static void setGpuFenceForTest(int fd);
64#endif
65
66private:
68 QVideoFrameTexturesUPtr importFrame(QRhi& rhi, QVideoFrameTexturesUPtr& old, ImportOutcome& failure);
69#if defined(QGC_HAS_GST_DMABUF_VULKAN_IMPORT)
70 QVideoFrameTexturesUPtr importVulkan(QRhi& rhi, GstBuffer* buffer, QVideoFrameTexturesUPtr& old,
71 ImportOutcome& failure);
72#endif
73 QVideoFrameTexturesUPtr importGl(QRhi& rhi, GstBuffer* buffer, ImportOutcome& failure);
76 void noteImportOutcome(ImportOutcome outcome) const;
78 bool isTiled() const noexcept;
79
80 EGLDisplay _eglDisplay = EGL_NO_DISPLAY;
82 guint64 _drmModifier;
84 quint32 _packedYuvFourcc = 0;
85};
86
87#endif // QGC_HAS_GST_DMABUF_GPU_PATH
Common base for GStreamer-backed QHwVideoBuffer subclasses.
MapData map(QVideoFrame::MapMode mode) override
virtual bool validatePlaneHandles() const
Streaming-thread sanity check on per-plane handles; failure routes to CPU memcpy.