diff --git a/android/src/main/java/com/brentvatne/exoplayer/CMCDConfig.kt b/android/src/main/java/com/brentvatne/exoplayer/CMCDConfig.kt index 60d9d598..0ae117c9 100644 --- a/android/src/main/java/com/brentvatne/exoplayer/CMCDConfig.kt +++ b/android/src/main/java/com/brentvatne/exoplayer/CMCDConfig.kt @@ -3,6 +3,7 @@ package com.brentvatne.exoplayer import androidx.media3.common.MediaItem import androidx.media3.exoplayer.upstream.CmcdConfiguration import com.brentvatne.common.api.CMCDProps +import com.brentvatne.common.toolbox.DebugLog import com.google.common.collect.ImmutableListMultimap class CMCDConfig(private val props: CMCDProps) { @@ -15,9 +16,21 @@ class CMCDConfig(private val props: CMCDProps) { object : CmcdConfiguration.RequestConfig { override fun getCustomData(): ImmutableListMultimap = buildCustomData() }, - props.mode + intToCmcdMode(props.mode) ) + private fun intToCmcdMode(mode: Int): Int = + when (mode) { + 0 -> CmcdConfiguration.MODE_REQUEST_HEADER + + 1 -> CmcdConfiguration.MODE_QUERY_PARAMETER + + else -> { + DebugLog.e("CMCDConfig", "Unsupported mode: $mode, fallback on MODE_REQUEST_HEADER") + CmcdConfiguration.MODE_REQUEST_HEADER + } + } + private fun buildCustomData(): ImmutableListMultimap = ImmutableListMultimap.builder().apply { addFormattedData(this, CmcdConfiguration.KEY_CMCD_OBJECT, props.cmcdObject)