QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstHwPathRegistry.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/qglobal.h>
4
5#if defined(QGC_HAS_ANY_GPU_PATH)
6
7#include <gst/gst.h>
8#include <gst/video/video-info.h>
9#include <initializer_list>
10#include <memory>
11#include <span>
12#include <vector>
13
14#include <QtMultimedia/QVideoFrameFormat>
15
16#include "GstHwTypes.h"
17
18class GstContextBridgeBase;
20class QRhi;
21
24struct HwPathDescriptor
25{
28
31 bool (*matches)(GstMemory* mem) = nullptr;
32
35 bool (*admits)(GstMemory* mem, const HwVideoBufferContext& context) = nullptr;
36
38 std::unique_ptr<GstHwVideoBuffer> (*construct)(GstSample* sample, const GstVideoInfo& info,
39 QVideoFrameFormat format,
40 const HwVideoBufferContext& context) = nullptr;
41
44 void (*prepareContext)(HwVideoBufferContext& context) = nullptr;
45
48 void (*probeDevice)(QRhi& rhi) = nullptr;
49
51 void (*resetCaches)() = nullptr;
52
55 bool (*proposePool)(GstQuery* query, GstCaps* caps, const GstVideoInfo* info, gsize size,
56 guint minBuffers) = nullptr;
57
59 GstContextBridgeBase& (*bridge)() = nullptr;
60};
61
63namespace GstHwPaths {
64
66template <class Buffer>
67std::unique_ptr<GstHwVideoBuffer> construct(GstSample* sample, const GstVideoInfo& info, QVideoFrameFormat format,
68 const HwVideoBufferContext& /*context*/)
69{
70 return std::make_unique<Buffer>(sample, info, format);
71}
72
73extern const HwPathDescriptor kCuda;
74extern const HwPathDescriptor kDmaBuf;
75extern const HwPathDescriptor kGlMemory;
76extern const HwPathDescriptor kD3D11;
77extern const HwPathDescriptor kD3D12;
78extern const HwPathDescriptor kVulkan;
79extern const HwPathDescriptor kIOSurface;
80extern const HwPathDescriptor kAHardwareBuffer;
81
82} // namespace GstHwPaths
83
85namespace GstHwPathRegistry {
86
88std::span<const HwPathDescriptor* const> paths() noexcept;
89
91bool has(HwVideoBufferPath path) noexcept;
92
93#ifdef QGC_UNITTEST_BUILD
95class ScopedPathsForTest
96{
97public:
98 explicit ScopedPathsForTest(std::initializer_list<const HwPathDescriptor*> paths);
99 ~ScopedPathsForTest();
100 ScopedPathsForTest(const ScopedPathsForTest&) = delete;
101 ScopedPathsForTest& operator=(const ScopedPathsForTest&) = delete;
102
103private:
104 std::vector<const HwPathDescriptor*> _paths;
105 const std::vector<const HwPathDescriptor*>* _previous = nullptr;
106};
107#endif
108
109} // namespace GstHwPathRegistry
110
111#endif // QGC_HAS_ANY_GPU_PATH
HwVideoBufferPath
GPU zero-copy path a frame is imported through; None means the frame takes the CPU path.
Definition GstHwTypes.h:7
Common base for GStreamer-backed QHwVideoBuffer subclasses.
bool has(HwVideoBufferPath path) noexcept
std::span< const HwPathDescriptor *const > paths() noexcept
QByteArray format(const QList< LogEntry > &entries, int fmt)