diff --git a/Sources/LKObjCHelpers/LKObjCHelpers.m b/Sources/LKObjCHelpers/LKObjCHelpers.m index e240da3a0..d9cbc97a9 100644 --- a/Sources/LKObjCHelpers/LKObjCHelpers.m +++ b/Sources/LKObjCHelpers/LKObjCHelpers.m @@ -4,25 +4,30 @@ @implementation LKObjCHelpers NS_ASSUME_NONNULL_BEGIN -+ (void)finishBroadcastWithoutError:(RPBroadcastSampleHandler *)handler API_AVAILABLE(ios(10.0), macCatalyst(13.1), macos(11.0), tvos(10.0)) { - // Call finishBroadcastWithError with nil error, which ends the broadcast without an error popup - // This is unsupported/undocumented but appears to work and is preferable to an error dialog with a cryptic default message - // See https://stackoverflow.com/a/63402492 for more discussion - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wnonnull" - [handler finishBroadcastWithError:nil]; - #pragma clang diagnostic pop ++ (void)finishBroadcastWithoutError:(RPBroadcastSampleHandler *)handler + API_AVAILABLE(ios(10.0), macCatalyst(13.1), macos(11.0), tvos(10.0), + visionos(1.0)) { +// Call finishBroadcastWithError with nil error, which ends the broadcast +// without an error popup This is unsupported/undocumented but appears to work +// and is preferable to an error dialog with a cryptic default message See +// https://stackoverflow.com/a/63402492 for more discussion +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnonnull" + [handler finishBroadcastWithError:nil]; +#pragma clang diagnostic pop } -+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error { - @try { - tryBlock(); - return YES; - } - @catch (NSException *exception) { - *error = [[NSError alloc] initWithDomain:exception.name code:0 userInfo:exception.userInfo]; - return NO; - } ++ (BOOL)catchException:(void (^)(void))tryBlock + error:(__autoreleasing NSError **)error { + @try { + tryBlock(); + return YES; + } @catch (NSException *exception) { + *error = [[NSError alloc] initWithDomain:exception.name + code:0 + userInfo:exception.userInfo]; + return NO; + } } NS_ASSUME_NONNULL_END diff --git a/Sources/LKObjCHelpers/include/LKObjCHelpers.h b/Sources/LKObjCHelpers/include/LKObjCHelpers.h index 714072661..ac0bc0615 100644 --- a/Sources/LKObjCHelpers/include/LKObjCHelpers.h +++ b/Sources/LKObjCHelpers/include/LKObjCHelpers.h @@ -3,8 +3,11 @@ @interface LKObjCHelpers : NSObject -+ (void)finishBroadcastWithoutError:(RPBroadcastSampleHandler *)handler API_AVAILABLE(ios(10.0), macCatalyst(13.1), macos(11.0), tvos(10.0)); ++ (void)finishBroadcastWithoutError:(RPBroadcastSampleHandler *)handler + API_AVAILABLE(ios(10.0), macCatalyst(13.1), macos(11.0), tvos(10.0), + visionos(1.0)); -+ (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error; ++ (BOOL)catchException:(void (^)(void))tryBlock + error:(__autoreleasing NSError **)error; @end diff --git a/Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift b/Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift index fb9108b54..7dd532052 100644 --- a/Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift +++ b/Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Foundation diff --git a/Sources/LiveKit/Broadcast/BroadcastManager.swift b/Sources/LiveKit/Broadcast/BroadcastManager.swift index d64ea0945..453443e6a 100644 --- a/Sources/LiveKit/Broadcast/BroadcastManager.swift +++ b/Sources/LiveKit/Broadcast/BroadcastManager.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Combine import Foundation diff --git a/Sources/LiveKit/Broadcast/BroadcastScreenCapturer.swift b/Sources/LiveKit/Broadcast/BroadcastScreenCapturer.swift index ca61de5ed..469349b0e 100644 --- a/Sources/LiveKit/Broadcast/BroadcastScreenCapturer.swift +++ b/Sources/LiveKit/Broadcast/BroadcastScreenCapturer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Foundation @@ -33,9 +33,14 @@ class BroadcastScreenCapturer: BufferCapturer, @unchecked Sendable { guard didStart else { return false } + var width = CGFloat(options.dimensions.max) + var height = CGFloat(options.dimensions.max) + + #if os(iOS) let bounds = await UIScreen.main.bounds - let width = bounds.size.width - let height = bounds.size.height + width = bounds.size.width + height = bounds.size.height + #endif let screenDimension = Dimensions(width: Int32(width), height: Int32(height)) // pre fill dimensions, so that we don't have to wait for the broadcast to start to get actual dimensions. diff --git a/Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift b/Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift index cfe59c70d..167ca7f54 100644 --- a/Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift +++ b/Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import AVFoundation diff --git a/Sources/LiveKit/Broadcast/IPC/BroadcastIPCHeader.swift b/Sources/LiveKit/Broadcast/IPC/BroadcastIPCHeader.swift index 607c708ce..f03f32d78 100644 --- a/Sources/LiveKit/Broadcast/IPC/BroadcastIPCHeader.swift +++ b/Sources/LiveKit/Broadcast/IPC/BroadcastIPCHeader.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) /// Message header for communication between uploader and receiver. enum BroadcastIPCHeader: Codable { diff --git a/Sources/LiveKit/Broadcast/IPC/BroadcastImageCodec.swift b/Sources/LiveKit/Broadcast/IPC/BroadcastImageCodec.swift index f3d001b6b..52eb931f1 100644 --- a/Sources/LiveKit/Broadcast/IPC/BroadcastImageCodec.swift +++ b/Sources/LiveKit/Broadcast/IPC/BroadcastImageCodec.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import AVFoundation @preconcurrency import CoreImage diff --git a/Sources/LiveKit/Broadcast/IPC/BroadcastReceiver.swift b/Sources/LiveKit/Broadcast/IPC/BroadcastReceiver.swift index 4aecc3d41..b0a6d2fc4 100644 --- a/Sources/LiveKit/Broadcast/IPC/BroadcastReceiver.swift +++ b/Sources/LiveKit/Broadcast/IPC/BroadcastReceiver.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import AVFoundation import CoreImage diff --git a/Sources/LiveKit/Broadcast/IPC/BroadcastUploader.swift b/Sources/LiveKit/Broadcast/IPC/BroadcastUploader.swift index ee7cd8ec3..80b5299f1 100644 --- a/Sources/LiveKit/Broadcast/IPC/BroadcastUploader.swift +++ b/Sources/LiveKit/Broadcast/IPC/BroadcastUploader.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import CoreMedia import ReplayKit diff --git a/Sources/LiveKit/Broadcast/IPC/IPCChannel.swift b/Sources/LiveKit/Broadcast/IPC/IPCChannel.swift index d30b5b108..f3ba0b19b 100644 --- a/Sources/LiveKit/Broadcast/IPC/IPCChannel.swift +++ b/Sources/LiveKit/Broadcast/IPC/IPCChannel.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Foundation import Network diff --git a/Sources/LiveKit/Broadcast/IPC/IPCProtocol.swift b/Sources/LiveKit/Broadcast/IPC/IPCProtocol.swift index ddced0d9f..215183303 100644 --- a/Sources/LiveKit/Broadcast/IPC/IPCProtocol.swift +++ b/Sources/LiveKit/Broadcast/IPC/IPCProtocol.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Foundation import Network diff --git a/Sources/LiveKit/Broadcast/IPC/SocketPath.swift b/Sources/LiveKit/Broadcast/IPC/SocketPath.swift index 936702949..3e7b31463 100644 --- a/Sources/LiveKit/Broadcast/IPC/SocketPath.swift +++ b/Sources/LiveKit/Broadcast/IPC/SocketPath.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) import Network diff --git a/Sources/LiveKit/Broadcast/LKSampleHandler.swift b/Sources/LiveKit/Broadcast/LKSampleHandler.swift index 31910a668..be0df245f 100644 --- a/Sources/LiveKit/Broadcast/LKSampleHandler.swift +++ b/Sources/LiveKit/Broadcast/LKSampleHandler.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -#if os(iOS) +#if os(iOS) || os(visionOS) #if canImport(ReplayKit) import ReplayKit