Unable to stream FPS-protected content over AirPlay to Apple TV

When attempting to stream fairplay-protected content to an Apple TV over AirPlay, we run into a problem, which is that the Apple TV does not request anything via FPS, but instead is seeking to do direct key-fetch from the App using the protocol handler (e.g. "fps://") - when disabling our protocol handler, and only having FPS, it just fails outright and does not contact the iOS App. Is there some special sequence of calls that needs to be made to make this work properly with an Apple TV?


Note that everything plays properly (and is properly protected by FPS) when playing locally on a device.

Accepted Reply

See the FairPlay Overview document Figure 1-3 (<https://developer.apple.com/services-account/download?path=/Documentation/FairPlay_Streaming_Overview/FairPlayStreaming_Overview.pdf>) which describes FPS streaming over AirPlay. In an AirPlay scenario, the FPS request is always routed through the app. The AppleTV never talks to the Key Server directly to get keys. To do this, the app must set the usesExternalPlaybackWhileExternalScreenIsActive property of the AVPlayer object to TRUE with code like this:


// create AVPlayer object

player = [AVPlayer playerWithURL:movieURL];

// set the property to TRUE

player.usesExternalPlaybackWhileExternalScreenIsActive = TRUE;


This is discussed in the FairPlay Streaming Programming Guide section titled “Configuring AirPlay Mode” (<https://developer.apple.com/services-account/download?path=/Developer_Tools/FairPlay_Streaming_SDK/FairPlay_Streaming_Server_SDK.zip>).


In other words, your app will receive the callback with the SPC just like in the local playback case. The behavior you are seeing is expected. You should expect your app to make the FPS request even in the case of AirPlay streaming.

Replies

See the FairPlay Overview document Figure 1-3 (<https://developer.apple.com/services-account/download?path=/Documentation/FairPlay_Streaming_Overview/FairPlayStreaming_Overview.pdf>) which describes FPS streaming over AirPlay. In an AirPlay scenario, the FPS request is always routed through the app. The AppleTV never talks to the Key Server directly to get keys. To do this, the app must set the usesExternalPlaybackWhileExternalScreenIsActive property of the AVPlayer object to TRUE with code like this:


// create AVPlayer object

player = [AVPlayer playerWithURL:movieURL];

// set the property to TRUE

player.usesExternalPlaybackWhileExternalScreenIsActive = TRUE;


This is discussed in the FairPlay Streaming Programming Guide section titled “Configuring AirPlay Mode” (<https://developer.apple.com/services-account/download?path=/Developer_Tools/FairPlay_Streaming_SDK/FairPlay_Streaming_Server_SDK.zip>).


In other words, your app will receive the callback with the SPC just like in the local playback case. The behavior you are seeing is expected. You should expect your app to make the FPS request even in the case of AirPlay streaming.

Thanks - this helped, somewhat, but I'm still having problems with AirPlay. I put in the usesExternalPlaybackWhileExternalScreenIsActive, and now I'm seeing the initial request from (presumably) the Apple TV. But, I'm getting an error in gnerating the actual SPC.


Note that this all works when I'm not playing through AirPlay (ie. when I'm playing local on the device).


Specifically, the error happens in my delegate code during the call to shouldWaitForLoadingOfRequestedResource:

NSData *requestBytes = nil;
requestBytes = [loadingRequest streamingContentKeyRequestDataForApp:[NSData dataWithBytes:(const void*)certificate.Data() length:certificate.Size()] contentIdentifier:urlParams options:nil error:&error];
if(requestBytes == nil) {
NSLog(@"Error creating server request: "%@", error);
return FALSE;
}


The error I see is similar to what I used to see when I did not have a valid certificate:

<Warning>: Error creating server request: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x190a83f0 {Error Domain=NSOSStatusErrorDomain Code=-6753 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-6753)}


Any idea where I'm going wrong from there? Again this all works fine if AirPlay is not involved.


Thanks!

Hi srk - any chance you can take a look at my other reply to this comment and see if you can help me out? We are still stuck trying to get this work at all. I'd really appreciate any help you can give us.


Thank you!

Is this the new Apple TV (4th generation), or the older Apple TV (3rd generation) or both?


I assume you have checked that the appIdentifier and contentIdentifier parameters being passed to the streamingContentKeyRequestDataForApp: method are valid?


And you can successfully AirPlay to this same Apple TV when not using FPS?


What version of iOS are you running on your device? What version of Xcode is being used?


This might be best handled as a bug report (http://developer.apple.com/bugreporter/) for the FPS engineering team to investigate.

Some of these issues turned out to be network-side, and those were resolved. Unfortunately, it does appear that while everything works fine for the 3rd generation of AppleTV, it does not stream properly to the 4th generation. We are using the latest iOS version, but an older Xcode (6.3.2).


We can't stream anything to the newest AppleTV from our App, so there appears to be some other issue there.We're still investigating, but will likely open a bug.


Thanks for all your help. The FPS-portion of this issue seems to be resolved.

Hi messerman,

try to use skd:// protocol instead of fps:// in the manifest URI. It should help.


Best regards,

Lukasz Pluto

Xstream A/S