Vlad Provalionok
Committed by GitHub

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 <davidliu@deviange.net>
  1 +---
  2 +"client-sdk-android": patch
  3 +---
  4 +
  5 +Fix IllegalStateException when switchCamera of localVideoTrack
@@ -256,7 +256,10 @@ constructor( @@ -256,7 +256,10 @@ constructor(
256 /** 256 /**
257 * Restart a track with new options. 257 * Restart a track with new options.
258 */ 258 */
259 - fun restartTrack(options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy()) { 259 + fun restartTrack(
  260 + options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy(),
  261 + videoProcessor: VideoProcessor? = null
  262 + ) {
260 if (isDisposed) { 263 if (isDisposed) {
261 LKLog.e { "Attempting to restart track that was already disposed, aborting." } 264 LKLog.e { "Attempting to restart track that was already disposed, aborting." }
262 return 265 return
@@ -290,6 +293,7 @@ constructor( @@ -290,6 +293,7 @@ constructor(
290 options, 293 options,
291 eglBase, 294 eglBase,
292 trackFactory, 295 trackFactory,
  296 + videoProcessor
293 ) 297 )
294 298
295 // migrate video sinks to the new track 299 // migrate video sinks to the new track
@@ -137,6 +137,7 @@ class VirtualBackgroundVideoProcessor(private val eglBase: EglBase, dispatcher: @@ -137,6 +137,7 @@ class VirtualBackgroundVideoProcessor(private val eglBase: EglBase, dispatcher:
137 137
138 override fun onCapturerStarted(started: Boolean) { 138 override fun onCapturerStarted(started: Boolean) {
139 if (started) { 139 if (started) {
  140 + surfaceTextureHelper.stopListening()
140 surfaceTextureHelper.startListening { frame -> 141 surfaceTextureHelper.startListening { frame ->
141 targetSink?.onFrame(frame) 142 targetSink?.onFrame(frame)
142 } 143 }