AssetId is malformed in Safari Demo Application if URI is greater than 16 characters

Hi,


I have noticed that when I use an AssetId that is greater than 16 characters long I see that the initData is Safari seems to include some random characters at the beginning - e.g $skd://....


This breaks the AssetId extraction logic in the demo app. Here is the logging (added by me) from playback of the example content "twelve"



AssetID : skd://twelve

Hostname :twelve



And with playlist file edited so that assetID is "twelvetwelve"


AssetID : $skd://twelvetwelve

Hostname :192.168.8.69 - this is the private IP that I am hosting the sample app on...



OSX 10.11.6

Safari 9.1.2

Has anyone else seen this?


Thanks,

Accepted Answer

I also came across this. I think the apple sample code does not take into account that initdata is starting with a 4 byte length value. When the length reaches a certain value the leading character will not be eliminated in the following routines. So I think you need to cut away the 4 bytes in arrayToString.


I also found strange that initdata and assetid (and certificate) need to be concatenated for following operation, as it is almost the same data and it is in contradiction to the FPS PG which only states assetid (and certificate).


Would be nice if apple could confirm both topics.

Thanks, I worked around the issue for now.


Is there information published on the format of the initData? - where can this be found?

I have come across this issue a while ago and gave up parsing the AssetId from SPC.

There is no issue with the IOS client, if the license request is made by the IOS client.


If the license request made by the Safari client, the same server code is used but the parsed assetId looks like corrupted, like some unicode chars in it.

I couldn't figure it out.


I have implemented a c# fair play server so I convert assetId into string like this:

System.Text.Encoding.Utf8.GetString(assetIdBytesFromSPC);


The above code works as expected for IOS clients but as i said above it looks corrupted for Safari client.


Could you please help me with this issue?


Thanks,

Barbaros.

Hi Karl, How did you get it work? Can you explain please? Thanks.

Hey,


Here are the details of the work around that I used to fix this (for me)


/** In the Safari Sample App **/

function extractContentId(data) {

myContentId = arrayToString(data);

console.log('AssetID : ' + myContentId);

// contentId is passed up as a URI, from which the host must be extracted: - Karl: Bug in Safari if URI is longer that 16 chars

var link = document.createElement('a');

var uri = encodeURIComponent(myContentId);

link.href = myContentId;

//return link.hostname;

console.log('AssetId :' + myContentId.split('//')[1]);

return myContentId.split('//')[1]; //Karl: work around for bug

}


/** Parsing AssetId in C# **/


System.Text.Encoding.ASCII.GetString(bytes);

AssetId is malformed in Safari Demo Application if URI is greater than 16 characters
 
 
Q