Skip to content

Commit

Permalink
refcator
Browse files Browse the repository at this point in the history
  • Loading branch information
PruthiviRaj27 committed Jul 29, 2024
1 parent 81424f7 commit 352a8c7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions player/src/main/java/com/tpstream/player/TPStreamSDK.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ object TPStreamsSDK {
internal fun constructOfflineDRMLicenseUrl(
contentId: String?,
accessToken: String?,
rentalDurationSeconds: Int
licenseDurationSeconds: Int
): String {
return "${
constructDRMLicenseUrl(
contentId,
accessToken
)
}&drm_type=widevine&download=true&rental_duration_seconds=$rentalDurationSeconds"
}&drm_type=widevine&download=true&rental_duration_seconds=$licenseDurationSeconds&license_duration_seconds=$licenseDurationSeconds"
}

enum class Provider {
Expand Down
8 changes: 4 additions & 4 deletions player/src/main/java/com/tpstream/player/TpInitParams.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data class TpInitParams (
var videoId: String? = null,
var isDownloadEnabled: Boolean = false,
var startAt: Long = 0L,
var rentalDurationSeconds: Int = FIFTEEN_DAYS,
var licenseDurationSeconds: Int = FIFTEEN_DAYS,
var userId: String? = null
): Parcelable {

Expand All @@ -22,7 +22,7 @@ data class TpInitParams (
private var videoId: String? = null
private var isDownloadEnabled: Boolean = false
private var startAt: Long = 0L
var rentalDurationSeconds: Int = FIFTEEN_DAYS
var licenseDurationSeconds: Int = FIFTEEN_DAYS
var userId: String? = null

fun setAutoPlay(autoPlay: Boolean) = apply { this.autoPlay = autoPlay }
Expand All @@ -31,7 +31,7 @@ data class TpInitParams (
fun setVideoId(videoId: String) = apply { this.videoId = videoId }
fun enableDownloadSupport(isDownloadEnabled: Boolean) = apply { this.isDownloadEnabled = isDownloadEnabled }
fun setOfflineLicenseExpireTime(@androidx.annotation.IntRange(from = 300) expireTimeInSecond: Int) =
apply { this.rentalDurationSeconds = expireTimeInSecond }
apply { this.licenseDurationSeconds = expireTimeInSecond }
fun setUserId(userId: String) = apply { this.userId = userId }

fun build(): TpInitParams {
Expand All @@ -44,7 +44,7 @@ data class TpInitParams (
videoId = videoId!!,
isDownloadEnabled = isDownloadEnabled,
startAt = startAt,
rentalDurationSeconds = rentalDurationSeconds,
licenseDurationSeconds = licenseDurationSeconds,
userId = userId
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ internal object OfflineDRMLicenseHelper {
val drmLicenseURL = TPStreamsSDK.constructOfflineDRMLicenseUrl(
tpInitParams.videoId,
tpInitParams.accessToken,
tpInitParams.rentalDurationSeconds
tpInitParams.licenseDurationSeconds
)
val offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(
drmLicenseURL,
Expand All @@ -105,7 +105,7 @@ internal object OfflineDRMLicenseHelper {
format: Format,
callback: DRMLicenseFetchCallback
) {
val drmLicenseURL = TPStreamsSDK.constructOfflineDRMLicenseUrl(tpInitParams.videoId,tpInitParams.accessToken, tpInitParams.rentalDurationSeconds)
val drmLicenseURL = TPStreamsSDK.constructOfflineDRMLicenseUrl(tpInitParams.videoId,tpInitParams.accessToken, tpInitParams.licenseDurationSeconds)
val offlineLicenseHelper = OfflineLicenseHelper.newWidevineInstance(
drmLicenseURL,
VideoDownloadManager.invoke(context).getHttpDataSourceFactory(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class VideoDownloadRequestCreationHandler(
init {
val url = asset.video.url
trackSelectionParameters = DownloadHelper.getDefaultTrackSelectorParameters(context)
val drmLicenseURL = TPStreamsSDK.constructOfflineDRMLicenseUrl(params.videoId, params.accessToken, params.rentalDurationSeconds)
val drmLicenseURL = TPStreamsSDK.constructOfflineDRMLicenseUrl(params.videoId, params.accessToken, params.licenseDurationSeconds)
mediaItem = MediaItemBuilder()
.setUri(url)
.setDrmConfiguration(
Expand Down

0 comments on commit 352a8c7

Please sign in to comment.