From f7b9942f11f130eec0d0764923496fdef81f411c Mon Sep 17 00:00:00 2001 From: Rashad Sookram Date: Fri, 29 Apr 2022 11:00:09 -0400 Subject: [PATCH] Stop showing video in group calls when it isn't being forwarded. --- .../securesms/components/webrtc/CallParticipantView.java | 2 +- .../java/org/thoughtcrime/securesms/events/CallParticipant.kt | 3 +++ .../service/webrtc/BeginCallActionProcessorDelegate.java | 2 ++ .../securesms/service/webrtc/GroupActionProcessor.java | 1 + .../securesms/service/webrtc/GroupPreJoinActionProcessor.java | 1 + .../service/webrtc/IncomingGroupCallActionProcessor.java | 1 + .../components/webrtc/CallParticipantListUpdateTest.java | 2 +- .../service/webrtc/collections/ParticipantCollectionTest.java | 1 + 8 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java index 6b6648f9eb..a7a74fdc68 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantView.java @@ -147,7 +147,7 @@ public class CallParticipantView extends ConstraintLayout { } else { infoOverlay.setVisibility(View.GONE); - boolean hasContentToRender = participant.isVideoEnabled() || participant.isScreenSharing(); + boolean hasContentToRender = (participant.isVideoEnabled() || participant.isScreenSharing()) && participant.isForwardingVideo(); rendererFrame.setVisibility(hasContentToRender ? View.VISIBLE : View.GONE); renderer.setVisibility(hasContentToRender ? View.VISIBLE : View.GONE); diff --git a/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt b/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt index 85df855048..5583b3c978 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/events/CallParticipant.kt @@ -13,6 +13,7 @@ data class CallParticipant constructor( val identityKey: IdentityKey? = null, val videoSink: BroadcastVideoSink = BroadcastVideoSink(), val cameraState: CameraState = CameraState.UNKNOWN, + val isForwardingVideo: Boolean = true, val isVideoEnabled: Boolean = false, val isMicrophoneEnabled: Boolean = false, val lastSpoke: Long = 0, @@ -126,6 +127,7 @@ data class CallParticipant constructor( recipient: Recipient, identityKey: IdentityKey?, renderer: BroadcastVideoSink, + isForwardingVideo: Boolean, audioEnabled: Boolean, videoEnabled: Boolean, lastSpoke: Long, @@ -139,6 +141,7 @@ data class CallParticipant constructor( recipient = recipient, identityKey = identityKey, videoSink = renderer, + isForwardingVideo = isForwardingVideo, isVideoEnabled = videoEnabled, isMicrophoneEnabled = audioEnabled, lastSpoke = lastSpoke, diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/BeginCallActionProcessorDelegate.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/BeginCallActionProcessorDelegate.java index b2bdd36347..00a1bc6b8b 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/BeginCallActionProcessorDelegate.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/BeginCallActionProcessorDelegate.java @@ -48,6 +48,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor { true, currentState.getLocalDeviceState().getOrientation().getDegrees()), true, + true, false, 0, true, @@ -102,6 +103,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor { true, currentState.getLocalDeviceState().getOrientation().getDegrees()), true, + true, false, 0, true, diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupActionProcessor.java index 1b5d6c694f..f4848f915d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupActionProcessor.java @@ -105,6 +105,7 @@ public class GroupActionProcessor extends DeviceAwareActionProcessor { recipient, null, videoSink, + device.getForwardingVideo() == null || device.getForwardingVideo(), Boolean.FALSE.equals(device.getAudioMuted()), Boolean.FALSE.equals(device.getVideoMuted()), device.getSpeakerTime(), diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupPreJoinActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupPreJoinActionProcessor.java index 37b2ddba86..9f8ec47218 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupPreJoinActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/GroupPreJoinActionProcessor.java @@ -130,6 +130,7 @@ public class GroupPreJoinActionProcessor extends GroupActionProcessor { new BroadcastVideoSink(), true, true, + true, 0, false, 0, diff --git a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java index 65b3014ac4..1b67761baa 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java +++ b/app/src/main/java/org/thoughtcrime/securesms/service/webrtc/IncomingGroupCallActionProcessor.java @@ -154,6 +154,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro true, currentState.getLocalDeviceState().getOrientation().getDegrees()), true, + true, false, 0, true, diff --git a/app/src/test/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantListUpdateTest.java b/app/src/test/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantListUpdateTest.java index dfa3859985..954accb427 100644 --- a/app/src/test/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantListUpdateTest.java +++ b/app/src/test/java/org/thoughtcrime/securesms/components/webrtc/CallParticipantListUpdateTest.java @@ -178,7 +178,7 @@ public class CallParticipantListUpdateTest { private static CallParticipant createParticipant(long recipientId, long deMuxId, @NonNull CallParticipant.DeviceOrdinal deviceOrdinal) { Recipient recipient = new Recipient(RecipientId.from(recipientId), mock(RecipientDetails.class), true); - return CallParticipant.createRemote(new CallParticipantId(deMuxId, recipient.getId()), recipient, null, new BroadcastVideoSink(), false, false, -1, false, 0, false, deviceOrdinal); + return CallParticipant.createRemote(new CallParticipantId(deMuxId, recipient.getId()), recipient, null, new BroadcastVideoSink(), false, false, false, -1, false, 0, false, deviceOrdinal); } } \ No newline at end of file diff --git a/app/src/test/java/org/thoughtcrime/securesms/service/webrtc/collections/ParticipantCollectionTest.java b/app/src/test/java/org/thoughtcrime/securesms/service/webrtc/collections/ParticipantCollectionTest.java index b9c18de5da..cfc80380c7 100644 --- a/app/src/test/java/org/thoughtcrime/securesms/service/webrtc/collections/ParticipantCollectionTest.java +++ b/app/src/test/java/org/thoughtcrime/securesms/service/webrtc/collections/ParticipantCollectionTest.java @@ -242,6 +242,7 @@ public class ParticipantCollectionTest { new BroadcastVideoSink(), false, false, + false, lastSpoke, false, added,