diff --git a/android/src/main/java/com/brentvatne/common/api/BufferConfig.kt b/android/src/main/java/com/brentvatne/common/api/BufferConfig.kt index 17f54c620b..c312f140d0 100644 --- a/android/src/main/java/com/brentvatne/common/api/BufferConfig.kt +++ b/android/src/main/java/com/brentvatne/common/api/BufferConfig.kt @@ -4,6 +4,7 @@ import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetDouble import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetFloat import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetInt import com.facebook.react.bridge.ReadableMap +import java.util.Objects /** * Class representing bufferConfig for host. @@ -42,6 +43,21 @@ class BufferConfig { ) } + override fun hashCode(): Int = + Objects.hash( + cacheSize, + minBufferMs, + maxBufferMs, + bufferForPlaybackMs, + bufferForPlaybackAfterRebufferMs, + backBufferDurationMs, + maxHeapAllocationPercent, + minBackBufferMemoryReservePercent, + minBufferMemoryReservePercent, + initialBitrate, + live + ) + class Live { var maxPlaybackSpeed: Float = BufferConfigPropUnsetDouble.toFloat() var minPlaybackSpeed: Float = BufferConfigPropUnsetDouble.toFloat() @@ -60,6 +76,8 @@ class BufferConfig { ) } + override fun hashCode(): Int = Objects.hash(maxPlaybackSpeed, minPlaybackSpeed, maxOffsetMs, minOffsetMs, targetOffsetMs) + companion object { private const val PROP_BUFFER_CONFIG_LIVE_MAX_PLAYBACK_SPEED = "maxPlaybackSpeed" private const val PROP_BUFFER_CONFIG_LIVE_MIN_PLAYBACK_SPEED = "minPlaybackSpeed" diff --git a/android/src/main/java/com/brentvatne/common/api/DRMProps.kt b/android/src/main/java/com/brentvatne/common/api/DRMProps.kt index 0c495e1177..c08609db7f 100644 --- a/android/src/main/java/com/brentvatne/common/api/DRMProps.kt +++ b/android/src/main/java/com/brentvatne/common/api/DRMProps.kt @@ -4,6 +4,7 @@ import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetArray import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetBool import com.brentvatne.common.toolbox.ReactBridgeUtils.safeGetString import com.facebook.react.bridge.ReadableMap +import java.util.Objects import java.util.UUID /** @@ -45,6 +46,8 @@ class DRMProps { drmLicenseHeader.contentDeepEquals(other.drmLicenseHeader) // drmLicenseHeader is never null } + override fun hashCode(): Int = Objects.hash(drmType, drmLicenseServer, multiDrm, drmLicenseHeader.contentHashCode()) + companion object { private const val PROP_DRM_TYPE = "type" private const val PROP_DRM_LICENSE_SERVER = "licenseServer" diff --git a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrack.kt b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrack.kt index 59408c78c4..699e7fefbb 100644 --- a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrack.kt +++ b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrack.kt @@ -3,6 +3,7 @@ package com.brentvatne.common.api import android.net.Uri import com.brentvatne.common.toolbox.ReactBridgeUtils import com.facebook.react.bridge.ReadableMap +import java.util.Objects /** * Class representing a sideLoaded text track from application @@ -13,6 +14,12 @@ class SideLoadedTextTrack { var title: String? = null var uri: Uri = Uri.EMPTY var type: String? = null + + override fun equals(other: Any?): Boolean = + other is SideLoadedTextTrack && language == other.language && title == other.title && uri == other.uri && type == other.type + + override fun hashCode(): Int = Objects.hash(language, title, uri, type) + companion object { val SIDELOAD_TEXT_TRACK_LANGUAGE = "language" val SIDELOAD_TEXT_TRACK_TITLE = "title" diff --git a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt index 1eb5f37901..f8d3c15a68 100644 --- a/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt +++ b/android/src/main/java/com/brentvatne/common/api/SideLoadedTextTrackList.kt @@ -17,6 +17,8 @@ class SideLoadedTextTrackList { return tracks == other.tracks } + override fun hashCode(): Int = tracks.hashCode() + companion object { fun parse(src: ReadableArray?): SideLoadedTextTrackList? { if (src == null) { diff --git a/android/src/main/java/com/brentvatne/common/api/Source.kt b/android/src/main/java/com/brentvatne/common/api/Source.kt index e9cf5abc84..85bfc7d4ff 100644 --- a/android/src/main/java/com/brentvatne/common/api/Source.kt +++ b/android/src/main/java/com/brentvatne/common/api/Source.kt @@ -89,7 +89,26 @@ class Source { */ var sideLoadedTextTracks: SideLoadedTextTrackList? = null - override fun hashCode(): Int = Objects.hash(uriString, uri, startPositionMs, cropStartMs, cropEndMs, extension, metadata, headers, adsProps) + override fun hashCode(): Int = + Objects.hash( + uri, + cropStartMs, + cropEndMs, + startPositionMs, + extension, + drmProps, + contentStartTime, + cmcdProps, + sideLoadedTextTracks, + adsProps, + minLoadRetryCount, + isLocalAssetFile, + isAsset, + bufferConfig, + textTracksAllowChunklessPreparation, + headers, + metadata + ) /** return true if this and src are equals */ override fun equals(other: Any?): Boolean { @@ -108,7 +127,10 @@ class Source { minLoadRetryCount == other.minLoadRetryCount && isLocalAssetFile == other.isLocalAssetFile && isAsset == other.isAsset && - bufferConfig == other.bufferConfig + bufferConfig == other.bufferConfig && + textTracksAllowChunklessPreparation == other.textTracksAllowChunklessPreparation && + headers == other.headers && + metadata == other.metadata ) } @@ -132,6 +154,16 @@ class Source { /** image uri to display */ var imageUri: Uri? = null + override fun equals(other: Any?): Boolean = + other is Metadata && + title == other.title && + subtitle == other.subtitle && + description == other.description && + artist == other.artist && + imageUri == other.imageUri + + override fun hashCode(): Int = Objects.hash(title, subtitle, description, artist, imageUri) + companion object { private const val PROP_SRC_METADATA_TITLE = "title" private const val PROP_SRC_METADATA_SUBTITLE = "subtitle"