Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maximize FOV on video call #2297

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading