Hello, I am trying to develop an app that broadcasts what the user sees via Apple Vision Pro.
I have applied for and obtained the Enterprise API and actually can stream via the "Main camera access" API, as reported on https://developer.apple.com/videos/play/wwdc2024/10139/.
My problem is that I have not found any reference to how to integrate the "Passthrough in screen capture" API into my project.
Have any of you been able to do this?
Thank you
You can live broadcast using ReplayKit (with a Broadcast Extension). ReplayKit is an existing multi platform framework. It's available without the EnterpriseKit entitlement, but without the entitlement the frames captured contain a black background instead of passthrough. This is covered around 4:30 of video, but only briefly. Here's some more specific information to help you.
At a high level, you need to 2 things to broadcast: An app for users to start/stop the broadcast and a broadcast upload extension to receive the video frames and send them to your broadcast endpoint.
In the application
Use RPSystemBroadcastPickerView to allow users to pick a broadcast destination (aka broadcast upload extension). Here's code for that.
// Define a wrapper for RPSystemBroadcastPickerView that you use to integrate into your SwiftUI view hierarchy.
struct BroadcastButtonView: UIViewRepresentable {
func makeUIView(context: Context) -> RPSystemBroadcastPickerView {
let broadcastPickerView = RPSystemBroadcastPickerView(frame: CGRect(x: 0, y: 0, width: 44, height: 44))
broadcastPickerView.preferredExtension = "com.yourdomain.broadcast-services-upload"
broadcastPickerView.showsMicrophoneButton = true
return broadcastPickerView
}
func updateUIView(_ uiView: RPSystemBroadcastPickerView, context: Context) {
// Update the view if needed
}
}
// Add the button to your view.
BroadcastButtonView()
.frame(width: 44, height: 44)
Creating the extension
Use Xcode to create a broadcast upload extension; be sure to add the aforementioned entitlement. "Broadcast upload extension" has been around for a while so there's lot's of examples online (in the context of iOS, but broadcast upload extensions are multi platform), but here's the TLDR: Creating the extension generates SampleHandler which extends RPBroadcastSampleHandler. Implement the methods in that class to upload content to your endpoint.
Please let me know how it goes!