From b907c4b608d8ffb2b5c625e497e745cae820ade5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 24 Jul 2021 15:57:55 -0500 Subject: [PATCH] Use the same remote streaming and packet size defaults as other clients --- docs/README.pod | 8 ++++---- moonlight.conf | 10 +++++++--- src/config.c | 18 ++++++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/docs/README.pod b/docs/README.pod index a6defed..48ff6e2 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -93,8 +93,8 @@ For other configurations, 5 Mbps is used by default. Change the network packetsize to I bytes. The packetsize should the smaller than the MTU of the network. -This value must be a multiply of 16. -By default a safe value of 1024 is used. +This value must be a multiple of 16. +By default, 1392 is used on LAN and 1024 on WAN. =item B<-codec> [I] @@ -103,9 +103,9 @@ Can be 'auto', 'h264', 'h265' or 'hevc'. Not all video decoders do support H.265/HEVC. Will still use H.264 if server doesn't support HEVC. -=item B<-remote> +=item B<-remote> [I] -Enable the optimizations for remote connections in GFE. +Enable optimizations for LAN or WAN streaming. =item B<-app> [I] diff --git a/moonlight.conf b/moonlight.conf index 63e5ad1..8603cbe 100644 --- a/moonlight.conf +++ b/moonlight.conf @@ -15,7 +15,8 @@ #bitrate = -1 ## Size of network packets should be lower than MTU -#packetsize = 1024 +## If streaming with WAN optimizations, this will be capped at 1024. +#packetsize = 1392 ## Select video codec (auto/h264/h265) #codec = auto @@ -64,8 +65,11 @@ ## By default keys are stored in $XDG_CACHE_DIR/moonlight or ~/.cache/moonlight #keydir = /dir/to/keys -## Enable QOS settings to optimize for internet instead of local network -#remote = false +## Enable QOS settings to optimize for internet or local network +## yes - optimize for WAN streaming +## no - optimize for LAN streaming +## auto (default) - decide automatically based on target IP address +#remote = auto ## Enable 5.1/7.1 surround sound #surround = 5.1 diff --git a/src/config.c b/src/config.c index ebdb9d3..2589229 100644 --- a/src/config.c +++ b/src/config.c @@ -59,7 +59,7 @@ static struct option long_options[] = { {"platform", required_argument, NULL, 'p'}, {"save", required_argument, NULL, 'q'}, {"keydir", required_argument, NULL, 'r'}, - {"remote", no_argument, NULL, 's'}, + {"remote", required_argument, NULL, 's'}, {"windowed", no_argument, NULL, 't'}, {"surround", required_argument, NULL, 'u'}, {"fps", required_argument, NULL, 'v'}, @@ -193,8 +193,14 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { strcpy(config->key_dir, value); break; case 's': - config->stream.streamingRemotely = 1; + if (strcasecmp(value, "auto") == 0) + config->stream.streamingRemotely = STREAM_CFG_AUTO; + else if (strcasecmp(value, "true") == 0 || strcasecmp(value, "yes") == 0) + config->stream.streamingRemotely = STREAM_CFG_REMOTE; + else if (strcasecmp(value, "false") == 0 || strcasecmp(value, "no") == 0) + config->stream.streamingRemotely = STREAM_CFG_LOCAL; break; + case 't': config->fullscreen = false; break; @@ -212,7 +218,7 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { config->codec = CODEC_UNSPECIFIED; else if (strcasecmp(value, "h264") == 0) config->codec = CODEC_H264; - if (strcasecmp(value, "h265") == 0 || strcasecmp(value, "hevc") == 0) + else if (strcasecmp(value, "h265") == 0 || strcasecmp(value, "hevc") == 0) config->codec = CODEC_HEVC; break; case 'y': @@ -318,8 +324,8 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->stream.height = 720; config->stream.fps = 60; config->stream.bitrate = -1; - config->stream.packetSize = 1024; - config->stream.streamingRemotely = 0; + config->stream.packetSize = 1392; + config->stream.streamingRemotely = STREAM_CFG_AUTO; config->stream.audioConfiguration = AUDIO_CONFIGURATION_STEREO; config->stream.supportsHevc = false; @@ -355,7 +361,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { } else { int option_index = 0; int c; - while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:stu:v:w:xy", long_options, &option_index)) != -1) { + while ((c = getopt_long_only(argc, argv, "-abc:d:efg:h:i:j:k:lm:no:p:q:r:s:tu:v:w:xy", long_options, &option_index)) != -1) { parse_argument(c, optarg, config); } }