Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qffmpegsurfacecapturethread_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QFFMPEGSURFACECAPTURETHREAD_P_H
5#define QFFMPEGSURFACECAPTURETHREAD_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qthread.h>
19
20#include "qvideoframe.h"
21#include "private/qplatformsurfacecapture_p.h"
22
23#include <memory>
24#include <optional>
25
27
28class QTimer;
29
30static constexpr qreal DefaultScreenCaptureFrameRate = 60.;
31
32// Mac screens often support 120 frames per sec; it looks, this is not
33// needed for the capturing now since it just affects CPI without valuable
34// advantages. In the future, the frame rate should be customized by
35// user's API.
36static constexpr qreal MaxScreenCaptureFrameRate = 60.;
37static constexpr qreal MinScreenCaptureFrameRate = 1.;
38
40{
42public:
44
46
47 void stop();
48
49 template<typename Object, typename Method>
50 void addFrameCallback(Object &object, Method method)
51 {
53 std::bind(method, &object, std::placeholders::_1));
54 }
55
59
60protected:
61 void run() override;
62
63 void updateError(QPlatformSurfaceCapture::Error error, const QString &description = {});
64
65 virtual QVideoFrame grabFrame() = 0;
66
67protected:
69
70 qreal frameRate() const;
71
73
74private:
75 qreal m_rate = 0;
76 std::unique_ptr<QTimer> m_timer;
77 std::optional<QPlatformSurfaceCapture::Error> m_prevError;
78};
79
81
82#endif // QFFMPEGSURFACECAPTURETHREAD_P_H
Definition main.cpp:8
virtual QVideoFrame grabFrame()=0
void frameGrabbed(const QVideoFrame &)
void addFrameCallback(Object &object, Method method)
void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description)
~QFFmpegSurfaceCaptureThread() override
void updateError(QPlatformSurfaceCapture::Error error, const QString &description={})
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qtimer.h:20
The QVideoFrame class represents a frame of video data.
Definition qvideoframe.h:26
Combined button and popup list for selecting options.
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static constexpr qreal MinScreenCaptureFrameRate
static constexpr qreal MaxScreenCaptureFrameRate
static constexpr qreal DefaultScreenCaptureFrameRate
GLuint GLenum * rate
#define Q_OBJECT
#define signals
double qreal
Definition qtypes.h:92