44 ~QSurfaceCaptureGrabber() override;
49 template<
typename Object,
typename Method>
50 void addFrameCallback(Object *object, Method method)
52 connect(
this, &QSurfaceCaptureGrabber::frameGrabbed, object, method,
53 Qt::DirectConnection);
56 void setFrameRate(std::optional<qreal>);
57 qreal frameRate()
const;
60 qreal activeFrameRate()
const;
63 void frameGrabbed(
const QVideoFrame&);
64 void errorUpdated(QPlatformSurfaceCapture::Error error,
const QString &description);
67 QSurfaceCaptureGrabber(ThreadPolicy threadPolicy = CreateGrabbingThread);
69 void updateError(QPlatformSurfaceCapture::Error error,
const QString &description = {});
71 virtual QVideoFrame grabFrame() = 0;
73 void updateTimerInterval();
74 void setTimerInterval(std::chrono::nanoseconds interval, quint64 generation);
76 virtual void initializeGrabbingContext();
77 virtual void finalizeGrabbingContext();
79 bool isGrabbingContextInitialized()
const;
81 void injectContextToGrabbingThread(QObject *context);
84 class GrabbingProfiler;
85 struct GrabbingContext;
88 mutable QMutex m_mutex;
89 std::unique_ptr<GrabbingContext> m_context;
90 std::optional<QPlatformSurfaceCapture::Error> m_prevError;
91 std::unique_ptr<QThread> m_thread;
92 std::chrono::nanoseconds m_timerInterval{ 0 };
93 quint64 m_contextGeneration{ 0 };
95 qreal m_rate{ DefaultScreenCaptureFrameRate };
97 qreal m_activeRate{ DefaultScreenCaptureFrameRate };