QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GstHwFrameTexturesBase.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtMultimedia/QVideoFrame>
4#include <gst/gst.h>
5#include <memory>
6#include <private/qhwvideobuffer_p.h>
7
8#include "GstHwVideoBuffer.h"
10
11class QRhiTexture;
12
14class GstHwFrameTexturesBase : public QVideoFrameTextures
15{
16public:
17 ~GstHwFrameTexturesBase() override { g_clear_pointer(&_srcSample, gst_sample_unref); }
18
19 void onFrameEndInvoked() override { g_clear_pointer(&_srcSample, gst_sample_unref); }
20
21 QRhiTexture* texture(uint plane) const override { return int(plane) < _count ? _textures[plane].get() : nullptr; }
22
25
27 void setSourceSample(GstSample* s) noexcept
28 {
29 g_clear_pointer(&_srcSample, gst_sample_unref);
30 _srcSample = s;
31 }
32
37 template <class FT>
38 static FT* reusableBundle(QVideoFrameTexturesUPtr& old, HwVideoBufferPath p)
39 {
40 auto* base = old ? dynamic_cast<GstHwFrameTexturesBase*>(old.get()) : nullptr;
41 return (base && base->sourcePath() == p) ? dynamic_cast<FT*>(base) : nullptr;
42 }
43
44protected:
45 int _count = 0;
46 std::unique_ptr<QRhiTexture> _textures[GstHw::kMaxPlanes];
47 GstSample* _srcSample = nullptr;
48};
HwVideoBufferPath
Identifies which GPU path was chosen; used by the adapter to increment the right counter.
Common base for per-platform FrameTextures : QVideoFrameTextures from *VideoBuffer::mapTextures().
static FT * reusableBundle(QVideoFrameTexturesUPtr &old, HwVideoBufferPath p)
virtual HwVideoBufferPath sourcePath() const
GPU path that produced this bundle; used after a type-safe downcast to decide path-local reuse.
QRhiTexture * texture(uint plane) const override
void setSourceSample(GstSample *s) noexcept
Transfers a ref into the bundle. Caller must have a fresh ref.
std::unique_ptr< QRhiTexture > _textures[GstHw::kMaxPlanes]
constexpr int kMaxPlanes
Matches GST_VIDEO_MAX_PLANES (gst-video pins it at 4); single source of truth for every per-platform ...