diff --git a/core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/CombineEndpoint.kt b/core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/CombineEndpoint.kt index 4a01eb79..d6dbae59 100644 --- a/core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/CombineEndpoint.kt +++ b/core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/CombineEndpoint.kt @@ -19,7 +19,7 @@ import io.github.thibaultbee.streampack.core.configuration.mediadescriptor.Media import io.github.thibaultbee.streampack.core.elements.data.Frame import io.github.thibaultbee.streampack.core.elements.encoders.CodecConfig import io.github.thibaultbee.streampack.core.elements.utils.combineStates -import io.github.thibaultbee.streampack.core.elements.utils.extensions.union +import io.github.thibaultbee.streampack.core.elements.utils.extensions.intersect import io.github.thibaultbee.streampack.core.logger.Logger import kotlinx.coroutines.flow.StateFlow @@ -70,14 +70,14 @@ open class CombineEndpoint(protected val endpointInternals: List acc union iEndpointInfo } + .reduce { acc, iEndpointInfo -> acc intersect iEndpointInfo } /** * The union of all endpoints' [IEndpoint.IEndpointInfo]. */ override fun getInfo(type: MediaDescriptor.Type): IEndpoint.IEndpointInfo { return endpointInternals.map { it.getInfo(type) } - .reduce { acc, iEndpointInfo -> acc union iEndpointInfo } + .reduce { acc, iEndpointInfo -> acc intersect iEndpointInfo } } /** diff --git a/core/src/main/java/io/github/thibaultbee/streampack/core/elements/utils/extensions/IEndpointInfoExtensions.kt b/core/src/main/java/io/github/thibaultbee/streampack/core/elements/utils/extensions/IEndpointInfoExtensions.kt index 092c6e6c..260d9d0e 100644 --- a/core/src/main/java/io/github/thibaultbee/streampack/core/elements/utils/extensions/IEndpointInfoExtensions.kt +++ b/core/src/main/java/io/github/thibaultbee/streampack/core/elements/utils/extensions/IEndpointInfoExtensions.kt @@ -20,42 +20,42 @@ import io.github.thibaultbee.streampack.core.elements.endpoints.IEndpoint /** * Returns the union of two [IEndpoint.IEndpointInfo] */ -internal infix fun IEndpoint.IEndpointInfo.union(other: IEndpoint.IEndpointInfo): IEndpoint.IEndpointInfo { +internal infix fun IEndpoint.IEndpointInfo.intersect(other: IEndpoint.IEndpointInfo): IEndpoint.IEndpointInfo { return object : IEndpoint.IEndpointInfo { override val audio = object : IEndpoint.IEndpointInfo.IAudioEndpointInfo { override val supportedEncoders: List - get() = this@union.audio.supportedEncoders.union(other.audio.supportedEncoders) + get() = this@intersect.audio.supportedEncoders.intersect(other.audio.supportedEncoders.toSet()) .toList() override val supportedSampleRates: List? get() { - val supportedSampleRates = this@union.audio.supportedSampleRates + val supportedSampleRates = this@intersect.audio.supportedSampleRates val otherSupportedSampleRates = other.audio.supportedSampleRates return if (supportedSampleRates == null) { otherSupportedSampleRates } else if (otherSupportedSampleRates == null) { supportedSampleRates } else { - supportedSampleRates.union(otherSupportedSampleRates).toList() + supportedSampleRates.intersect(otherSupportedSampleRates).toList() } } override val supportedByteFormats: List? get() { - val supportedByteFormats = this@union.audio.supportedByteFormats + val supportedByteFormats = this@intersect.audio.supportedByteFormats val otherSupportedByteFormats = other.audio.supportedByteFormats return if (supportedByteFormats == null) { otherSupportedByteFormats } else if (otherSupportedByteFormats == null) { supportedByteFormats } else { - supportedByteFormats.union(otherSupportedByteFormats).toList() + supportedByteFormats.intersect(otherSupportedByteFormats).toList() } } } override val video = object : IEndpoint.IEndpointInfo.IVideoEndpointInfo { override val supportedEncoders: List = - this@union.video.supportedEncoders.union(other.video.supportedEncoders) + this@intersect.video.supportedEncoders.intersect(other.video.supportedEncoders.toSet()) .toList() } }