Skip to content

Commit

Permalink
Fix unnecessarily updating transceivers
Browse files Browse the repository at this point in the history
  • Loading branch information
ipavlidakis committed Dec 18, 2024
1 parent 2217b21 commit b3c4345
Show file tree
Hide file tree
Showing 3 changed files with 190 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,19 +275,19 @@ final class LocalAudioMediaAdapter: LocalMediaAdapting {
for options: PublishOptions.AudioPublishOptions,
with track: RTCAudioTrack
) {
if let transceiver = transceiverStorage.get(for: options) {
transceiver.sender.track = track
} else {
let transceiver = peerConnection.addTransceiver(
trackType: .audio,
with: track,
init: .init(
direction: .sendOnly,
streamIds: streamIds,
audioOptions: options
)
)
transceiverStorage.set(transceiver, for: options)
guard !transceiverStorage.contains(key: options) else {
return
}

let transceiver = peerConnection.addTransceiver(
trackType: .audio,
with: track,
init: .init(
direction: .sendOnly,
streamIds: streamIds,
audioOptions: options
)
)
transceiverStorage.set(transceiver, for: options)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,21 @@ final class LocalScreenShareMediaAdapter: LocalMediaAdapting, @unchecked Sendabl
with track: RTCVideoTrack,
screenSharingType: ScreensharingType
) {
if let transceiver = transceiverStorage.get(for: options) {
transceiver.sender.track = track
} else {
let transceiver = peerConnection.addTransceiver(
guard !transceiverStorage.contains(key: options) else {
return
}

let transceiver = peerConnection.addTransceiver(
trackType: .screenshare,
with: track,
init: .init(
trackType: .screenshare,
with: track,
init: .init(
trackType: .screenshare,
direction: .sendOnly,
streamIds: ["\(sessionID)-screenshare-\(screenSharingType)"],
videoOptions: options
)
direction: .sendOnly,
streamIds: ["\(sessionID)-screenshare-\(screenSharingType)"],
videoOptions: options
)
transceiverStorage.set(transceiver, for: options)
}
)
transceiverStorage.set(transceiver, for: options)
}

/// Configures the active screen sharing session with the given type and track.
Expand Down
Loading

0 comments on commit b3c4345

Please sign in to comment.