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
49private:
50 QFFmpegMediaCaptureSession *m_session = nullptr;
51
52 // Tracks the next ID for establishing stream.
53 // Having stream IDs helps us track whether we should
54 // ignore events from lingering stream callbacks.
55 int64_t m_streamIdAllocator = 0;
56 [[nodiscard]] QMacScreenCaptureKit::StreamId allocateStreamId() {
57 return QMacScreenCaptureKit::StreamId { m_streamIdAllocator++ };
58 }
59
60 struct ActiveData {
61 QMacScreenCaptureKit::StreamId streamId = {};
62 AVFScopedPointer<SCDisplay> scDisplay;
63 std::unique_ptr<QMacScreenCaptureKit> macScreenCaptureKit;
64 };
65 // Is allowed to be null when we have no on-going stream.
66 std::unique_ptr<ActiveData> m_activeData;
67
68 std::optional<QVideoFrameFormat> m_videoFrameFormat;
69
70 [[nodiscard]] std::optional<QMacScreenCaptureKit::StreamId> activeStreamId() const noexcept {
71 if (m_activeData)
72 return m_activeData->streamId;
73 return std::nullopt;
74 }
75
76};
77
78} // namespace QFFmpeg
79
80QT_END_NAMESPACE
81
82#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 &)
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)
QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) QMacScreenCaptureStreamDelegate
std::unique_ptr< QPlatformSurfaceCapture > makeQSckScreenCapture()