Skip to content

Commit f10fe64

Browse files
binkosdavidliu
andauthored
Fix IllegalStateException when switchCamera of localVideoTrack (#725)
* Added calling surfaceTextureHelper.stopListening() inside onCapturerStarted to prevent crush when switchCamera in LocalVideoTrack. Added videoProcessor param into Local .restartTrack to keep videoProcessor when restart the track. * changeset --------- Co-authored-by: davidliu <[email protected]>
1 parent c6c0728 commit f10fe64

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

.changeset/cool-numbers-perform.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"client-sdk-android": patch
3+
---
4+
5+
Fix IllegalStateException when switchCamera of localVideoTrack

livekit-android-sdk/src/main/java/io/livekit/android/room/track/LocalVideoTrack.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ constructor(
256256
/**
257257
* Restart a track with new options.
258258
*/
259-
fun restartTrack(options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy()) {
259+
fun restartTrack(
260+
options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy(),
261+
videoProcessor: VideoProcessor? = null
262+
) {
260263
if (isDisposed) {
261264
LKLog.e { "Attempting to restart track that was already disposed, aborting." }
262265
return
@@ -290,6 +293,7 @@ constructor(
290293
options,
291294
eglBase,
292295
trackFactory,
296+
videoProcessor
293297
)
294298

295299
// migrate video sinks to the new track

livekit-android-track-processors/src/main/java/io/livekit/android/track/processing/video/VirtualBackgroundVideoProcessor.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ class VirtualBackgroundVideoProcessor(private val eglBase: EglBase, dispatcher:
137137

138138
override fun onCapturerStarted(started: Boolean) {
139139
if (started) {
140+
surfaceTextureHelper.stopListening()
140141
surfaceTextureHelper.startListening { frame ->
141142
targetSink?.onFrame(frame)
142143
}

0 commit comments

Comments
 (0)