DAI with DRM(Fairplay) for iOS

362 views
Skip to first unread message

Hailiang

unread,
Jan 8, 2023, 8:29:56 PM1/8/23
to Interactive Media Ads SDK
Hi Team:

We are trying to implement a feature using google DAI with DRM(Fairplay) on iOS.
We have setup an asset with DRM stream, using SAMPLE-AES to encrypt the streams, 

The m3u8 looks like:
#EXTM3U
#EXT-X-VERSION:5
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:248572
#EXT-X-DISCONTINUITY-SEQUENCE:22


#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://2BA10A268D805ED1FB9047D18342592F",IV=0x2BA10A268D805ED1FB9047D18342592F,KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"
#EXT-X-CUE-IN
#EXTINF:6.000000,
#EXT-X-PROGRAM-DATE-TIME:2023-01-06T03:41:33.059Z
#EXTINF:6.000000,

When trying to play it with the latest google ads ima sdk, we got an error says 
"The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1002 - unsupported URL”.
The unsupported URL in the error is ’skd://2BA10A268D805ED1FB9047D18342592F'. 

Main codes as below:
    // Create an ad display container for ad rendering.
    let adDisplayContainer = IMAAdDisplayContainer(adContainer: videoView, viewController: self, companionSlots: nil)
    // Create an IMAAVPlayerVideoDisplay to give the SDK access to your video player.
    let imaVideoDisplay = IMAAVPlayerVideoDisplay(avPlayer: avPlayer)
    // Create a stream request. Use one of "Live stream request" or "VOD request".
    // Live stream request.
    let request = IMALiveStreamRequest(assetKey: Constants.assetKey, adDisplayContainer: adDisplayContainer, videoDisplay: imaVideoDisplay)
    self.adsLoader.requestStream(with: request)

We do have a license server for the client to get the data to decrypt the streams when the player trying to load the url asset with prefix ’skd://', but we can’t find a way to set the license server url to the ima sdk, or something else to make this.

We have tried `IMAAVPlayerVideoDisplayDelegate`, but this is just an async callback, it can not block the original asset loading request, so we can not get the data from our license server and pass it to the resource loader.

So for this case, how can I do to implement this feature with google ima sdk? Any help is appreciated.

Thanks, 
Hailiang

IMA SDK

unread,
Jan 9, 2023, 1:32:50 AM1/9/23
to shl8...@gmail.com, ima...@googlegroups.com

Hello Hailiang,

 

Michael here from IMA SDK Support team. Thank you for reaching out to us.

 

The IMA DAI SDK supports only video streams rendered by Ad Manager 360's Ad Insertion servers. For specific implementation questions about the capabilities of these streams, I would recommend contacting your Ad Manager support representative.

 

Regards,

Google Logo
Michael Angelo
IMA SDK Team
 


ref:_00D1U1174p._5004Q2hb98m:ref

Hailiang

unread,
Jan 9, 2023, 8:31:40 PM1/9/23
to Interactive Media Ads SDK
Hello Michael,

Thanks for your replay.
We do use Ad Manager 360's Ad Insertion server now, the assetKey for testing is `cAbVVJKiTLu60LtXzSSZFw`.
In our test, the ad stream is able to playback, but the encrypted content stream is not able to playback.
Please could you help to check what is the problem for this?

Thanks,
Hailiang

IMA SDK

unread,
Jan 10, 2023, 2:43:26 AM1/10/23
to shl8...@gmail.com, ima...@googlegroups.com

Hello Hailiang,

 

Thank you for responding back to us. Would you be able to share with us the below information so we can raise this concern to the rest of our team?

  • Sample project implementation where the issue is reproducible
  • Screen recording of the behavior for better illustration of the issue (highlighting the concern)

 

If the file(s) you are looking to share are less than 25mb in total you can attach them to this case privately via "Reply To Author" button on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, you can share your files with me by performing the following steps:

 

1. Navigate to

https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=IMA+SDK&entry.460850823=5004Q00002hb98mQAA&entry.80707362=00162872

2. Fill out all fields, and attach your file(s).

3. Please reply back on this thread when you have uploaded your file(s). Please do not share this link.

Regards,

Hailiang

unread,
Jan 13, 2023, 5:32:28 AM1/13/23
to Interactive Media Ads SDK
Hello Michael,

Is there any update for this? Have you received the files I uploaded?

Thanks,
Hailiang

IMA SDK

unread,
Jan 13, 2023, 2:25:33 PM1/13/23
to shl8...@gmail.com, ima...@googlegroups.com
Hi Hailiang,

It seems that you didn't receive my last response. With that, I'll be resending it here again.

I work along with Michael. Allow me to assist you in this.

I went ahead and test your app. As per testing, I'm consistently getting Vast Error 400 and I'm not able to proceed checking the reported behavior on my end. Could you please check if the asset being used on on your app actually works?

For reference, here's the logs that I'm getting.
Play asset: cAbVVJKiTLu60LtXzSSZFw
Stream created with: ed3b8eef-111e-4e7f-b351-3c6974612272:SIN2
playerVideoDisplay willLoadStreamAsset <AVURLAsset: 0x6000036814c0, URL = https://nldsmsltest01.akamaized.net/hls/live/2011713/2022120801-87261/playlist.m3u8?hdnea=st=1673444659~exp=1673444959~acl=*~id=7a523bcd-5908-4725-95ec-7de80d8ef016~hmac=55fd06d702c1cf1bd48657608eba202ea8fcbd53bc4267a0811bbe4e05f3de44&originpath=/linear/hls/pb/event/cAbVVJKiTLu60LtXzSSZFw/stream/ed3b8eef-111e-4e7f-b351-3c6974612272:SIN2/master.m3u8>;
StreamManager event (Stream Loaded)
playerVideoDisplay didLoad <AVPlayerItem: 0x6000034127e0, asset = <AVURLAsset: 0x6000036814c0, URL = https://nldsmsltest01.akamaized.net/hls/live/2011713/2022120801-87261/playlist.m3u8?hdnea=st=1673444659~exp=1673444959~acl=*~id=7a523bcd-5908-4725-95ec-7de80d8ef016~hmac=55fd06d702c1cf1bd48657608eba202ea8fcbd53bc4267a0811bbe4e05f3de44&originpath=/linear/hls/pb/event/cAbVVJKiTLu60LtXzSSZFw/stream/ed3b8eef-111e-4e7f-b351-3c6974612272:SIN2/master.m3u8>>;
Playback finished
Playback Error: Error Domain=CoreMediaErrorDomain Code=1718449215 "See -[AVPlayerItem errorLog] for 2 events" UserInfo={NSDebugDescription=See -[AVPlayerItem errorLog] for 2 events}
StreamManager error with type: IMAErrorType(rawValue: 2)
code: IMAErrorCode(rawValue: 400)
message:The operation couldn’t be completed. (CoreMediaErrorDomain error 1718449215.)
Regards,
Google Logo
Teejay Wennie
IMA SDK Team
 


ref:_00D1U1174p._5004Q2hb98m:ref

Hailiang

unread,
Jan 15, 2023, 9:44:27 PM1/15/23
to Interactive Media Ads SDK
Hello Teejay,

I think you should test this using a device, not simulator, as the stream is DRM encrypted.
You may see some errors like this when testing in a device:

Play asset: cAbVVJKiTLu60LtXzSSZFw

Stream created with: f126c0c4-427b-4eef-b568-9cec4c582873:SIN

playerVideoDisplay willLoadStreamAsset <AVURLAsset: 0x280f2fc80, URL = https://nldsmsltest01.akamaized.net/hls/live/2011713/2022120801-87261/playlist.m3u8?hdnea=st=1673835552~exp=1673835852~acl=*~id=e4cd110b-20c1-4c15-bf6c-dec9c2411d4a~hmac=951530434d68776a4eb9ac2a8ca698a9f5378aca16d0f0a2e9f5b01243170db8&originpath=/linear/hls/pb/event/cAbVVJKiTLu60LtXzSSZFw/stream/f126c0c4-427b-4eef-b568-9cec4c582873:SIN/master.m3u8>

StreamManager event (Stream Loaded)

playerVideoDisplay didLoad <AVPlayerItem: 0x280d04e30, asset = <AVURLAsset: 0x280f2fc80, URL = https://nldsmsltest01.akamaized.net/hls/live/2011713/2022120801-87261/playlist.m3u8?hdnea=st=1673835552~exp=1673835852~acl=*~id=e4cd110b-20c1-4c15-bf6c-dec9c2411d4a~hmac=951530434d68776a4eb9ac2a8ca698a9f5378aca16d0f0a2e9f5b01243170db8&originpath=/linear/hls/pb/event/cAbVVJKiTLu60LtXzSSZFw/stream/f126c0c4-427b-4eef-b568-9cec4c582873:SIN/master.m3u8>>

2023-01-16 10:19:14.996763+0800 GoogleDAIDemo[11399:21602444] NSURLConnection finished with error - code -1002

2023-01-16 10:19:15.710941+0800 GoogleDAIDemo[11399:21602446] NSURLConnection finished with error - code -1002

2023-01-16 10:19:16.320800+0800 GoogleDAIDemo[11399:21602507] NSURLConnection finished with error - code -1002

2023-01-16 10:19:19.332653+0800 GoogleDAIDemo[11399:21602507] NSURLConnection finished with error - code -1002

2023-01-16 10:19:23.351330+0800 GoogleDAIDemo[11399:21602507] NSURLConnection finished with error - code -1002

2023-01-16 10:19:23.490031+0800 GoogleDAIDemo[11399:21602447] NSURLConnection finished with error - code -1002

2023-01-16 10:19:28.500894+0800 GoogleDAIDemo[11399:21602447] NSURLConnection finished with error - code -1002

2023-01-16 10:19:33.514677+0800 GoogleDAIDemo[11399:21602507] NSURLConnection finished with error - code -1002

2023-01-16 10:19:33.731590+0800 GoogleDAIDemo[11399:21602443] NSURLConnection finished with error - code -1002

2023-01-16 10:19:38.750385+0800 GoogleDAIDemo[11399:21602443] NSURLConnection finished with error - code -1002

2023-01-16 10:19:43.775620+0800 GoogleDAIDemo[11399:21602447] NSURLConnection finished with error - code -1002

2023-01-16 10:19:44.052062+0800 GoogleDAIDemo[11399:21602507] NSURLConnection finished with error - code -1002

2023-01-16 10:19:49.084767+0800 GoogleDAIDemo[11399:21602447] NSURLConnection finished with error - code -1002

Playback finished

Playback Error: Error Domain=NSURLErrorDomain Code=-1002 "See -[AVPlayerItem errorLog] for 12 events" UserInfo={NSDebugDescription=See -[AVPlayerItem errorLog] for 12 events, NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x2801a89c0 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1002 - unsupported URL)" UserInfo={NSDescription=The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1002 - unsupported URL)}}}

StreamManager error with type: IMAErrorType(rawValue: 2) 

code: IMAErrorCode(rawValue: 400) 

#EXTM3U
#EXT-X-VERSION:5
#EXT-X-TARGETDURATION:6

#EXT-X-MEDIA-SEQUENCE:394796
#EXT-X-DISCONTINUITY-SEQUENCE:39



#EXT-X-KEY:METHOD=SAMPLE-AES,URI="skd://2BA10A268D805ED1FB9047D18342592F",IV=0x2BA10A268D805ED1FB9047D18342592F,KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

#EXTINF:6.000000,

I think this is becuase the URI started with `skd://` is not correctly handled in ima sdk. 

In my understanding, the expected behavior should be: 

When detective that the URI is started with `skd://`, the ima sdk should call the DRM license server (should be passed by the client app) to get the data, and put the data into the asset request to decrypt the stream content for playback. 


Please help to check this, any help is appreciated.

Thanks,
Hailiang

IMA SDK

unread,
Jan 16, 2023, 11:33:39 AM1/16/23
to shl8...@gmail.com, ima...@googlegroups.com
Hi Hailiang,

Thank you for pointing this out. I conducted a test again using an actual device, and I was able to reproduce the issue now. With that, I'll be sharing this to a wider team for further investigation and to get their insight as well. I'll update this thread the soonest I hear back from them.

IMA SDK

unread,
Jan 24, 2023, 12:15:34 PM1/24/23
to ima...@googlegroups.com, shl8...@gmail.com
Hi Hailiang,

Sorry for the long delay on this, we don't often have support questions about fairplay integration, so it can take some time to get routed to the correct party.

I'm looking through our internal docs, and it looks like the main issue here is needing to configure your AVAsset to support fairplay. Using the IMAAVPlayerVideoDisplayDelegate, the necessary method would look something like:
 
- (void)avPlayerVideoDisplay:(IMAAVPlayerVideoDisplayDelegate *)avPlayerVideoDisplay willLoadStreamAsset:(AVURLAsset *)avUrlAsset {
  AVContentKeySession *keySession;
  id<AVAssetResourceLoaderDelegate> resourceLoaderDelegate;
  dispatch_queue_t delegateQueue;
  ...
  asset.resourceLoader.preloadsEligibleContentKeys = true;
  [asset.resourceLoader setDelegate:resourceLoaderDelegate queue:delegateQueue];
  [keySession addContentKeyRecipient: asset];
}

Let me know if this helps you get past the error.


Thanks,

Greg Schoppe

Hailiang

unread,
Jan 31, 2023, 2:36:27 AM1/31/23
to Interactive Media Ads SDK
Thanks team, this is really helpful.
Reply all
Reply to author
Forward
0 new messages