diff --git a/player/playback-engine/src/androidTest/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngineLooperTest.kt b/player/playback-engine/src/androidTest/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngineLooperTest.kt index dcbe97ef..17495fd7 100644 --- a/player/playback-engine/src/androidTest/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngineLooperTest.kt +++ b/player/playback-engine/src/androidTest/kotlin/com/tidal/sdk/player/playbackengine/ExoPlayerPlaybackEngineLooperTest.kt @@ -41,7 +41,7 @@ internal class ExoPlayerPlaybackEngineLooperTest { TrueTimeWrapper(), mock(), mock(), - mock(), + null, Base64Codec(), Dispatchers.IO, CoroutineScope(Dispatchers.IO), diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/Encryption.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/Encryption.kt deleted file mode 100644 index 274c39f2..00000000 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/Encryption.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.tidal.sdk.player.playbackengine - -import androidx.media3.datasource.DataSource - -/** - * Implement this to provide encryption details from a host app. - */ -interface Encryption { - - /** - * A secretKey of [ByteArray]. Must be the same value for the same content when reading from a - * [DataSource] and writing to a[androidx.media3.datasource.DataSink]. - * Only necessary when the host app has downloaded the content to ensure we are using the same - * key when playing back that downloaded content. - */ - val secretKey: ByteArray - - /** - * A decryptedHeader of [ByteArray] if this was used as an offlining strategy in the host app. - * Only necessary when the host app has downloaded the content in this specific way to ensure - * we are getting the correctly decrypted header when playing back that downloaded content. - */ - fun getDecryptedHeader(productId: String): ByteArray -} diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/PlaybackEngineModuleRoot.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/PlaybackEngineModuleRoot.kt index a55188c4..d962e0d3 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/PlaybackEngineModuleRoot.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/PlaybackEngineModuleRoot.kt @@ -45,7 +45,7 @@ class PlaybackEngineModuleRoot( trueTimeWrapper: TrueTimeWrapper, playbackPrivilegeProvider: PlaybackPrivilegeProvider, offlineCacheProvider: OfflineCacheProvider?, - encryption: Encryption?, + offlineSecretKey: ByteArray?, base64Codec: Base64Codec, coroutineDispatcher: CoroutineDispatcher, coroutineScope: CoroutineScope, @@ -72,7 +72,7 @@ class PlaybackEngineModuleRoot( trueTimeWrapper, playbackPrivilegeProvider, offlineCacheProvider, - encryption, + offlineSecretKey, base64Codec, coroutineDispatcher, coroutineScope, diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/datasource/CacheKeyAesCipherDataSourceFactoryFactory.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/datasource/CacheKeyAesCipherDataSourceFactoryFactory.kt index fd260a48..0396fe18 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/datasource/CacheKeyAesCipherDataSourceFactoryFactory.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/datasource/CacheKeyAesCipherDataSourceFactoryFactory.kt @@ -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), ) diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/di/ExoPlayerPlaybackEngineComponent.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/di/ExoPlayerPlaybackEngineComponent.kt index bc155a10..f0457cdc 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/di/ExoPlayerPlaybackEngineComponent.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/di/ExoPlayerPlaybackEngineComponent.kt @@ -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 @@ -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, diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory.kt deleted file mode 100644 index f2a80ac9..00000000 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.tidal.sdk.player.playbackengine.mediasource - -import androidx.media3.common.MediaItem -import androidx.media3.exoplayer.source.ProgressiveMediaSource -import com.tidal.sdk.player.playbackengine.Encryption -import com.tidal.sdk.player.playbackengine.bts.BtsManifestFactory -import com.tidal.sdk.player.playbackengine.datasource.DecryptedHeaderFileDataSourceFactoryFactory - -internal class PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory( - private val progressiveMediaSourceFactoryFactory: ProgressiveMediaSourceFactoryFactory, - @Suppress("MaxLineLength") private val decryptedHeaderFileDataSourceFactoryFactory: DecryptedHeaderFileDataSourceFactoryFactory, // ktlint-disable max-line-length parameter-wrapping - private val encryption: Encryption?, - private val btsManifestFactory: BtsManifestFactory, -) { - - fun create( - mediaItem: MediaItem, - encodedManifest: String, - productId: String, - ): ProgressiveMediaSource { - val btsManifest = btsManifestFactory.create(encodedManifest) - val newMediaItem = mediaItem.buildUpon() - .setUri(btsManifest.urls.firstOrNull()) - .build() - - return progressiveMediaSourceFactoryFactory.create( - decryptedHeaderFileDataSourceFactoryFactory.create( - encryption!!.getDecryptedHeader(productId), - ), - ).createMediaSource(newMediaItem) - } -} diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreator.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreator.kt index a35a194d..606c0ba1 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreator.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreator.kt @@ -15,7 +15,6 @@ internal class TidalMediaSourceCreator( private val playerProgressiveMediaSourceFactory: PlayerProgressiveMediaSourceFactory, private val playerDashMediaSourceFactory: PlayerDashMediaSourceFactory, private val playerHlsMediaSourceFactory: PlayerHlsMediaSourceFactory, - @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, @@ -26,35 +25,23 @@ internal class TidalMediaSourceCreator( override fun invoke(mediaItem: MediaItem, playbackInfo: PlaybackInfo): 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, - ), + ManifestMimeType.DASH -> playerDashOfflineMediaSourceFactory.create( + mediaItem, + playbackInfo.manifest, + playbackInfo.offlineLicense!!, + playbackInfo.storage!!, + drmSessionManagerProviderFactory.create( + drmSessionManagerFactory.createDrmSessionManagerForOfflinePlay( + playbackInfo, ), - ) - } + ), + ) else -> throw IllegalArgumentException( "No valid manifestMimeType for offline playback: " + @@ -99,11 +86,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") - } } diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/offline/crypto/CacheKeyAesCipherDataSourceFactory.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/offline/crypto/CacheKeyAesCipherDataSourceFactory.kt index 98bd3026..c1a8a550 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/offline/crypto/CacheKeyAesCipherDataSourceFactory.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/offline/crypto/CacheKeyAesCipherDataSourceFactory.kt @@ -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) } } diff --git a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/player/di/MediaSourcererModule.kt b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/player/di/MediaSourcererModule.kt index 68ac47bd..32ffc749 100644 --- a/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/player/di/MediaSourcererModule.kt +++ b/player/playback-engine/src/main/kotlin/com/tidal/sdk/player/playbackengine/player/di/MediaSourcererModule.kt @@ -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 @@ -49,7 +48,6 @@ import com.tidal.sdk.player.playbackengine.mediasource.MediaSourcerer import com.tidal.sdk.player.playbackengine.mediasource.PlaybackInfoMediaSourceFactory 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 @@ -239,11 +237,11 @@ internal object MediaSourcererModule { @Named("cacheDataSourceFactoryForOfflinePlay") cacheDataSourceFactory: CacheDataSource.Factory, cacheKeyFactory: CacheKeyFactory, - encryption: Encryption?, + offlineSecretKey: ByteArray?, ) = CacheKeyAesCipherDataSourceFactoryFactory( cacheDataSourceFactory, cacheKeyFactory, - encryption, + offlineSecretKey, ) @Provides @@ -295,20 +293,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 = DashManifestParser() @@ -440,7 +424,6 @@ internal object MediaSourcererModule { playerProgressiveMediaSourceFactory: PlayerProgressiveMediaSourceFactory, playerDashMediaSourceFactory: PlayerDashMediaSourceFactory, playerHlsMediaSourceFactory: PlayerHlsMediaSourceFactory, - @Suppress("MaxLineLength") playerDecryptedHeaderProgressiveOfflineMediaSourceFactory: PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory, // ktlint-disable max-line-length parameter-wrapping playerProgressiveOfflineMediaSourceFactory: PlayerProgressiveOfflineMediaSourceFactory, playerDashOfflineMediaSourceFactory: PlayerDashOfflineMediaSourceFactory, drmSessionManagerFactory: DrmSessionManagerFactory, @@ -449,7 +432,6 @@ internal object MediaSourcererModule { playerProgressiveMediaSourceFactory, playerDashMediaSourceFactory, playerHlsMediaSourceFactory, - playerDecryptedHeaderProgressiveOfflineMediaSourceFactory, playerProgressiveOfflineMediaSourceFactory, playerDashOfflineMediaSourceFactory, drmSessionManagerFactory, diff --git a/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactoryTest.kt b/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactoryTest.kt deleted file mode 100644 index a120abf9..00000000 --- a/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactoryTest.kt +++ /dev/null @@ -1,112 +0,0 @@ -package com.tidal.sdk.player.playbackengine.mediasource - -import androidx.media3.common.MediaItem -import androidx.media3.exoplayer.source.ProgressiveMediaSource -import assertk.assertThat -import assertk.assertions.isSameAs -import com.tidal.sdk.player.playbackengine.Encryption -import com.tidal.sdk.player.playbackengine.bts.BtsManifest -import com.tidal.sdk.player.playbackengine.bts.BtsManifestFactory -import com.tidal.sdk.player.playbackengine.datasource.DecryptedHeaderFileDataSourceFactory -import com.tidal.sdk.player.playbackengine.datasource.DecryptedHeaderFileDataSourceFactoryFactory -import org.junit.jupiter.api.AfterEach -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.Arguments -import org.junit.jupiter.params.provider.MethodSource -import org.mockito.Answers -import org.mockito.kotlin.doReturn -import org.mockito.kotlin.mock -import org.mockito.kotlin.verify -import org.mockito.kotlin.verifyNoMoreInteractions -import org.mockito.kotlin.whenever - -private const val ENCODED_MANIFEST = "encodedManifest" - -internal class PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactoryTest { - - private val progressiveMediaSourceFactoryFactory = mock() - private val decryptedHeaderFileDataSourceFactoryFactory = - mock() - private val encryption = mock() - private val btsManifestFactory = mock() - private val playerDecryptedHeaderProgressiveOfflineMediaSourceFactory = - PlayerDecryptedHeaderProgressiveOfflineMediaSourceFactory( - progressiveMediaSourceFactoryFactory, - decryptedHeaderFileDataSourceFactoryFactory, - encryption, - btsManifestFactory, - ) - - @AfterEach - fun afterEach() = verifyNoMoreInteractions( - progressiveMediaSourceFactoryFactory, - decryptedHeaderFileDataSourceFactoryFactory, - encryption, - btsManifestFactory, - ) - - @ParameterizedTest - @MethodSource("btsManifests") - fun create(btsManifest: BtsManifest) { - val mediaItem = mock() - val productId = "123" - val builtMediaItem = mock() - val expectedProgressiveMediaSource = mock() - val progressiveMediaSourceFactory = mock { - on { createMediaSource(builtMediaItem) } doReturn expectedProgressiveMediaSource - } - val decryptedHeaderFileDataSourceFactory = mock() - val decryptedHeader = "decryptedHeader".toByteArray() - whenever(btsManifestFactory.create(ENCODED_MANIFEST)).thenReturn(btsManifest) - val mediaItemBuilder = mock(defaultAnswer = Answers.RETURNS_SELF) - whenever(mediaItem.buildUpon()) doReturn mediaItemBuilder - whenever(mediaItemBuilder.build()) doReturn builtMediaItem - whenever(encryption.getDecryptedHeader(productId)).thenReturn(decryptedHeader) - whenever(decryptedHeaderFileDataSourceFactoryFactory.create(decryptedHeader)) - .thenReturn(decryptedHeaderFileDataSourceFactory) - whenever(progressiveMediaSourceFactoryFactory.create(decryptedHeaderFileDataSourceFactory)) - .thenReturn(progressiveMediaSourceFactory) - - val actualProgressiveMediaSource = - playerDecryptedHeaderProgressiveOfflineMediaSourceFactory.create( - mediaItem, - ENCODED_MANIFEST, - productId, - ) - - assertThat(actualProgressiveMediaSource).isSameAs(expectedProgressiveMediaSource) - verify(btsManifestFactory).create(ENCODED_MANIFEST) - verify(mediaItem).buildUpon() - verify(mediaItemBuilder).setUri(btsManifest.urls.firstOrNull()) - verify(mediaItemBuilder).build() - verify(encryption).getDecryptedHeader(productId) - verify(decryptedHeaderFileDataSourceFactoryFactory).create(decryptedHeader) - verify(progressiveMediaSourceFactoryFactory).create(decryptedHeaderFileDataSourceFactory) - verify(progressiveMediaSourceFactory).createMediaSource(builtMediaItem) - verifyNoMoreInteractions( - mediaItem, - mediaItemBuilder, - builtMediaItem, - expectedProgressiveMediaSource, - progressiveMediaSourceFactory, - decryptedHeaderFileDataSourceFactory, - ) - } - - companion object { - - @JvmStatic - @Suppress("UnusedPrivateMember") - private fun btsManifests() = setOf( - Arguments.of(BtsManifest("", listOf())), - Arguments.of(BtsManifest("", listOf("url"))), - Arguments.of(BtsManifest("", listOf("url", "url2"))), - Arguments.of(BtsManifest("codecs", listOf())), - Arguments.of(BtsManifest("codecs", listOf("url"))), - Arguments.of(BtsManifest("codecs", listOf("url", "url2"))), - Arguments.of(BtsManifest("codecs,codecs", listOf())), - Arguments.of(BtsManifest("codecs,codecs", listOf("url"))), - Arguments.of(BtsManifest("codecs,codecs", listOf("url", "url2"))), - ) - } -} diff --git a/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreatorTest.kt b/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreatorTest.kt index 9d0be660..b626b5cf 100644 --- a/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreatorTest.kt +++ b/player/playback-engine/src/test/kotlin/com/tidal/sdk/player/playbackengine/mediasource/TidalMediaSourceCreatorTest.kt @@ -24,8 +24,6 @@ internal class TidalMediaSourceCreatorTest { private val playerProgressiveMediaSourceFactory = mock() private val playerDashMediaSourceFactory = mock() private val playerHlsMediaSourceFactory = mock() - private val playerDecryptedHeaderProgressiveOfflineMediaSourceFactory = - mock() private val playerProgressiveOfflineMediaSourceFactory = mock() private val playerDashOfflineMediaSourceFactory = mock() @@ -35,7 +33,6 @@ internal class TidalMediaSourceCreatorTest { playerProgressiveMediaSourceFactory, playerDashMediaSourceFactory, playerHlsMediaSourceFactory, - playerDecryptedHeaderProgressiveOfflineMediaSourceFactory, playerProgressiveOfflineMediaSourceFactory, playerDashOfflineMediaSourceFactory, drmSessionManagerFactory, @@ -141,32 +138,6 @@ internal class TidalMediaSourceCreatorTest { assertThat(actual).isSameAs(expectedProgressiveMediaSource) } - @Test - fun invokeWithManifestMimeTypeBtsForOffline() { - val mediaItem = mock() - val playbackInfoTrack = mock { - on { it.trackId } doReturn 123 - } - val playbackInfoOfflineTrack = mock { - on { it.track } doReturn playbackInfoTrack - on { it.manifest } doReturn "btsManifest" - on { it.manifestMimeType } doReturn ManifestMimeType.BTS - on { it.partiallyEncrypted } doReturn true - } - val expectedProgressiveMediaSource = mock() - whenever( - playerDecryptedHeaderProgressiveOfflineMediaSourceFactory.create( - mediaItem, - playbackInfoOfflineTrack.manifest, - playbackInfoOfflineTrack.track.trackId.toString(), - ), - ).thenReturn(expectedProgressiveMediaSource) - - val actual = tidalMediaSourceCreator.invoke(mediaItem, playbackInfoOfflineTrack) - - assertThat(actual).isSameAs(expectedProgressiveMediaSource) - } - @Test fun invokeWithManifestMimeTypeBtsForOfflineWithFullEncryption() { val mediaItem = mock() @@ -174,7 +145,6 @@ internal class TidalMediaSourceCreatorTest { val playbackInfoOfflineTrack = mock { on { it.manifest } doReturn "btsManifest" on { it.manifestMimeType } doReturn ManifestMimeType.BTS - on { it.partiallyEncrypted } doReturn false on { it.storage } doReturn storage } val expectedProgressiveMediaSource = mock() @@ -211,7 +181,6 @@ internal class TidalMediaSourceCreatorTest { val playbackInfoOfflineTrack = mock { on { it.manifest } doReturn "dashManifest" on { it.manifestMimeType } doReturn ManifestMimeType.DASH - on { it.partiallyEncrypted } doReturn false on { it.storage } doReturn storage on { it.offlineLicense } doReturn offlineLicense } diff --git a/player/src/main/kotlin/com/tidal/sdk/player/di/PlaybackEngineModule.kt b/player/src/main/kotlin/com/tidal/sdk/player/di/PlaybackEngineModule.kt index 5754d38c..2ae67cf3 100644 --- a/player/src/main/kotlin/com/tidal/sdk/player/di/PlaybackEngineModule.kt +++ b/player/src/main/kotlin/com/tidal/sdk/player/di/PlaybackEngineModule.kt @@ -86,7 +86,7 @@ internal object PlaybackEngineModule { trueTimeWrapper, playbackPrivilegeProvider, offlinePlayProvider?.offlineCacheProvider, - offlinePlayProvider?.encryption, + offlinePlayProvider?.offlineSecretKey, base64Codec, coroutineDispatcher, coroutineScope, diff --git a/player/src/main/kotlin/com/tidal/sdk/player/offlineplay/OfflinePlayProvider.kt b/player/src/main/kotlin/com/tidal/sdk/player/offlineplay/OfflinePlayProvider.kt index cc2bfa5a..11833bcf 100644 --- a/player/src/main/kotlin/com/tidal/sdk/player/offlineplay/OfflinePlayProvider.kt +++ b/player/src/main/kotlin/com/tidal/sdk/player/offlineplay/OfflinePlayProvider.kt @@ -1,6 +1,5 @@ package com.tidal.sdk.player.offlineplay -import com.tidal.sdk.player.playbackengine.Encryption import com.tidal.sdk.player.playbackengine.offline.cache.OfflineCacheProvider import com.tidal.sdk.player.streamingapi.playbackinfo.offline.OfflinePlaybackInfoProvider @@ -10,5 +9,5 @@ import com.tidal.sdk.player.streamingapi.playbackinfo.offline.OfflinePlaybackInf class OfflinePlayProvider( val offlinePlaybackInfoProvider: OfflinePlaybackInfoProvider? = null, val offlineCacheProvider: OfflineCacheProvider? = null, - val encryption: Encryption? = null, + val offlineSecretKey: ByteArray? = null, ) diff --git a/player/streaming-api/src/main/kotlin/com/tidal/sdk/player/streamingapi/playbackinfo/model/PlaybackInfo.kt b/player/streaming-api/src/main/kotlin/com/tidal/sdk/player/streamingapi/playbackinfo/model/PlaybackInfo.kt index efc9a87b..0a612615 100644 --- a/player/streaming-api/src/main/kotlin/com/tidal/sdk/player/streamingapi/playbackinfo/model/PlaybackInfo.kt +++ b/player/streaming-api/src/main/kotlin/com/tidal/sdk/player/streamingapi/playbackinfo/model/PlaybackInfo.kt @@ -148,12 +148,10 @@ sealed interface PlaybackInfo { * * @property[offlineLicense] The stored offlineLicense in case it is protected. * @property[storage] Information about storage and path. - * @property[partiallyEncrypted] Information about legacy encryption strategy. */ interface Offline { val offlineLicense: String? val storage: Storage? - val partiallyEncrypted: Boolean /** * Playback info with track specific properties for offline. @@ -164,7 +162,6 @@ sealed interface PlaybackInfo { val track: PlaybackInfo.Track, override val offlineLicense: String? = null, override val storage: Storage? = null, - override val partiallyEncrypted: Boolean = false, ) : PlaybackInfo by track, Offline /** @@ -176,7 +173,6 @@ sealed interface PlaybackInfo { val video: PlaybackInfo.Video, override val offlineLicense: String? = null, override val storage: Storage? = null, - override val partiallyEncrypted: Boolean = false, ) : PlaybackInfo by video, Offline } } diff --git a/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/TrackPlaybackInfoFactory.kt b/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/TrackPlaybackInfoFactory.kt index 58d02b5b..461bf063 100644 --- a/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/TrackPlaybackInfoFactory.kt +++ b/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/TrackPlaybackInfoFactory.kt @@ -47,6 +47,5 @@ object TrackPlaybackInfoFactory { DEFAULT, "", Storage(false, ""), - false, ) } diff --git a/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/VideoPlaybackInfoFactory.kt b/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/VideoPlaybackInfoFactory.kt index 6fcb1f92..0fb13ff5 100644 --- a/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/VideoPlaybackInfoFactory.kt +++ b/player/streaming-api/src/test/kotlin/com/tidal/sdk/player/streamingapi/VideoPlaybackInfoFactory.kt @@ -44,6 +44,5 @@ object VideoPlaybackInfoFactory { DEFAULT, "", Storage(false, ""), - false, ) }