Add --list-cameras

Add an option to list the device cameras.

Co-authored-by: Romain Vimont <rom@rom1v.com>
This commit is contained in:
Simon Chan
2023-07-16 17:07:19 +08:00
committed by Romain Vimont
parent de10be8153
commit 5bba202f01
14 changed files with 115 additions and 6 deletions

View File

@@ -23,6 +23,7 @@ _scrcpy() {
--kill-adb-on-close
-K --hid-keyboard
--legacy-paste
--list-cameras
--list-displays
--list-encoders
--lock-video-orientation

View File

@@ -30,6 +30,7 @@ arguments=(
'--kill-adb-on-close[Kill adb when scrcpy terminates]'
{-K,--hid-keyboard}'[Simulate a physical keyboard by using HID over AOAv2]'
'--legacy-paste[Inject computer clipboard text as a sequence of key events on Ctrl+v]'
'--list-cameras[List cameras available on the device]'
'--list-displays[List displays available on the device]'
'--list-encoders[List video and audio encoders available on the device]'
'--lock-video-orientation=[Lock video orientation]:orientation:(unlocked initial 0 1 2 3)'

View File

@@ -155,6 +155,9 @@ Inject computer clipboard text as a sequence of key events on Ctrl+v (like MOD+S
This is a workaround for some devices not behaving as expected when setting the device clipboard programmatically.
.B \-\-list\-cameras
List cameras available on the device.
.TP
.B \-\-list\-encoders
List video and audio encoders available on the device.

View File

@@ -79,6 +79,7 @@ enum {
OPT_AUDIO_SOURCE,
OPT_KILL_ADB_ON_CLOSE,
OPT_TIME_LIMIT,
OPT_LIST_CAMERAS,
};
struct sc_option {
@@ -312,6 +313,11 @@ static const struct sc_option options[] = {
"This is a workaround for some devices not behaving as "
"expected when setting the device clipboard programmatically.",
},
{
.longopt_id = OPT_LIST_CAMERAS,
.longopt = "list-cameras",
.text = "List device cameras.",
},
{
.longopt_id = OPT_LIST_DISPLAYS,
.longopt = "list-displays",
@@ -1944,6 +1950,9 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
"platform).");
return false;
#endif
case OPT_LIST_CAMERAS:
opts->list_cameras = true;
break;
case OPT_LIST_ENCODERS:
opts->list_encoders = true;
break;

View File

@@ -81,5 +81,6 @@ const struct scrcpy_options scrcpy_options_default = {
.require_audio = false,
.list_encoders = false,
.list_displays = false,
.list_cameras = false,
.kill_adb_on_close = false,
};

View File

@@ -181,6 +181,7 @@ struct scrcpy_options {
bool require_audio;
bool list_encoders;
bool list_displays;
bool list_cameras;
bool kill_adb_on_close;
};

View File

@@ -381,6 +381,7 @@ scrcpy(struct scrcpy_options *options) {
.power_on = options->power_on,
.list_encoders = options->list_encoders,
.list_displays = options->list_displays,
.list_cameras = options->list_cameras,
.kill_adb_on_close = options->kill_adb_on_close,
};
@@ -399,7 +400,8 @@ scrcpy(struct scrcpy_options *options) {
server_started = true;
if (options->list_encoders || options->list_displays) {
if (options->list_encoders || options->list_displays
|| options->list_cameras) {
bool ok = await_for_server(NULL);
ret = ok ? SCRCPY_EXIT_SUCCESS : SCRCPY_EXIT_FAILURE;
goto end;

View File

@@ -316,6 +316,9 @@ execute_server(struct sc_server *server,
if (params->list_displays) {
ADD_PARAM("list_displays=true");
}
if (params->list_cameras) {
ADD_PARAM("list_cameras=true");
}
#undef ADD_PARAM
@@ -895,7 +898,8 @@ run_server(void *data) {
// If --list-* is passed, then the server just prints the requested data
// then exits.
if (params->list_encoders || params->list_displays) {
if (params->list_encoders || params->list_displays
|| params->list_cameras) {
sc_pid pid = execute_server(server, params);
if (pid == SC_PROCESS_NONE) {
goto error_connection_failed;

View File

@@ -58,6 +58,7 @@ struct sc_server_params {
bool power_on;
bool list_encoders;
bool list_displays;
bool list_cameras;
bool kill_adb_on_close;
};