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
qmacscreencapturekit.mm
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
5
6#include <QtCore/qmutex.h>
7
8#include <QtFFmpegMediaPluginImpl/private/qcvimagevideobuffer_p.h>
9#include <QtFFmpegMediaPluginImpl/private/qffmpegdarwinhwframehelpers_p.h>
10#define AVMediaType XAVMediaType
11#include <QtFFmpegMediaPluginImpl/private/qffmpeghwaccel_p.h>
12#include <QtFFmpegMediaPluginImpl/private/qffmpegvideobuffer_p.h>
13extern "C" {
14#include <libavutil/hwcontext_videotoolbox.h>
15}
16#undef AVMediaType
17
18#include <QtMultimedia/private/qavfcamerautility_p.h>
19#include <QtMultimedia/private/qavfhelpers_p.h>
20#include <QtMultimedia/private/qvideoframe_p.h>
21
22#include <CoreMedia/CMSync.h>
23#include <CoreMedia/CMTime.h>
24#include <ScreenCaptureKit/ScreenCaptureKit.h>
25
26#include <chrono>
27
28using namespace Qt::Literals::StringLiterals;
29using QMacScreenCaptureKit = QT_PREPEND_NAMESPACE(QFFmpeg::QMacScreenCaptureKit);
30
32 QT_PREPEND_NAMESPACE(QFFmpeg::qLcMacScreenCapture),
33 "qt.multimedia.screencapture.macscreencapturekit");
34
35namespace {
36
37struct QMacScreenCaptureStreamDelegateHelper : public QObject {
38 Q_OBJECT
39Q_SIGNALS:
40 void didStopWithError(QMacScreenCaptureKit::StreamId streamId, QString);
41};
42
43} // Anonymous namespace
44
45// Events are invoked on system background thread that we don't control.
46@implementation QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamDelegate) {
47@public
48 QMacScreenCaptureKit::StreamId m_streamId;
49 QMacScreenCaptureStreamDelegateHelper m_helper;
50}
51
52- (void)stream:(SCStream *)stream didStopWithError:(NSError *)error
53{
54 Q_EMIT m_helper.didStopWithError(
55 m_streamId,
56 QString::fromNSString(error.localizedDescription));
57}
58
59@end
60
61QT_BEGIN_NAMESPACE
62
63namespace QFFmpeg {
64
65static void handleFrameOutput(
66 QMacScreenCaptureStreamOutput &scStreamOutput,
67 CMSampleBufferRef sampleBufferRef);
68} // namespace QFFmpeg
69
70QT_END_NAMESPACE
71
72// Invoked on background dispatch-queue.
73@implementation QT_MANGLE_NAMESPACE(QMacScreenCaptureStreamOutput) {
74@public
75 // Assigned at construction. We assume it is safe to never reset it, because
76 // we flush the background queue anytime we stop a stream.
77 QT_PREPEND_NAMESPACE(QFFmpeg::QMacScreenCaptureKit) *m_qScreenCaptureKit;
78
79 // Used to track when the underlying window size changed, in pixel-coordinates.
80 QSize m_previousFrameContentRect;
81
82 // Presentation timestamp of the first frame of the stream. Used to report
83 // frame times relative to the start of the stream.
84 std::optional<std::chrono::microseconds> m_baseTime;
85 // Start time of the most recent frame, relative to m_baseTime.
86 std::chrono::microseconds m_lastPresentationTime;
87 std::unique_ptr<QT_PREPEND_NAMESPACE(QFFmpeg::HWAccel)> m_hwAccel;
88}
89
90- (void) stream:(SCStream *) stream
91didOutputSampleBuffer:(CMSampleBufferRef) sampleBufferRef
92 ofType:(SCStreamOutputType) type
93{
94 QT_USE_NAMESPACE
95 using namespace QFFmpeg;
96
97 // SCStreamOutputTypeScreen implies we are receiving video frames
98 // rather than audio samples. It doesn't exclude windows.
99 // Our stream is hardcoded to never report audio samples.
100 Q_ASSERT(type == SCStreamOutputTypeScreen);
101
102 handleFrameOutput(*self, sampleBufferRef);
103}
104
105@end
106
107QT_BEGIN_NAMESPACE
108
109namespace QFFmpeg {
110
111// Useful metadata grabbed from a CMSampleBufferRef.
113{
115
116 // The size of the captured content, in pixel-coordinates.
117 // Can be used to detect e.g. window size changes.
119};
120
121// Reads the frame status and content rect for the given CMSampleBufferRef.
122// The content rect usually means the window size at the time a frame was
123// outputted. The resolution is in pixel coordinates.
124// Error message is not user-facing.
125[[nodiscard]] static q23::expected<FrameInfo, QString> readFrameInfo(CMSampleBufferRef sampleBuffer)
126{
127 CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, false);
128 if (!attachments || CFArrayGetCount(attachments) == 0)
129 return q23::unexpected{ u"CMSampleBuffer has no attachments array"_s };
130
131 CFDictionaryRef attachment = (CFDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);
132 NSDictionary *dict = (__bridge NSDictionary *)attachment;
133
134 NSNumber *statusNumber = dict[(id)SCStreamFrameInfoStatus];
135 if (!statusNumber)
136 return q23::unexpected{ u"CMSampleBuffer has no frame status"_s };
137
138 FrameInfo info;
139 info.status = static_cast<SCFrameStatus>(statusNumber.intValue);
140
141 CGRect contentRect = CGRectZero;
142 NSDictionary *frameInfo = dict[(id)SCStreamFrameInfoContentRect];
143 if (frameInfo) {
144 contentRect = CGRectMakeWithDictionaryRepresentation(
145 (__bridge CFDictionaryRef)frameInfo, &contentRect)
146 ? contentRect
147 : CGRectZero;
148 }
149
150 NSNumber *scaleNumber = dict[(id)SCStreamFrameInfoScaleFactor];
151 CGFloat scaleFactor = scaleNumber ? scaleNumber.doubleValue : 1.0;
152
153 NSNumber *contentScaleNumber = dict[(id)SCStreamFrameInfoContentScale];
154 CGFloat contentScale = contentScaleNumber ? contentScaleNumber.doubleValue : 1.0;
155 if (contentScale <= 0.0)
156 contentScale = 1.0;
157
158 info.contentRect = QSize{
159 static_cast<int>(std::lround(contentRect.size.width * scaleFactor / contentScale)),
160 static_cast<int>(std::lround(contentRect.size.height * scaleFactor / contentScale)), };
161
162 return info;
163}
164
165// Invoked on background dispatch-queue.
166// Error message is not user-facing.
168 QMacScreenCaptureStreamOutput &scStreamOutput,
169 CMSampleBufferRef sampleBufferRef)
170{
171 CVImageBufferRef imageBufferRef = CMSampleBufferGetImageBuffer(sampleBufferRef);
172 if (!imageBufferRef)
173 return q23::unexpected(u"Cannot get CVImageBufferRef from CMSampleBufferRef"_s);
174 if (CFGetTypeID(imageBufferRef) != CVPixelBufferGetTypeID())
175 return q23::unexpected(u"Grabbed CVImageBufferRef that is not of type CVPixelBuffer"_s);
176
177 auto pixelBuffer = QAVFHelpers::QSharedCVPixelBuffer(
178 imageBufferRef,
179 QAVFHelpers::QSharedCVPixelBuffer::RefMode::NeedsRef);
180
181 // ScreenCaptureKit hands us buffers from its internal pool (see queueDepth),
182 // so copy into a free-standing CVPixelBuffer to decouple the frame's
183 // lifetime from the stream's pool.
184 q23::expected<QAVFHelpers::QSharedCVPixelBuffer, QString> copyResult = deepCopyCvPixelBuffer(
185 pixelBuffer.get());
186 if (!copyResult)
187 return q23::unexpected(u"Failed to copy incoming pixel buffer: "_s + copyResult.error());
188 pixelBuffer = std::move(*copyResult);
189
190 // If the new incoming frames have a different size, update the FFmpeg frames context.
191 QSize incomingFrameSize = QAVFHelpers::CVPixelBufferSize(pixelBuffer.get());
192 Q_ASSERT(!incomingFrameSize.isEmpty());
193 CvPixelFormat incomingCvPixelFormat = CVPixelBufferGetPixelFormatType(pixelBuffer.get());
194 Q_ASSERT(scStreamOutput.m_hwAccel);
195 scStreamOutput.m_hwAccel->updateFramesContext(
196 av_map_videotoolbox_format_to_pixfmt(incomingCvPixelFormat),
197 incomingFrameSize);
198
199 // ScreenCaptureKit timestamps frames on the host clock. QVideoFrame times are
200 // relative to the start of the stream, so use the first frame as our zero point.
201 const std::chrono::microseconds frameTime =
202 QAVFHelpers::CMTimeToMicroseconds(CMSampleBufferGetPresentationTimeStamp(sampleBufferRef));
203 if (!scStreamOutput.m_baseTime)
204 scStreamOutput.m_baseTime = frameTime;
205 const std::chrono::microseconds presentationTime = frameTime - *scStreamOutput.m_baseTime;
206 scStreamOutput.m_lastPresentationTime = presentationTime;
207
208 QVideoFrameFormat format = QAVFHelpers::videoFormatForImageBuffer(pixelBuffer.get());
209 if (!format.isValid())
210 return q23::unexpected(u"Cannot get get video format for image buffer"_s);
211
212 format.setColorSpace(QMacScreenCaptureKit::colorSpace);
213 format.setColorRange(QMacScreenCaptureKit::colorRange);
214 format.setColorTransfer(QMacScreenCaptureKit::colorTransfer);
215
216 Q_ASSERT(scStreamOutput.m_hwAccel);
217 QVideoFrame frame;
218 q23::expected<QVideoFrame, QString> frameResult = QFFmpeg::qVideoFrameFromCvPixelBuffer(
219 *scStreamOutput.m_hwAccel,
220 presentationTime,
221 pixelBuffer,
222 format);
223 if (!frameResult)
224 qCWarning(qLcMacScreenCapture) << frameResult.error();
225 else
226 frame = *frameResult;
227
228 if (!frame.isValid()) {
229 frame = QVideoFramePrivate::createFrame(
230 std::make_unique<QFFmpeg::CVImageVideoBuffer>(std::move(pixelBuffer)),
231 std::move(format));
232 }
233
234 frame.setStartTime(presentationTime.count());
235
236 frame.setEndTime(-1);
237
238 return frame;
239}
240
242 std::chrono::microseconds baseTime,
243 std::chrono::microseconds lastPresentationTime)
244{
245 using namespace std::chrono_literals;
246
247 // ScreenCaptureKit timestamps frames on the host clock, so we can use that clock
248 // to express the end of the stream relative to the start of the stream.
249 // Frame timestamps can be ahead of the host clock, so the end of the stream must
250 // still be placed after the last frame.
251 const std::chrono::microseconds hostTime =
252 QAVFHelpers::CMTimeToMicroseconds(CMClockGetTime(CMClockGetHostTimeClock()));
253 std::chrono::microseconds endTime = hostTime - baseTime;
254 if (endTime <= lastPresentationTime)
255 endTime = lastPresentationTime + 1us;
256 return QVideoFramePrivate::createEndOfStreamFrame(endTime);
257}
258
259// Main frame handler.
260// Invoked on background dispatch-queue.
262 QFFmpeg::QMacScreenCaptureStreamOutput &streamOutput,
263 CMSampleBufferRef sampleBufferRef)
264{
265 Q_ASSERT(streamOutput.m_qScreenCaptureKit);
266
267 q23::expected<FrameInfo, QString> frameInfoResult = readFrameInfo(sampleBufferRef);
268 if (!frameInfoResult) {
269 qCDebug(qLcMacScreenCapture)
270 << "Error while reading frame info of CMSampleBufferRef:"
271 << frameInfoResult.error();
272 return;
273 }
274
275 const FrameInfo &frameInfo = *frameInfoResult;
276
277 // ScreenCaptureKit only hands us a new hardware buffer when the frame status
278 // is complete. For other statuses (e.g. idle when the captured content is
279 if (frameInfo.status != SCFrameStatusComplete)
280 return;
281
282 // The content rect is the updated resolution of the window we are capturing.
283 // If the window size is different from our current stream configuration,
284 // issue a reconfiguration.
285 //
286 // If the content rect is empty, it's usually an indication that the window has
287 // been minimized while capturing it. We keep the stream unchanged so that it
288 // is automatically resumed when the window is restored.
289 if (!frameInfo.contentRect.isEmpty()) {
290 if (streamOutput.m_previousFrameContentRect != frameInfo.contentRect)
291 streamOutput.m_qScreenCaptureKit->updateStream(frameInfo.contentRect);
292
293 streamOutput.m_previousFrameContentRect = frameInfo.contentRect;
294 }
295
296 q23::expected<QVideoFrame, QString> videoFrameResult = createQVideoFrame(
297 streamOutput,
298 sampleBufferRef);
299 if (!videoFrameResult) {
300 qCWarning(qLcMacScreenCapture)
301 << "Failed to create qVideoFrame from CMSampleBufferRef:"
302 << videoFrameResult.error();
303 return;
304 }
305
306 Q_EMIT streamOutput.m_qScreenCaptureKit->newVideoFrameGenerated(
307 streamOutput.m_qScreenCaptureKit->streamId(),
308 std::move(*videoFrameResult));
309}
310
312 QSize resolutionPx,
313 QMacScreenCaptureKit::StreamSettings const& settings)
314{
315 // SCStreamConfiguration defines the output format, having zero resolution makes no sense.
316 Q_ASSERT(!resolutionPx.isEmpty());
317
318 // TODO: Possible improvements include specifying pixel format, HDR,
319 // capturing system audio...
320 auto scStreamConfig = AVFScopedPointer{ [[SCStreamConfiguration alloc] init] };
321 scStreamConfig.data().width = resolutionPx.width();
322 scStreamConfig.data().height = resolutionPx.height();
323 // We make a best-effort to always adjust our video output to match the window/screen size.
324 // So we leave scaling off to be pixel-perfect whenever we can.
325 scStreamConfig.data().scalesToFit = false;
326 scStreamConfig.data().queueDepth = QMacScreenCaptureKit::queueDepth;
327 scStreamConfig.data().pixelFormat = QMacScreenCaptureKit::cvPixelFormat;
328 scStreamConfig.data().colorSpaceName = QMacScreenCaptureKit::cgColorSpace();
329 scStreamConfig.data().ignoreShadowsSingleWindow = true;
330 scStreamConfig.data().captureResolution = SCCaptureResolutionBest;
331 if (@available(macOS 15.0, *))
332 scStreamConfig.data().captureDynamicRange = SCCaptureDynamicRangeSDR;
333
334 if (settings.frameRate) {
335 Q_ASSERT(settings.frameRate > 0);
336 scStreamConfig.data().minimumFrameInterval =
337 CMTimeMake(1, static_cast<int32_t>(std::round(*settings.frameRate)));
338 } else {
339 scStreamConfig.data().minimumFrameInterval = kCMTimeZero;
340 }
341
342 // These settings are meant to override whatever the default is.
343 if (settings.overrideIgnoreCursor)
344 scStreamConfig.data().showsCursor = false;
345
346 return scStreamConfig;
347}
348
350 QMacScreenCaptureStreamDelegate &streamDelegate,
351 QMacScreenCaptureKit::StreamId streamId,
352 const QMacScreenCaptureKit &macScreenCaptureKit)
353{
354 streamDelegate.m_streamId = streamId;
355 QObject::connect(
356 &streamDelegate.m_helper,
357 &QMacScreenCaptureStreamDelegateHelper::didStopWithError,
358 &macScreenCaptureKit,
359 &QMacScreenCaptureKit::streamStoppedWithError);
360}
361
364 QMacScreenCaptureKit &macScreenCaptureKit,
365 uint32_t cvPixelFormat,
366 QSize resolution)
367{
368 auto streamOutput = AVFScopedPointer{ [[QMacScreenCaptureStreamOutput alloc] init] };
369
370 streamOutput.data()->m_qScreenCaptureKit = &macScreenCaptureKit;
371
372 streamOutput.data()->m_previousFrameContentRect = resolution;
373
374 streamOutput.data()->m_hwAccel = HWAccel::create(AV_HWDEVICE_TYPE_VIDEOTOOLBOX);
375 if (!streamOutput.data()->m_hwAccel)
376 return q23::unexpected(
377 u"Unable to create FFmpeg HW context when starting ScreenCaptureKit stream"_s);
378
379 streamOutput.data()->m_hwAccel->createFramesContext(
380 av_map_videotoolbox_format_to_pixfmt(cvPixelFormat),
381 resolution);
382
383 if (!streamOutput.data()->m_hwAccel->hwFramesContextAsBuffer())
384 return q23::unexpected(
385 u"Unable to create FFmpeg HW context when starting ScreenCaptureKit stream"_s);
386
387 return streamOutput;
388}
389
391{
392 Q_ASSERT(scDisplay);
393 return AVFScopedPointer<SCContentFilter>{ [[SCContentFilter alloc]
394 initWithDisplay: scDisplay
395 excludingWindows: @[] ] };
396}
397
399{
400 Q_ASSERT(scWindow);
401 return AVFScopedPointer<SCContentFilter>{ [[SCContentFilter alloc]
402 initWithDesktopIndependentWindow: scWindow] };
403}
404
405// Returns the resolution of the filtered content, in pixel-coordinates.
406// Error message is not user-facing.
408 SCContentFilter *scContentFilter)
409{
410 // SCContentFilter.contentRect is in screen-points, not pixels. Multiply by
411 // pointPixelScale.
412 const CGRect contentRect = scContentFilter.contentRect;
413 const QSize resolutionPx =
414 (QSizeF::fromCGSize(contentRect.size) * scContentFilter.pointPixelScale).toSize();
415
416 // Rare edge cases have shown contentRect to sometimes be empty.
417 if (resolutionPx.isEmpty())
418 return q23::unexpected{ u"SCContentFilter contentRect reported as zero size"_s };
419
420 return resolutionPx;
421}
422
423// The strategy is to flush any remaining jobs on the background thread, and then
424// mark the end of the stream with a null-frame.
426{
427 if (!m_stream)
428 return;
429
430 // Issue a blocking stop command.
431 dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
432 [m_stream.data() stopCaptureWithCompletionHandler:[semaphore](NSError *error) {
433 if (error) {
434 qCWarning(qLcMacScreenCapture)
435 << "Error while stopping ScreenCaptureKit stream during teardown:"
436 << QString::fromNSString(error.localizedDescription);
437 }
438 dispatch_semaphore_signal(semaphore);
439 }];
440 dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
441 dispatch_release(semaphore);
442
443 // Mark the end of the stream with a null-frame. We emit it from the background
444 // queue so that it is ordered after, and serialized with, the normal frames.
445 // Note that dispatch_sync() may run its block on the calling thread, so the
446 // emit must use dispatch_async().
447 if (m_dispatchQueue) {
448 Q_ASSERT(m_streamOutput);
449 // m_baseTime is owned by the background queue, so it is only read from there.
450 // The queue is serial, so this runs after all frames that were already delivered.
451 dispatch_async(m_dispatchQueue.data(), [this] {
452 QMacScreenCaptureStreamOutput *streamOutput = m_streamOutput.data();
453 std::optional<std::chrono::microseconds> baseTime = streamOutput->m_baseTime;
454
455 // A stream that never delivered a frame never started, in which case there is
456 // no stream for consumers to see the end of.
457 if (!baseTime)
458 return;
459
460 QVideoFrame endFrame = createEndOfStreamFrame(
461 *baseTime,
462 streamOutput->m_lastPresentationTime);
463 emit newVideoFrameGenerated(m_streamId, endFrame);
464 });
465
466 // Flush the dispatch_queue. After this we assume it's safe to tear everything down.
467 dispatch_sync(m_dispatchQueue.data(), []{});
468 }
469}
470
471// This will commonly fail if we are missing permissions for screen capturing.
472// It will also open the "Grant permissions" system dialog if we are missing
473// permissions.
474//
475// Thread-safe.
476//
477// Error-message is not user-facing
480{
481 // Block functions can only capture copyable types.
482 // Wrap the promise in a shared-ptr.
484
485 // This function call will open the permissions system dialog when applicable.
488 NSError *error)
489 {
490 if (error != nil) {
492 return;
493 }
494
496
500
504
506 }];
507
508 return promise->get_future();
509}
510
520
521// Note that we are using manual memory management here, because Obj-C block functions
522// do not support capturing move-only types.
527{
529
531 auto future = promise->get_future();
532
534 if (!resolutionResult) {
536 return future;
537 }
539
541
545
551 }
552
555 *captureKit,
558 if (!streamOutputResult) {
560 return future;
561 }
563
566
571
573 dispatch_queue_create("qt_screencapture", DISPATCH_QUEUE_SERIAL) };
574
575 NSError *addStreamError = nullptr;
580 if (addStreamError != nil) {
581 promise->set_value(q23::unexpected(u"Unable to add stream output to SCStream"_s));
582 return future;
583 }
584
589
590 // Block functions for the completion handler require
591 // that the callable is copyable. This means we can't capture
592 // move-only types. So we temporarily release the unique_ptr here,
593 // and switch to manual memory management and then adopt them
594 // back into AVFScopedPointer inside the callback.
595 // We assume the completion handler is always called, either with success or error.
599 (NSError *error)
600 {
602
603 if (error != nil) {
604 promise->set_value(q23::unexpected{ u"Error when starting screen capturing stream"_s });
605 return;
606 }
607
609 }];
610
611 return future;
612}
613
614// Frames may arrive on the background thread immediately after the
615// creation success event has been emitted, sometimes even out of order.
616// This function takes a function that allows us to establish
617// the connections on the newly constructed object before
618// the stream ever starts, so we never miss any frames.
628
629// We first switch the content filter, and then reconfigure the stream for the
630// resolution of the new content. Finally we flush the background queue, so the
631// frames that were queued up for the old content are emitted before we signal.
634{
635 using ResultType = q23::expected<void, QString>;
636
639
641 auto future = promise->get_future();
642
644 if (!resolutionResult) {
646 return future;
647 }
649
651 if (error != nil) {
653 u"Error when reconfiguring stream for new content: "_s
655 return;
656 }
657
659 // The stream is already configured for the new content,
660 // so the frame handler doesn't need to reconfigure it.
663 });
664 };
665
667 NSError *error)
668 {
669 if (error != nil) {
671 u"Error when switching stream content: "_s
673 return;
674 }
675
679
680 [m_stream.data()
683 };
684
685 [m_stream.data()
688
689 return future;
690}
691
697
703
704// Issues a stream configuration update, so that the stream will give us video frames
705// of a new resolution.
706void QMacScreenCaptureKit::startStreamReconfigure(
707 SCStream *scStream,
708 QSize resolutionPx,
709 StreamSettings const &streamSettings)
710{
711 Q_ASSERT(scStream);
712
713 AVFScopedPointer<SCStreamConfiguration> scStreamConfig = createStreamConfig(
714 resolutionPx,
715 streamSettings);
716
717 [scStream
718 updateConfiguration:scStreamConfig.data()
719 completionHandler:[](NSError *err) {
720 if (err) {
721 // TODO: Send potential error back to QMacScreenCaptureKit, but only
722 // if the error stops the stream.
723 qCWarning(qLcMacScreenCapture)
724 << "Error when reconfiguring ScreenCaptureKit stream:"
725 << QString::fromNSString(err.description);
726 return;
727 }
728 }];
729}
730
731// Reconfigures the stream with a new output resolution.
732// Does not stop the stream.
733// Input resolution is in pixel-coordinates.
734// Must be called from background dispatch_queue.
735void QMacScreenCaptureKit::updateStream(QSize resolutionPx)
736{
737 Q_ASSERT(m_dispatchQueue);
738 dispatch_assert_queue(m_dispatchQueue.data());
739
740 startStreamReconfigure(m_stream.data(), resolutionPx, m_streamSettings);
741}
742
743} // namespace QFFmpeg
744
745QT_END_NAMESPACE
746
747#include "moc_qmacscreencapturekit_p.cpp"
748#include "qmacscreencapturekit.moc"
void updateStream(QSize resolutionPx)
static AVFScopedPointer< SCStreamConfiguration > createStreamConfig(QSize resolutionPx, QMacScreenCaptureKit::StreamSettings const &settings)
static AVFScopedPointer< SCContentFilter > createDisplayFilter(SCDisplay *scDisplay)
Q_DECLARE_LOGGING_CATEGORY(qLcMacScreenCapture)
static void handleFrameOutput(QMacScreenCaptureStreamOutput &scStreamOutput, CMSampleBufferRef sampleBufferRef)
static q23::expected< QVideoFrame, QString > createQVideoFrame(QMacScreenCaptureStreamOutput &scStreamOutput, CMSampleBufferRef sampleBufferRef)
static QVideoFrame createEndOfStreamFrame(std::chrono::microseconds baseTime, std::chrono::microseconds lastPresentationTime)
static q23::expected< AVFScopedPointer< QMacScreenCaptureStreamOutput >, QString > createStreamOutput(QMacScreenCaptureKit &macScreenCaptureKit, uint32_t cvPixelFormat, QSize resolution)
static AVFScopedPointer< SCContentFilter > createWindowFilter(SCWindow *scWindow)
static void configureStreamDelegate(QMacScreenCaptureStreamDelegate &streamDelegate, QMacScreenCaptureKit::StreamId streamId, const QMacScreenCaptureKit &macScreenCaptureKit)
static q23::expected< FrameInfo, QString > readFrameInfo(CMSampleBufferRef sampleBuffer)
static q23::expected< QSize, QString > resolutionForFilter(SCContentFilter *scContentFilter)
Q_LOGGING_CATEGORY_IMPL(QT_PREPEND_NAMESPACE(QFFmpeg::qLcMacScreenCapture), "qt.multimedia.screencapture.macscreencapturekit")