mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-12-13 12:52:27 +00:00
Add StreamingPreferences class
This commit is contained in:
parent
6fa4faa285
commit
6e4104ac15
3 changed files with 122 additions and 2 deletions
|
@ -62,7 +62,8 @@ SOURCES += \
|
|||
streaming/video.c \
|
||||
streaming/connection.cpp \
|
||||
backend/computermanager.cpp \
|
||||
backend/boxartmanager.cpp
|
||||
backend/boxartmanager.cpp \
|
||||
settings/streamingpreferences.cpp
|
||||
|
||||
HEADERS += \
|
||||
utils.h \
|
||||
|
@ -73,7 +74,8 @@ HEADERS += \
|
|||
backend/nvpairingmanager.h \
|
||||
streaming/streaming.h \
|
||||
backend/computermanager.h \
|
||||
backend/boxartmanager.h
|
||||
backend/boxartmanager.h \
|
||||
settings/streamingpreferences.h
|
||||
|
||||
FORMS += \
|
||||
gui/mainwindow.ui
|
||||
|
|
76
app/settings/streamingpreferences.cpp
Normal file
76
app/settings/streamingpreferences.cpp
Normal file
|
@ -0,0 +1,76 @@
|
|||
#include "streamingpreferences.h"
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#define SER_STREAMSETTINGS "streamsettings"
|
||||
#define SER_WIDTH "width"
|
||||
#define SER_HEIGHT "height"
|
||||
#define SER_FPS "fps"
|
||||
#define SER_BITRATE "bitrate"
|
||||
#define SER_FULLSCREEN "fullscreen"
|
||||
#define SER_GAMEOPTS "gameopts"
|
||||
#define SER_HOSTAUDIO "hostaudio"
|
||||
#define SER_MULTICONT "multicontroller"
|
||||
#define SER_AUDIOCFG "audiocfg"
|
||||
#define SER_VIDEOCFG "videocfg"
|
||||
|
||||
StreamingPreferences::StreamingPreferences()
|
||||
{
|
||||
reload();
|
||||
}
|
||||
|
||||
void StreamingPreferences::reload()
|
||||
{
|
||||
QSettings settings;
|
||||
|
||||
width = settings.value(SER_WIDTH, 1280).toInt();
|
||||
height = settings.value(SER_HEIGHT, 720).toInt();
|
||||
fps = settings.value(SER_FPS, 60).toInt();
|
||||
bitrateKbps = settings.value(SER_BITRATE, getDefaultBitrate(width, height, fps)).toInt();
|
||||
fullScreen = settings.value(SER_FULLSCREEN, true).toBool();
|
||||
enableGameOptimizations = settings.value(SER_GAMEOPTS, true).toBool();
|
||||
playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool();
|
||||
multiController = settings.value(SER_MULTICONT, true).toBool();
|
||||
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
|
||||
static_cast<int>(AudioConfig::AC_AUTO)).toInt());
|
||||
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
|
||||
static_cast<int>(VideoCodecConfig::VCC_AUTO)).toInt());
|
||||
}
|
||||
|
||||
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);
|
||||
settings.setValue(SER_FULLSCREEN, fullScreen);
|
||||
settings.setValue(SER_GAMEOPTS, enableGameOptimizations);
|
||||
settings.setValue(SER_HOSTAUDIO, playAudioOnHost);
|
||||
settings.setValue(SER_MULTICONT, multiController);
|
||||
settings.setValue(SER_AUDIOCFG, static_cast<int>(audioConfig));
|
||||
settings.setValue(SER_VIDEOCFG, static_cast<int>(videoCodecConfig));
|
||||
}
|
||||
|
||||
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)
|
||||
{
|
||||
if (width * height * fps <= 1280 * 720 * 30) {
|
||||
return 5000;
|
||||
}
|
||||
else if (width * height * fps <= 1280 * 720 * 60) {
|
||||
return 10000;
|
||||
}
|
||||
else if (width * height * fps <= 1920 * 1080 * 30) {
|
||||
return 10000;
|
||||
}
|
||||
else if (width * height * fps <= 1920 * 1080 * 60) {
|
||||
return 20000;
|
||||
}
|
||||
else if (width * height * fps <= 3840 * 2160 * 30) {
|
||||
return 40000;
|
||||
}
|
||||
else /* if (width * height * fps <= 3840 * 2160 * 60) */ {
|
||||
return 80000;
|
||||
}
|
||||
}
|
42
app/settings/streamingpreferences.h
Normal file
42
app/settings/streamingpreferences.h
Normal file
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
class StreamingPreferences
|
||||
{
|
||||
public:
|
||||
StreamingPreferences();
|
||||
|
||||
static int
|
||||
getDefaultBitrate(int width, int height, int fps);
|
||||
|
||||
void save();
|
||||
|
||||
void reload();
|
||||
|
||||
enum AudioConfig
|
||||
{
|
||||
AC_AUTO,
|
||||
AC_FORCE_STEREO,
|
||||
AC_FORCE_SURROUND
|
||||
};
|
||||
|
||||
enum VideoCodecConfig
|
||||
{
|
||||
VCC_AUTO,
|
||||
VCC_FORCE_H264,
|
||||
VCC_FORCE_HEVC,
|
||||
VCC_FORCE_HEVC_HDR
|
||||
};
|
||||
|
||||
// Directly accessible members for preferences
|
||||
int width;
|
||||
int height;
|
||||
int fps;
|
||||
int bitrateKbps;
|
||||
bool fullScreen;
|
||||
bool enableGameOptimizations;
|
||||
bool playAudioOnHost;
|
||||
bool multiController;
|
||||
AudioConfig audioConfig;
|
||||
VideoCodecConfig videoCodecConfig;
|
||||
};
|
||||
|
Loading…
Reference in a new issue