mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-23 16:50:09 +01:00
Stop screen sharing when disabled from system UI.
This commit is contained in:
@@ -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) -> {
|
||||
|
||||
Reference in New Issue
Block a user