Revert "mac: Work around an inccorect availability annotation in the 13.3 SDK"

This reverts commit 0f87b3853554ee5d4e92e487a5165b57771b6742.

This is not needed with the macOS 14 SDK, which has the fix, and which
was landed in https://crrev.com/c/4875713.

Bug: chromium:1484363, chromium:1431897
Change-Id: I1e019ce71b90333d5d1333a3cf8bb510a3dbd212
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/320820
Reviewed-by: Tomas Gunnarsson <tommi@google.com>
Auto-Submit: Avi Drissman <avi@chromium.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40777}
This commit is contained in:
Avi Drissman 2023-09-19 13:15:27 -04:00 committed by WebRTC LUCI CQ
parent 5551776035
commit 46da472f82

View File

@ -20,87 +20,6 @@
#include "rtc_base/trace_event.h"
#include "sdk/objc/helpers/scoped_cftyperef.h"
// All these symbols have incorrect availability annotations in the 13.3 SDK.
// These have the correct annotation. See https://crbug.com/1431897.
// TODO(thakis): Remove this once FB12109479 is fixed and we updated to an SDK
// with the fix.
static CGDisplayStreamRef __nullable
wrapCGDisplayStreamCreate(CGDirectDisplayID display,
size_t outputWidth,
size_t outputHeight,
int32_t pixelFormat,
CFDictionaryRef __nullable properties,
CGDisplayStreamFrameAvailableHandler __nullable handler)
CG_AVAILABLE_BUT_DEPRECATED(
10.8,
14.0,
"Please use ScreenCaptureKit API's initWithFilter:configuration:delegate: instead") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return CGDisplayStreamCreate(
display, outputWidth, outputHeight, pixelFormat, properties, handler);
#pragma clang diagnostic pop
}
static CFRunLoopSourceRef __nullable
wrapCGDisplayStreamGetRunLoopSource(CGDisplayStreamRef cg_nullable displayStream)
CG_AVAILABLE_BUT_DEPRECATED(10.8,
14.0,
"There is no direct replacement for this function. Please use "
"ScreenCaptureKit API's SCStream to replace CGDisplayStream") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return CGDisplayStreamGetRunLoopSource(displayStream);
#pragma clang diagnostic pop
}
static CGError wrapCGDisplayStreamStart(CGDisplayStreamRef cg_nullable displayStream)
CG_AVAILABLE_BUT_DEPRECATED(10.8,
14.0,
"Please use ScreenCaptureKit API's "
"startCaptureWithCompletionHandler: to start a stream instead") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return CGDisplayStreamStart(displayStream);
#pragma clang diagnostic pop
}
static CGError wrapCGDisplayStreamStop(CGDisplayStreamRef cg_nullable displayStream)
CG_AVAILABLE_BUT_DEPRECATED(10.8,
14.0,
"Please use ScreenCaptureKit API's "
"stopCaptureWithCompletionHandler: to stop a stream instead") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return CGDisplayStreamStop(displayStream);
#pragma clang diagnostic pop
}
static CFStringRef wrapkCGDisplayStreamShowCursor() CG_AVAILABLE_BUT_DEPRECATED(
10.8,
14.0,
"Please use ScreenCaptureKit API's SCStreamConfiguration showsCursor property instead") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return kCGDisplayStreamShowCursor;
#pragma clang diagnostic pop
}
static const CGRect* __nullable
wrapCGDisplayStreamUpdateGetRects(CGDisplayStreamUpdateRef __nullable updateRef,
CGDisplayStreamUpdateRectType rectType,
size_t* rectCount)
CG_AVAILABLE_BUT_DEPRECATED(10.8,
14.0,
"Please use ScreenCaptureKit API's SCStreamFrameInfo with "
"SCStreamFrameInfoContentRect instead") {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability-new"
return CGDisplayStreamUpdateGetRects(updateRef, rectType, rectCount);
#pragma clang diagnostic pop
}
namespace webrtc {
namespace {
@ -540,7 +459,7 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
size_t count = 0;
const CGRect* rects =
wrapCGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count);
CGDisplayStreamUpdateGetRects(updateRef, kCGDisplayStreamUpdateDirtyRects, &count);
if (count != 0) {
// According to CGDisplayStream.h, it's safe to call
// CGDisplayStreamStop() from within the callback.
@ -550,20 +469,20 @@ bool ScreenCapturerMac::RegisterRefreshAndMoveHandlers() {
rtc::ScopedCFTypeRef<CFDictionaryRef> properties_dict(
CFDictionaryCreate(kCFAllocatorDefault,
(const void*[]){wrapkCGDisplayStreamShowCursor()},
(const void*[]){kCGDisplayStreamShowCursor},
(const void*[]){kCFBooleanFalse},
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
CGDisplayStreamRef display_stream = wrapCGDisplayStreamCreate(
CGDisplayStreamRef display_stream = CGDisplayStreamCreate(
display_id, pixel_width, pixel_height, 'BGRA', properties_dict.get(), handler);
if (display_stream) {
CGError error = wrapCGDisplayStreamStart(display_stream);
CGError error = CGDisplayStreamStart(display_stream);
if (error != kCGErrorSuccess) return false;
CFRunLoopSourceRef source = wrapCGDisplayStreamGetRunLoopSource(display_stream);
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(display_stream);
CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
display_streams_.push_back(display_stream);
}
@ -576,9 +495,9 @@ void ScreenCapturerMac::UnregisterRefreshAndMoveHandlers() {
RTC_DCHECK(thread_checker_.IsCurrent());
for (CGDisplayStreamRef stream : display_streams_) {
CFRunLoopSourceRef source = wrapCGDisplayStreamGetRunLoopSource(stream);
CFRunLoopSourceRef source = CGDisplayStreamGetRunLoopSource(stream);
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), source, kCFRunLoopCommonModes);
wrapCGDisplayStreamStop(stream);
CGDisplayStreamStop(stream);
CFRelease(stream);
}
display_streams_.clear();