From 6f451bf9f2e4ec312da8b67f33715514bda79ca1 Mon Sep 17 00:00:00 2001 From: Hong Ngoc Nguyen Date: Tue, 13 Feb 2024 15:40:07 -0500 Subject: [PATCH] [APT-9577] Add DRM for downloads for offline usage : code improvement : accept an empty map of custom headers for the HTTP data source, as there's no reason to exclude that case --- .../armadillo/download/drm/DashDrmLicenseDownloader.kt | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Armadillo/src/main/java/com/scribd/armadillo/download/drm/DashDrmLicenseDownloader.kt b/Armadillo/src/main/java/com/scribd/armadillo/download/drm/DashDrmLicenseDownloader.kt index 8794ed5..ca2a2a2 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/download/drm/DashDrmLicenseDownloader.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/download/drm/DashDrmLicenseDownloader.kt @@ -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) { @@ -66,10 +66,4 @@ internal class DashDrmLicenseDownloader @Inject constructor(context: Context) : throw DrmDownloadException(e) } } - - private fun DefaultHttpDataSource.Factory.addCustomHeaders(customHeaders: Map) { - customHeaders.takeIf { it.isNotEmpty() }?.let { headers -> - setDefaultRequestProperties(headers) - } - } } \ No newline at end of file