1
0
Fork 0
firefox/third_party/libwebrtc/moz-patch-stack/0119.patch
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

82 lines
3.6 KiB
Diff

From: Andreas Pehrson <apehrson@mozilla.com>
Date: Thu, 12 Sep 2024 22:36:00 +0000
Subject: Bug 1918096 - In ScreenCapturerSck improve dictionary ergonomics.
r=webrtc-reviewers,ng
Differential Revision: https://phabricator.services.mozilla.com/D221940
Mercurial Revision: https://hg.mozilla.org/mozilla-central/rev/aabf0bd94f282ae97a010016058446e45fc781c8
---
.../mac/screen_capturer_sck.mm | 26 +++++++------------
1 file changed, 10 insertions(+), 16 deletions(-)
diff --git a/modules/desktop_capture/mac/screen_capturer_sck.mm b/modules/desktop_capture/mac/screen_capturer_sck.mm
index 379784afa2..915aa90bd7 100644
--- a/modules/desktop_capture/mac/screen_capturer_sck.mm
+++ b/modules/desktop_capture/mac/screen_capturer_sck.mm
@@ -110,7 +110,7 @@ class API_AVAILABLE(macos(14.0)) ScreenCapturerSck final
// Called by SckHelper to notify of a newly captured frame. May run on an
// arbitrary thread.
- void OnNewIOSurface(IOSurfaceRef io_surface, CFDictionaryRef attachment);
+ void OnNewIOSurface(IOSurfaceRef io_surface, NSDictionary* attachment);
private:
// Called when starting the capturer or the configuration has changed (either
@@ -524,10 +524,13 @@ void ScreenCapturerSck::StartWithFilter(SCContentFilter* __strong filter) {
}
void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface,
- CFDictionaryRef attachment) {
+ NSDictionary* attachment) {
RTC_LOG(LS_VERBOSE) << "ScreenCapturerSck " << this << " " << __func__
<< " width=" << IOSurfaceGetWidth(io_surface)
<< ", height=" << IOSurfaceGetHeight(io_surface) << ".";
+
+ const auto* dirty_rects = (NSArray*)attachment[SCStreamFrameInfoDirtyRects];
+
rtc::ScopedCFTypeRef<IOSurfaceRef> scoped_io_surface(
io_surface, rtc::RetainPolicy::RETAIN);
std::unique_ptr<DesktopFrameIOSurface> desktop_frame_io_surface =
@@ -551,29 +554,20 @@ void ScreenCapturerSck::OnNewIOSurface(IOSurfaceRef io_surface,
}
if (!dirty) {
- const void* dirty_rects_ptr = CFDictionaryGetValue(
- attachment, (__bridge CFStringRef)SCStreamFrameInfoDirtyRects);
- if (!dirty_rects_ptr) {
+ if (!dirty_rects) {
// This is never expected to happen - SCK attaches a non-empty dirty-rects
// list to every frame, even when nothing has changed.
return;
}
- if (CFGetTypeID(dirty_rects_ptr) != CFArrayGetTypeID()) {
- return;
- }
-
- CFArrayRef dirty_rects_array = static_cast<CFArrayRef>(dirty_rects_ptr);
- int size = CFArrayGetCount(dirty_rects_array);
- for (int i = 0; i < size; i++) {
- const void* rect_ptr = CFArrayGetValueAtIndex(dirty_rects_array, i);
+ for (NSUInteger i = 0; i < dirty_rects.count; i++) {
+ const auto* rect_ptr = (__bridge CFDictionaryRef)dirty_rects[i];
if (CFGetTypeID(rect_ptr) != CFDictionaryGetTypeID()) {
// This is never expected to happen - the dirty-rects attachment should
// always be an array of dictionaries.
return;
}
CGRect rect{};
- CGRectMakeWithDictionaryRepresentation(
- static_cast<CFDictionaryRef>(rect_ptr), &rect);
+ CGRectMakeWithDictionaryRepresentation(rect_ptr, &rect);
if (!CGRectIsEmpty(rect)) {
dirty = true;
break;
@@ -728,7 +722,7 @@ std::unique_ptr<DesktopCapturer> CreateGenericCapturerSck(
webrtc::MutexLock lock(&_capturer_lock);
if (_capturer) {
- _capturer->OnNewIOSurface(ioSurface, attachment);
+ _capturer->OnNewIOSurface(ioSurface, (__bridge NSDictionary*)attachment);
}
}