Extraneous http request being made by AVFoundation

We're using AVPlayer on iOS 8.4 to play HLS, AES-encrypted video.


Our .m3u8 files include the url of the license server, e.g.:


#EXT-X-KEY:METHOD=AES-128,URI="https://...."


In our iOS application, we're using AVAssetResourceLoaderDelegate method

resourceLoader:shouldWaitForLoadingOfRequestedResource:

to intercept the request that gets sent by the AVPlayer (or some object within AVFoundation) to the license server. Within that method, we add a token (required by the license server) to the request's queryString.


The license server receives the request with the token, returns the encryption key, and playback begins.

In other words, everything works as expected.


However, we're noticing (using the "Charles" http monitor) that following the creation of the AVPlayerItem and prior to the invocation of the resourceLoader: method, AVFoundation sends an initial request to the license server url; a request that's not "routed" through method resourceLoader:. This request fails as our iOS code never has a chance to append the token before the request goes out.


Summary of events:


AVPlayerItem/AVAsset is created and initialized with the url of the .m3u8 index file.


Something within the AVFoundation framwork makes a request to the license server specified in the .m3u8 file. This initial request is NOT intercepted by method recourceLoader:shouldWaitForLoadingOfRequestedResource: and the unmodified request hits the license server. Because the request doesn't contain a required token in the queryString, it fails and no encrypton key is returned.


A second request is made by AVFoundation to the licesnse server. This request IS caught by recourceLoader:...and modified appropriately. The license server returns an encryption key and playback begins.


This behavior can be replicated using Apple's AVARLDelegateDemo app.



Questions:


Is the initial http request sent by AVFoundatin normal?


If so, why is it necesssary?


Is it possible to suppress the intial request or modify it before it's sent?


Thank you.

Replies

Bump.

Bump, again.


Does anyone at Apple monitor this board?

I thought reserved schemes like "HTTP" and "HTTPS" will not work if we use AVAssetResourceLoaderDelegate. It's great if these schemes also work with that mechanisms.

Hello, Did you ever get this to work? all AVAssetResourceLoaderDelegate work except for the shouldWaitForResponseToAuthenticationChallenge delegate call.