Problem
In the iOS 11 beta, I am successfully receiving video and audio sample buffers in my implementation of RPBroadcastSampleHandler. It's a broadcast extension with an NSExtensionPointIdentifier of com.apple.broadcast-services-upload.
From beta 1 through beta 4, I was able create an AVAssetWriter in this extension. Receive video and audio sample buffers, and write them into a QuickTime movie file.
In beta 5, I'm no longer able to get an AVAssetWriter to work. The call to startWriting() fails with the following error:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={
NSLocalizedFailureReason=An unknown error occurred (-16980),
NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x1c0047590 {
Error Domain=NSOSStatusErrorDomain Code=-16980 "(null)"
}
}
Details
I believe I have tracked the issue down to the following log messages in beta 5:
-CMSessionMgr- CMSessionMgrHandleApplicationStateChange: CMSession: Client <extension-bundle-identifier> with pid '<number>' is now Background Running. Background entitlement: NO
...
-CMSessionMgr- _CMSessionBeginInterruption_WithFlags: CMSessionBeginInterruption failed as client has insufficient privileges to take control
This is corresponding log message I used to get in beta 4:
-CMSessionMgr- CMSessionMgrHandleApplicationStateChange: CMSession: Client <extension-bundle-identifier> with pid '<number>' is now Foreground Running. Background entitlement: NO
Prospects
At this point, I can only think of three potential solutions:
- Figure out what is required to make my broadcast extension run in the foreground.
- Figure out how to get an AVAssetWriter to work in the background.
- Hope that Apple increments the privileges of com.apple.broadcast-services-upload from Background back up to Foreground.
Does anyone have advice for any of these? Is there a different solution that I have overlooked?
Thanks,
Otto