Skip to content

Commit

Permalink
Fix visionOS & tvOS CI (#473)
Browse files Browse the repository at this point in the history
Correct simulator was not being selected and tests were passing.
  • Loading branch information
hiroshihorie authored Sep 3, 2024
1 parent dfb8b2e commit 949b584
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/testing-matrix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ jobs:
platform: "macOS,variant=Mac Catalyst"
- os: macos-14
xcode: 15.4
platform: "visionOS Simulator" # visionOS 1.2
platform: "visionOS Simulator,name=Apple Vision Pro" # visionOS 1.2
- os: macos-14
xcode: 15.4
platform: "tvOS"
platform: "tvOS Simulator,name=Apple TV"
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-Readme.md
- os: macos-14
xcode: 16.1-beta
Expand Down
2 changes: 2 additions & 0 deletions Sources/LiveKit/Track/Capturers/CameraCapturer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,12 @@ public class CameraCapturer: VideoCapturer {
var devices = try await CameraCapturer.captureDevices()
#endif

#if !os(visionOS)
// Filter by deviceType if specified in options.
if let deviceType = options.deviceType {
devices = devices.filter { $0.deviceType == deviceType }
}
#endif

device = devices.first { $0.position == self.options.position } ?? devices.first
}
Expand Down
35 changes: 31 additions & 4 deletions Sources/LiveKit/Types/Options/CameraCaptureOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ import Foundation

@objc
public class CameraCaptureOptions: NSObject, VideoCaptureOptions {
/// Preferred deviceType to use. If ``device`` is specified, it will be used instead.
#if !os(visionOS)
/// Preferred deviceType to use. If ``device`` is specified, it will be used instead. This is currently ignored for visionOS.
@objc
public let deviceType: AVCaptureDevice.DeviceType?
#endif

/// Exact devce to use.
@objc
Expand All @@ -44,14 +46,17 @@ public class CameraCaptureOptions: NSObject, VideoCaptureOptions {

@objc
override public init() {
#if !os(visionOS)
deviceType = nil
position = .unspecified
#endif
device = nil
position = .unspecified
preferredFormat = nil
dimensions = .h720_169
fps = 30
}

#if !os(visionOS)
@objc
public init(deviceType: AVCaptureDevice.DeviceType? = nil,
device: AVCaptureDevice? = nil,
Expand All @@ -67,22 +72,45 @@ public class CameraCaptureOptions: NSObject, VideoCaptureOptions {
self.dimensions = dimensions
self.fps = fps
}
#else
@objc
public init(device: AVCaptureDevice? = nil,
position: AVCaptureDevice.Position = .unspecified,
preferredFormat: AVCaptureDevice.Format? = nil,
dimensions: Dimensions = .h720_169,
fps: Int = 30)
{
self.device = device
self.position = position
self.preferredFormat = preferredFormat
self.dimensions = dimensions
self.fps = fps
}
#endif

// MARK: - Equal

override public func isEqual(_ object: Any?) -> Bool {
guard let other = object as? Self else { return false }
return deviceType == other.deviceType &&
let isCommonEqual =
device == other.device &&
position == other.position &&
preferredFormat == other.preferredFormat &&
dimensions == other.dimensions &&
fps == other.fps

#if !os(visionOS)
return deviceType == other.deviceType && isCommonEqual
#else
return isCommonEqual
#endif
}

override public var hash: Int {
var hasher = Hasher()
#if !os(visionOS)
hasher.combine(deviceType)
#endif
hasher.combine(device)
hasher.combine(position)
hasher.combine(preferredFormat)
Expand All @@ -95,7 +123,6 @@ public class CameraCaptureOptions: NSObject, VideoCaptureOptions {

override public var description: String {
"CameraCaptureOptions(" +
"deviceType: \(String(describing: deviceType)), " +
"device: \(String(describing: device)), " +
"position: \(String(describing: position))" +
")"
Expand Down

0 comments on commit 949b584

Please sign in to comment.