Skip to content

Commit

Permalink
Maximize FOV on video call
Browse files Browse the repository at this point in the history
1) Use 4:3 video aspect ratio to prevent cropping to 16:9
2) Disable EIS
3) Zoom out
  • Loading branch information
ASerbinski committed Sep 20, 2024
1 parent 22c3f62 commit 35a403e
Show file tree
Hide file tree
Showing 5 changed files with 454 additions and 4 deletions.
10 changes: 8 additions & 2 deletions app/src/main/java/com/nextcloud/talk/activities/CallActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ import org.webrtc.CameraVideoCapturer.CameraSwitchHandler
import org.webrtc.DefaultVideoDecoderFactory
import org.webrtc.DefaultVideoEncoderFactory
import org.webrtc.EglBase
import org.webrtc.ExtCamera2Enumerator
import org.webrtc.Logging
import org.webrtc.MediaConstraints
import org.webrtc.MediaStream
Expand Down Expand Up @@ -232,6 +233,9 @@ class CallActivity : CallBaseActivity() {

private val callTimeHandler = Handler(Looper.getMainLooper())

private var disableEIS = true
private var zoomOut = true

// push to talk
private var isPushToTalkActive = false
private var pulseAnimation: PulseAnimation? = null
Expand Down Expand Up @@ -708,7 +712,9 @@ class CallActivity : CallBaseActivity() {
} catch (t: Throwable) {
Log.w(TAG, "Camera2Enumerator threw an error", t)
}
cameraEnumerator = if (camera2EnumeratorIsSupported) {
cameraEnumerator = if (camera2EnumeratorIsSupported && (disableEIS || zoomOut)){
ExtCamera2Enumerator(this, disableEIS, zoomOut)
} else if (camera2EnumeratorIsSupported) {
Camera2Enumerator(this)
} else {
Camera1Enumerator(WebRTCUtils.shouldEnableVideoHardwareAcceleration())
Expand Down Expand Up @@ -2071,7 +2077,7 @@ class CallActivity : CallBaseActivity() {

private fun startVideoCapture() {
if (videoCapturer != null) {
videoCapturer!!.startCapture(1280, 720, 30)
videoCapturer!!.startCapture(1280, 960, 30)
}
}

Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/org/webrtc/ExtCamera2Capturer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.webrtc;

import android.content.Context;
import android.hardware.camera2.CameraManager;

import org.jetbrains.annotations.Nullable;

public class ExtCamera2Capturer extends Camera2Capturer {

@Nullable private final CameraManager cameraManager;
private final boolean disableEIS, zoomOut;

public ExtCamera2Capturer(Context context, String cameraName, CameraEventsHandler eventsHandler,
boolean disableEIS, boolean zoomOut) {
super(context, cameraName, eventsHandler);
cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
this.disableEIS = disableEIS;
this.zoomOut = zoomOut;
}

@Override
protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback,
CameraSession.Events events, Context applicationContext,
SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height,
int framerate) {

CameraSession.CreateSessionCallback myCallback = new CameraSession.CreateSessionCallback() {
@Override
public void onDone(CameraSession cameraSession) {
createSessionCallback.onDone(cameraSession);
}

@Override
public void onFailure(CameraSession.FailureType failureType, String s) {
createSessionCallback.onFailure(failureType, s);
}
};

ExtCamera2Session.create(myCallback, events, applicationContext, cameraManager,
surfaceTextureHelper, cameraName, width, height, framerate, disableEIS, zoomOut);
}
}
27 changes: 27 additions & 0 deletions app/src/main/java/org/webrtc/ExtCamera2Enumerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.webrtc;

import android.content.Context;
import android.hardware.camera2.CameraManager;

import org.jetbrains.annotations.Nullable;

public class ExtCamera2Enumerator extends Camera2Enumerator {

final Context context;
@Nullable final CameraManager cameraManager;
private final boolean disableEIS, zoomOut;

public ExtCamera2Enumerator(Context context, boolean disableEIS, boolean zoomOut) {
super(context);
this.context = context;
this.disableEIS = disableEIS;
this.zoomOut = zoomOut;
this.cameraManager = (CameraManager) context.getSystemService(Context.CAMERA_SERVICE);
}

@Override
public CameraVideoCapturer createCapturer(String deviceName,
CameraVideoCapturer.CameraEventsHandler eventsHandler) {
return new ExtCamera2Capturer(context, deviceName, eventsHandler, disableEIS, zoomOut);
}
}
Loading

0 comments on commit 35a403e

Please sign in to comment.