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.;
29
30// Mac screens often support 120 frames per sec; it looks, this is not
31// needed for the capturing now since it just affects CPI without valuable
32// advantages. In the future, the frame rate should be customized by
33// user's API.
34static constexpr qreal MaxScreenCaptureFrameRate = 60.;
35static constexpr qreal MinScreenCaptureFrameRate = 1.;
36
38{
40public:
45
46 QFFmpegSurfaceCaptureGrabber(ThreadPolicy threadPolicy = CreateGrabbingThread);
47
49
50 void start();
51 void stop();
52
53 template<typename Object, typename Method>
54 void addFrameCallback(Object &object, Method method)
55 {
56 connect(this, &QFFmpegSurfaceCaptureGrabber::frameGrabbed,
57 &object, method, Qt::DirectConnection);
58 }
59
62 void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description);
63
64protected:
65 void updateError(QPlatformSurfaceCapture::Error error, const QString &description = {});
66
67 virtual QVideoFrame grabFrame() = 0;
68
69 void setFrameRate(qreal rate);
70
71 qreal frameRate() const;
72
74
75 virtual void initializeGrabbingContext();
76 virtual void finalizeGrabbingContext();
77
79
80private:
81 class GrabbingProfiler;
82 struct GrabbingContext;
83 class GrabbingThread;
84
85 std::unique_ptr<GrabbingContext> m_context;
86 qreal m_rate = 0;
87 std::optional<QPlatformSurfaceCapture::Error> m_prevError;
88 std::unique_ptr<QThread> m_thread;
89};
90
91QT_END_NAMESPACE
92
93#endif // QFFMPEGSURFACECAPTUREGRABBER_P_H
Grabber(QEglfsScreenCapture &screenCapture, QScreen *screen)
QuickGrabber(QEglfsScreenCapture &screenCapture, QScreen *screen, QQuickWindow *quickWindow)
void errorUpdated(QPlatformSurfaceCapture::Error error, const QString &description)
virtual QVideoFrame grabFrame()=0
void addFrameCallback(Object &object, Method method)
~QFFmpegSurfaceCaptureGrabber() override
QFFmpegSurfaceCaptureGrabber(ThreadPolicy threadPolicy=CreateGrabbingThread)
void updateError(QPlatformSurfaceCapture::Error error, const QString &description={})
static constexpr qreal MinScreenCaptureFrameRate
static constexpr qreal MaxScreenCaptureFrameRate
static constexpr qreal DefaultScreenCaptureFrameRate