diff --git a/app/main.cpp b/app/main.cpp index c9ab990c..0191d5ca 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -11,6 +11,7 @@ #include "gui/computermodel.h" #include "gui/appmodel.h" #include "streaming/session.hpp" +#include "settings/streamingpreferences.h" int main(int argc, char *argv[]) { @@ -36,6 +37,7 @@ int main(int argc, char *argv[]) // Register our C++ types for QML qmlRegisterType("ComputerModel", 1, 0, "ComputerModel"); qmlRegisterType("AppModel", 1, 0, "AppModel"); + qmlRegisterType("StreamingPreferences", 1, 0, "StreamingPreferences"); qmlRegisterUncreatableType("Session", 1, 0, "Session", "Session cannot be created from QML"); qmlRegisterSingletonType("ComputerManager", 1, 0, "ComputerManager", diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index 1e41aacd..51907b87 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -13,6 +13,7 @@ #define SER_MULTICONT "multicontroller" #define SER_AUDIOCFG "audiocfg" #define SER_VIDEOCFG "videocfg" +#define SER_VIDEODEC "videodec" StreamingPreferences::StreamingPreferences() { @@ -28,13 +29,15 @@ void StreamingPreferences::reload() 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(); + gameOptimizations = settings.value(SER_GAMEOPTS, true).toBool(); playAudioOnHost = settings.value(SER_HOSTAUDIO, false).toBool(); multiController = settings.value(SER_MULTICONT, true).toBool(); audioConfig = static_cast(settings.value(SER_AUDIOCFG, static_cast(AudioConfig::AC_AUTO)).toInt()); videoCodecConfig = static_cast(settings.value(SER_VIDEOCFG, static_cast(VideoCodecConfig::VCC_AUTO)).toInt()); + videoDecoderSelection = static_cast(settings.value(SER_VIDEODEC, + static_cast(VideoDecoderSelection::VDS_AUTO)).toInt()); } void StreamingPreferences::save() @@ -46,11 +49,12 @@ void StreamingPreferences::save() settings.setValue(SER_FPS, fps); settings.setValue(SER_BITRATE, bitrateKbps); settings.setValue(SER_FULLSCREEN, fullScreen); - settings.setValue(SER_GAMEOPTS, enableGameOptimizations); + settings.setValue(SER_GAMEOPTS, gameOptimizations); settings.setValue(SER_HOSTAUDIO, playAudioOnHost); settings.setValue(SER_MULTICONT, multiController); settings.setValue(SER_AUDIOCFG, static_cast(audioConfig)); settings.setValue(SER_VIDEOCFG, static_cast(videoCodecConfig)); + settings.setValue(SER_VIDEODEC, static_cast(videoDecoderSelection)); } int StreamingPreferences::getDefaultBitrate(int width, int height, int fps) diff --git a/app/settings/streamingpreferences.h b/app/settings/streamingpreferences.h index 48cd8c28..41d9fb87 100644 --- a/app/settings/streamingpreferences.h +++ b/app/settings/streamingpreferences.h @@ -1,14 +1,18 @@ #pragma once -class StreamingPreferences +#include + +class StreamingPreferences : public QObject { + Q_OBJECT + public: StreamingPreferences(); - static int + Q_INVOKABLE static int getDefaultBitrate(int width, int height, int fps); - void save(); + Q_INVOKABLE void save(); void reload(); @@ -18,6 +22,7 @@ public: AC_FORCE_STEREO, AC_FORCE_SURROUND }; + Q_ENUM(AudioConfig) enum VideoCodecConfig { @@ -26,6 +31,27 @@ public: VCC_FORCE_HEVC, VCC_FORCE_HEVC_HDR }; + Q_ENUM(VideoCodecConfig) + + enum VideoDecoderSelection + { + VDS_AUTO, + VDS_FORCE_HARDWARE, + VDS_FORCE_SOFTWARE + }; + Q_ENUM(VideoDecoderSelection) + + Q_PROPERTY(int width MEMBER width NOTIFY resolutionOrFpsChanged) + Q_PROPERTY(int height MEMBER height NOTIFY resolutionOrFpsChanged) + Q_PROPERTY(int fps MEMBER fps NOTIFY resolutionOrFpsChanged) + Q_PROPERTY(int bitrateKbps MEMBER bitrateKbps NOTIFY bitrateChanged) + Q_PROPERTY(bool fullScreen MEMBER fullScreen NOTIFY fullScreenChanged) + Q_PROPERTY(bool gameOptimizations MEMBER gameOptimizations NOTIFY gameOptimizationsChanged) + Q_PROPERTY(bool playAudioOnHost MEMBER playAudioOnHost NOTIFY playAudioOnHostChanged) + Q_PROPERTY(bool multiController MEMBER multiController NOTIFY multiControllerChanged) + Q_PROPERTY(AudioConfig audioConfig MEMBER audioConfig NOTIFY audioConfigChanged) + Q_PROPERTY(VideoCodecConfig videoCodecConfig MEMBER videoCodecConfig NOTIFY videoCodecConfigChanged) + Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged) // Directly accessible members for preferences int width; @@ -33,10 +59,22 @@ public: int fps; int bitrateKbps; bool fullScreen; - bool enableGameOptimizations; + bool gameOptimizations; bool playAudioOnHost; bool multiController; AudioConfig audioConfig; VideoCodecConfig videoCodecConfig; + VideoDecoderSelection videoDecoderSelection; + +signals: + void resolutionOrFpsChanged(); + void bitrateChanged(); + void fullScreenChanged(); + void gameOptimizationsChanged(); + void playAudioOnHostChanged(); + void multiControllerChanged(); + void audioConfigChanged(); + void videoCodecConfigChanged(); + void videoDecoderSelectionChanged(); }; diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index dc84f1b8..ee82a9df 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -203,7 +203,7 @@ void Session::exec() } else { http.launchApp(m_App.id, &m_StreamConfig, - prefs.enableGameOptimizations, + prefs.gameOptimizations, prefs.playAudioOnHost, inputHandler.getAttachedGamepadMask()); }