From 9959fa33aeb3d6ff0272418409062ea82361e4d2 Mon Sep 17 00:00:00 2001 From: Liubov Danilina Date: Wed, 17 Apr 2024 10:51:17 +1000 Subject: [PATCH 1/3] Interactive Player connect-subscribe flow's changed in 1.8.2 --- .../data/multistream/MultiStreamListener.kt | 7 +++++-- .../data/multistream/MultiStreamingRepository.kt | 8 ++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt index 329056f0..9c51af5b 100644 --- a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt +++ b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt @@ -6,6 +6,7 @@ import com.millicast.clients.stats.RtsReport import com.millicast.devices.track.AudioTrack import com.millicast.devices.track.TrackType import com.millicast.devices.track.VideoTrack +import com.millicast.subscribers.Option import com.millicast.subscribers.ProjectionData import com.millicast.subscribers.state.ActivityStream import com.millicast.subscribers.state.LayerData @@ -27,7 +28,8 @@ import kotlinx.coroutines.launch class MultiStreamListener( private val data: MutableStateFlow, - private var subscriber: Subscriber + private var subscriber: Subscriber, + private val options: Option ) { private lateinit var coroutineScope: CoroutineScope @@ -137,11 +139,12 @@ class MultiStreamListener( subscriber.release() } - private fun onConnected() { + private suspend fun onConnected() { Log.d( TAG, "onConnected, this: $this, thread: ${Thread.currentThread().id}" ) + subscriber.subscribe(options = options) } private fun onDisconnected() { diff --git a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamingRepository.kt b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamingRepository.kt index a2a28151..5bdd8972 100644 --- a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamingRepository.kt +++ b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamingRepository.kt @@ -174,9 +174,6 @@ class MultiStreamingRepository( } val subscriber = Core.createSubscriber() - listener = MultiStreamListener(_data, subscriber).apply { - start() - } subscriber.enableStats(true) subscriber.setCredentials( @@ -209,11 +206,14 @@ class MultiStreamingRepository( options = options.copy(rtcEventLogOutputPath = path + "/${timeStamp}_rtclogs.proto") } + listener = MultiStreamListener(_data, subscriber, options).apply { + start() + } + Log.d(TAG, "Connecting ...") try { subscriber.connect(ConnectionOptions(true)) - subscriber.subscribe(options = options) } catch (e: Throwable) { e.printStackTrace() } From 951e8847a90bb18b7fae34c4a37331e866f6307a Mon Sep 17 00:00:00 2001 From: Liubov Danilina Date: Wed, 17 Apr 2024 13:45:02 +1000 Subject: [PATCH 2/3] Crash fixed on connection restored --- .../dolby/rtscomponentkit/data/SingleStreamListener.kt | 6 +++++- .../data/multistream/MultiStreamListener.kt | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/SingleStreamListener.kt b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/SingleStreamListener.kt index 545c9fa7..59e2594b 100644 --- a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/SingleStreamListener.kt +++ b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/SingleStreamListener.kt @@ -198,7 +198,11 @@ class SingleStreamListener( private suspend fun onConnected() { Log.d(TAG, "onConnected") - subscriber.subscribe(Option(statsDelayMs = 1_000)) + try { + subscriber.subscribe(Option(statsDelayMs = 1_000)) + } catch (e: MillicastException) { + e.printStackTrace() + } } private fun onActive(p0: String?, p1: Array, p2: String?) { diff --git a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt index 9c51af5b..2b78247f 100644 --- a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt +++ b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt @@ -11,6 +11,7 @@ import com.millicast.subscribers.ProjectionData import com.millicast.subscribers.state.ActivityStream import com.millicast.subscribers.state.LayerData import com.millicast.subscribers.state.SubscriberConnectionState +import com.millicast.utils.MillicastException import io.dolby.rtscomponentkit.domain.MultiStreamStatisticsData import io.dolby.rtscomponentkit.domain.MultiStreamingData import kotlinx.coroutines.CoroutineScope @@ -40,7 +41,8 @@ class MultiStreamListener( Log.d(TAG, "Listener start") coroutineScope = CoroutineScope(Dispatchers.IO) - subscriber.state.map { it.connectionState }.collectInLocalScope { state -> + subscriber.state.map { it.connectionState }.distinctUntilChanged().collectInLocalScope { state -> + Log.d(TAG, "New state: $state") when (state) { SubscriberConnectionState.Connected -> { onConnected() @@ -144,7 +146,11 @@ class MultiStreamListener( TAG, "onConnected, this: $this, thread: ${Thread.currentThread().id}" ) - subscriber.subscribe(options = options) + try { + subscriber.subscribe(options = options) + } catch (e: MillicastException) { + e.printStackTrace() + } } private fun onDisconnected() { From f472a28b63512bf3353103217b7e59ddedd4106f Mon Sep 17 00:00:00 2001 From: Liubov Danilina Date: Thu, 18 Apr 2024 10:51:38 +1000 Subject: [PATCH 3/3] Interactive Player: ignoring Signaling error to fix the issue --- .../rtscomponentkit/data/multistream/MultiStreamListener.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt index 2b78247f..5a5bed90 100644 --- a/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt +++ b/rtscomponentkit/src/main/java/io/dolby/rtscomponentkit/data/multistream/MultiStreamListener.kt @@ -169,9 +169,6 @@ class MultiStreamListener( private fun onSignalingError(p0: String?) { Log.d(TAG, "onSignalingError: $p0") - data.update { - it.populateError(error = p0 ?: "Signaling error") - } } private fun onStatsReport(p0: RtsReport?) {