Stop screen sharing when disabled from system UI.

This commit is contained in:
Cody Henthorne
2026-05-20 09:56:18 -04:00
parent e750b81a31
commit 00042b9579
4 changed files with 16 additions and 3 deletions
@@ -11,4 +11,5 @@ public interface CameraEventListener {
void onFullyInitialized();
void onCameraSwitchCompleted(@NonNull CameraState newCameraState);
void onCameraStopped();
void onScreenShareStopped();
}
@@ -19,7 +19,7 @@ import kotlin.concurrent.Volatile
class OutgoingVideoSourceRouter(
private val context: Context,
private val eglBase: EglBaseWrapper,
cameraEventListener: CameraEventListener,
private val cameraEventListener: CameraEventListener,
desiredCameraDirection: CameraState.Direction
) : CameraControl {
@@ -92,7 +92,12 @@ class OutgoingVideoSourceRouter(
}
if (screenShareCapturer == null) {
screenShareCapturer = ScreenShareCapturer(context, eglBase, ScreenSideObserver())
screenShareCapturer = ScreenShareCapturer(
context = context,
eglBase = eglBase,
sink = ScreenSideObserver(),
onMediaProjectionStopped = cameraEventListener::onScreenShareStopped
)
}
screenShareCapturer!!.start(mediaProjectionData)
@@ -24,7 +24,8 @@ import kotlin.math.max
class ScreenShareCapturer(
private val context: Context,
private val eglBase: EglBaseWrapper,
private val sink: CapturerObserver
private val sink: CapturerObserver,
private val onMediaProjectionStopped: () -> Unit
) {
companion object {
@@ -70,6 +71,7 @@ class ScreenShareCapturer(
object : MediaProjection.Callback() {
override fun onStop() {
Log.i(TAG, "MediaProjection stopped")
onMediaProjectionStopped()
}
override fun onCapturedContentResize(width: Int, height: Int) {
@@ -1098,6 +1098,11 @@ public final class SignalCallManager implements CallManager.Observer, GroupCall.
setEnableVideo(false);
}
@Override
public void onScreenShareStopped() {
stopScreenShare();
}
@Override
public void onForeground() {
process((s, p) -> {