Skip to content

Commit

Permalink
MF-167: Drop support for playback of partially encrypted content
Browse files Browse the repository at this point in the history
  • Loading branch information
stoyicker committed Aug 30, 2024
1 parent 53e160b commit 9a27ce5
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 274 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal class ExoPlayerPlaybackEngineLooperTest {
TrueTimeWrapper(),
mock(),
mock(),
mock(),
null,
Base64Codec(),
Dispatchers.IO,
CoroutineScope(Dispatchers.IO),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PlaybackEngineModuleRoot(
trueTimeWrapper: TrueTimeWrapper,
playbackPrivilegeProvider: PlaybackPrivilegeProvider,
offlineCacheProvider: OfflineCacheProvider?,
encryption: Encryption?,
offlineSecretKey: ByteArray?,
base64Codec: Base64Codec,
coroutineDispatcher: CoroutineDispatcher,
coroutineScope: CoroutineScope,
Expand All @@ -71,7 +71,7 @@ class PlaybackEngineModuleRoot(
trueTimeWrapper,
playbackPrivilegeProvider,
offlineCacheProvider,
encryption,
offlineSecretKey,
base64Codec,
coroutineDispatcher,
coroutineScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ package com.tidal.sdk.player.playbackengine.datasource
import androidx.media3.datasource.cache.Cache
import androidx.media3.datasource.cache.CacheDataSource
import androidx.media3.datasource.cache.CacheKeyFactory
import com.tidal.sdk.player.playbackengine.Encryption
import com.tidal.sdk.player.playbackengine.offline.crypto.CacheKeyAesCipherDataSourceFactory

internal class CacheKeyAesCipherDataSourceFactoryFactory(
private val cacheDataSourceFactory: CacheDataSource.Factory,
private val cacheKeyFactory: CacheKeyFactory,
private val encryption: Encryption?,
private val offlineSecretKey: ByteArray?,
) {

fun create(cache: Cache) = CacheKeyAesCipherDataSourceFactory(
cacheKeyFactory,
encryption!!.secretKey,
offlineSecretKey,
cacheDataSourceFactory.setCache(cache)
.setFlags(CacheDataSource.FLAG_IGNORE_CACHE_ON_ERROR),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.tidal.sdk.player.common.UUIDWrapper
import com.tidal.sdk.player.commonandroid.Base64Codec
import com.tidal.sdk.player.commonandroid.TrueTimeWrapper
import com.tidal.sdk.player.events.EventReporter
import com.tidal.sdk.player.playbackengine.Encryption
import com.tidal.sdk.player.playbackengine.PlaybackEngine
import com.tidal.sdk.player.playbackengine.model.AssetTimeoutConfig
import com.tidal.sdk.player.playbackengine.model.BufferConfiguration
Expand Down Expand Up @@ -58,7 +57,7 @@ interface ExoPlayerPlaybackEngineComponent {
@BindsInstance trueTimeWrapper: TrueTimeWrapper,
@BindsInstance playbackPrivilegeProvider: PlaybackPrivilegeProvider,
@BindsInstance offlineCacheProvider: OfflineCacheProvider?,
@BindsInstance encryption: Encryption?,
@BindsInstance offlineSecretKey: ByteArray?,
@BindsInstance base64Codec: Base64Codec,
@BindsInstance coroutineDispatcher: CoroutineDispatcher,
@BindsInstance coroutineScope: CoroutineScope,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ internal class TidalMediaSourceCreator(
private val playerDashMediaSourceFactory: PlayerDashMediaSourceFactory,
private val playerHlsMediaSourceFactory: PlayerHlsMediaSourceFactory,
private val playerAuthHlsMediaSourceFactory: PlayerAuthHlsMediaSourceFactory,
@Suppress("MaxLineLength") private val playerDecryptedHeaderProgressiveOfflineMediaSourceFactory: PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory, // ktlint-disable max-line-length parameter-wrapping
@Suppress("MaxLineLength") private val playerProgressiveOfflineMediaSourceFactory: PlayerProgressiveOfflineMediaSourceFactory, // ktlint-disable max-line-length parameter-wrapping
private val playerDashOfflineMediaSourceFactory: PlayerDashOfflineMediaSourceFactory,
private val drmSessionManagerFactory: DrmSessionManagerFactory,
Expand All @@ -31,36 +30,24 @@ internal class TidalMediaSourceCreator(
): MediaSource {
return if (playbackInfo is PlaybackInfo.Offline) {
when (playbackInfo.manifestMimeType) {
ManifestMimeType.BTS -> {
if (playbackInfo.partiallyEncrypted) {
playerDecryptedHeaderProgressiveOfflineMediaSourceFactory.create(
mediaItem,
playbackInfo.manifest,
playbackInfo.productId,
)
} else {
playerProgressiveOfflineMediaSourceFactory.create(
mediaItem,
playbackInfo.manifest,
playbackInfo.storage!!,
)
}
}
ManifestMimeType.BTS -> playerProgressiveOfflineMediaSourceFactory.create(
mediaItem,
playbackInfo.manifest,
playbackInfo.storage!!,
)

ManifestMimeType.DASH -> {
playerDashOfflineMediaSourceFactory.create(
mediaItem,
playbackInfo.manifest,
playbackInfo.offlineLicense!!,
playbackInfo.storage!!,
drmSessionManagerProviderFactory.create(
drmSessionManagerFactory.createDrmSessionManagerForOfflinePlay(
playbackInfo,
extras,
),
ManifestMimeType.DASH -> playerDashOfflineMediaSourceFactory.create(
mediaItem,
playbackInfo.manifest,
playbackInfo.offlineLicense!!,
playbackInfo.storage!!,
drmSessionManagerProviderFactory.create(
drmSessionManagerFactory.createDrmSessionManagerForOfflinePlay(
playbackInfo,
extras,
),
)
}
),
)

else -> throw IllegalArgumentException(
"No valid manifestMimeType for offline playback: " +
Expand Down Expand Up @@ -110,11 +97,4 @@ internal class TidalMediaSourceCreator(
}
}
}

private val PlaybackInfo.Offline.productId: String
get() = when (this) {
is PlaybackInfo.Offline.Track -> track.trackId.toString()
is PlaybackInfo.Offline.Video -> video.videoId.toString()
else -> throw IllegalArgumentException("Not a valid delegate for PlaybackInfo.Offline")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import androidx.media3.datasource.cache.CacheKeyFactory
*/
class CacheKeyAesCipherDataSourceFactory(
private val cacheKeyFactory: CacheKeyFactory,
private val secretKey: ByteArray,
private val secretKey: ByteArray?,
private val upstream: DataSource.Factory,
) : DataSource.Factory {

override fun createDataSource(): DataSource {
val aesCipherDataSource = AesCipherDataSource(secretKey, upstream.createDataSource())
val aesCipherDataSource = AesCipherDataSource(secretKey!!, upstream.createDataSource())
return CacheKeyAesCipherDataSource(cacheKeyFactory, aesCipherDataSource)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import com.tidal.sdk.player.common.UUIDWrapper
import com.tidal.sdk.player.commonandroid.Base64Codec
import com.tidal.sdk.player.commonandroid.TrueTimeWrapper
import com.tidal.sdk.player.events.EventReporter
import com.tidal.sdk.player.playbackengine.Encryption
import com.tidal.sdk.player.playbackengine.PlayerLoadErrorHandlingPolicy
import com.tidal.sdk.player.playbackengine.StreamingApiRepository
import com.tidal.sdk.player.playbackengine.TidalExtractorsFactory
Expand All @@ -51,7 +50,6 @@ import com.tidal.sdk.player.playbackengine.mediasource.PlaybackInfoMediaSourceFa
import com.tidal.sdk.player.playbackengine.mediasource.PlayerAuthHlsMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerDashMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerDashOfflineMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerHlsMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerProgressiveMediaSourceFactory
import com.tidal.sdk.player.playbackengine.mediasource.PlayerProgressiveOfflineMediaSourceFactory
Expand Down Expand Up @@ -278,11 +276,11 @@ internal object MediaSourcererModule {
@Named("cacheDataSourceFactoryForOfflinePlay")
cacheDataSourceFactory: CacheDataSource.Factory,
cacheKeyFactory: CacheKeyFactory,
encryption: Encryption?,
offlineSecretKey: ByteArray?,
) = CacheKeyAesCipherDataSourceFactoryFactory(
cacheDataSourceFactory,
cacheKeyFactory,
encryption,
offlineSecretKey,
)

@Provides
Expand Down Expand Up @@ -334,20 +332,6 @@ internal object MediaSourcererModule {
upstream: FileDataSource.Factory,
) = DecryptedHeaderFileDataSourceFactoryFactory(upstream)

@Provides
@Reusable
fun playerDecryptedHeaderProgressiveOfflineMediaSourceFactory(
progressiveMediaSourceFactoryFactory: ProgressiveMediaSourceFactoryFactory,
decryptedHeaderFileDataSourceFactoryFactory: DecryptedHeaderFileDataSourceFactoryFactory,
encryption: Encryption?,
btsManifestFactory: DefaultBtsManifestFactory,
) = PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory(
progressiveMediaSourceFactoryFactory,
decryptedHeaderFileDataSourceFactoryFactory,
encryption,
btsManifestFactory,
)

@Provides
@Reusable
fun dashManifestParser(): ParsingLoadable.Parser<DashManifest> = DashManifestParser()
Expand Down Expand Up @@ -488,7 +472,6 @@ internal object MediaSourcererModule {
playerDashMediaSourceFactory: PlayerDashMediaSourceFactory,
playerHlsMediaSourceFactory: PlayerHlsMediaSourceFactory,
playerAuthHlsMediaSourceFactory: PlayerAuthHlsMediaSourceFactory,
@Suppress("MaxLineLength") playerDecryptedHeaderProgressiveOfflineMediaSourceFactory: PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory, // ktlint-disable max-line-length parameter-wrapping
playerProgressiveOfflineMediaSourceFactory: PlayerProgressiveOfflineMediaSourceFactory,
playerDashOfflineMediaSourceFactory: PlayerDashOfflineMediaSourceFactory,
drmSessionManagerFactory: DrmSessionManagerFactory,
Expand All @@ -498,7 +481,6 @@ internal object MediaSourcererModule {
playerDashMediaSourceFactory,
playerHlsMediaSourceFactory,
playerAuthHlsMediaSourceFactory,
playerDecryptedHeaderProgressiveOfflineMediaSourceFactory,
playerProgressiveOfflineMediaSourceFactory,
playerDashOfflineMediaSourceFactory,
drmSessionManagerFactory,
Expand Down

This file was deleted.

Loading

0 comments on commit 9a27ce5

Please sign in to comment.