9#include "private/qabstractvideobuffer_p.h"
16#include "private/qcapturablewindow_p.h"
20#include <QtCore/qloggingcategory.h>
88 m_waitForFormat.
wait(&m_formatMutex);
111 if (m_screenRemovingLocked) {
113 <<
"is removed while screen window grabbing lock is active";
116 while (m_screenRemovingLocked)
117 m_screenRemovingWc.
wait(&m_screenRemovingMutex);
120 void setScreenRemovingLocked(
bool locked)
122 Q_ASSERT(locked != m_screenRemovingLocked);
126 m_screenRemovingLocked = locked;
135 if (m_format && m_format->isValid())
148 setScreenRemovingLocked(
true);
149 auto screenGuard =
qScopeGuard(std::bind(&Grabber::setScreenRemovingLocked,
this,
false));
151 WId wid = m_window ? m_window->winId() : 0;
152 QScreen *
screen = m_window ? m_window->screen() : m_screen ? m_screen.
data() :
nullptr;
171 "Failed to grab the screen content");
185 std::optional<QVideoFrameFormat> m_format;
187 QMutex m_screenRemovingMutex;
188 bool m_screenRemovingLocked =
false;
202 return m_grabber->format();
209 if (active ==
static_cast<bool>(m_grabber))
217 return static_cast<bool>(m_grabber) == active;
220void QGrabWindowSurfaceCapture::activate(ScreenSource
screen)
225 m_grabber = std::make_unique<Grabber>(*
this,
screen);
229void QGrabWindowSurfaceCapture::activate(WindowSource
window)
233 if (
auto wnd =
WindowUPtr(QWindow::fromWinId(wid))) {
234 if (!wnd->screen()) {
238 m_grabber = std::make_unique<Grabber>(*
this, std::move(wnd));
243 "Window " +
QString::number(wid) +
"doesn't exist or permissions denied");
The QAbstractVideoBuffer class is an abstraction for video data. \inmodule QtMultimedia.
static const QCapturableWindowPrivate * handle(const QCapturableWindow &window)
void addFrameCallback(Object &object, Method method)
void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description)
void setFrameRate(qreal rate)
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...
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...
QImageVideoBuffer(QImage &&image)
void unmap() override
Releases the memory mapped by the map() function.
MapData map(QVideoFrame::MapMode mode) override
Independently maps the planes of a video buffer to memory.
QVideoFrame::MapMode mapMode() const override
The QVideoFrame class represents a frame of video data.
MapMode
Enumerates how a video buffer's data is mapped to system memory.
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
static QAbstractVideoBuffer::MapData mapData(const camera_frame_nv12_t &frame, unsigned char *baseAddress)
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]