From 979de190dca77418aa9d1958c39432320f9164d9 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 23 Feb 2020 00:43:43 -0800 Subject: [PATCH] Cap resolution options at 1080p on Steam Link and Raspberry Pi due to hardware limitations --- app/backend/systemproperties.cpp | 2 +- app/backend/systemproperties.h | 2 ++ app/gui/SettingsView.qml | 14 ++++++++++++++ app/streaming/session.cpp | 3 ++- app/streaming/session.h | 2 +- app/streaming/video/decoder.h | 1 + app/streaming/video/ffmpeg-renderers/mmal.cpp | 4 ++-- app/streaming/video/ffmpeg-renderers/renderer.h | 1 + app/streaming/video/ffmpeg.cpp | 11 +++++++++++ app/streaming/video/ffmpeg.h | 1 + app/streaming/video/slvid.cpp | 5 +++++ app/streaming/video/slvid.h | 1 + 12 files changed, 42 insertions(+), 5 deletions(-) diff --git a/app/backend/systemproperties.cpp b/app/backend/systemproperties.cpp index 6af1c8e4..10fc58c1 100644 --- a/app/backend/systemproperties.cpp +++ b/app/backend/systemproperties.cpp @@ -114,7 +114,7 @@ void SystemProperties::querySdlVideoInfo() return; } - Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen); + Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen, maximumResolution); SDL_DestroyWindow(testWindow); diff --git a/app/backend/systemproperties.h b/app/backend/systemproperties.h index fcda3825..02cf3c58 100644 --- a/app/backend/systemproperties.h +++ b/app/backend/systemproperties.h @@ -20,6 +20,7 @@ public: Q_PROPERTY(bool hasDiscordIntegration MEMBER hasDiscordIntegration CONSTANT) Q_PROPERTY(QString unmappedGamepads MEMBER unmappedGamepads NOTIFY unmappedGamepadsChanged) Q_PROPERTY(int maximumStreamingFrameRate MEMBER maximumStreamingFrameRate CONSTANT) + Q_PROPERTY(QSize maximumResolution MEMBER maximumResolution CONSTANT) Q_INVOKABLE QRect getDesktopResolution(int displayIndex); Q_INVOKABLE QRect getNativeResolution(int displayIndex); @@ -40,6 +41,7 @@ private: bool hasDiscordIntegration; QString unmappedGamepads; int maximumStreamingFrameRate; + QSize maximumResolution; QList monitorDesktopResolutions; QList monitorNativeResolutions; }; diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index dd15b946..d17416f2 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -131,6 +131,20 @@ Flickable { } } + // Prune resolutions that are over the decoder's maximum + var max_pixels = SystemProperties.maximumResolution.width * SystemProperties.maximumResolution.height; + if (max_pixels > 0) { + for (var j = 0; j < resolutionComboBox.count; j++) { + var existing_width = parseInt(resolutionListModel.get(j).video_width); + var existing_height = parseInt(resolutionListModel.get(j).video_height); + + if (existing_width * existing_height > max_pixels) { + resolutionListModel.remove(j) + j-- + } + } + } + // load the saved width/height, and iterate through the ComboBox until a match is found // and set it to that index. var saved_width = StreamingPreferences.width diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 774defc9..7c605a2b 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -253,7 +253,7 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du) } void Session::getDecoderInfo(SDL_Window* window, - bool& isHardwareAccelerated, bool& isFullScreenOnly) + bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution) { IVideoDecoder* decoder; @@ -266,6 +266,7 @@ void Session::getDecoderInfo(SDL_Window* window, isHardwareAccelerated = decoder->isHardwareAccelerated(); isFullScreenOnly = decoder->isAlwaysFullScreen(); + maxResolution = decoder->getDecoderMaxResolution(); delete decoder; } diff --git a/app/streaming/session.h b/app/streaming/session.h index 064aff1d..4d977691 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -26,7 +26,7 @@ public: static void getDecoderInfo(SDL_Window* window, - bool& isHardwareAccelerated, bool& isFullScreenOnly); + bool& isHardwareAccelerated, bool& isFullScreenOnly, QSize& maxResolution); static Session* get() { diff --git a/app/streaming/video/decoder.h b/app/streaming/video/decoder.h index 59cb2dfc..b3e67f02 100644 --- a/app/streaming/video/decoder.h +++ b/app/streaming/video/decoder.h @@ -46,6 +46,7 @@ public: virtual bool isAlwaysFullScreen() = 0; virtual int getDecoderCapabilities() = 0; virtual int getDecoderColorspace() = 0; + virtual QSize getDecoderMaxResolution() = 0; virtual int submitDecodeUnit(PDECODE_UNIT du) = 0; virtual void renderFrameOnMainThread() = 0; }; diff --git a/app/streaming/video/ffmpeg-renderers/mmal.cpp b/app/streaming/video/ffmpeg-renderers/mmal.cpp index 972ad7ff..cb228e5d 100644 --- a/app/streaming/video/ffmpeg-renderers/mmal.cpp +++ b/app/streaming/video/ffmpeg-renderers/mmal.cpp @@ -134,8 +134,8 @@ enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat) int MmalRenderer::getRendererAttributes() { - // This renderer can only draw in full-screen - return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY; + // This renderer can only draw in full-screen and maxes out at 1080p + return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY | RENDERER_ATTRIBUTE_1080P_MAX; } bool MmalRenderer::needsTestFrame() diff --git a/app/streaming/video/ffmpeg-renderers/renderer.h b/app/streaming/video/ffmpeg-renderers/renderer.h index cd798415..291321e4 100644 --- a/app/streaming/video/ffmpeg-renderers/renderer.h +++ b/app/streaming/video/ffmpeg-renderers/renderer.h @@ -10,6 +10,7 @@ extern "C" { } #define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01 +#define RENDERER_ATTRIBUTE_1080P_MAX 0x02 class IFFmpegRenderer : public Overlay::IOverlayRenderer { public: diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 07abe7f8..8347842f 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -71,6 +71,17 @@ int FFmpegVideoDecoder::getDecoderColorspace() return m_FrontendRenderer->getDecoderColorspace(); } +QSize FFmpegVideoDecoder::getDecoderMaxResolution() +{ + if (m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_1080P_MAX) { + return QSize(1920, 1080); + } + else { + // No known maximum + return QSize(0, 0); + } +} + enum AVPixelFormat FFmpegVideoDecoder::ffGetFormat(AVCodecContext* context, const enum AVPixelFormat* pixFmts) { diff --git a/app/streaming/video/ffmpeg.h b/app/streaming/video/ffmpeg.h index dcc8912d..9e91f9eb 100644 --- a/app/streaming/video/ffmpeg.h +++ b/app/streaming/video/ffmpeg.h @@ -19,6 +19,7 @@ public: virtual bool isAlwaysFullScreen() override; virtual int getDecoderCapabilities() override; virtual int getDecoderColorspace() override; + virtual QSize getDecoderMaxResolution() override; virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual void renderFrameOnMainThread() override; diff --git a/app/streaming/video/slvid.cpp b/app/streaming/video/slvid.cpp index 8aca6590..234c420d 100644 --- a/app/streaming/video/slvid.cpp +++ b/app/streaming/video/slvid.cpp @@ -42,6 +42,11 @@ SLVideoDecoder::getDecoderColorspace() return COLORSPACE_REC_709; } +QSize SLVideoDecoder::getDecoderMaxResolution() +{ + return QSize(1920, 1080); +} + bool SLVideoDecoder::initialize(PDECODER_PARAMETERS params) { diff --git a/app/streaming/video/slvid.h b/app/streaming/video/slvid.h index 961269e3..145b985f 100644 --- a/app/streaming/video/slvid.h +++ b/app/streaming/video/slvid.h @@ -14,6 +14,7 @@ public: virtual bool isAlwaysFullScreen(); virtual int getDecoderCapabilities(); virtual int getDecoderColorspace(); + virtual QSize getDecoderMaxResolution(); virtual int submitDecodeUnit(PDECODE_UNIT du); // Unused since rendering is done directly from the decode thread