Loading...
Searching...
No Matches
DMACaptureInputNode.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4
33#include <Gfx/Graph/Node.hpp>
35
36#include <Video/VideoInterface.hpp>
37
38#include <score_plugin_gfx_export.h>
39
40#include <functional>
41#include <memory>
42#include <vector>
43
44namespace score::gfx
45{
46class GPUVideoDecoder;
47
48namespace interop
49{
50struct VideoCaptureStrategy;
51struct VideoCaptureSlotRing;
52class CaptureSyncGroup;
53}
54
63struct SCORE_PLUGIN_GFX_EXPORT DMACaptureBackend
64{
65 virtual ~DMACaptureBackend();
66
70 virtual bool open() = 0;
71
73 virtual int width() const noexcept = 0;
74 virtual int height() const noexcept = 0;
75 virtual uint32_t frameByteSize() const noexcept = 0;
76
80 virtual Video::ImageFormat imageFormat() const = 0;
81
85 virtual std::unique_ptr<GPUVideoDecoder>
86 makeDecoder(Video::VideoMetadata&) = 0;
87
96 virtual std::unique_ptr<interop::VideoCaptureStrategy>
97 pickStrategy(QRhi::Implementation backend, const interop::GpuCapabilities& caps)
98 = 0;
99
114 virtual std::vector<std::function<std::unique_ptr<interop::VideoCaptureStrategy>()>>
115 pickStrategies(
116 QRhi::Implementation backend, const interop::GpuCapabilities& caps);
117
120 virtual std::unique_ptr<interop::VideoCaptureStrategy>
121 makeCpuStrategy() = 0;
122
125 virtual void setStrategy(interop::VideoCaptureStrategy*) noexcept = 0;
126
128 virtual void start() = 0;
129 virtual void stop() = 0;
130
136 virtual bool decoderNeedsExternalImage() const noexcept { return false; }
137
140 virtual void dropExternalImageRequest() noexcept { }
141
149 {
151 std::size_t member{0};
152 };
153 virtual SyncMembership syncGroup() noexcept { return {}; }
154
155
165 virtual void setSyncGroupEngaged(bool) noexcept { }
166};
167
175struct SCORE_PLUGIN_GFX_EXPORT DMACaptureInputNode : ProcessNode
176{
178 ~DMACaptureInputNode() override;
179
180 NodeRenderer* createRenderer(RenderList& r) const noexcept override;
181
184 virtual std::unique_ptr<DMACaptureBackend>
186
189 const char* engagedCaptureStrategy() const noexcept
190 {
191 return m_engagedStrategy.load(std::memory_order_acquire);
192 }
193
196 bool captureStrategyPinUnmet() const noexcept
197 {
198 return m_pinUnmet.load(std::memory_order_acquire);
199 }
200
202 void setEngagedCaptureStrategy(const char* name, bool pinUnmet) const noexcept
203 {
204 m_engagedStrategy.store(name, std::memory_order_release);
205 m_pinUnmet.store(pinUnmet, std::memory_order_release);
206 }
207
211 std::uint64_t capturedFrameCount() const noexcept
212 {
213 return m_capturedFrames.load(std::memory_order_acquire);
214 }
215
217 void setCapturedFrameCount(std::uint64_t n) const noexcept
218 {
219 m_capturedFrames.store(n, std::memory_order_release);
220 }
221
225 CaptureAdjustSlot& adjustments() const noexcept { return m_adjust; }
226
227 class Renderer;
228
229private:
230 mutable std::atomic<const char*> m_engagedStrategy{nullptr};
231 mutable std::atomic<bool> m_pinUnmet{false};
232 mutable std::atomic<std::uint64_t> m_capturedFrames{0};
233 mutable CaptureAdjustSlot m_adjust;
234
235public:
236};
237
238} // namespace score::gfx
The corrections a capture node applies on its way out of the sensor.
Runtime probe of which GPU interop mechanisms are available on this system.
Cross-thread handoff for CaptureAdjust.
Definition CaptureAdjust.hpp:80
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:90
Renderer for a given node.
Definition NodeRenderer.hpp:11
Common base class for nodes that map to score processes.
Definition score-plugin-gfx/Gfx/Graph/Node.hpp:201
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Definition CaptureSyncGroup.hpp:100
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
STL namespace.
Definition DMACaptureInputNode.hpp:149
Vendor seam for a DMA capture card's input path.
Definition DMACaptureInputNode.hpp:64
virtual int width() const noexcept=0
Negotiated geometry + total wire-format frame size, valid after open().
virtual void setSyncGroupEngaged(bool) noexcept
Definition DMACaptureInputNode.hpp:165
virtual void dropExternalImageRequest() noexcept
Definition DMACaptureInputNode.hpp:140
ProcessNode base for DMA capture-card inputs. One Image output port; its renderer is the generic DMAC...
Definition DMACaptureInputNode.hpp:176
std::uint64_t capturedFrameCount() const noexcept
Definition DMACaptureInputNode.hpp:211
void setEngagedCaptureStrategy(const char *name, bool pinUnmet) const noexcept
Set by the renderer once the ladder resolves (render thread).
Definition DMACaptureInputNode.hpp:202
bool captureStrategyPinUnmet() const noexcept
Definition DMACaptureInputNode.hpp:196
CaptureAdjustSlot & adjustments() const noexcept
Definition DMACaptureInputNode.hpp:225
const char * engagedCaptureStrategy() const noexcept
Definition DMACaptureInputNode.hpp:189
virtual std::unique_ptr< DMACaptureBackend > makeCaptureBackend(interop::VideoCaptureSlotRing &ring) const =0
void setCapturedFrameCount(std::uint64_t n) const noexcept
Set by the renderer each frame from the ring's latest id (render thread).
Definition DMACaptureInputNode.hpp:217
Lock-free SPSC handoff between the capture thread and the renderer. Capture thread bumps latestFrameI...
Definition VideoCaptureStrategy.hpp:210