Skip to content

Commit

Permalink
Releases/v3.5.1 (#374)
Browse files Browse the repository at this point in the history
* fix: rename all methods

* Really rename
  • Loading branch information
daytime-em authored Jun 27, 2024
1 parent e4cb4e9 commit bd8fc62
Show file tree
Hide file tree
Showing 27 changed files with 94 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ private class AnalyticsListenerBinding216ToNow : MuxPlayerAdapter.PlayerBinding<
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener = exoAnalyticsListener(player, collector).also {
player.addAnalyticsListener(it)
player.watchContentPosition(collector)
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener?.let { player.removeAnalyticsListener(it) }
collector.positionWatcher?.stop("unbound")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye

private var listener: AnalyticsListener? by weak(null)

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
if (isHlsExtensionAvailable()) {
listener = SessionDataListener(player, collector).also { player.addAnalyticsListener(it) }
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener?.let { player.removeAnalyticsListener(it) }
}

Expand All @@ -30,7 +30,7 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
* This class should only be instantiated if ExoPlayer's HLS extension is available at runtime
* @see [.isHlsExtensionAvailable]
*/
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player by weak(player)
Expand Down Expand Up @@ -94,5 +94,5 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
* @see [.isHlsExtensionAvailable]
*/
@Suppress("unused") // using the receiver to avoid polluting customers' namespace
fun MuxStateCollector.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
fun MuxStateCollectorBase.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
SessionDataPlayerBinding()
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ private class AnalyticsListenerBinding216ToNow : MuxPlayerAdapter.PlayerBinding<
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener = exoAnalyticsListener(player, collector).also {
player.addAnalyticsListener(it)
player.watchContentPosition(collector)
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener?.let { player.removeAnalyticsListener(it) }
collector.positionWatcher?.stop("unbound")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye

private var listener: AnalyticsListener? by weak(null)

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
if (isHlsExtensionAvailable()) {
listener = SessionDataListener(player, collector).also { player.addAnalyticsListener(it) }
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
listener?.let { player.removeAnalyticsListener(it) }
}

Expand All @@ -30,7 +30,7 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
* This class should only be instantiated if ExoPlayer's HLS extension is available at runtime
* @see [.isHlsExtensionAvailable]
*/
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player by weak(player)
Expand Down Expand Up @@ -94,5 +94,5 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
* @see [.isHlsExtensionAvailable]
*/
@Suppress("unused") // using the receiver to avoid polluting customers' namespace
fun MuxStateCollector.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
fun MuxStateCollectorBase.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
SessionDataPlayerBinding()
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import com.google.android.exoplayer2.source.LoadEventInfo
import com.google.android.exoplayer2.source.MediaLoadData
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
import com.mux.stats.sdk.muxstats.MuxStateCollector
import com.mux.stats.sdk.muxstats.MuxStateCollectorBase
import java.io.IOException

/**
* There's only one required AnalyticsListener implementation (as of Exo 2.17) so it's here in the
* common code.
*/
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player: ExoPlayer? by weak(player)
Expand Down Expand Up @@ -203,6 +203,6 @@ private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCol
}

@JvmSynthetic
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollector)
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollectorBase)
: AnalyticsListener = ExoAnalyticsListener(player, collector)

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo
import com.google.android.exoplayer2.source.MediaLoadData
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
import com.mux.stats.sdk.muxstats.MuxStateCollector
import com.mux.stats.sdk.muxstats.MuxStateCollectorBase
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.BandwidthMetricDispatcher
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.MuxMediaHasVideoTrack
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.handleExoPlaybackState
Expand All @@ -22,7 +22,7 @@ import java.io.IOException
* There's only one required AnalyticsListener implementation (as of Exo 2.17) so it's here in the
* common code.
*/
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player: ExoPlayer? by weak(player)
Expand Down Expand Up @@ -205,6 +205,6 @@ private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCol
}

@JvmSynthetic
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollector)
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollectorBase)
: AnalyticsListener = ExoAnalyticsListener(player, collector)

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo
import com.google.android.exoplayer2.source.MediaLoadData
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.video.VideoSize
import com.mux.stats.sdk.muxstats.MuxStateCollector
import com.mux.stats.sdk.muxstats.MuxStateCollectorBase
import com.mux.stats.sdk.muxstats.exoplayeradapter.MuxPlayerState
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.BandwidthMetricDispatcher
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.MuxMediaHasVideoTrack
Expand All @@ -20,7 +20,7 @@ import java.io.IOException
* There's only one required AnalyticsListener implementation (as of Exo 2.17) so it's here in the
* common code.
*/
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player: ExoPlayer? by weak(player)
Expand Down Expand Up @@ -196,6 +196,6 @@ private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCol
}

@JvmSynthetic
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollector)
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollectorBase)
: AnalyticsListener = ExoAnalyticsListener(player, collector)

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.google.android.exoplayer2.source.LoadEventInfo
import com.google.android.exoplayer2.source.MediaLoadData
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
import com.mux.stats.sdk.muxstats.MuxStateCollector
import com.mux.stats.sdk.muxstats.MuxStateCollectorBase
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.BandwidthMetricDispatcher
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.MuxMediaHasVideoTrack
import com.mux.stats.sdk.muxstats.exoplayeradapter.internal.handleExoPlaybackState
Expand All @@ -22,7 +22,7 @@ import java.io.IOException
* There's only one required AnalyticsListener implementation (as of Exo 2.17) so it's here in the
* common code.
*/
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player: ExoPlayer? by weak(player)
Expand Down Expand Up @@ -201,6 +201,6 @@ private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCol
}

@JvmSynthetic
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollector)
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollectorBase)
: AnalyticsListener = ExoAnalyticsListener(player, collector)

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import com.google.android.exoplayer2.source.MediaSourceEventListener.MediaLoadDa
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
import com.mux.stats.sdk.core.util.MuxLogger
import com.mux.stats.sdk.muxstats.MuxStateCollector
import com.mux.stats.sdk.muxstats.MuxStateCollectorBase
import java.io.IOException

/**
* There's only one required AnalyticsListener implementation (as of Exo 2.17) so it's here in the
* common code.
*/
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player: ExoPlayer? by weak(player)
Expand Down Expand Up @@ -154,6 +154,6 @@ private class ExoAnalyticsListener(player: ExoPlayer, val collector: MuxStateCol
}

@JvmSynthetic
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollector)
internal fun <P : ExoPlayer> exoAnalyticsListener(player: P, collector: MuxStateCollectorBase)
: AnalyticsListener = ExoAnalyticsListener(player, collector)

Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ private class AnalyticsListenerBindingUpTo16 : MuxPlayerAdapter.PlayerBinding<Si
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: SimpleExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: SimpleExoPlayer, collector: MuxStateCollectorBase) {
listener = exoAnalyticsListener(player, collector).also {
player.addAnalyticsListener(it)
player.watchContentPosition(collector)
}
}

override fun unbindPlayer(player: SimpleExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: SimpleExoPlayer, collector: MuxStateCollectorBase) {
listener?.let { player.removeAnalyticsListener(it) }
collector.positionWatcher?.stop("unbound")
listener = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye

private var listener: AnalyticsListener? by weak(null)

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
if (isHlsExtensionAvailable() && player is SimpleExoPlayer) {
listener = SessionDataListener(player, collector).also { player.addAnalyticsListener(it) }
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
if (player is SimpleExoPlayer) {
listener?.let { player.removeAnalyticsListener(it) }
}
Expand All @@ -37,7 +37,7 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
* This class should only be instantiated if ExoPlayer's HLS extension is available at runtime
* @see [.isHlsExtensionAvailable]
*/
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class SessionDataListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
AnalyticsListener {

private val player by weak(player)
Expand Down Expand Up @@ -102,5 +102,5 @@ private class SessionDataPlayerBinding : MuxPlayerAdapter.PlayerBinding<ExoPlaye
*/
@Suppress("unused") // using the receiver to avoid polluting customers' namespace
@JvmSynthetic
fun MuxStateCollector.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
fun MuxStateCollectorBase.createExoSessionDataBinding(): MuxPlayerAdapter.PlayerBinding<ExoPlayer> =
SessionDataPlayerBinding()
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package com.mux.stats.sdk.muxstats

import com.google.android.exoplayer2.source.hls.HlsManifest
import com.mux.stats.sdk.core.events.IEventDispatcher
import com.mux.stats.sdk.muxstats.exoplayeradapter.MuxStateCollectorBase

open class MuxStateCollector(
open class MuxStateCollectorExoImpl(
private val _muxStats: () -> MuxStats,
private val _dispatcher: IEventDispatcher,
private val _trackFirstFrameRendered: Boolean = true,
): MuxStateCollectorBase(_muxStats, _dispatcher, _trackFirstFrameRendered) {
): MuxStateCollectorBase(_muxStats, _dispatcher, _trackFirstFrameRendered) {
override fun isLivePlayback(): Boolean {
return currentTimelineWindow.isLive
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ private class ExoErrorMetricsByListener215ToNow : MuxPlayerAdapter.PlayerBinding
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
playerListener = newListener(collector).also { player.addListener(it) }
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
collector.positionWatcher?.stop("player unbound")
collector.positionWatcher = null
playerListener?.let { player.removeListener(it) }
}

private fun newListener(collector: MuxStateCollector) = ErrorPlayerListenerUpTo214(collector)
private fun newListener(collector: MuxStateCollectorBase) = ErrorPlayerListenerUpTo214(collector)
} // class ErrorPlayerBuListenerUpTo214

private class ErrorPlayerListenerUpTo214(val collector: MuxStateCollector) : Player.Listener {
private class ErrorPlayerListenerUpTo214(val collector: MuxStateCollectorBase) : Player.Listener {
override fun onPlayerError(error: PlaybackException) {
if (error is ExoPlaybackException) {
collector.handleExoPlaybackException(error.errorCode, error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ private class ExoErrorMetricsByListenerJust214 : MuxPlayerAdapter.PlayerBinding<
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
playerListener = newListener(collector).also { player.addListener(it) }
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
collector.positionWatcher?.stop("player unbound")
collector.positionWatcher = null
playerListener?.let { player.removeListener(it) }
}

private fun newListener(collector: MuxStateCollector) = ErrorPlayerListenerUpTo214(collector)
private fun newListener(collector: MuxStateCollectorBase) = ErrorPlayerListenerUpTo214(collector)
} // class ErrorPlayerBuListenerUpTo214

private class ErrorPlayerListenerUpTo214(val collector: MuxStateCollector) : Player.Listener {
private class ErrorPlayerListenerUpTo214(val collector: MuxStateCollectorBase) : Player.Listener {
override fun onPlayerError(error: ExoPlaybackException) {
collector.handleExoPlaybackException(error.type, error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ private class BasicExoMetrics14toNow : MuxPlayerAdapter.PlayerBinding<ExoPlayer>
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
playerListener = newListener(player, collector).also {
player.addListener(it)
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
collector.positionWatcher?.stop("player unbound")
collector.positionWatcher = null
playerListener?.let { player.removeListener(it) }
}

private fun newListener(player: ExoPlayer, collector: MuxStateCollector) =
private fun newListener(player: ExoPlayer, collector: MuxStateCollectorBase) =
PlayerListener(player, collector)
} // class BaseExoMetrics

private class PlayerListener(player: ExoPlayer, val collector: MuxStateCollector) :
private class PlayerListener(player: ExoPlayer, val collector: MuxStateCollectorBase) :
Player.Listener {
val player by weak(player) // player should be weakly reachable in case user doesn't clean up

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ private class PlayerStateMetrics216ToNow : MuxPlayerAdapter.PlayerBinding<ExoPla
MuxLogger.d(logTag(), "created");
}

override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun bindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
playerListener = analyticsListenerMetrics().also {
it.bindPlayer(player, collector)
}
}

override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollector) {
override fun unbindPlayer(player: ExoPlayer, collector: MuxStateCollectorBase) {
playerListener?.unbindPlayer(player, collector)
}
}
Expand Down
Loading

0 comments on commit bd8fc62

Please sign in to comment.