Namespace `Devices` under `Aperture`
This commit is contained in:
parent
5f80b523c1
commit
5e4c311540
|
@ -22,7 +22,6 @@ public final class Aperture: NSObject {
|
||||||
public var onResume: (() -> Void)?
|
public var onResume: (() -> Void)?
|
||||||
public var isRecording: Bool { output.isRecording }
|
public var isRecording: Bool { output.isRecording }
|
||||||
public var isPaused: Bool { output.isRecordingPaused }
|
public var isPaused: Bool { output.isRecordingPaused }
|
||||||
public let devices = Devices.self
|
|
||||||
|
|
||||||
private init(
|
private init(
|
||||||
destination: URL,
|
destination: URL,
|
||||||
|
@ -80,7 +79,7 @@ public final class Aperture: NSObject {
|
||||||
/**
|
/**
|
||||||
Start a capture session with the given screen ID.
|
Start a capture session with the given screen ID.
|
||||||
|
|
||||||
Use `Aperture.devices.screen()` to get a list of available screens.
|
Use `Aperture.Devices.screen()` to get a list of available screens.
|
||||||
|
|
||||||
Then pass the `id` property from those dictionaries to this initializer to start recording.
|
Then pass the `id` property from those dictionaries to this initializer to start recording.
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ public final class Aperture: NSObject {
|
||||||
/**
|
/**
|
||||||
Start a capture session with the given iOS device.
|
Start a capture session with the given iOS device.
|
||||||
|
|
||||||
Use `Aperture.devices.iOS()` to get a list of connected iOS devices.
|
Use `Aperture.Devices.iOS()` to get a list of connected iOS devices.
|
||||||
|
|
||||||
Use the `id` property from those dictionaries to create an `AVCaptureDevice` like in the following example:
|
Use the `id` property from those dictionaries to create an `AVCaptureDevice` like in the following example:
|
||||||
|
|
||||||
|
|
|
@ -14,37 +14,39 @@ private func enableDalDevices() {
|
||||||
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &property, 0, nil, UInt32(sizeOfAllow), &allow)
|
CMIOObjectSetPropertyData(CMIOObjectID(kCMIOObjectSystemObject), &property, 0, nil, UInt32(sizeOfAllow), &allow)
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Devices {
|
extension Aperture {
|
||||||
public static func screen() -> [[String: Any]] {
|
public struct Devices {
|
||||||
NSScreen.screens.map {
|
public static func screen() -> [[String: Any]] {
|
||||||
[
|
NSScreen.screens.map {
|
||||||
// TODO: Use `NSScreen#localizedName` when targeting macOS 10.15.
|
[
|
||||||
"name": $0.name,
|
// TODO: Use `NSScreen#localizedName` when targeting macOS 10.15.
|
||||||
"id": $0.id
|
"name": $0.name,
|
||||||
]
|
"id": $0.id
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public static func audio() -> [[String: String]] {
|
public static func audio() -> [[String: String]] {
|
||||||
AVCaptureDevice.devices(for: .audio).map {
|
AVCaptureDevice.devices(for: .audio).map {
|
||||||
[
|
|
||||||
"name": $0.localizedName,
|
|
||||||
"id": $0.uniqueID
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static func ios() -> [[String: String]] {
|
|
||||||
enableDalDevices()
|
|
||||||
|
|
||||||
return AVCaptureDevice
|
|
||||||
.devices(for: .muxed)
|
|
||||||
.filter { $0.localizedName.contains("iPhone") || $0.localizedName.contains("iPad") }
|
|
||||||
.map {
|
|
||||||
[
|
[
|
||||||
"name": $0.localizedName,
|
"name": $0.localizedName,
|
||||||
"id": $0.uniqueID
|
"id": $0.uniqueID
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func ios() -> [[String: String]] {
|
||||||
|
enableDalDevices()
|
||||||
|
|
||||||
|
return AVCaptureDevice
|
||||||
|
.devices(for: .muxed)
|
||||||
|
.filter { $0.localizedName.contains("iPhone") || $0.localizedName.contains("iPad") }
|
||||||
|
.map {
|
||||||
|
[
|
||||||
|
"name": $0.localizedName,
|
||||||
|
"id": $0.uniqueID
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue