Decrypting HTTP Streaming Video with NSURLProtocol

I want to share what I thought was a clever idea from a member of Apple’s DTS team. I’d been working on an app featuring a custom video player and video delivered via HTTP streaming. The challenge centered on how to elegantly decrypt an encrypted video stream in the app without transmitting the key with the stream. Some examples I Googled talked about serving the video up over a custom protocol and using a subclass of NSURLProtocol and then manually decrypting the stream, and while these worked, it seemed like a lot of unnecessary work. As it turned out subclassing NSURLProtocol was the right place to start but the final solution was so much simpler than the examples I’d seen.

Continue reading