mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-01-18 05:04:27 +01:00
Add option to turn on the camera torch
Add --camera-torch to turn on the camera torch when the camera starts. TODO ref 6243. Signed-off-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
@@ -46,6 +46,7 @@ public class Options {
|
||||
private CameraAspectRatio cameraAspectRatio;
|
||||
private int cameraFps;
|
||||
private boolean cameraHighSpeed;
|
||||
private boolean cameraTorch;
|
||||
private boolean showTouches;
|
||||
private boolean stayAwake;
|
||||
private int screenOffTimeout = -1;
|
||||
@@ -176,6 +177,10 @@ public class Options {
|
||||
return cameraHighSpeed;
|
||||
}
|
||||
|
||||
public boolean getCameraTorch() {
|
||||
return cameraTorch;
|
||||
}
|
||||
|
||||
public boolean getShowTouches() {
|
||||
return showTouches;
|
||||
}
|
||||
@@ -474,6 +479,9 @@ public class Options {
|
||||
case "camera_high_speed":
|
||||
options.cameraHighSpeed = Boolean.parseBoolean(value);
|
||||
break;
|
||||
case "camera_torch":
|
||||
options.cameraTorch = Boolean.parseBoolean(value);
|
||||
break;
|
||||
case "new_display":
|
||||
options.newDisplay = parseNewDisplay(value);
|
||||
break;
|
||||
|
||||
@@ -64,6 +64,7 @@ public class CameraCapture extends SurfaceCapture {
|
||||
private final Rect crop;
|
||||
private final Orientation captureOrientation;
|
||||
private final float angle;
|
||||
private final boolean initialTorch;
|
||||
|
||||
private String cameraId;
|
||||
private Size captureSize;
|
||||
@@ -94,6 +95,7 @@ public class CameraCapture extends SurfaceCapture {
|
||||
this.captureOrientation = options.getCaptureOrientation();
|
||||
assert captureOrientation != null;
|
||||
this.angle = options.getAngle();
|
||||
this.initialTorch = options.getCameraTorch();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -291,6 +293,10 @@ public class CameraCapture extends SurfaceCapture {
|
||||
if (fps > 0) {
|
||||
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(fps, fps));
|
||||
}
|
||||
if (initialTorch) {
|
||||
Ln.i("Turn camera torch on");
|
||||
requestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH);
|
||||
}
|
||||
|
||||
CaptureRequest request = requestBuilder.build();
|
||||
setRepeatingRequest(session, request);
|
||||
|
||||
Reference in New Issue
Block a user