Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qffmpegsurfacecapturegrabber_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 QFFMPEGSURFACECAPTUREGRABBER_P_H
5#define QFFMPEGSURFACECAPTUREGRABBER_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 "qvideoframe.h"
19#include <QtMultimedia/private/qplatformsurfacecapture_p.h>
20
21#include <memory>
22#include <optional>
23
24QT_BEGIN_NAMESPACE
25
26class QThread;
27
28static constexpr qreal DefaultScreenCaptureFrameRate = 60.f;
29static constexpr qreal MinScreenCaptureFrameRate = 1.f;
30
32{
34public:
39
41
42 void start();
43 void stop();
44
45 template<typename Object, typename Method>
46 void addFrameCallback(Object *object, Method method)
47 {
48 connect(this, &QFFmpegSurfaceCaptureGrabber::frameGrabbed, object, method,
49 Qt::DirectConnection);
50 }
51
53 qreal frameRate() const;
54
57 void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description);
58
59protected:
60 QFFmpegSurfaceCaptureGrabber(ThreadPolicy threadPolicy = CreateGrabbingThread);
61
62 void updateError(QPlatformSurfaceCapture::Error error, const QString &description = {});
63
64 virtual QVideoFrame grabFrame() = 0;
65
67
68 virtual void initializeGrabbingContext();
69 virtual void finalizeGrabbingContext();
70
72
73private:
74 class GrabbingProfiler;
75 struct GrabbingContext;
76 class GrabbingThread;
77
78 std::unique_ptr<GrabbingContext> m_context;
79 std::optional<QPlatformSurfaceCapture::Error> m_prevError;
80 std::unique_ptr<QThread> m_thread;
81
82 qreal m_rate{ DefaultScreenCaptureFrameRate };
83};
84
85QT_END_NAMESPACE
86
87#endif // QFFMPEGSURFACECAPTUREGRABBER_P_H
Grabber(QEglfsScreenCapture &screenCapture, QScreen *screen)
QuickGrabber(QEglfsScreenCapture &screenCapture, QScreen *screen, QQuickWindow *quickWindow)
void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description)
void addFrameCallback(Object *object, Method method)
virtual QVideoFrame grabFrame()=0
void setFrameRate(std::optional< qreal >)
~QFFmpegSurfaceCaptureGrabber() override
QFFmpegSurfaceCaptureGrabber(ThreadPolicy threadPolicy=CreateGrabbingThread)
void updateError(QPlatformSurfaceCapture::Error error, const QString &description={})
Combined button and popup list for selecting options.
static constexpr qreal MinScreenCaptureFrameRate
static constexpr qreal DefaultScreenCaptureFrameRate