Jqvk Blqck
Jqvk Blqck

Reputation: 33

Error Domain=AVFoundationErrorDomain Code=-11835 "Cannot Open"

I'm currently trying to implement a service to handle DRM with FairPlay streaming on a tvOS App. Here is my workflow :

  1. I get the app certificate as Data

  2. From this certificate i get the SPC Datas, using :

    resourceLoadingRequest.streamingContentKeyRequestData(forApp: applicationCertificate, contentIdentifier: assetIDData, options: resourceLoadingRequestOptions)
    
  3. From the SPC Datas encoded to base64Data I request POST (with SPC in payload) on our server to get the license which gives me the CKD Datas

  4. Then when I get the CKC Datas, I use them as below :

     guard let dataRequest = resourceLoadingRequest.dataRequest else {
        print("no data is being requested in loadingRequest")
        let error = NSError(domain: AssetLoaderDelegate.errorDomain, code: -6, userInfo: nil)
        resourceLoadingRequest.finishLoading(with: error)
        return
     }
     dataRequest.respond(with: datas)
     resourceLoadingRequest.finishLoading() 
    

But after these steps I get the error :

Error Domain=AVFoundationErrorDomain Code=-11835 "Cannot Open" UserInfo={NSUnderlyingError=0x170440de0 {Error Domain=NSOSStatusErrorDomain Code=-42681 "(null)"}, NSLocalizedFailureReason=This content is not authorized., NSLocalizedDescription=Cannot Open}

Does anyone have an idea or a tips ?

Additional infos :

Upvotes: 3

Views: 2471

Answers (1)

Tucker Sherman
Tucker Sherman

Reputation: 459

I recently ran into this exact same problem. The problem is the CKC response data returned from streamingContentKeyRequestData(forApp... is not just data, it is base 64 encoded string data. All you need to do is decode it before you respond to the data request:

 dataRequest.respond(with: Data(base64Encoded: datas)!)

For production code you'll want to handle the optionality properly. Hope this helps!

Upvotes: 2

Related Questions