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