Post

Replies

Boosts

Views

Activity

Offline FairPlay Streaming on iOS: Unable to create SPC and persist CKC
FairPlay streaming content key persistence Implementation We use FairPlay with: The AVContentKeySession API for iOS 11+ The AVAssetResourceLoader API for iOS 10.x References We based our implementation on: The official Apple developer documentation WWDC17 - 504 - Advances in HTTP Live Streaming - https://developer.apple.com/videos/play/wwdc2017/504/ WWDC18 - 507 - AVContentKeySession Best Practices - https://developer.apple.com/videos/play/wwdc2018/507/ WWDC20 - 10655 - Discover how to download and play HLS offline - https://developer.apple.com/videos/play/wwdc2020/10655/ Several versions of Apple's HLSCatalog sample project found there - https://developer.apple.com/streaming/fps/ Issues Everything works fine on most iOS versions, but on iOS 12.x we are facing blocking errors when trying to create SPCs with a valid FairPlay certificate or persisting received CKCs. SPC Creation AVContentKeySession The following line causes the error: keyRequest.makeStreamingContentKeyRequestData(forApp: certificate, contentIdentifier: contentIdentifierData, options: [AVContentKeyRequestProtocolVersionsKey: [1]]) AVAssetResourceLoader The following line causes the error: try loadingRequest.streamingContentKeyRequestData(forApp: certificate, contentIdentifier: contentIdentifierData, options: [AVAssetResourceLoadingRequestStreamingContentKeyRequestRequiresPersistentKey: true]) Error log (Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed." UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12158), NSLocalizedDescription=The operation could not be completed., NSUnderlyingError=0x2820a55c0 {Error Domain=NSOSStatusErrorDomain Code=-12158 "(null)"}}) CKC persistence AVContentKeySession The following line causes the error: try keyRequest.persistableContentKey(fromKeyVendorResponse: keyData, options: nil) AVAssetResourceLoader The following line causes the error: try loadingRequest.persistentContentKey(fromKeyVendorResponse: keyData, options: nil) Error log (Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed." UserInfo={NSLocalizedFailureReason=An unknown error occurred (-12158), NSLocalizedDescription=The operation could not be completed., NSUnderlyingError=0x28104ef40 {Error Domain=NSOSStatusErrorDomain Code=-12158 "(null)"}}) Related issues Here are different references related to our current issue, that we thought could be of intereset: Stack Overflow - Fairplay stops working on iOS 12.4 and 13 - https://stackoverflow.com/questions/57293653/fairplay-stops-working-on-ios-12-4-and-13/57311397#57311397 Stack Overflow - Error while fetching Server Playback Context when downloading Fairplay enabled videos - https://stackoverflow.com/questions/58974325/error-while-fetching-server-playback-context-when-downloading-fairplay-enabled-v What we tried Implementing a retry mechanism on the failing methods: obviously does not fix the issue, but it works sometimes. Implementing the AVContentKeySession APIs since we were at first only using AVAssetResourceLoader and its delegate protocol: as said earlier, we are facing now the issues with both APIs. Removing AVContentKeySession and stop calling asset.resourceLoader.preloadsEligibleContentKeys = true on iOS 12.4+, as suggested in the first Stack Overflow related issue Does anyone encounter the same issues ? Is there a working solution or a stable workaround ? Thanks in advance, William
3
1
2.1k
Jan ’21