davidliu

Stop and start camera when disabling/enabling camera track.

@@ -171,6 +171,10 @@ internal constructor( @@ -171,6 +171,10 @@ internal constructor(
171 if (enabled) { 171 if (enabled) {
172 if (pub != null) { 172 if (pub != null) {
173 pub.muted = false 173 pub.muted = false
  174 +
  175 + if (source == Track.Source.CAMERA && pub.track is LocalVideoTrack) {
  176 + (pub.track as? LocalVideoTrack)?.startCapture()
  177 + }
174 } else { 178 } else {
175 when (source) { 179 when (source) {
176 Track.Source.CAMERA -> { 180 Track.Source.CAMERA -> {
@@ -199,6 +203,11 @@ internal constructor( @@ -199,6 +203,11 @@ internal constructor(
199 unpublishTrack(track) 203 unpublishTrack(track)
200 } else { 204 } else {
201 pub.muted = true 205 pub.muted = true
  206 +
  207 + // Release camera session so other apps can use.
  208 + if (pub.source == Track.Source.CAMERA && track is LocalVideoTrack) {
  209 + track.stopCapture()
  210 + }
202 } 211 }
203 } 212 }
204 } 213 }