QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstHwVideoBuffer Class Reference

Common base for GStreamer-backed QHwVideoBuffer subclasses. More...

#include <GstHwVideoBuffer.h>

Inheritance diagram for GstHwVideoBuffer:
Collaboration diagram for GstHwVideoBuffer:

Public Member Functions

 GstHwVideoBuffer (GstSample *sample, const GstVideoInfo &videoInfo, QVideoFrameFormat format)
 ~GstHwVideoBuffer () override
QVideoFrameFormat format () const override
MapData map (QVideoFrame::MapMode mode) override
void unmap () override
virtual bool validatePlaneHandles () const
 Streaming-thread sanity check on per-plane handles; failure routes to CPU memcpy.
GstSample * refSample () noexcept

Protected Member Functions

template<class PlanePred>
bool validatePlanes (PlanePred &&planePred) const
 Validate each plane satisfies planePred; predicate runs once per plane on the streaming thread.
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.

Protected Attributes

GstSample * _sample = nullptr
GstVideoInfo _videoInfo = {}
QVideoFrameFormat _format

Detailed Description

Common base for GStreamer-backed QHwVideoBuffer subclasses.

Definition at line 70 of file GstHwVideoBuffer.h.

Constructor & Destructor Documentation

◆ GstHwVideoBuffer()

GstHwVideoBuffer::GstHwVideoBuffer ( GstSample * sample,
const GstVideoInfo & videoInfo,
QVideoFrameFormat format )

Definition at line 19 of file GstHwVideoBuffer.cc.

References _format, _sample, _videoInfo, and format().

◆ ~GstHwVideoBuffer()

GstHwVideoBuffer::~GstHwVideoBuffer ( )
override

Definition at line 29 of file GstHwVideoBuffer.cc.

References _sample, and unmap().

Member Function Documentation

◆ checkMapPreconditions()

bool GstHwVideoBuffer::checkMapPreconditions ( const QRhi & rhi,
int expectedBackend,
const QLoggingCategory & cat,
GstHw::MapDiagnostics & diag,
GstBuffer *& outBuffer ) const
protected

Shared mapTextures preamble; warns once per cause via diag flags, returns false on first failure.

Definition at line 54 of file GstHwVideoBuffer.cc.

References _sample, GstHw::MapDiagnostics::loggedBadBackend, GstHw::MapDiagnostics::loggedNullBuffer, GstHw::MapDiagnostics::loggedNullSample, GstHw::MapDiagnostics::loggedWrongThread, and QGC_HW_WARN_ONCE.

◆ format()

QVideoFrameFormat GstHwVideoBuffer::format ( ) const
inlineoverride

Definition at line 76 of file GstHwVideoBuffer.h.

References _format.

Referenced by GstHwVideoBuffer().

◆ map()

QAbstractVideoBuffer::MapData GstHwVideoBuffer::map ( QVideoFrame::MapMode mode)
override

CPU view of the sample through gst_video_frame_map (e.g. GL memory downloads, DMABuf mmaps). Qt's createTextures() uploads this whenever mapTextures() fails, so a failed GPU import still shows the frame. ReadOnly only. Refused when format() advertises another pixel format than the memory holds: Qt would upload it in the wrong format or read past it.

Definition at line 37 of file GstHwVideoBuffer.cc.

References _format, _sample, and _videoInfo.

◆ refSample()

GstSample * GstHwVideoBuffer::refSample ( )
inlinenoexcept

New sample ref for the texture bundle built in mapTextures(). The buffer keeps its own ref so map() and a repeated mapTextures() (another window, QRhi re-creation) still find the sample; Qt keeps this frame alive alongside the bundle anyway (QVideoFrameTextures::setSourceFrame), so no buffer is held longer.

Definition at line 91 of file GstHwVideoBuffer.h.

References _sample.

Referenced by GstHwFrameTexturesBase::finishMap().

◆ unmap()

void GstHwVideoBuffer::unmap ( )
override

Definition at line 49 of file GstHwVideoBuffer.cc.

Referenced by ~GstHwVideoBuffer().

◆ validatePlaneHandles()

virtual bool GstHwVideoBuffer::validatePlaneHandles ( ) const
inlinevirtual

Streaming-thread sanity check on per-plane handles; failure routes to CPU memcpy.

Definition at line 86 of file GstHwVideoBuffer.h.

◆ validatePlanes()

template<class PlanePred>
bool GstHwVideoBuffer::validatePlanes ( PlanePred && planePred) const
inlineprotected

Validate each plane satisfies planePred; predicate runs once per plane on the streaming thread.

Definition at line 96 of file GstHwVideoBuffer.h.

References _sample, and GstHw::kMaxPlanes.

Member Data Documentation

◆ _format

QVideoFrameFormat GstHwVideoBuffer::_format
protected

Definition at line 120 of file GstHwVideoBuffer.h.

Referenced by format(), GstHwVideoBuffer(), and map().

◆ _sample

GstSample* GstHwVideoBuffer::_sample = nullptr
protected

◆ _videoInfo

GstVideoInfo GstHwVideoBuffer::_videoInfo = {}
protected

Definition at line 119 of file GstHwVideoBuffer.h.

Referenced by GstHwVideoBuffer(), and map().


The documentation for this class was generated from the following files: