3#include <QtCore/QLoggingCategory>
4#include <QtCore/qglobal.h>
5#include <QtMultimedia/QVideoFrame>
6#include <QtMultimedia/QVideoFrameFormat>
10#include <gst/video/video-info.h>
11#include <private/qhwvideobuffer_p.h>
32#define QGC_HW_WARN_ONCE(LOGCAT, FLAG, ...) \
34 if (!(FLAG).exchange(true, std::memory_order_relaxed)) { \
35 qCWarning(LOGCAT) << __VA_ARGS__; \
43 GstHwVideoBuffer(QVideoFrame::HandleType handleType, GstSample* sample,
const GstVideoInfo& videoInfo,
49 MapData
map(QVideoFrame::MapMode )
override {
return {}; }
55 virtual const char*
storageTag()
const {
return "Unknown"; }
66 static void logFirstSuccess(std::atomic<bool>& flag,
const QLoggingCategory& cat,
const char* tag, QSize frameSize,
67 QVideoFrameFormat::PixelFormat pixelFormat,
int planes);
71 template <
class PlanePred>
76 GstBuffer* buffer = gst_sample_get_buffer(
_sample);
79 const int memCount = (std::min)(
int(gst_buffer_n_memory(buffer)),
GstHw::kMaxPlanes);
82 for (
int i = 0; i < memCount; ++i) {
83 GstMemory* mem = gst_buffer_peek_memory(buffer, i);
Common base for GStreamer-backed QHwVideoBuffer subclasses.
GstSample * takeSample() noexcept
Transfers GstSample ownership out for early pool-slot release in mapTextures.
virtual const char * storageTag() const
Human-readable GPU path identifier (e.g. "DMABuf"); string literal, safe from any thread.
~GstHwVideoBuffer() override
MapData map(QVideoFrame::MapMode) override
QVideoFrameFormat format() const override
static void logFirstSuccess(std::atomic< bool > &flag, const QLoggingCategory &cat, const char *tag, QSize frameSize, QVideoFrameFormat::PixelFormat pixelFormat, int planes)
One-shot "first zero-copy success" info line; silent after flag first flips.
QVideoFrameFormat _format
bool checkMapPreconditions(const QRhi &rhi, int expectedBackend, const QLoggingCategory &cat, GstHw::MapDiagnostics &diag, GstBuffer *&outBuffer) const
Shared mapTextures preamble; warns once per cause via diag flags, returns false on first failure.
bool validatePlanes(PlanePred &&planePred) const
Validate each plane satisfies planePred; predicate runs once per plane on the streaming thread.
virtual bool validatePlaneHandles() const
Streaming-thread sanity check on per-plane handles; failure routes to CPU memcpy.
constexpr int kMaxPlanes
Matches GST_VIDEO_MAX_PLANES (gst-video pins it at 4); single source of truth for every per-platform ...
One-shot warning flags per failure cause; paths with extra causes (D3D, IOSurface) derive and add mem...
std::atomic< bool > loggedNullSample
std::atomic< bool > loggedTextureCreateFail
std::atomic< bool > loggedNullBuffer
std::atomic< bool > loggedBadBackend
std::atomic< bool > loggedFirstSuccess
std::atomic< bool > loggedWrongThread