mirror of
https://github.com/Genymobile/scrcpy
synced 2025-09-01 06:45:40 +00:00
Add --tcpip feature
Expose an option to automatically configure and reconnect the device over TCP/IP, to simplify wireless connection without using adb explicitly. There are two variants: - If a destination address is provided, then scrcpy connects to this address before starting. The device must listen on the given TCP port (default is 5555). - If no destination address is provided, then scrcpy attempts to find the IP address of the current device (typically connected over USB), enables TCP/IP mode, then connects to this address before starting. PR #2827 <https://github.com/Genymobile/scrcpy/pull/2827>
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
#define OPT_TUNNEL_HOST 1030
|
||||
#define OPT_TUNNEL_PORT 1031
|
||||
#define OPT_NO_CLIPBOARD_AUTOSYNC 1032
|
||||
#define OPT_TCPIP 1033
|
||||
|
||||
struct sc_option {
|
||||
char shortopt;
|
||||
@@ -404,6 +405,20 @@ static const struct sc_option options[] = {
|
||||
.text = "Keep the device on while scrcpy is running, when the device "
|
||||
"is plugged in.",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_TCPIP,
|
||||
.longopt = "tcpip",
|
||||
.argdesc = "ip[:port]",
|
||||
.optional_arg = true,
|
||||
.text = "Configure and reconnect the device over TCP/IP.\n"
|
||||
"If a destination address is provided, then scrcpy connects to "
|
||||
"this address before starting. The device must listen on the "
|
||||
"given TCP port (default is 5555).\n"
|
||||
"If no destination address is provided, then scrcpy attempts "
|
||||
"to find the IP address of the current device (typically "
|
||||
"connected over USB), enables TCP/IP mode, then connects to "
|
||||
"this address before starting.",
|
||||
},
|
||||
{
|
||||
.longopt_id = OPT_WINDOW_BORDERLESS,
|
||||
.longopt = "window-borderless",
|
||||
@@ -1378,6 +1393,10 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||
case OPT_NO_CLIPBOARD_AUTOSYNC:
|
||||
opts->clipboard_autosync = false;
|
||||
break;
|
||||
case OPT_TCPIP:
|
||||
opts->tcpip = true;
|
||||
opts->tcpip_dst = optarg;
|
||||
break;
|
||||
#ifdef HAVE_V4L2
|
||||
case OPT_V4L2_SINK:
|
||||
opts->v4l2_device = optarg;
|
||||
@@ -1400,6 +1419,14 @@ parse_args_with_getopt(struct scrcpy_cli_args *args, int argc, char *argv[],
|
||||
return false;
|
||||
}
|
||||
|
||||
// If a TCP/IP address is provided, then tcpip must be enabled
|
||||
assert(opts->tcpip || !opts->tcpip_dst);
|
||||
|
||||
if (opts->serial && opts->tcpip_dst) {
|
||||
LOGE("Incompatible options: -s/--serial and --tcpip with an argument");
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_V4L2
|
||||
if (!opts->display && !opts->record_filename && !opts->v4l2_device) {
|
||||
LOGE("-N/--no-display requires either screen recording (-r/--record)"
|
||||
|
Reference in New Issue
Block a user