From fe3bc8b0237007af270adb4d1709ced3bc60ec6d Mon Sep 17 00:00:00 2001 From: Brazol Date: Thu, 1 Feb 2024 11:37:49 +0100 Subject: [PATCH] fixed rtc tracks when switching between screen share types on ios --- .../stream_video/lib/src/webrtc/rtc_manager.dart | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/stream_video/lib/src/webrtc/rtc_manager.dart b/packages/stream_video/lib/src/webrtc/rtc_manager.dart index 44c1cc9c2..653d6b79c 100644 --- a/packages/stream_video/lib/src/webrtc/rtc_manager.dart +++ b/packages/stream_video/lib/src/webrtc/rtc_manager.dart @@ -714,6 +714,21 @@ extension RtcManagerTrackHelper on RtcManager { // Track found, mute/unmute it. if (track != null) { + if (enabled && + track.trackType == SfuTrackType.screenShare && + constraints is ScreenShareConstraints && + (track.mediaConstraints as ScreenShareConstraints) + .useiOSBroadcastExtension != + constraints.useiOSBroadcastExtension) { + // If existing screen share track has different broadcast extension constraints, unpublish it and create a new one. + await unpublishTrack(trackId: track.trackId); + + return _createAndPublishTrack( + trackType: trackType, + constraints: constraints, + ); + } + final toggledTrack = await _toggleTrackMuteState( track: track, muted: !enabled,