2018-06-28 06:15:13 +00:00
|
|
|
#include "streamingpreferences.h"
|
2022-05-20 00:22:01 +00:00
|
|
|
#include "utils.h"
|
2018-06-28 06:15:13 +00:00
|
|
|
|
|
|
|
#include <QSettings>
|
2021-01-30 18:14:31 +00:00
|
|
|
#include <QTranslator>
|
|
|
|
#include <QCoreApplication>
|
2021-01-30 18:53:57 +00:00
|
|
|
#include <QLocale>
|
2024-04-14 18:01:30 +00:00
|
|
|
#include <QReadWriteLock>
|
2023-09-08 07:04:15 +00:00
|
|
|
#include <QtMath>
|
2021-01-30 18:53:57 +00:00
|
|
|
|
|
|
|
#include <QtDebug>
|
2018-06-28 06:15:13 +00:00
|
|
|
|
|
|
|
#define SER_STREAMSETTINGS "streamsettings"
|
|
|
|
#define SER_WIDTH "width"
|
|
|
|
#define SER_HEIGHT "height"
|
|
|
|
#define SER_FPS "fps"
|
|
|
|
#define SER_BITRATE "bitrate"
|
2024-08-20 02:43:00 +00:00
|
|
|
#define SER_UNLOCK_BITRATE "unlockbitrate"
|
2018-06-28 06:15:13 +00:00
|
|
|
#define SER_FULLSCREEN "fullscreen"
|
2018-08-21 05:25:19 +00:00
|
|
|
#define SER_VSYNC "vsync"
|
2018-06-28 06:15:13 +00:00
|
|
|
#define SER_GAMEOPTS "gameopts"
|
|
|
|
#define SER_HOSTAUDIO "hostaudio"
|
|
|
|
#define SER_MULTICONT "multicontroller"
|
|
|
|
#define SER_AUDIOCFG "audiocfg"
|
|
|
|
#define SER_VIDEOCFG "videocfg"
|
2023-07-16 20:38:58 +00:00
|
|
|
#define SER_HDR "hdr"
|
2024-05-15 13:22:42 +00:00
|
|
|
#define SER_YUV444 "yuv444"
|
2018-07-09 00:33:47 +00:00
|
|
|
#define SER_VIDEODEC "videodec"
|
2018-09-04 02:17:34 +00:00
|
|
|
#define SER_WINDOWMODE "windowmode"
|
2018-09-09 19:33:19 +00:00
|
|
|
#define SER_MDNS "mdns"
|
2018-12-06 02:45:28 +00:00
|
|
|
#define SER_QUITAPPAFTER "quitAppAfter"
|
2020-04-25 20:00:39 +00:00
|
|
|
#define SER_ABSMOUSEMODE "mouseacceleration"
|
2020-05-01 03:55:15 +00:00
|
|
|
#define SER_ABSTOUCHMODE "abstouchmode"
|
2021-01-10 16:09:31 +00:00
|
|
|
#define SER_STARTWINDOWED "startwindowed"
|
2018-12-25 20:57:00 +00:00
|
|
|
#define SER_FRAMEPACING "framepacing"
|
2019-03-19 03:21:52 +00:00
|
|
|
#define SER_CONNWARNINGS "connwarnings"
|
2021-01-10 15:50:12 +00:00
|
|
|
#define SER_UIDISPLAYMODE "uidisplaymode"
|
2019-06-30 00:40:30 +00:00
|
|
|
#define SER_RICHPRESENCE "richpresence"
|
2019-06-30 01:24:59 +00:00
|
|
|
#define SER_GAMEPADMOUSE "gamepadmouse"
|
2019-12-07 21:27:47 +00:00
|
|
|
#define SER_DEFAULTVER "defaultver"
|
2020-01-22 03:10:10 +00:00
|
|
|
#define SER_PACKETSIZE "packetsize"
|
2020-08-09 01:29:36 +00:00
|
|
|
#define SER_DETECTNETBLOCKING "detectnetblocking"
|
2024-05-01 02:37:52 +00:00
|
|
|
#define SER_SHOWPERFOVERLAY "showperfoverlay"
|
2020-08-23 14:05:00 +00:00
|
|
|
#define SER_SWAPMOUSEBUTTONS "swapmousebuttons"
|
2021-01-09 23:56:23 +00:00
|
|
|
#define SER_MUTEONFOCUSLOSS "muteonfocusloss"
|
2020-12-25 21:32:11 +00:00
|
|
|
#define SER_BACKGROUNDGAMEPAD "backgroundgamepad"
|
2020-12-26 04:21:20 +00:00
|
|
|
#define SER_REVERSESCROLL "reversescroll"
|
|
|
|
#define SER_SWAPFACEBUTTONS "swapfacebuttons"
|
2021-01-13 02:05:18 +00:00
|
|
|
#define SER_CAPTURESYSKEYS "capturesyskeys"
|
2022-03-17 02:48:56 +00:00
|
|
|
#define SER_KEEPAWAKE "keepawake"
|
2021-01-30 18:14:31 +00:00
|
|
|
#define SER_LANGUAGE "language"
|
2019-12-07 21:27:47 +00:00
|
|
|
|
2022-05-20 00:22:01 +00:00
|
|
|
#define CURRENT_DEFAULT_VER 2
|
2018-06-28 06:15:13 +00:00
|
|
|
|
2024-04-14 18:01:30 +00:00
|
|
|
static StreamingPreferences* s_GlobalPrefs;
|
|
|
|
static QReadWriteLock s_GlobalPrefsLock;
|
|
|
|
|
|
|
|
StreamingPreferences::StreamingPreferences(QQmlEngine *qmlEngine)
|
|
|
|
: m_QmlEngine(qmlEngine)
|
2021-01-30 18:14:31 +00:00
|
|
|
{
|
|
|
|
reload();
|
|
|
|
}
|
|
|
|
|
2024-04-14 18:01:30 +00:00
|
|
|
StreamingPreferences* StreamingPreferences::get(QQmlEngine *qmlEngine)
|
2018-06-28 06:15:13 +00:00
|
|
|
{
|
2024-04-14 18:01:30 +00:00
|
|
|
{
|
|
|
|
QReadLocker readGuard(&s_GlobalPrefsLock);
|
|
|
|
|
|
|
|
// If we have a preference object and it's associated with a QML engine or
|
|
|
|
// if the caller didn't specify a QML engine, return the existing object.
|
|
|
|
if (s_GlobalPrefs && (s_GlobalPrefs->m_QmlEngine || !qmlEngine)) {
|
|
|
|
// The lifetime logic here relies on the QML engine also being a singleton.
|
|
|
|
Q_ASSERT(!qmlEngine || s_GlobalPrefs->m_QmlEngine == qmlEngine);
|
|
|
|
return s_GlobalPrefs;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
QWriteLocker writeGuard(&s_GlobalPrefsLock);
|
|
|
|
|
|
|
|
// If we already have an preference object but the QML engine is now available,
|
|
|
|
// associate the QML engine with the preferences.
|
|
|
|
if (s_GlobalPrefs) {
|
|
|
|
if (!s_GlobalPrefs->m_QmlEngine) {
|
|
|
|
s_GlobalPrefs->m_QmlEngine = qmlEngine;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We could reach this codepath if another thread raced with us
|
|
|
|
// and created the object while we were outside the pref lock.
|
|
|
|
Q_ASSERT(!qmlEngine || s_GlobalPrefs->m_QmlEngine == qmlEngine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
s_GlobalPrefs = new StreamingPreferences(qmlEngine);
|
|
|
|
}
|
|
|
|
|
|
|
|
return s_GlobalPrefs;
|
|
|
|
}
|
2018-06-28 06:15:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void StreamingPreferences::reload()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
2019-12-07 21:27:47 +00:00
|
|
|
int defaultVer = settings.value(SER_DEFAULTVER, 0).toInt();
|
|
|
|
|
2019-06-29 21:58:27 +00:00
|
|
|
#ifdef Q_OS_DARWIN
|
|
|
|
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
|
|
|
#else
|
2022-05-20 00:22:01 +00:00
|
|
|
// Wayland doesn't support modesetting, so use fullscreen desktop mode.
|
|
|
|
if (WMUtils::isRunningWayland()) {
|
|
|
|
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
recommendedFullScreenMode = WindowMode::WM_FULLSCREEN;
|
|
|
|
}
|
2019-06-29 21:58:27 +00:00
|
|
|
#endif
|
|
|
|
|
2018-06-28 06:15:13 +00:00
|
|
|
width = settings.value(SER_WIDTH, 1280).toInt();
|
|
|
|
height = settings.value(SER_HEIGHT, 720).toInt();
|
|
|
|
fps = settings.value(SER_FPS, 60).toInt();
|
2024-05-15 13:22:42 +00:00
|
|
|
enableYUV444 = settings.value(SER_YUV444, false).toBool();
|
|
|
|
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps, enableYUV444)).toInt();
|
2024-08-20 02:43:00 +00:00
|
|
|
unlockBitrate = settings.value(SER_UNLOCK_BITRATE, false).toBool();
|
2018-08-21 05:25:19 +00:00
|
|
|
enableVsync = settings.value(SER_VSYNC, true).toBool();
|
2018-07-09 00:33:47 +00:00
|
|
|
gameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
2018-06-28 06:15:13 +00:00
|
|
|
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
|
|
|
multiController = settings.value(SER_MULTICONT, true).toBool();
|
2018-09-09 19:33:19 +00:00
|
|
|
enableMdns = settings.value(SER_MDNS, true).toBool();
|
2018-12-06 02:45:28 +00:00
|
|
|
quitAppAfter = settings.value(SER_QUITAPPAFTER, false).toBool();
|
2020-04-25 20:00:39 +00:00
|
|
|
absoluteMouseMode = settings.value(SER_ABSMOUSEMODE, false).toBool();
|
2020-05-01 03:55:15 +00:00
|
|
|
absoluteTouchMode = settings.value(SER_ABSTOUCHMODE, true).toBool();
|
2018-12-25 20:57:00 +00:00
|
|
|
framePacing = settings.value(SER_FRAMEPACING, false).toBool();
|
2019-03-19 03:21:52 +00:00
|
|
|
connectionWarnings = settings.value(SER_CONNWARNINGS, true).toBool();
|
2019-06-30 00:40:30 +00:00
|
|
|
richPresence = settings.value(SER_RICHPRESENCE, true).toBool();
|
2019-06-30 01:24:59 +00:00
|
|
|
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
|
2020-08-09 01:29:36 +00:00
|
|
|
detectNetworkBlocking = settings.value(SER_DETECTNETBLOCKING, true).toBool();
|
2024-05-01 02:37:52 +00:00
|
|
|
showPerformanceOverlay = settings.value(SER_SHOWPERFOVERLAY, false).toBool();
|
2020-01-22 03:10:10 +00:00
|
|
|
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
|
2020-08-23 14:05:00 +00:00
|
|
|
swapMouseButtons = settings.value(SER_SWAPMOUSEBUTTONS, false).toBool();
|
2021-01-09 23:56:23 +00:00
|
|
|
muteOnFocusLoss = settings.value(SER_MUTEONFOCUSLOSS, false).toBool();
|
2020-12-25 21:32:11 +00:00
|
|
|
backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool();
|
2020-12-26 04:21:20 +00:00
|
|
|
reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool();
|
|
|
|
swapFaceButtons = settings.value(SER_SWAPFACEBUTTONS, false).toBool();
|
2022-03-17 02:48:56 +00:00
|
|
|
keepAwake = settings.value(SER_KEEPAWAKE, true).toBool();
|
2023-07-16 20:38:58 +00:00
|
|
|
enableHdr = settings.value(SER_HDR, false).toBool();
|
2021-02-27 22:47:38 +00:00
|
|
|
captureSysKeysMode = static_cast<CaptureSysKeysMode>(settings.value(SER_CAPTURESYSKEYS,
|
|
|
|
static_cast<int>(CaptureSysKeysMode::CSK_OFF)).toInt());
|
2018-06-28 06:15:13 +00:00
|
|
|
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
2018-10-02 22:30:22 +00:00
|
|
|
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
|
2018-06-28 06:15:13 +00:00
|
|
|
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
|
|
|
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
2018-07-09 00:33:47 +00:00
|
|
|
videoDecoderSelection = static_cast<VideoDecoderSelection>(settings.value(SER_VIDEODEC,
|
|
|
|
static_cast<int>(VideoDecoderSelection::VDS_AUTO)).toInt());
|
2018-09-04 02:17:34 +00:00
|
|
|
windowMode = static_cast<WindowMode>(settings.value(SER_WINDOWMODE,
|
|
|
|
// Try to load from the old preference value too
|
|
|
|
static_cast<int>(settings.value(SER_FULLSCREEN, true).toBool() ?
|
2019-06-29 21:58:27 +00:00
|
|
|
recommendedFullScreenMode : WindowMode::WM_WINDOWED)).toInt());
|
2021-01-10 15:50:12 +00:00
|
|
|
uiDisplayMode = static_cast<UIDisplayMode>(settings.value(SER_UIDISPLAYMODE,
|
2021-01-10 16:09:31 +00:00
|
|
|
static_cast<int>(settings.value(SER_STARTWINDOWED, true).toBool() ? UIDisplayMode::UI_WINDOWED
|
|
|
|
: UIDisplayMode::UI_MAXIMIZED)).toInt());
|
2021-01-30 18:14:31 +00:00
|
|
|
language = static_cast<Language>(settings.value(SER_LANGUAGE,
|
|
|
|
static_cast<int>(Language::LANG_AUTO)).toInt());
|
2021-01-10 15:50:12 +00:00
|
|
|
|
2019-12-07 21:27:47 +00:00
|
|
|
|
|
|
|
// Perform default settings updates as required based on last default version
|
2022-05-20 00:22:01 +00:00
|
|
|
if (defaultVer < 1) {
|
2019-12-07 21:27:47 +00:00
|
|
|
#ifdef Q_OS_DARWIN
|
|
|
|
// Update window mode setting on macOS from full-screen (old default) to borderless windowed (new default)
|
|
|
|
if (windowMode == WindowMode::WM_FULLSCREEN) {
|
|
|
|
windowMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2022-05-20 00:22:01 +00:00
|
|
|
if (defaultVer < 2) {
|
|
|
|
if (windowMode == WindowMode::WM_FULLSCREEN && WMUtils::isRunningWayland()) {
|
|
|
|
windowMode = WindowMode::WM_FULLSCREEN_DESKTOP;
|
|
|
|
}
|
|
|
|
}
|
2023-07-16 20:38:58 +00:00
|
|
|
|
|
|
|
// Fixup VCC value to the new settings format with codec and HDR separate
|
|
|
|
if (videoCodecConfig == VCC_FORCE_HEVC_HDR_DEPRECATED) {
|
|
|
|
videoCodecConfig = VCC_AUTO;
|
|
|
|
enableHdr = true;
|
|
|
|
}
|
2018-06-28 06:15:13 +00:00
|
|
|
}
|
|
|
|
|
2021-01-30 18:14:31 +00:00
|
|
|
bool StreamingPreferences::retranslate()
|
|
|
|
{
|
|
|
|
static QTranslator* translator = nullptr;
|
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
if (m_QmlEngine != nullptr) {
|
|
|
|
// Dynamic retranslation is not supported until Qt 5.10
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
QTranslator* newTranslator = new QTranslator();
|
|
|
|
QString languageSuffix = getSuffixFromLanguage(language);
|
|
|
|
|
|
|
|
// Remove the old translator, even if we can't load a new one.
|
|
|
|
// Otherwise we'll be stuck with the old translated values instead
|
|
|
|
// of defaulting to English.
|
|
|
|
if (translator != nullptr) {
|
|
|
|
QCoreApplication::removeTranslator(translator);
|
|
|
|
delete translator;
|
|
|
|
translator = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (newTranslator->load(QString(":/languages/qml_") + languageSuffix)) {
|
2022-11-03 00:25:44 +00:00
|
|
|
qInfo() << "Successfully loaded translation for" << languageSuffix;
|
2021-01-30 18:14:31 +00:00
|
|
|
|
|
|
|
translator = newTranslator;
|
|
|
|
QCoreApplication::installTranslator(translator);
|
|
|
|
}
|
|
|
|
else {
|
2022-11-03 00:25:44 +00:00
|
|
|
qInfo() << "No translation available for" << languageSuffix;
|
2021-01-30 18:14:31 +00:00
|
|
|
delete newTranslator;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_QmlEngine != nullptr) {
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
|
|
|
|
// This is a dynamic retranslation from the settings page.
|
|
|
|
// We have to kick the QML engine into reloading our text.
|
|
|
|
m_QmlEngine->retranslate();
|
|
|
|
#else
|
|
|
|
// Unreachable below Qt 5.10 due to the check above
|
2021-01-30 18:53:57 +00:00
|
|
|
Q_ASSERT(false);
|
2021-01-30 18:14:31 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// This is a translation from a non-QML context, which means
|
|
|
|
// it is probably app startup. There's nothing to refresh.
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString StreamingPreferences::getSuffixFromLanguage(StreamingPreferences::Language lang)
|
|
|
|
{
|
|
|
|
switch (lang)
|
|
|
|
{
|
2021-03-10 02:10:36 +00:00
|
|
|
case LANG_DE:
|
|
|
|
return "de";
|
2021-01-30 18:14:31 +00:00
|
|
|
case LANG_EN:
|
|
|
|
return "en";
|
|
|
|
case LANG_FR:
|
|
|
|
return "fr";
|
|
|
|
case LANG_ZH_CN:
|
2022-11-07 14:01:58 +00:00
|
|
|
return "zh_CN";
|
2021-03-25 01:40:22 +00:00
|
|
|
case LANG_NB_NO:
|
|
|
|
return "nb_NO";
|
2021-04-04 15:25:06 +00:00
|
|
|
case LANG_RU:
|
|
|
|
return "ru";
|
|
|
|
case LANG_ES:
|
|
|
|
return "es";
|
2021-05-13 05:24:00 +00:00
|
|
|
case LANG_JA:
|
|
|
|
return "ja";
|
|
|
|
case LANG_VI:
|
|
|
|
return "vi";
|
2021-05-22 18:44:45 +00:00
|
|
|
case LANG_TH:
|
|
|
|
return "th";
|
|
|
|
case LANG_KO:
|
|
|
|
return "ko";
|
2021-10-07 02:03:02 +00:00
|
|
|
case LANG_HU:
|
|
|
|
return "hu";
|
|
|
|
case LANG_NL:
|
|
|
|
return "nl";
|
|
|
|
case LANG_SV:
|
|
|
|
return "sv";
|
|
|
|
case LANG_TR:
|
|
|
|
return "tr";
|
|
|
|
case LANG_UK:
|
|
|
|
return "uk";
|
2022-11-25 20:18:06 +00:00
|
|
|
case LANG_ZH_TW:
|
|
|
|
return "zh_TW";
|
2022-02-20 20:14:34 +00:00
|
|
|
case LANG_PT:
|
|
|
|
return "pt";
|
|
|
|
case LANG_PT_BR:
|
|
|
|
return "pt_BR";
|
|
|
|
case LANG_EL:
|
|
|
|
return "el";
|
|
|
|
case LANG_IT:
|
|
|
|
return "it";
|
|
|
|
case LANG_HI:
|
|
|
|
return "hi";
|
2022-05-07 19:32:07 +00:00
|
|
|
case LANG_PL:
|
|
|
|
return "pl";
|
|
|
|
case LANG_CS:
|
|
|
|
return "cs";
|
2023-07-16 20:47:31 +00:00
|
|
|
case LANG_HE:
|
|
|
|
return "he";
|
2024-05-01 03:35:04 +00:00
|
|
|
case LANG_CKB:
|
|
|
|
return "ckb";
|
2024-06-29 22:17:45 +00:00
|
|
|
case LANG_LT:
|
|
|
|
return "lt";
|
2024-08-29 06:35:07 +00:00
|
|
|
case LANG_ET:
|
|
|
|
return "et";
|
2021-01-30 18:14:31 +00:00
|
|
|
case LANG_AUTO:
|
|
|
|
default:
|
|
|
|
return QLocale::system().name();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-28 06:15:13 +00:00
|
|
|
void StreamingPreferences::save()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
|
|
|
|
settings.setValue(SER_WIDTH, width);
|
|
|
|
settings.setValue(SER_HEIGHT, height);
|
|
|
|
settings.setValue(SER_FPS, fps);
|
|
|
|
settings.setValue(SER_BITRATE, bitrateKbps);
|
2024-08-20 02:43:00 +00:00
|
|
|
settings.setValue(SER_UNLOCK_BITRATE, unlockBitrate);
|
2018-08-21 05:25:19 +00:00
|
|
|
settings.setValue(SER_VSYNC, enableVsync);
|
2018-07-09 00:33:47 +00:00
|
|
|
settings.setValue(SER_GAMEOPTS, gameOptimizations);
|
2018-06-28 06:15:13 +00:00
|
|
|
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
|
|
|
settings.setValue(SER_MULTICONT, multiController);
|
2018-09-09 19:33:19 +00:00
|
|
|
settings.setValue(SER_MDNS, enableMdns);
|
2018-12-06 02:45:28 +00:00
|
|
|
settings.setValue(SER_QUITAPPAFTER, quitAppAfter);
|
2020-04-25 20:00:39 +00:00
|
|
|
settings.setValue(SER_ABSMOUSEMODE, absoluteMouseMode);
|
2020-05-01 03:55:15 +00:00
|
|
|
settings.setValue(SER_ABSTOUCHMODE, absoluteTouchMode);
|
2018-12-25 20:57:00 +00:00
|
|
|
settings.setValue(SER_FRAMEPACING, framePacing);
|
2019-03-19 03:21:52 +00:00
|
|
|
settings.setValue(SER_CONNWARNINGS, connectionWarnings);
|
2019-06-30 00:40:30 +00:00
|
|
|
settings.setValue(SER_RICHPRESENCE, richPresence);
|
2019-06-30 01:24:59 +00:00
|
|
|
settings.setValue(SER_GAMEPADMOUSE, gamepadMouse);
|
2020-01-22 03:10:10 +00:00
|
|
|
settings.setValue(SER_PACKETSIZE, packetSize);
|
2020-08-09 01:29:36 +00:00
|
|
|
settings.setValue(SER_DETECTNETBLOCKING, detectNetworkBlocking);
|
2024-05-01 02:37:52 +00:00
|
|
|
settings.setValue(SER_SHOWPERFOVERLAY, showPerformanceOverlay);
|
2018-06-28 06:15:13 +00:00
|
|
|
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
2023-07-16 20:38:58 +00:00
|
|
|
settings.setValue(SER_HDR, enableHdr);
|
2024-05-15 13:22:42 +00:00
|
|
|
settings.setValue(SER_YUV444, enableYUV444);
|
2018-06-28 06:15:13 +00:00
|
|
|
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
2018-07-09 00:33:47 +00:00
|
|
|
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
|
2018-09-04 02:17:34 +00:00
|
|
|
settings.setValue(SER_WINDOWMODE, static_cast<int>(windowMode));
|
2021-01-10 15:50:12 +00:00
|
|
|
settings.setValue(SER_UIDISPLAYMODE, static_cast<int>(uiDisplayMode));
|
2021-01-30 18:14:31 +00:00
|
|
|
settings.setValue(SER_LANGUAGE, static_cast<int>(language));
|
2019-12-07 21:27:47 +00:00
|
|
|
settings.setValue(SER_DEFAULTVER, CURRENT_DEFAULT_VER);
|
2020-08-23 14:05:00 +00:00
|
|
|
settings.setValue(SER_SWAPMOUSEBUTTONS, swapMouseButtons);
|
2021-01-09 23:56:23 +00:00
|
|
|
settings.setValue(SER_MUTEONFOCUSLOSS, muteOnFocusLoss);
|
2020-12-25 21:32:11 +00:00
|
|
|
settings.setValue(SER_BACKGROUNDGAMEPAD, backgroundGamepad);
|
2020-12-26 04:21:20 +00:00
|
|
|
settings.setValue(SER_REVERSESCROLL, reverseScrollDirection);
|
|
|
|
settings.setValue(SER_SWAPFACEBUTTONS, swapFaceButtons);
|
2021-02-27 22:47:38 +00:00
|
|
|
settings.setValue(SER_CAPTURESYSKEYS, captureSysKeysMode);
|
2022-04-24 21:49:36 +00:00
|
|
|
settings.setValue(SER_KEEPAWAKE, keepAwake);
|
2018-06-28 06:15:13 +00:00
|
|
|
}
|
|
|
|
|
2024-05-15 13:22:42 +00:00
|
|
|
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps, bool yuv444)
|
2018-06-28 06:15:13 +00:00
|
|
|
{
|
2023-09-08 05:59:33 +00:00
|
|
|
// Don't scale bitrate linearly beyond 60 FPS. It's definitely not a linear
|
2023-09-02 20:54:12 +00:00
|
|
|
// bitrate increase for frame rate once we get to values that high.
|
2023-09-08 07:04:15 +00:00
|
|
|
float frameRateFactor = (fps <= 60 ? fps : (qSqrt(fps / 60.f) * 60.f)) / 30.f;
|
2023-09-02 20:54:12 +00:00
|
|
|
|
2023-09-11 03:34:20 +00:00
|
|
|
// TODO: Collect some empirical data to see if these defaults make sense.
|
|
|
|
// We're just using the values that the Shield used, as we have for years.
|
|
|
|
static const struct resTable {
|
|
|
|
int pixels;
|
|
|
|
int factor;
|
|
|
|
} resTable[] {
|
2023-09-11 06:18:52 +00:00
|
|
|
{ 640 * 360, 1 },
|
|
|
|
{ 854 * 480, 2 },
|
|
|
|
{ 1280 * 720, 5 },
|
|
|
|
{ 1920 * 1080, 10 },
|
|
|
|
{ 2560 * 1440, 20 },
|
|
|
|
{ 3840 * 2160, 40 },
|
2023-09-11 03:34:20 +00:00
|
|
|
{ -1, -1 },
|
|
|
|
};
|
|
|
|
|
|
|
|
// Calculate the resolution factor by linear interpolation of the resolution table
|
2023-09-11 06:18:52 +00:00
|
|
|
float resolutionFactor;
|
2023-09-11 03:34:20 +00:00
|
|
|
int pixels = width * height;
|
|
|
|
for (int i = 0;; i++) {
|
|
|
|
if (pixels == resTable[i].pixels) {
|
|
|
|
// We can bail immediately for exact matches
|
|
|
|
resolutionFactor = resTable[i].factor;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (pixels < resTable[i].pixels) {
|
|
|
|
if (i == 0) {
|
|
|
|
// Never go below the lowest resolution entry
|
|
|
|
resolutionFactor = resTable[i].factor;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Interpolate between the entry greater than the chosen resolution (i) and the entry less than the chosen resolution (i-1)
|
|
|
|
resolutionFactor = ((float)(pixels - resTable[i-1].pixels) / (resTable[i].pixels - resTable[i-1].pixels)) * (resTable[i].factor - resTable[i-1].factor) + resTable[i-1].factor;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (resTable[i].pixels == -1) {
|
|
|
|
// Never go above the highest resolution entry
|
|
|
|
resolutionFactor = resTable[i-1].factor;
|
|
|
|
break;
|
|
|
|
}
|
2018-06-28 06:15:13 +00:00
|
|
|
}
|
2023-09-03 01:05:27 +00:00
|
|
|
|
2024-05-15 13:22:42 +00:00
|
|
|
if (yuv444) {
|
|
|
|
// This is rough estimation based on the fact that 4:4:4 doubles the amount of raw YUV data compared to 4:2:0
|
|
|
|
resolutionFactor *= 2;
|
|
|
|
}
|
|
|
|
|
2023-09-11 06:18:52 +00:00
|
|
|
return qRound(resolutionFactor * frameRateFactor) * 1000;
|
2018-06-28 06:15:13 +00:00
|
|
|
}
|