Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 22 additions & 17 deletions Sources/LKObjCHelpers/LKObjCHelpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions Sources/LKObjCHelpers/include/LKObjCHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/BroadcastBundleInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Foundation

Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/BroadcastManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Combine
import Foundation
Expand Down
11 changes: 8 additions & 3 deletions Sources/LiveKit/Broadcast/BroadcastScreenCapturer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Foundation

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import AVFoundation

Expand Down Expand Up @@ -93,7 +93,7 @@
}
}

extension AudioStreamBasicDescription: Codable {

Check warning on line 96 in Sources/LiveKit/Broadcast/IPC/BroadcastAudioCodec.swift

View workflow job for this annotation

GitHub Actions / Build & Test (macos-26, latest, macOS,variant=Mac Catalyst)

extension declares a conformance of imported type 'AudioStreamBasicDescription' to imported protocols 'Decodable', 'Encodable'; this will not behave correctly if the owners of 'CoreAudioTypes' introduce this conformance in the future
public func encode(to encoder: any Encoder) throws {
var container = encoder.unkeyedContainer()
try container.encode(mSampleRate)
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/BroadcastIPCHeader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/BroadcastImageCodec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import AVFoundation
@preconcurrency import CoreImage
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/BroadcastReceiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import AVFoundation
import CoreImage
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/BroadcastUploader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import CoreMedia
import ReplayKit
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/IPCChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Foundation
import Network
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/IPCProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Foundation
import Network
Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/IPC/SocketPath.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

import Network

Expand Down
2 changes: 1 addition & 1 deletion Sources/LiveKit/Broadcast/LKSampleHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

#if os(iOS)
#if os(iOS) || os(visionOS)

#if canImport(ReplayKit)
import ReplayKit
Expand Down
Loading