Skip to content

Commit

Permalink
Update media3 to 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ziad-halabi9 committed Oct 8, 2024
1 parent cfda2d2 commit f485104
Show file tree
Hide file tree
Showing 32 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ retrofit = "2.11.0"
room = "2.6.1"
slf4j-api = "2.0.12"
tickaroo = "0.8.13"
tidal-androidx-media = "1.1.1.2"
tidal-androidx-media = "1.2.1.1"
plugins-tidal = "unspecified"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private const val MAX_5XX_RETRIES = 3
private const val MAX_RETRY_INTERVAL_MS = 5_000L
private const val TOO_MANY_REQUESTS_STATUS = 429

@Suppress("UnsafeOptInUsageError")
internal class PlayerLoadErrorHandlingPolicy(
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
) : LoadErrorHandlingPolicy by loadErrorHandlingPolicy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.tidal.sdk.player.playbackengine.cache
import androidx.media3.datasource.DataSpec
import androidx.media3.datasource.cache.CacheKeyFactory

@Suppress("UnsafeOptInUsageError")
internal class DefaultCacheKeyFactory : CacheKeyFactory {
override fun buildCacheKey(dataSpec: DataSpec) = dataSpec.uri.path.toString()
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.nio.charset.Charset
* Create ExoPlayer's [DashManifest] from our encoded [String] manifest, decoded with the provided
* [base64Codec], then parsed with the provided [dashManifestParser].
*/
@Suppress("UnsafeOptInUsageError")
internal class DashManifestFactory(
private val base64Codec: Base64Codec,
private val dashManifestParser: ParsingLoadable.Parser<DashManifest>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.media3.datasource.cache.CacheKeyFactory
import com.tidal.sdk.player.playbackengine.Encryption
import com.tidal.sdk.player.playbackengine.offline.crypto.CacheKeyAesCipherDataSourceFactory

@Suppress("UnsafeOptInUsageError")
internal class CacheKeyAesCipherDataSourceFactoryFactory(
private val cacheDataSourceFactory: CacheDataSource.Factory,
private val cacheKeyFactory: CacheKeyFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.datasource.DataSource
import androidx.media3.datasource.DataSpec
import kotlin.math.max

@Suppress("UnsafeOptInUsageError")
internal class DecryptedHeaderFileDataSource(
private val decryptedHeader: ByteArray,
private val upstream: DataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.tidal.sdk.player.playbackengine.datasource
import androidx.media3.datasource.DataSource
import androidx.media3.datasource.FileDataSource

@Suppress("UnsafeOptInUsageError")
internal class DecryptedHeaderFileDataSourceFactory(
private val decryptedHeader: ByteArray,
private val upstream: FileDataSource.Factory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.tidal.sdk.player.playbackengine.datasource

import androidx.media3.datasource.FileDataSource

@Suppress("UnsafeOptInUsageError")
internal class DecryptedHeaderFileDataSourceFactoryFactory(
private val upstream: FileDataSource.Factory,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ package com.tidal.sdk.player.playbackengine.dj
import androidx.media3.common.util.Util

internal class DateParser {
@Suppress("UnsafeOptInUsageError")
fun parseXsDateTime(value: String) = Util.parseXsDateTime(value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.media3.exoplayer.drm.DefaultDrmSessionManager
import androidx.media3.exoplayer.drm.DrmSessionManager
import com.tidal.sdk.player.streamingapi.playbackinfo.model.PlaybackInfo

@Suppress("UnsafeOptInUsageError")
internal class DrmSessionManagerFactory(
private val defaultDrmSessionManagerBuilder: DefaultDrmSessionManager.Builder,
private val tidalMediaDrmCallbackFactory: TidalMediaDrmCallbackFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.exoplayer.drm.DrmSessionManagerProvider

internal class DrmSessionManagerProviderFactory {

@Suppress("UnsafeOptInUsageError")
fun create(drmSessionManager: DrmSessionManager) =
DrmSessionManagerProvider { drmSessionManager }
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ internal class TidalMediaDrmCallbackFactory(
private val okHttpClient: OkHttpClient,
) {

@Suppress("UnsafeOptInUsageError")
fun create(playbackInfo: PlaybackInfo, mode: DrmMode, extras: Map<String, String?>?) =
TidalMediaDrmCallback(
streamingApiRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.media3.datasource.DataSource
import androidx.media3.exoplayer.dash.DashMediaSource
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy

@Suppress("UnsafeOptInUsageError")
internal class DashMediaSourceFactoryFactory(
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.io.IOException
* A [CompositeMediaSource] that fetches Playback info with the help of a [PlaybackInfoLoadable],
* and then creates a [MediaSource] with the help of a [PlaybackInfoLoadableLoaderCallback].
*/
@Suppress("LongParameterList")
@Suppress("LongParameterList", "UnsafeOptInUsageError")
internal class PlaybackInfoMediaSource(
val forwardingMediaProduct: ForwardingMediaProduct<MediaProduct>,
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import com.tidal.sdk.player.playbackengine.mediasource.loadable.PlaybackInfoLoad
import com.tidal.sdk.player.playbackengine.mediasource.loadable.PlaybackInfoLoadableLoaderCallbackFactory
import com.tidal.sdk.player.playbackengine.mediasource.streamingsession.StreamingSession

@Suppress("UnsafeOptInUsageError")
private const val DATA_TYPE = C.DATA_TYPE_MANIFEST
private const val LOADER_THREAD_NAME_SUFFIX = "PlaybackInfoMediaSource"

@Suppress("UnsafeOptInUsageError")
internal class PlaybackInfoMediaSourceFactory(
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
private val playbackInfoLoadableFactory: PlaybackInfoLoadableFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.exoplayer.dash.DashMediaSource
import androidx.media3.exoplayer.drm.DrmSessionManagerProvider
import com.tidal.sdk.player.playbackengine.dash.DashManifestFactory

@Suppress("UnsafeOptInUsageError")
internal class PlayerDashMediaSourceFactory(
private val dashMediaSourceFactory: DashMediaSource.Factory,
private val dashManifestFactory: DashManifestFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal class PlayerDashOfflineMediaSourceFactory(
private val offlineDrmHelper: OfflineDrmHelper?,
) {

@Suppress("UnsafeOptInUsageError")
fun create(
mediaItem: MediaItem,
encodedManifest: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.media3.exoplayer.hls.HlsMediaSource
import androidx.media3.exoplayer.source.MediaSource
import com.tidal.sdk.player.playbackengine.emu.EmuManifestFactory

@Suppress("UnsafeOptInUsageError")
internal class PlayerHlsMediaSourceFactory(
private val hlsMediaSourceFactory: HlsMediaSource.Factory,
private val emuManifestFactory: EmuManifestFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.datasource.cache.CacheDataSource
import androidx.media3.exoplayer.source.ProgressiveMediaSource
import com.tidal.sdk.player.playbackengine.bts.BtsManifestFactory

@Suppress("UnsafeOptInUsageError")
internal class PlayerProgressiveMediaSourceFactory(
private val progressiveMediaSourceFactoryFactory: ProgressiveMediaSourceFactoryFactory,
private val cacheDataSourceFactory: CacheDataSource.Factory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import androidx.media3.exoplayer.source.ProgressiveMediaSource
import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
import androidx.media3.extractor.ExtractorsFactory

@Suppress("UnsafeOptInUsageError")
internal class ProgressiveMediaSourceFactoryFactory(
private val extractorsFactory: ExtractorsFactory,
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import com.tidal.sdk.player.playbackengine.mediasource.TidalMediaSourceCreator
import com.tidal.sdk.player.streamingapi.playbackinfo.model.PlaybackInfo
import java.io.IOException

@Suppress("LongParameterList")
@Suppress("LongParameterList", "UnsafeOptInUsageError")
internal class PlaybackInfoLoadableLoaderCallback(
private val mediaItem: MediaItem,
private val tidalMediaSourceCreator: TidalMediaSourceCreator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.media3.exoplayer.upstream.LoadErrorHandlingPolicy
import com.tidal.sdk.player.playbackengine.mediasource.TidalMediaSourceCreator
import java.io.IOException

@Suppress("UnsafeOptInUsageError")
internal class PlaybackInfoLoadableLoaderCallbackFactory(
private val tidalMediaSourceCreator: TidalMediaSourceCreator,
private val loadErrorHandlingPolicy: LoadErrorHandlingPolicy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.tidal.sdk.player.commonandroid.Base64Codec
*/
internal class OfflineDrmHelper(private val base64Codec: Base64Codec) {

@Suppress("UnsafeOptInUsageError")
fun setOfflineLicense(offlineLicense: String, drmSessionManager: DrmSessionManager) {
val decodedOfflineLicense = base64Codec.decode(offlineLicense.toByteArray(CHARSET))
(drmSessionManager as? DefaultDrmSessionManager)?.setMode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ internal class OfflinePlayDataSourceFactoryHelper(
offlineCacheProvider: OfflineCacheProvider?,
) : OfflineDataSourceFactoryHelper<DataSource.Factory>(offlineCacheProvider) {

@Suppress("UnsafeOptInUsageError")
override fun create(cache: Cache) = cacheKeyAesCipherDataSourceFactoryFactory.create(cache)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.tidal.sdk.player.playbackengine.offline.cache.OfflineCacheProvider
* @param[offlineCacheProvider] An instance of [OfflineCacheProvider]. Used to get the correct
* [Cache] instance.
*/
@Suppress("UnsafeOptInUsageError")
internal class OfflinePlayDrmDataSourceFactoryHelper(
private val cacheDataSourceFactory: CacheDataSource.Factory,
offlineCacheProvider: OfflineCacheProvider?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.media3.datasource.TransferListener
* Note: If we don't set this as upstream, it will use the [DummyDataSource] which just sends a
* default [IOException], but we want to control this and use our own [StorageException].
*/
@Suppress("UnsafeOptInUsageError")
internal class StorageDataSource : DataSource {

class Factory(private val storageDataSource: StorageDataSource) : DataSource.Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.media3.datasource.cache.CacheKeyFactory
* for caching or offlining this piece of content.
* @param[aesCipherDataSource] An instance of [AesCipherDataSource].
*/
@Suppress("UnsafeOptInUsageError")
internal class CacheKeyAesCipherDataSource(
private val cacheKeyFactory: CacheKeyFactory,
private val aesCipherDataSource: AesCipherDataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import androidx.media3.datasource.cache.CacheKeyFactory
* [androidx.media3.datasource.cache.CacheDataSource.Factory], depending on if your
* content has been cached or offlined.
*/
@Suppress("UnsafeOptInUsageError")
class CacheKeyAesCipherDataSourceFactory(
private val cacheKeyFactory: CacheKeyFactory,
private val secretKey: ByteArray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ internal object ExtendedExoPlayerModule {

@Provides
@Reusable
@Suppress("UnsafeOptInUsageError")
fun trackSelectionFactory(): ExoTrackSelection.Factory = AdaptiveTrackSelection.Factory()

@Provides
@Reusable
@Suppress("UnsafeOptInUsageError")
fun trackSelector(context: Context, trackSelectionFactory: ExoTrackSelection.Factory):
TrackSelector = DefaultTrackSelector(context, trackSelectionFactory)

@Provides
@ExtendedExoPlayerComponent.Scoped
@Suppress("UnsafeOptInUsageError")
fun loadControl(bufferConfiguration: BufferConfiguration): LoadControl =
bufferConfiguration.run {
DefaultLoadControl.Builder()
Expand All @@ -58,6 +61,7 @@ internal object ExtendedExoPlayerModule {

@Provides
@ExtendedExoPlayerComponent.Scoped
@Suppress("UnsafeOptInUsageError")
fun priorityTaskManager() = PriorityTaskManager()

@Provides
Expand All @@ -69,6 +73,7 @@ internal object ExtendedExoPlayerModule {

@Provides
@ExtendedExoPlayerComponent.Scoped
@Suppress("UnsafeOptInUsageError")
fun exoPlayer(
context: Context,
renderersFactory: RenderersFactory,
Expand All @@ -93,6 +98,7 @@ internal object ExtendedExoPlayerModule {

@Provides
@ExtendedExoPlayerComponent.Scoped
@Suppress("UnsafeOptInUsageError")
fun extendedExoPlayer(
exoPlayer: ExoPlayer,
loadControl: LoadControl,
Expand Down
Loading

0 comments on commit f485104

Please sign in to comment.