Skip to content

Commit

Permalink
[APT-10449] Rename "helper" to FactoryFactory
Browse files Browse the repository at this point in the history
FactoryFactory reflects design pattern used. Helper & Util names are an anti-pattern.
  • Loading branch information
kabliz committed Sep 20, 2024
1 parent b2f97df commit ef6538e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import com.scribd.armadillo.playback.PlaybackStateBuilderImpl
import com.scribd.armadillo.playback.PlaybackStateCompatBuilder
import com.scribd.armadillo.playback.mediasource.DrmMediaSourceHelper
import com.scribd.armadillo.playback.mediasource.DrmMediaSourceHelperImpl
import com.scribd.armadillo.playback.mediasource.HeadersMediaSourceHelper
import com.scribd.armadillo.playback.mediasource.HeadersMediaSourceHelperImpl
import com.scribd.armadillo.playback.mediasource.HeadersMediaSourceFactoryFactory
import com.scribd.armadillo.playback.mediasource.HeadersMediaSourceFactoryFactoryImpl
import com.scribd.armadillo.playback.mediasource.MediaSourceRetriever
import com.scribd.armadillo.playback.mediasource.MediaSourceRetrieverImpl
import dagger.Module
Expand Down Expand Up @@ -66,7 +66,7 @@ internal class PlaybackModule {

@Provides
@Singleton
fun mediaSourceHelper(mediaSourceHelperImpl: HeadersMediaSourceHelperImpl): HeadersMediaSourceHelper = mediaSourceHelperImpl
fun mediaSourceHelper(mediaSourceHelperImpl: HeadersMediaSourceFactoryFactoryImpl): HeadersMediaSourceFactoryFactory = mediaSourceHelperImpl

@Provides
@Singleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import javax.inject.Inject
/** For playback, both streaming and downloaded */
internal class DashMediaSourceGenerator @Inject constructor(
context: Context,
private val mediaSourceHelper: HeadersMediaSourceHelper,
private val mediaSourceFactoryFactory: HeadersMediaSourceFactoryFactory,
private val downloadTracker: DownloadTracker,
private val drmMediaSourceHelper: DrmMediaSourceHelper,
private val drmSessionManagerProvider: DrmSessionManagerProvider,
Expand All @@ -33,7 +33,7 @@ internal class DashMediaSourceGenerator @Inject constructor(
if (request.drmInfo != null) {
stateStore.dispatch(OpeningLicenseAction(request.drmInfo.drmType))
}
val dataSourceFactory = mediaSourceHelper.createDataSourceFactory(context, request)
val dataSourceFactory = mediaSourceFactoryFactory.createDataSourceFactory(context, request)

val download = downloadTracker.getDownload(id = mediaId, uri = request.url)
val isDownloaded = download != null && download.state == Download.STATE_COMPLETED
Expand All @@ -45,7 +45,7 @@ internal class DashMediaSourceGenerator @Inject constructor(
)

return if (isDownloaded) {
val drmManager = if (request.drmInfo == null) {
val drmManager = if (request.drmInfo != null) {
drmSessionManagerProvider.get(mediaItem)
} else null

Expand Down Expand Up @@ -74,5 +74,6 @@ internal class DashMediaSourceGenerator @Inject constructor(
}
}

override fun updateMediaSourceHeaders(request: AudioPlayable.MediaRequest) = mediaSourceHelper.updateMediaSourceHeaders(request)
override fun updateMediaSourceHeaders(request: AudioPlayable.MediaRequest) =
mediaSourceFactoryFactory.updateMediaSourceHeaders(request)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.Context
import com.google.android.exoplayer2.upstream.DataSource
import com.scribd.armadillo.models.AudioPlayable

internal interface HeadersMediaSourceHelper {
internal interface HeadersMediaSourceFactoryFactory {
fun createDataSourceFactory(context: Context, request: AudioPlayable.MediaRequest): DataSource.Factory
fun updateMediaSourceHeaders(request: AudioPlayable.MediaRequest)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import javax.inject.Inject
import javax.inject.Singleton

@Singleton
internal class HeadersMediaSourceHelperImpl @Inject constructor(
internal class HeadersMediaSourceFactoryFactoryImpl @Inject constructor(
private val cacheManager: CacheManager,
private val headersStore: HeadersStore
): HeadersMediaSourceHelper {
): HeadersMediaSourceFactoryFactory {
private val previousRequests = mutableMapOf<String, DefaultHttpDataSource.Factory>()

override fun createDataSourceFactory(context: Context, request: AudioPlayable.MediaRequest): DataSource.Factory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.google.android.exoplayer2.offline.DownloadHelper
import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.source.hls.HlsMediaSource
import com.scribd.armadillo.download.DownloadTracker
import com.scribd.armadillo.extensions.toUri
import com.scribd.armadillo.models.AudioPlayable
import javax.inject.Inject

Expand All @@ -17,7 +16,7 @@ import javax.inject.Inject
*
*/
internal class HlsMediaSourceGenerator @Inject constructor(
private val mediaSourceHelper: HeadersMediaSourceHelper,
private val mediaSourceHelper: HeadersMediaSourceFactoryFactory,
private val downloadTracker: DownloadTracker) : MediaSourceGenerator {


Expand Down

0 comments on commit ef6538e

Please sign in to comment.