mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 05:24:19 +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:
@@ -18,6 +18,7 @@ _scrcpy() {
|
|||||||
--camera-fps=
|
--camera-fps=
|
||||||
--camera-high-speed
|
--camera-high-speed
|
||||||
--camera-size=
|
--camera-size=
|
||||||
|
--camera-torch
|
||||||
--capture-orientation=
|
--capture-orientation=
|
||||||
--crop=
|
--crop=
|
||||||
-d --select-usb
|
-d --select-usb
|
||||||
@@ -197,6 +198,7 @@ _scrcpy() {
|
|||||||
|--camera-id \
|
|--camera-id \
|
||||||
|--camera-fps \
|
|--camera-fps \
|
||||||
|--camera-size \
|
|--camera-size \
|
||||||
|
|--camera-torch \
|
||||||
|--crop \
|
|--crop \
|
||||||
|--display-id \
|
|--display-id \
|
||||||
|--max-fps \
|
|--max-fps \
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ arguments=(
|
|||||||
'--camera-facing=[Select the device camera by its facing direction]:facing:(front back external)'
|
'--camera-facing=[Select the device camera by its facing direction]:facing:(front back external)'
|
||||||
'--camera-fps=[Specify the camera capture frame rate]'
|
'--camera-fps=[Specify the camera capture frame rate]'
|
||||||
'--camera-size=[Specify an explicit camera capture size]'
|
'--camera-size=[Specify an explicit camera capture size]'
|
||||||
|
'--camera-torch[Turn on the camera torch when the camera starts]'
|
||||||
'--capture-orientation=[Set the capture video orientation]:orientation:(0 90 180 270 flip0 flip90 flip180 flip270 @0 @90 @180 @270 @flip0 @flip90 @flip180 @flip270)'
|
'--capture-orientation=[Set the capture video orientation]:orientation:(0 90 180 270 flip0 flip90 flip180 flip270 @0 @90 @180 @270 @flip0 @flip90 @flip180 @flip270)'
|
||||||
'--crop=[\[width\:height\:x\:y\] Crop the device screen on the server]'
|
'--crop=[\[width\:height\:x\:y\] Crop the device screen on the server]'
|
||||||
{-d,--select-usb}'[Use USB device]'
|
{-d,--select-usb}'[Use USB device]'
|
||||||
|
|||||||
@@ -131,6 +131,10 @@ The available camera ids can be listed by \fB\-\-list\-cameras\fR.
|
|||||||
.BI "\-\-camera\-size " width\fRx\fIheight
|
.BI "\-\-camera\-size " width\fRx\fIheight
|
||||||
Specify an explicit camera capture size.
|
Specify an explicit camera capture size.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.BI \-\-camera\-torch
|
||||||
|
Turn on the camera torch when the camera starts.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.BI "\-\-capture\-orientation " value
|
.BI "\-\-capture\-orientation " value
|
||||||
Possible values are 0, 90, 180, 270, flip0, flip90, flip180 and flip270, possibly prefixed by '@'.
|
Possible values are 0, 90, 180, 270, flip0, flip90, flip180 and flip270, possibly prefixed by '@'.
|
||||||
|
|||||||
@@ -114,6 +114,7 @@ enum {
|
|||||||
OPT_NO_VD_SYSTEM_DECORATIONS,
|
OPT_NO_VD_SYSTEM_DECORATIONS,
|
||||||
OPT_NO_VD_DESTROY_CONTENT,
|
OPT_NO_VD_DESTROY_CONTENT,
|
||||||
OPT_DISPLAY_IME_POLICY,
|
OPT_DISPLAY_IME_POLICY,
|
||||||
|
OPT_CAMERA_TORCH,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sc_option {
|
struct sc_option {
|
||||||
@@ -313,6 +314,11 @@ static const struct sc_option options[] = {
|
|||||||
.argdesc = "<width>x<height>",
|
.argdesc = "<width>x<height>",
|
||||||
.text = "Specify an explicit camera capture size.",
|
.text = "Specify an explicit camera capture size.",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.longopt_id = OPT_CAMERA_TORCH,
|
||||||
|
.longopt = "camera-torch",
|
||||||
|
.text = "Turn on the camera torch when the camera starts.",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.longopt_id = OPT_CAPTURE_ORIENTATION,
|
.longopt_id = OPT_CAPTURE_ORIENTATION,
|
||||||
.longopt = "capture-orientation",
|
.longopt = "capture-orientation",
|
||||||
@@ -2780,6 +2786,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
|||||||
case OPT_CAMERA_HIGH_SPEED:
|
case OPT_CAMERA_HIGH_SPEED:
|
||||||
opts->camera_high_speed = true;
|
opts->camera_high_speed = true;
|
||||||
break;
|
break;
|
||||||
|
case OPT_CAMERA_TORCH:
|
||||||
|
opts->camera_torch = true;
|
||||||
|
break;
|
||||||
case OPT_NO_WINDOW:
|
case OPT_NO_WINDOW:
|
||||||
opts->window = false;
|
opts->window = false;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ const struct scrcpy_options scrcpy_options_default = {
|
|||||||
.angle = NULL,
|
.angle = NULL,
|
||||||
.vd_destroy_content = true,
|
.vd_destroy_content = true,
|
||||||
.vd_system_decorations = true,
|
.vd_system_decorations = true,
|
||||||
|
.camera_torch = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum sc_orientation
|
enum sc_orientation
|
||||||
|
|||||||
@@ -327,6 +327,7 @@ struct scrcpy_options {
|
|||||||
const char *start_app;
|
const char *start_app;
|
||||||
bool vd_destroy_content;
|
bool vd_destroy_content;
|
||||||
bool vd_system_decorations;
|
bool vd_system_decorations;
|
||||||
|
bool camera_torch;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct scrcpy_options scrcpy_options_default;
|
extern const struct scrcpy_options scrcpy_options_default;
|
||||||
|
|||||||
@@ -469,6 +469,7 @@ scrcpy(struct scrcpy_options *options) {
|
|||||||
.power_on = options->power_on,
|
.power_on = options->power_on,
|
||||||
.kill_adb_on_close = options->kill_adb_on_close,
|
.kill_adb_on_close = options->kill_adb_on_close,
|
||||||
.camera_high_speed = options->camera_high_speed,
|
.camera_high_speed = options->camera_high_speed,
|
||||||
|
.camera_torch = options->camera_torch,
|
||||||
.vd_destroy_content = options->vd_destroy_content,
|
.vd_destroy_content = options->vd_destroy_content,
|
||||||
.vd_system_decorations = options->vd_system_decorations,
|
.vd_system_decorations = options->vd_system_decorations,
|
||||||
.list = options->list,
|
.list = options->list,
|
||||||
|
|||||||
@@ -357,6 +357,9 @@ execute_server(struct sc_server *server,
|
|||||||
if (params->camera_high_speed) {
|
if (params->camera_high_speed) {
|
||||||
ADD_PARAM("camera_high_speed=true");
|
ADD_PARAM("camera_high_speed=true");
|
||||||
}
|
}
|
||||||
|
if (params->camera_torch) {
|
||||||
|
ADD_PARAM("camera_torch=true");
|
||||||
|
}
|
||||||
if (params->show_touches) {
|
if (params->show_touches) {
|
||||||
ADD_PARAM("show_touches=true");
|
ADD_PARAM("show_touches=true");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ struct sc_server_params {
|
|||||||
bool power_on;
|
bool power_on;
|
||||||
bool kill_adb_on_close;
|
bool kill_adb_on_close;
|
||||||
bool camera_high_speed;
|
bool camera_high_speed;
|
||||||
|
bool camera_torch;
|
||||||
bool vd_destroy_content;
|
bool vd_destroy_content;
|
||||||
bool vd_system_decorations;
|
bool vd_system_decorations;
|
||||||
uint8_t list;
|
uint8_t list;
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ public class Options {
|
|||||||
private CameraAspectRatio cameraAspectRatio;
|
private CameraAspectRatio cameraAspectRatio;
|
||||||
private int cameraFps;
|
private int cameraFps;
|
||||||
private boolean cameraHighSpeed;
|
private boolean cameraHighSpeed;
|
||||||
|
private boolean cameraTorch;
|
||||||
private boolean showTouches;
|
private boolean showTouches;
|
||||||
private boolean stayAwake;
|
private boolean stayAwake;
|
||||||
private int screenOffTimeout = -1;
|
private int screenOffTimeout = -1;
|
||||||
@@ -176,6 +177,10 @@ public class Options {
|
|||||||
return cameraHighSpeed;
|
return cameraHighSpeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getCameraTorch() {
|
||||||
|
return cameraTorch;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getShowTouches() {
|
public boolean getShowTouches() {
|
||||||
return showTouches;
|
return showTouches;
|
||||||
}
|
}
|
||||||
@@ -474,6 +479,9 @@ public class Options {
|
|||||||
case "camera_high_speed":
|
case "camera_high_speed":
|
||||||
options.cameraHighSpeed = Boolean.parseBoolean(value);
|
options.cameraHighSpeed = Boolean.parseBoolean(value);
|
||||||
break;
|
break;
|
||||||
|
case "camera_torch":
|
||||||
|
options.cameraTorch = Boolean.parseBoolean(value);
|
||||||
|
break;
|
||||||
case "new_display":
|
case "new_display":
|
||||||
options.newDisplay = parseNewDisplay(value);
|
options.newDisplay = parseNewDisplay(value);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ public class CameraCapture extends SurfaceCapture {
|
|||||||
private final Rect crop;
|
private final Rect crop;
|
||||||
private final Orientation captureOrientation;
|
private final Orientation captureOrientation;
|
||||||
private final float angle;
|
private final float angle;
|
||||||
|
private final boolean initialTorch;
|
||||||
|
|
||||||
private String cameraId;
|
private String cameraId;
|
||||||
private Size captureSize;
|
private Size captureSize;
|
||||||
@@ -94,6 +95,7 @@ public class CameraCapture extends SurfaceCapture {
|
|||||||
this.captureOrientation = options.getCaptureOrientation();
|
this.captureOrientation = options.getCaptureOrientation();
|
||||||
assert captureOrientation != null;
|
assert captureOrientation != null;
|
||||||
this.angle = options.getAngle();
|
this.angle = options.getAngle();
|
||||||
|
this.initialTorch = options.getCameraTorch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -291,6 +293,9 @@ public class CameraCapture extends SurfaceCapture {
|
|||||||
if (fps > 0) {
|
if (fps > 0) {
|
||||||
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(fps, fps));
|
requestBuilder.set(CaptureRequest.CONTROL_AE_TARGET_FPS_RANGE, new Range<>(fps, fps));
|
||||||
}
|
}
|
||||||
|
if (initialTorch) {
|
||||||
|
requestBuilder.set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH);
|
||||||
|
}
|
||||||
|
|
||||||
CaptureRequest request = requestBuilder.build();
|
CaptureRequest request = requestBuilder.build();
|
||||||
setRepeatingRequest(session, request);
|
setRepeatingRequest(session, request);
|
||||||
|
|||||||
Reference in New Issue
Block a user