androidx / androidx/media

Is there any way to find out from the downloads DataSource if the DataSpec represents a decryption key?

Open
#782 0 comments 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Oct 31, 2023.

needs triage question
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.