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
qcgcapturablewindows.mm
Go to the documentation of this file.
1
// Copyright (C) 2023 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
#
include
<
QtFFmpegMediaPluginImpl
/
private
/
qcgcapturablewindows_p
.
h
>
5
6
#
include
<
QtCore
/
private
/
qcore_mac_p
.
h
>
7
8
#
include
<
QtGui
/
qwindow
.
h
>
9
10
#
include
<
QtMultimedia
/
private
/
qcapturablewindow_p
.
h
>
11
12
#
include
<
QtFFmpegMediaPluginImpl
/
private
/
qffmpegdarwinintegrationfactory_p
.
h
>
13
14
#
import
<
AppKit
/
NSWindow
.
h
>
15
16
QT_BEGIN_NAMESPACE
17
18
namespace
QFFmpeg
{
19
20
QList
<
QCapturableWindow
>
QCGCapturableWindows
::
windows
()
const
21
{
22
QList
<
QCapturableWindow
>
result
;
23
QCFType
<
CFArrayRef
>
windowList
(
24
CGWindowListCopyWindowInfo
(
kCGWindowListOptionOnScreenOnly
,
kCGNullWindowID
));
25
26
// Iterate through the window dictionaries
27
CFIndex
count
=
CFArrayGetCount
(
windowList
);
28
for
(
CFIndex
i
= 0;
i
<
count
; ++
i
) {
29
auto
windowInfo
= (
CFDictionaryRef
)
CFArrayGetValueAtIndex
(
windowList
,
i
);
30
auto
windowNumber
= (
CFNumberRef
)
CFDictionaryGetValue
(
windowInfo
,
kCGWindowNumber
);
31
auto
windowName
= (
CFStringRef
)
CFDictionaryGetValue
(
windowInfo
,
kCGWindowName
);
32
33
CGWindowID
windowId
= 0;
34
static_assert
(
sizeof
(
windowId
) == 4,
35
"CGWindowID size is not compatible with kCFNumberSInt32Type"
);
36
CFNumberGetValue
(
windowNumber
,
kCFNumberSInt32Type
, &
windowId
);
37
38
QString
windowDescription
;
39
if
(
windowName
)
40
windowDescription
=
QString
::
fromCFString
(
windowName
);
41
42
result
.
push_back
(
QCapturableWindowPrivate
::
create
(
43
static_cast
<
QCapturableWindowPrivate
::
Id
>(
windowId
),
44
std
::
move
(
windowDescription
)));
45
}
46
47
return
result
;
48
}
49
50
bool
QCGCapturableWindows
::
isWindowValid
(
const
QCapturableWindowPrivate
&
window
)
const
51
{
52
QCFType
<
CFArrayRef
>
windowList
(
53
CGWindowListCreate
(
kCGWindowListOptionIncludingWindow
,
window
.
id
));
54
return
CFArrayGetCount
(
windowList
) > 0;
55
}
56
57
q23
::
expected
<
QCapturableWindow
,
QString
>
QCGCapturableWindows
::
fromQWindow
(
QWindow
*
window
)
const
58
{
59
auto
*
nsView
=
reinterpret_cast
<
NSView
*>(
window
->
winId
());
60
61
NSWindow
*
nsWindow
= [
nsView
window
];
62
if
(
nsWindow
==
nullptr
)
63
return
q23
::
unexpected
{
QStringLiteral
(
"NSView had no associated NSWindow"
) };
64
65
const
auto
cgWindowId
= (
CGWindowID
)[
nsWindow
windowNumber
];
66
if
(
cgWindowId
==
kCGNullWindowID
)
67
return
q23
::
unexpected
{
QStringLiteral
(
"NSWindow has no CGWindowID"
) };
68
69
return
QCapturableWindowPrivate
::
create
(
70
static_cast
<
QCapturableWindowPrivate
::
Id
>(
cgWindowId
),
71
window
->
title
());
72
}
73
74
std
::
unique_ptr
<
QPlatformCapturableWindows
>
makeQCgCapturableWindows
()
75
{
76
return
std::make_unique<QCGCapturableWindows>();
77
}
78
79
}
// namespace QFFmpeg
80
81
QT_END_NAMESPACE
QFFmpeg::makeQCgCapturableWindows
std::unique_ptr< QPlatformCapturableWindows > makeQCgCapturableWindows()
Definition
qcgcapturablewindows.mm:74
QFFmpeg::AvioWriteBufferType
std::conditional_t< QT_FFMPEG_AVIO_WRITE_CONST, const uint8_t *, uint8_t * > AvioWriteBufferType
Definition
qffmpegioutils_p.h:29
qtmultimedia
src
plugins
multimedia
ffmpeg
darwin
qcgcapturablewindows.mm
Generated on
for Qt by
1.16.1