Is there any way to find out from the downloads DataSource if the DataSpec represents a decryption key?
@marcbaechinger is already working on this.
Since Oct 31, 2023.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
When downloading an HLS stream, I would like to apply a ResolvingDataSource to change the uri on the DataSpec, only in the case of the spec being a request for an in-band decryption key from the HLS manifest.
However all I can see coming in the DataSpec is a uri, from which heuristically we can deduce its a key but this is hard to represent algorithmically as my key urls can be literally of any scheme.
When handling in-band keys for streaming I can create an HlsDataSource on my MediaSource.Factory:
val hlsMediaSourceFactory: MediaSource.Factory =
HlsMediaSource.Factory(hlsDataSourceFactory),
and HlsDataSourceFactory allows me to provide different DataSources depending on type:
override fun createDataSource(dataType: Int): DataSource {
return if (dataType == C.DATA_TYPE_DRM) {
KeyDataSource()
} else {
defaultHlsDataSourceFactory.createDataSource(dataType)
}
}
However for downloads the HlsDownloader implementation makes no distinction between Segments and keys, everything is returned as a Segment to be fetched:
if (seenEncryptionKeyUris.add(keyUri)) {
out.add(new Segment(startTimeUs, SegmentDownloader.getCompressibleDataSpec(keyUri)));
}
(the only differnece being the ALLOW_GZIP flag). I guess it would be convenient if a datatype indication would be given in the DataSpec as customData
Is there any way Im missing to employ a different dataSource for the key retrieval?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.