From 80659160d396e6a128c4446109e94fd78c015ba5 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 3 Feb 2023 00:36:30 -0600 Subject: [PATCH] Consolidate launch and resume and skip FPS hack for Sunshine --- app/backend/nvhttp.cpp | 44 ++++++++++----------------------------- app/backend/nvhttp.h | 18 +++++++--------- app/streaming/session.cpp | 17 +++++++-------- 3 files changed, 26 insertions(+), 53 deletions(-) diff --git a/app/backend/nvhttp.cpp b/app/backend/nvhttp.cpp index 406249ba..5e147d39 100644 --- a/app/backend/nvhttp.cpp +++ b/app/backend/nvhttp.cpp @@ -187,12 +187,14 @@ NvHTTP::getServerInfo(NvLogLevel logLevel, bool fastFail) } void -NvHTTP::launchApp(int appId, - PSTREAM_CONFIGURATION streamConfig, - bool sops, - bool localAudio, - int gamepadMask, - QString& rtspSessionUrl) +NvHTTP::startApp(QString verb, + bool isGfe, + int appId, + PSTREAM_CONFIGURATION streamConfig, + bool sops, + bool localAudio, + int gamepadMask, + QString& rtspSessionUrl) { int riKeyId; @@ -201,15 +203,15 @@ NvHTTP::launchApp(int appId, QString response = openConnectionToString(m_BaseUrlHttps, - "launch", + verb, "appid="+QString::number(appId)+ "&mode="+QString::number(streamConfig->width)+"x"+ QString::number(streamConfig->height)+"x"+ // Using an FPS value over 60 causes SOPS to default to 720p60, // so force it to 0 to ensure the correct resolution is set. We // used to use 60 here but that locked the frame rate to 60 FPS - // on GFE 3.20.3. - QString::number(streamConfig->fps > 60 ? 0 : streamConfig->fps)+ + // on GFE 3.20.3. We don't need this hack for Sunshine. + QString::number((streamConfig->fps > 60 && isGfe) ? 0 : streamConfig->fps)+ "&additionalStates=1&sops="+QString::number(sops ? 1 : 0)+ "&rikey="+QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex()+ "&rikeyid="+QString::number(riKeyId)+ @@ -230,30 +232,6 @@ NvHTTP::launchApp(int appId, rtspSessionUrl = getXmlString(response, "sessionUrl0"); } -void -NvHTTP::resumeApp(PSTREAM_CONFIGURATION streamConfig, QString& rtspSessionUrl) -{ - int riKeyId; - - memcpy(&riKeyId, streamConfig->remoteInputAesIv, sizeof(riKeyId)); - riKeyId = qFromBigEndian(riKeyId); - - QString response = - openConnectionToString(m_BaseUrlHttps, - "resume", - "rikey="+QString(QByteArray(streamConfig->remoteInputAesKey, sizeof(streamConfig->remoteInputAesKey)).toHex())+ - "&rikeyid="+QString::number(riKeyId)+ - "&surroundAudioInfo="+QString::number(SURROUNDAUDIOINFO_FROM_AUDIO_CONFIGURATION(streamConfig->audioConfiguration)), - RESUME_TIMEOUT_MS); - - qInfo() << "Resume response:" << response; - - // Throws if the request failed - verifyResponseStatus(response); - - rtspSessionUrl = getXmlString(response, "sessionUrl0"); -} - void NvHTTP::quitApp() { diff --git a/app/backend/nvhttp.h b/app/backend/nvhttp.h index 01715f41..a5cc7b6a 100644 --- a/app/backend/nvhttp.h +++ b/app/backend/nvhttp.h @@ -162,16 +162,14 @@ public: quitApp(); void - resumeApp(PSTREAM_CONFIGURATION streamConfig, - QString& rtspSessionUrl); - - void - launchApp(int appId, - PSTREAM_CONFIGURATION streamConfig, - bool sops, - bool localAudio, - int gamepadMask, - QString& rtspSessionUrl); + startApp(QString verb, + bool isGfe, + int appId, + PSTREAM_CONFIGURATION streamConfig, + bool sops, + bool localAudio, + int gamepadMask, + QString& rtspSessionUrl); QVector getAppList(); diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 1897334e..0cc78377 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -1172,16 +1172,13 @@ bool Session::startConnectionAsync() try { NvHTTP http(m_Computer); - if (m_Computer->currentGameId != 0) { - http.resumeApp(&m_StreamConfig, rtspSessionUrl); - } - else { - http.launchApp(m_App.id, &m_StreamConfig, - enableGameOptimizations, - m_Preferences->playAudioOnHost, - m_InputHandler->getAttachedGamepadMask(), - rtspSessionUrl); - } + http.startApp(m_Computer->currentGameId != 0 ? "resume" : "launch", + m_Computer->isNvidiaServerSoftware, + m_App.id, &m_StreamConfig, + enableGameOptimizations, + m_Preferences->playAudioOnHost, + m_InputHandler->getAttachedGamepadMask(), + rtspSessionUrl); } catch (const GfeHttpResponseException& e) { emit displayLaunchError(tr("GeForce Experience returned error: %1").arg(e.toQString())); return false;