Add --packet-size command-line option

This commit is contained in:
Cameron Gutman
2020-01-21 19:10:10 -08:00
parent ee5c61fb74
commit 7aff148e9f
4 changed files with 33 additions and 9 deletions
+9
View File
@@ -280,6 +280,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
parser.addToggleOption("vsync", "V-Sync"); parser.addToggleOption("vsync", "V-Sync");
parser.addValueOption("fps", "FPS"); parser.addValueOption("fps", "FPS");
parser.addValueOption("bitrate", "bitrate in Kbps"); parser.addValueOption("bitrate", "bitrate in Kbps");
parser.addValueOption("packet-size", "video packet size");
parser.addChoiceOption("display-mode", "display mode", m_WindowModeMap.keys()); parser.addChoiceOption("display-mode", "display mode", m_WindowModeMap.keys());
parser.addChoiceOption("audio-config", "audio config", m_AudioConfigMap.keys()); parser.addChoiceOption("audio-config", "audio config", m_AudioConfigMap.keys());
parser.addToggleOption("multi-controller", "multiple controller support"); parser.addToggleOption("multi-controller", "multiple controller support");
@@ -345,6 +346,14 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
preferences->width, preferences->height, preferences->fps); preferences->width, preferences->height, preferences->fps);
} }
// Resolve --packet-size option
if (parser.isSet("packet-size")) {
preferences->packetSize = parser.getIntOption("packet-size");
if (preferences->packetSize < 1024) {
parser.showError("Packet size must be greater than 1024 bytes");
}
}
// Resolve --display option // Resolve --display option
if (parser.isSet("display-mode")) { if (parser.isSet("display-mode")) {
preferences->windowMode = mapValue(m_WindowModeMap, parser.getChoiceOptionValue("display-mode")); preferences->windowMode = mapValue(m_WindowModeMap, parser.getChoiceOptionValue("display-mode"));
+3
View File
@@ -26,6 +26,7 @@
#define SER_RICHPRESENCE "richpresence" #define SER_RICHPRESENCE "richpresence"
#define SER_GAMEPADMOUSE "gamepadmouse" #define SER_GAMEPADMOUSE "gamepadmouse"
#define SER_DEFAULTVER "defaultver" #define SER_DEFAULTVER "defaultver"
#define SER_PACKETSIZE "packetsize"
#define CURRENT_DEFAULT_VER 1 #define CURRENT_DEFAULT_VER 1
@@ -64,6 +65,7 @@ void StreamingPreferences::reload()
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool(); connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
richPresence = settings.value(SER_RICHPRESENCE, true).toBool(); richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool(); gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG, audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
static_cast<int>(AudioConfig::AC_STEREO)).toInt()); static_cast<int>(AudioConfig::AC_STEREO)).toInt());
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG, videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
@@ -107,6 +109,7 @@ void StreamingPreferences::save()
settings.setValue(SER_CONNWARNINGS, connectionWarnings); settings.setValue(SER_CONNWARNINGS, connectionWarnings);
settings.setValue(SER_RICHPRESENCE, richPresence); settings.setValue(SER_RICHPRESENCE, richPresence);
settings.setValue(SER_GAMEPADMOUSE, gamepadMouse); settings.setValue(SER_GAMEPADMOUSE, gamepadMouse);
settings.setValue(SER_PACKETSIZE, packetSize);
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig)); settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig)); settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection)); settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
+1
View File
@@ -90,6 +90,7 @@ public:
bool connectionWarnings; bool connectionWarnings;
bool richPresence; bool richPresence;
bool gamepadMouse; bool gamepadMouse;
int packetSize;
AudioConfig audioConfig; AudioConfig audioConfig;
VideoCodecConfig videoCodecConfig; VideoCodecConfig videoCodecConfig;
VideoDecoderSelection videoDecoderSelection; VideoDecoderSelection videoDecoderSelection;
+11
View File
@@ -942,6 +942,16 @@ void Session::exec(int displayOriginX, int displayOriginY)
hostInfo.serverInfoGfeVersion = siGfeVersion.data(); hostInfo.serverInfoGfeVersion = siGfeVersion.data();
} }
if (m_Preferences->packetSize != 0) {
// Override default packet size and remote streaming detection
// NB: Using STREAM_CFG_AUTO will cap our packet size at 1024 for remote hosts.
m_StreamConfig.streamingRemotely = STREAM_CFG_LOCAL;
m_StreamConfig.packetSize = m_Preferences->packetSize;
SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
"Using custom packet size: %d bytes",
m_Preferences->packetSize);
}
else {
// isReachableOverVpn() does network I/O, so we only attempt to check // isReachableOverVpn() does network I/O, so we only attempt to check
// VPN reachability if we've already contacted the PC successfully // VPN reachability if we've already contacted the PC successfully
if (m_Computer->isReachableOverVpn()) { if (m_Computer->isReachableOverVpn()) {
@@ -954,6 +964,7 @@ void Session::exec(int displayOriginX, int displayOriginY)
m_StreamConfig.streamingRemotely = STREAM_CFG_AUTO; m_StreamConfig.streamingRemotely = STREAM_CFG_AUTO;
m_StreamConfig.packetSize = 1392; m_StreamConfig.packetSize = 1392;
} }
}
int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks, int err = LiStartConnection(&hostInfo, &m_StreamConfig, &k_ConnCallbacks,
&m_VideoCallbacks, &m_VideoCallbacks,