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
qsckwindowcapture_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QSCKWINDOWCAPTURE_H
5#define QSCKWINDOWCAPTURE_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 <QtMultimedia/private/qplatformsurfacecapture_p.h>
19
20#include <QtFFmpegMediaPluginImpl/private/qmacscreencapturekit_p.h>
21
22#include <memory>
23
24QT_BEGIN_NAMESPACE
25
26class QFFmpegMediaCaptureSession;
27
28namespace QFFmpeg {
29
31{
33
34public:
35 explicit QSckWindowCapture();
37
38 void setCaptureSession(QPlatformMediaCaptureSession *) override;
39
40 QVideoFrameFormat frameFormat() const override;
41
42 std::optional<int> ffmpegHWPixelFormat() const override;
43
44 void onNewFrameFormatReceived(QMacScreenCaptureKit::StreamId streamId, const QVideoFrameFormat &);
45
46 void onStreamStoppedWithErrorEvent(QMacScreenCaptureKit::StreamId streamId, const QString &);
47
48protected:
49 bool setActiveInternal(bool active) override;
50
51private:
52 QFFmpegMediaCaptureSession *m_session = nullptr;
53
54 // Tracks the next ID for establishing stream.
55 // Having stream IDs helps us track whether we should
56 // ignore events from lingering stream callbacks.
57 int64_t m_streamIdAllocator = 0;
58 [[nodiscard]] QMacScreenCaptureKit::StreamId allocateStreamId() {
59 return QMacScreenCaptureKit::StreamId { m_streamIdAllocator++ };
60 }
61
62 struct ActiveData {
63 QMacScreenCaptureKit::StreamId streamId = {};
64 AVFScopedPointer<SCWindow> scWindow;
65 std::unique_ptr<QMacScreenCaptureKit> macScreenCaptureKit;
66 };
67 // Is allowed to be null when we have no on-going stream.
68 std::unique_ptr<ActiveData> m_activeData;
69
70 std::optional<QVideoFrameFormat> m_videoFrameFormat;
71
72 [[nodiscard]] std::optional<QMacScreenCaptureKit::StreamId> activeStreamId() const noexcept {
73 if (m_activeData)
74 return m_activeData->streamId;
75 return std::nullopt;
76 }
77};
78
79} // namespace QFFmpeg
80
81QT_END_NAMESPACE
82
83#endif // QSCKWINDOWCAPTURE_H
void onStreamStoppedWithErrorEvent(QMacScreenCaptureKit::StreamId streamId, const QString &)
void setCaptureSession(QPlatformMediaCaptureSession *) override
std::optional< int > ffmpegHWPixelFormat() const override
QVideoFrameFormat frameFormat() const override
void onNewFrameFormatReceived(QMacScreenCaptureKit::StreamId streamId, const QVideoFrameFormat &)
bool setActiveInternal(bool active) override
~QSckWindowCapture() override=default
QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) QMacScreenCaptureStreamDelegate
std::unique_ptr< QPlatformSurfaceCapture > makeQSckWindowCapture()