Skip to content

Commit

Permalink
[APT-9577] Add DRM for downloads for offline usage : code improvement…
Browse files Browse the repository at this point in the history
… : accept an empty map of custom headers for the HTTP data source, as there's no reason to exclude that case
  • Loading branch information
rubeus90 committed Feb 13, 2024
1 parent d3ac619 commit 6f451bf
Showing 1 changed file with 2 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ internal class DashDrmLicenseDownloader @Inject constructor(context: Context) :
drmInfo: DrmInfo,
): DrmDownload {
// Update data source for DRM license to add any DRM-specific request headers
drmDataSourceFactory.addCustomHeaders(drmInfo.drmHeaders)
drmDataSourceFactory.setDefaultRequestProperties(drmInfo.drmHeaders)
// Update data source for audio to add custom headers
audioDataSourceFactory.addCustomHeaders(customRequestHeaders)
audioDataSourceFactory.setDefaultRequestProperties(customRequestHeaders)

// Create helper to download DRM license
val offlineHelper = when (drmInfo.drmType) {
Expand Down Expand Up @@ -66,10 +66,4 @@ internal class DashDrmLicenseDownloader @Inject constructor(context: Context) :
throw DrmDownloadException(e)
}
}

private fun DefaultHttpDataSource.Factory.addCustomHeaders(customHeaders: Map<String, String>) {
customHeaders.takeIf { it.isNotEmpty() }?.let { headers ->
setDefaultRequestProperties(headers)
}
}
}

0 comments on commit 6f451bf

Please sign in to comment.