Change calling rotation behavior for 1:1 calls.

fork-5.53.8
Cody Henthorne 2022-08-09 15:09:19 -04:00
rodzic acf811c79a
commit e83a4692c5
6 zmienionych plików z 22 dodań i 47 usunięć

Wyświetl plik

@ -1,10 +1,12 @@
package org.thoughtcrime.securesms.components.sensors;
import android.content.ContentResolver;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.provider.Settings;
import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
@ -22,8 +24,9 @@ public final class DeviceOrientationMonitor implements DefaultLifecycleObserver
private static final float LANDSCAPE_PITCH_MINIMUM = -0.5f;
private static final float LANDSCAPE_PITCH_MAXIMUM = 0.5f;
private final SensorManager sensorManager;
private final EventListener eventListener = new EventListener();
private final SensorManager sensorManager;
private final ContentResolver contentResolver;
private final EventListener eventListener = new EventListener();
private final float[] accelerometerReading = new float[3];
private final float[] magnetometerReading = new float[3];
@ -34,7 +37,8 @@ public final class DeviceOrientationMonitor implements DefaultLifecycleObserver
private final MutableLiveData<Orientation> orientation = new MutableLiveData<>(Orientation.PORTRAIT_BOTTOM_EDGE);
public DeviceOrientationMonitor(@NonNull Context context) {
this.sensorManager = ServiceUtil.getSensorManager(context);
this.sensorManager = ServiceUtil.getSensorManager(context);
this.contentResolver = context.getContentResolver();
}
@Override
@ -65,6 +69,12 @@ public final class DeviceOrientationMonitor implements DefaultLifecycleObserver
}
private void updateOrientationAngles() {
int rotationLocked = Settings.System.getInt(contentResolver, Settings.System.ACCELEROMETER_ROTATION, -1);
if (rotationLocked == 0) {
orientation.setValue(Orientation.PORTRAIT_BOTTOM_EDGE);
return;
}
boolean success = SensorManager.getRotationMatrix(rotationMatrix, null, accelerometerReading, magnetometerReading);
if (!success) {
SensorUtil.getRotationMatrixWithoutMagneticSensorData(rotationMatrix, accelerometerReading);

Wyświetl plik

@ -26,8 +26,8 @@ public class BroadcastVideoSink implements VideoSink {
private final WeakHashMap<Object, Point> requestingSizes;
private int deviceOrientationDegrees;
private boolean rotateToRightSide;
private boolean forceRotate;
private boolean rotateWithDevice;
private final boolean forceRotate;
private final boolean rotateWithDevice;
private RequestedSize currentlyRequestedMaxSize;
public BroadcastVideoSink() {
@ -62,14 +62,6 @@ public class BroadcastVideoSink implements VideoSink {
sinks.remove(sink);
}
public void setForceRotate(boolean forceRotate) {
this.forceRotate = forceRotate;
}
public void setRotateWithDevice(boolean rotateWithDevice) {
this.rotateWithDevice = rotateWithDevice;
}
/**
* Set the specific rotation desired when not rotating with device.
*
@ -86,9 +78,8 @@ public class BroadcastVideoSink implements VideoSink {
@Override
public synchronized void onFrame(@NonNull VideoFrame videoFrame) {
boolean isDeviceRotationIgnored = deviceOrientationDegrees == DEVICE_ROTATION_IGNORE;
boolean isWideVideoFrame = videoFrame.getRotatedHeight() < videoFrame.getRotatedWidth();
if (!isDeviceRotationIgnored && (isWideVideoFrame || forceRotate)) {
if (!isDeviceRotationIgnored && forceRotate) {
int rotation = calculateRotation();
if (rotation > 0) {
rotation += rotateWithDevice ? videoFrame.getRotation() : 0;

Wyświetl plik

@ -15,7 +15,9 @@ object CallParticipantsLayoutStrategies {
if (callParticipant.isScreenSharing) {
callParticipantView.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT)
} else {
callParticipantView.setScalingType(if (isPortrait || childCount < 3) RendererCommon.ScalingType.SCALE_ASPECT_FILL else RendererCommon.ScalingType.SCALE_ASPECT_BALANCED)
val matchOrientationScaling = if (isPortrait || childCount < 3) RendererCommon.ScalingType.SCALE_ASPECT_FILL else RendererCommon.ScalingType.SCALE_ASPECT_BALANCED
val mismatchOrientationScaling = if (childCount == 1) RendererCommon.ScalingType.SCALE_ASPECT_FIT else matchOrientationScaling
callParticipantView.setScalingType(matchOrientationScaling, mismatchOrientationScaling)
}
}

Wyświetl plik

@ -122,26 +122,10 @@ public class TextureViewRenderer extends TextureView implements TextureView.Surf
}
}
public void addFrameListener(@NonNull EglRenderer.FrameListener listener, float scale, @NonNull RendererCommon.GlDrawer drawerParam) {
eglRenderer.addFrameListener(listener, scale, drawerParam);
}
public void addFrameListener(@NonNull EglRenderer.FrameListener listener, float scale) {
eglRenderer.addFrameListener(listener, scale);
}
public void removeFrameListener(@NonNull EglRenderer.FrameListener listener) {
eglRenderer.removeFrameListener(listener);
}
public void setEnableHardwareScaler(boolean enabled) {
ThreadUtils.checkIsOnMainThread();
enableFixedSize = enabled;
updateSurfaceSize();
}
public void setMirror(boolean mirror) {
eglRenderer.setMirror(mirror);
}
@ -164,18 +148,6 @@ public class TextureViewRenderer extends TextureView implements TextureView.Surf
requestLayout();
}
public void setFpsReduction(float fps) {
eglRenderer.setFpsReduction(fps);
}
public void disableFpsReduction() {
eglRenderer.disableFpsReduction();
}
public void pauseVideo() {
eglRenderer.pauseVideo();
}
@Override
protected void onMeasure(int widthSpec, int heightSpec) {
ThreadUtils.checkIsOnMainThread();

Wyświetl plik

@ -44,7 +44,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor {
remotePeer.getRecipient(),
null,
new BroadcastVideoSink(currentState.getVideoState().getLockableEglBase(),
false,
true,
true,
currentState.getLocalDeviceState().getOrientation().getDegrees()),
true,
@ -99,7 +99,7 @@ public class BeginCallActionProcessorDelegate extends WebRtcActionProcessor {
remotePeer.getRecipient(),
null,
new BroadcastVideoSink(currentState.getVideoState().getLockableEglBase(),
false,
true,
true,
currentState.getLocalDeviceState().getOrientation().getDegrees()),
true,

Wyświetl plik

@ -150,7 +150,7 @@ public final class IncomingGroupCallActionProcessor extends DeviceAwareActionPro
remotePeerGroup.getRecipient(),
null,
new BroadcastVideoSink(currentState.getVideoState().getLockableEglBase(),
false,
true,
true,
currentState.getLocalDeviceState().getOrientation().getDegrees()),
true,