You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/StreamVideo/WebRTC/v2/PeerConnection/MediaAdapters/LocalMediaAdapters/LocalVideoMediaAdapter.swift
+49-31Lines changed: 49 additions & 31 deletions
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ final class LocalVideoMediaAdapter: LocalMediaAdapting, @unchecked Sendable {
125
125
/// Removes all transceivers from storage and logs details about the
126
126
/// deallocation process.
127
127
deinit{
128
-
Task{@MainActor[transceiverStorage]in
128
+
Task{[transceiverStorage]in
129
129
transceiverStorage.removeAll()
130
130
}
131
131
@@ -207,35 +207,52 @@ final class LocalVideoMediaAdapter: LocalMediaAdapting, @unchecked Sendable {
207
207
208
208
/// Starts publishing the local video track.
209
209
func publish(){
210
-
processingQueue.async{@MainActor[weak self]in
210
+
processingQueue.async{[weak self]in
211
211
guard
212
212
let self,
213
213
!primaryTrack.isEnabled
214
214
else{
215
215
return
216
216
}
217
217
primaryTrack.isEnabled =true
218
-
219
-
do{
220
-
tryawaitstartVideoCapturingSession()
221
-
}catch{
222
-
log.error(error)
218
+
219
+
// Don't wait for camera to start - do it in parallel
220
+
Task{[weak self]in
221
+
do{
222
+
tryawaitself?.startVideoCapturingSession()
223
+
}catch{
224
+
log.error("Failed to start video capturing session: \(error)")
225
+
}
223
226
}
224
-
225
-
publishOptions
226
-
.forEach{
227
-
self.addTransceiverIfRequired(
228
-
for: $0,
229
-
with:self
230
-
.primaryTrack
231
-
.clone(from:self.peerConnectionFactory)
232
-
)
227
+
228
+
// Clone tracks and setup transceivers (don't block UI thread)
229
+
Task{[weak self]in
230
+
guardlet self else{return}
231
+
232
+
// Clone tracks in parallel
233
+
awaitwithTaskGroup(of:(PublishOptions.VideoPublishOptions, RTCVideoTrack)?.self){ group in
0 commit comments