9#include "private/qimagevideobuffer_p.h"
10#include "private/qcapturablewindow_p.h"
20#include <QtCore/qloggingcategory.h>
54 m_waitForFormat.
wait(&m_formatMutex);
83 if (m_screenRemovingLocked) {
85 <<
"is removed while screen window grabbing lock is active";
88 while (m_screenRemovingLocked)
89 m_screenRemovingWc.
wait(&m_screenRemovingMutex);
92 void setScreenRemovingLocked(
bool locked)
94 Q_ASSERT(locked != m_screenRemovingLocked);
98 m_screenRemovingLocked = locked;
107 if (m_format && m_format->isValid())
120 setScreenRemovingLocked(
true);
121 auto screenGuard =
qScopeGuard(std::bind(&Grabber::setScreenRemovingLocked,
this,
false));
123 WId wid = m_window ? m_window->winId() : 0;
124 QScreen *
screen = m_window ? m_window->screen() : m_screen ? m_screen.
data() :
nullptr;
134 auto buffer = std::make_unique<QImageVideoBuffer>(
p.toImage());
135 const auto img =
buffer->underlyingImage();
144 "Failed to grab the screen content");
153 QPointer<QScreen> m_screen;
158 std::optional<QVideoFrameFormat> m_format;
160 QMutex m_screenRemovingMutex;
161 bool m_screenRemovingLocked =
false;
175 return m_grabber->format();
182 if (active ==
static_cast<bool>(m_grabber))
190 return static_cast<bool>(m_grabber) == active;
193void QGrabWindowSurfaceCapture::activate(ScreenSource
screen)
198 m_grabber = std::make_unique<Grabber>(*
this,
screen);
202void QGrabWindowSurfaceCapture::activate(WindowSource
window)
206 if (
auto wnd =
WindowUPtr(QWindow::fromWinId(wid))) {
207 if (!wnd->screen()) {
211 m_grabber = std::make_unique<Grabber>(*
this, std::move(wnd));
216 "Window " +
QString::number(wid) +
"doesn't exist or permissions denied");
static const QCapturableWindowPrivate * handle(const QCapturableWindow &window)
void setFrameRate(qreal rate)
void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description)
void addFrameCallback(Object &object, Method method)
void updateError(QPlatformSurfaceCapture::Error error, const QString &description={})
Grabber(QGrabWindowSurfaceCapture &capture, WindowUPtr window)
Grabber(QGrabWindowSurfaceCapture &capture, QScreen *screen)
const QVideoFrameFormat & format()
QVideoFrame grabFrame() override
QGrabWindowSurfaceCapture(Source initialSource)
~QGrabWindowSurfaceCapture() override
bool setActiveInternal(bool active) override
QVideoFrameFormat frameFormat() const override
void screenRemoved(QScreen *screen)
This signal is emitted whenever a screen is removed from the system.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
T * data() const noexcept
The QScreen class is used to query screen properties. \inmodule QtGui.
QPixmap grabWindow(WId window=0, int x=0, int y=0, int w=-1, int h=-1)
Creates and returns a pixmap constructed by grabbing the contents of the given window restricted by Q...
qreal refreshRate
the approximate vertical refresh rate of the screen in Hz
QString name
a user presentable string representing the screen
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QVideoFrame class represents a frame of video data.
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
Combined button and popup list for selecting options.
std::unique_ptr< QWindow > WindowUPtr
GLuint64 GLenum void * handle
GLint GLsizei GLsizei GLenum format
GLsizei GLsizei GLchar * source
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]