Can not play the HLS DAI stream which encrypted by AES-128 (SSAI)
- Dominant language
- Java
- Stars
- 21.9k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
I tested this issue on version 2.17.1, no problem. But after updating ExoPlayer to version 2.18.0 or above, then playback cannot start. And the request to the license server is also absent.
Player setup:
```
adsLoader = ImaAdsLoader.Builder(context.applicationContext)
.setDebugModeEnabled(BuildConfig.DEBUG)
.setAdEventListener { event ->
adEventListener?.onAdEvent(event)
}
.setAdErrorListener { error ->
adErrorListener?.onAdError(error)
}
.setImaSdkSettings(imaSdkSettings).build()
val adsMediaSourceFactory = DefaultMediaSourceFactory(dataSourceFactory)
.setLocalAdInsertionComponents( { adsLoader }, playerView)
// Create a server side ad insertion AdsLoader
daiAdsLoader = ImaServerSideAdInsertionMediaSource.AdsLoader.Builder(context, playerView)
.setAdEventListener { event ->
adEventListener?.onAdEvent(event)
}
.setAdErrorListener { error ->
adErrorListener?.onAdError(error)
}
.setImaSdkSettings(imaSdkSettings).build()
// MediaSource.Factory to create the ad sources for the current player.
daiAdsLoader?.let {
val daiAdsMediaSourceFactory = ImaServerSideAdInsertionMediaSource.Factory(it, adsMediaSourceFactory)
adsMediaSourceFactory.setServerSideAdInsertionMediaSourceFactory(daiAdsMediaSourceFactory)
}
playerBuilder.setMediaSourceFactory(adsMediaSourceFactory)
```
createServerSideAdInsertionMediaItemBuilder() method.
```
private fun createServerSideAdInsertionMediaItemBuilder(): MediaItem.Builder? {
httpDataSourceFactory.setDefaultRequestProperties(requestHeaders)
// Build an IMA SSAI media item to prepare the player with.
val ssaiLiveUri = ImaServerSideAdInsertionUriBuilder()
.setAssetKey(assetKey)
.setFormat(C.CONTENT_TYPE_HLS)
.build()
// Create the MediaItem to play, specifying the stream URI.
return MediaItem.Builder().setUri(ssaiLiveUri)
}
```
We use `requestHeaders` for the request to the license server.
```
httpDataSourceFactory.setDefaultRequestProperties(requestHeaders)
```
Note that, there are no problems on 2.17.1 version
On 2.17.1
Has request to the license server: https://qaplg02east.keydelivery.japaneast.media.azure.net/?kid=d54fb5c8-513e-4340-a936-a45f818997de
On 2.18.0 or above
No request to the license server: https://qaplg02east.keydelivery.japaneast.media.azure.net/?kid=d54fb5c8-513e-4340-a936-a45f818997de
--> So the video or audio fragment can not be downloaded.
There aren't any errors thrown from the ExoPlayer side, but if you look at the event log it looks a bit strange. With a `period [?]`.
Event log:
```
EventLogger: timeline [eventTime=156.27, mediaPos=8778.77, window=0, period=0, periodCount=1, windowCount=1, reason=SOURCE_UPDATE
EventLogger: period [?]
EventLogger: window [8932.92, seekable=true, dynamic=true]
EventLogger: ]
```
### ExoPlayer Version
2.18.0 - 2.18.2
### Devices that reproduce the issue
Any devices
### Devices that do not reproduce the issue
_No response_
### Reproducible in the demo app?
Not tested
### Reproduction steps
Play a SSAI content (Play the HLS DAI stream which encrypted by AES-128)
For example:
```
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-I-FRAMES-ONLY
#EXT-X-KEY:METHOD=AES-128,URI="https://qaplg02east.keydelivery.japaneast.media.azure.net/?kid=d54fb5c8-513e-4340-a936-a45f818997de",IV=0X79D4C126D68BB73240DF2B5292ED2EC0
#EXT-X-PROGRAM-DATE-TIME:2022-12-07T05:31:07Z
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=20020000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=40040000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=60060000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=80080000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
....
```
### Expected result
Can play the HLS DAI stream which encrypted by AES-128 (SSAI) without problems
### Actual result
Can not play the HLS DAI stream which encrypted by AES-128 (SSAI)
### Media
Play the HLS DAI stream which encrypted by AES-128 (SSAI)
master.m3u8
```
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="comment",LANGUAGE="en",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/8397dbf6f5275d2c2e5c2ccb97fc92a6/bandwidth/000.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",NAME="no_comment",LANGUAGE="en",DEFAULT=YES,URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/c2fec07d74cff68e829756591de604a2/bandwidth/000.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=416944,RESOLUTION=320x180,CODECS="avc1.4d400d",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/3b6b972edfa49e18c040c772e9edc3d5/bandwidth/416944.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=621344,RESOLUTION=480x270,CODECS="avc1.4d4015",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/d9d4e21b01042049647515421f1684bf/bandwidth/621344.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=927911,RESOLUTION=480x270,CODECS="avc1.4d4015",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/828ae3bf7aa9a12139bd3331cd8338c9/bandwidth/927911.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=1234544,RESOLUTION=640x360,CODECS="avc1.4d401e",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/40ce50f237f4f35dde8f0e5418c2e9de/bandwidth/1234544.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=2869744,RESOLUTION=960x540,CODECS="avc1.4d401f",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/c863c4529550391e57a1ba71ac35a889/bandwidth/2869744.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=4300544,RESOLUTION=1280x720,CODECS="avc1.4d401f",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/e8aa31dfd075656ad17e2c6499a7d595/bandwidth/4300544.m3u8"
#EXT-X-I-FRAME-STREAM-INF:BANDWIDTH=6344544,RESOLUTION=1920x1080,CODECS="avc1.4d4028",URI="https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/c9fc492e9546140c7246932450685201/bandwidth/6344544.m3u8"
#EXT-X-STREAM-INF:BANDWIDTH=416944,RESOLUTION=320x180,CODECS="avc1.4d400d,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/2c00fd17a3911cbd27c9328a6f9b94aa/bandwidth/416944.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=621344,RESOLUTION=480x270,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/60a211d0900691a31e4804b07974512b/bandwidth/621344.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=927911,RESOLUTION=480x270,CODECS="avc1.4d4015,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/56f05553b386644e973b2edf97691292/bandwidth/927911.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1234544,RESOLUTION=640x360,CODECS="avc1.4d401e,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/005e8314a59288941742dfec28a99db6/bandwidth/1234544.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=2869744,RESOLUTION=960x540,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/5da73a79d09d08bb811051fce3a23954/bandwidth/2869744.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=4300544,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/367d506b8ca0c5c4488322519c241108/bandwidth/4300544.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=6344544,RESOLUTION=1920x1080,CODECS="avc1.4d4028,mp4a.40.2",AUDIO="audio"
https://dai.google.com/linear/hls/pb/event/JqpG8XXcQGiqyPDrUWAaWw/stream/5c753129-3f43-443e-bf57-25ce555730ff:TPE/variant/6a1085862b9293770cedd59bd6213e29/bandwidth/6344544.m3u8
```
416944.m3u8:
```
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:3
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-DISCONTINUITY-SEQUENCE:0
#EXT-X-I-FRAMES-ONLY
#EXT-X-KEY:METHOD=AES-128,URI="https://qaplg02east.keydelivery.japaneast.media.azure.net/?kid=d54fb5c8-513e-4340-a936-a45f818997de",IV=0X79D4C126D68BB73240DF2B5292ED2EC0
#EXT-X-PROGRAM-DATE-TIME:2022-12-07T05:31:07Z
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=20020000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=40040000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=60060000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
https://qartvnplg-hls02-east.akamaized.net/09bad558-a9ca-44d0-9350-f0655eedd77b/4f9e1815-629d-4797-912d-d08909eb25e6.ism/QualityLevels(200000)/KeyFrames(video=80080000,format=m3u8-aapl,encryption=cbc)
#EXTINF:2.002000,no-desc
....
```
### Bug Report
- [ ] You will email the zip file produced by `adb bugreport` to dev.exoplayer@gmail.com after filing this issue.
Contributor guide
Assessment
This issue has not been assessed yet.