diff --git a/app/backend/systemproperties.cpp b/app/backend/systemproperties.cpp index 49017d31..db7323fd 100644 --- a/app/backend/systemproperties.cpp +++ b/app/backend/systemproperties.cpp @@ -114,11 +114,7 @@ void SystemProperties::querySdlVideoInfo() return; } - hasHardwareAcceleration = - Session::isHardwareDecodeAvailable(testWindow, - StreamingPreferences::VDS_AUTO, - VIDEO_FORMAT_H264, - 1920, 1080, 60); + Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen); SDL_DestroyWindow(testWindow); diff --git a/app/backend/systemproperties.h b/app/backend/systemproperties.h index 7b9263ff..fcda3825 100644 --- a/app/backend/systemproperties.h +++ b/app/backend/systemproperties.h @@ -11,6 +11,7 @@ public: SystemProperties(); Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT) + Q_PROPERTY(bool rendererAlwaysFullScreen MEMBER rendererAlwaysFullScreen CONSTANT) Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT) @@ -30,6 +31,7 @@ private: void querySdlVideoInfo(); bool hasHardwareAcceleration; + bool rendererAlwaysFullScreen; bool isRunningWayland; bool isRunningXWayland; bool isWow64; diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index c8e4cef7..816b62ac 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -340,7 +340,7 @@ Flickable { currentIndex = 0 - if (SystemProperties.hasWindowManager) { + if (SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen) { var savedWm = StreamingPreferences.windowMode for (var i = 0; i < windowModeListModel.count; i++) { var thisWm = windowModeListModel.get(i).val; @@ -355,7 +355,7 @@ Flickable { } id: windowModeComboBox - enabled: SystemProperties.hasWindowManager + enabled: SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen hoverEnabled: true textRole: "text" model: ListModel { diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 30a60c11..f6c3c948 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -252,6 +252,24 @@ int Session::drSubmitDecodeUnit(PDECODE_UNIT du) } } +void Session::getDecoderInfo(SDL_Window* window, + bool& isHardwareAccelerated, bool& isFullScreenOnly) +{ + IVideoDecoder* decoder; + + if (!chooseDecoder(StreamingPreferences::VDS_AUTO, + window, VIDEO_FORMAT_H264, 1920, 1080, 60, + true, false, true, decoder)) { + isHardwareAccelerated = isFullScreenOnly = false; + return; + } + + isHardwareAccelerated = decoder->isHardwareAccelerated(); + isFullScreenOnly = decoder->isAlwaysFullScreen(); + + delete decoder; +} + bool Session::isHardwareDecodeAvailable(SDL_Window* window, StreamingPreferences::VideoDecoderSelection vds, int videoFormat, int width, int height, int frameRate) diff --git a/app/streaming/session.h b/app/streaming/session.h index a9a9a8c4..064aff1d 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -25,9 +25,8 @@ public: Q_INVOKABLE void exec(int displayOriginX, int displayOriginY); static - bool isHardwareDecodeAvailable(SDL_Window* window, - StreamingPreferences::VideoDecoderSelection vds, - int videoFormat, int width, int height, int frameRate); + void getDecoderInfo(SDL_Window* window, + bool& isHardwareAccelerated, bool& isFullScreenOnly); static Session* get() { @@ -78,6 +77,11 @@ private: void updateOptimalWindowDisplayMode(); + static + bool isHardwareDecodeAvailable(SDL_Window* window, + StreamingPreferences::VideoDecoderSelection vds, + int videoFormat, int width, int height, int frameRate); + static bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds, SDL_Window* window, int videoFormat, int width, int height, diff --git a/app/streaming/video/decoder.h b/app/streaming/video/decoder.h index b0a6ba03..59cb2dfc 100644 --- a/app/streaming/video/decoder.h +++ b/app/streaming/video/decoder.h @@ -43,6 +43,7 @@ public: virtual ~IVideoDecoder() {} virtual bool initialize(PDECODER_PARAMETERS params) = 0; virtual bool isHardwareAccelerated() = 0; + virtual bool isAlwaysFullScreen() = 0; virtual int getDecoderCapabilities() = 0; virtual int getDecoderColorspace() = 0; virtual int submitDecodeUnit(PDECODE_UNIT du) = 0; diff --git a/app/streaming/video/ffmpeg-renderers/drm.cpp b/app/streaming/video/ffmpeg-renderers/drm.cpp index bf57963b..d6a6c8dd 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.cpp +++ b/app/streaming/video/ffmpeg-renderers/drm.cpp @@ -194,6 +194,12 @@ enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int) return AV_PIX_FMT_DRM_PRIME; } +int DrmRenderer::getRendererAttributes() +{ + // This renderer can only draw in full-screen + return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY; +} + void DrmRenderer::renderFrame(AVFrame* frame) { AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0]; diff --git a/app/streaming/video/ffmpeg-renderers/drm.h b/app/streaming/video/ffmpeg-renderers/drm.h index f9f90199..7d88e223 100644 --- a/app/streaming/video/ffmpeg-renderers/drm.h +++ b/app/streaming/video/ffmpeg-renderers/drm.h @@ -13,6 +13,7 @@ public: virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override; virtual void renderFrame(AVFrame* frame) override; virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override; + virtual int getRendererAttributes() override; private: int m_DrmFd; diff --git a/app/streaming/video/ffmpeg-renderers/mmal.cpp b/app/streaming/video/ffmpeg-renderers/mmal.cpp index 1c6099a0..32f06d70 100644 --- a/app/streaming/video/ffmpeg-renderers/mmal.cpp +++ b/app/streaming/video/ffmpeg-renderers/mmal.cpp @@ -127,6 +127,12 @@ enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat) return AV_PIX_FMT_MMAL; } +int MmalRenderer::getRendererAttributes() +{ + // This renderer can only draw in full-screen + return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY; +} + bool MmalRenderer::needsTestFrame() { // We won't be able to decode if the GPU memory is 64 MB or lower, diff --git a/app/streaming/video/ffmpeg-renderers/mmal.h b/app/streaming/video/ffmpeg-renderers/mmal.h index cc94e850..2571aa69 100644 --- a/app/streaming/video/ffmpeg-renderers/mmal.h +++ b/app/streaming/video/ffmpeg-renderers/mmal.h @@ -16,6 +16,7 @@ public: virtual void renderFrame(AVFrame* frame) override; virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override; virtual bool needsTestFrame() override; + virtual int getRendererAttributes() override; private: static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer); diff --git a/app/streaming/video/ffmpeg-renderers/renderer.h b/app/streaming/video/ffmpeg-renderers/renderer.h index 6a072fc9..cd798415 100644 --- a/app/streaming/video/ffmpeg-renderers/renderer.h +++ b/app/streaming/video/ffmpeg-renderers/renderer.h @@ -9,14 +9,10 @@ extern "C" { #include } +#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01 + class IFFmpegRenderer : public Overlay::IOverlayRenderer { public: - enum FramePacingConstraint { - PACING_FORCE_OFF, - PACING_FORCE_ON, - PACING_ANY - }; - virtual bool initialize(PDECODER_PARAMETERS params) = 0; virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0; virtual void renderFrame(AVFrame* frame) = 0; @@ -31,16 +27,16 @@ public: return 0; } + virtual int getRendererAttributes() { + // No special attributes by default + return 0; + } + virtual int getDecoderColorspace() { // Rec 601 is default return COLORSPACE_REC_601; } - virtual FramePacingConstraint getFramePacingConstraint() { - // No pacing preference - return PACING_ANY; - } - virtual bool isRenderThreadSupported() { // Render thread is supported by default return true; diff --git a/app/streaming/video/ffmpeg.cpp b/app/streaming/video/ffmpeg.cpp index 280bc003..07abe7f8 100644 --- a/app/streaming/video/ffmpeg.cpp +++ b/app/streaming/video/ffmpeg.cpp @@ -45,6 +45,11 @@ bool FFmpegVideoDecoder::isHardwareAccelerated() (m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0; } +bool FFmpegVideoDecoder::isAlwaysFullScreen() +{ + return m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_FULLSCREEN_ONLY; +} + int FFmpegVideoDecoder::getDecoderCapabilities() { int capabilities = m_BackendRenderer->getDecoderCapabilities(); @@ -187,23 +192,6 @@ bool FFmpegVideoDecoder::createFrontendRenderer(PDECODER_PARAMETERS params) } } - // Determine whether the frontend renderer prefers frame pacing - auto vsyncConstraint = m_FrontendRenderer->getFramePacingConstraint(); - if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_OFF && params->enableFramePacing) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Frame pacing is forcefully disabled by the frontend renderer"); - params->enableFramePacing = false; - } - else if (vsyncConstraint == IFFmpegRenderer::PACING_FORCE_ON && !params->enableFramePacing) { - // FIXME: This duplicates logic in Session.cpp - int displayHz = StreamUtils::getDisplayRefreshRate(params->window); - if (displayHz + 5 >= params->frameRate) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Frame pacing is forcefully enabled by the frontend renderer"); - params->enableFramePacing = true; - } - } - return true; } diff --git a/app/streaming/video/ffmpeg.h b/app/streaming/video/ffmpeg.h index ca55e812..dcc8912d 100644 --- a/app/streaming/video/ffmpeg.h +++ b/app/streaming/video/ffmpeg.h @@ -16,6 +16,7 @@ public: virtual ~FFmpegVideoDecoder() override; virtual bool initialize(PDECODER_PARAMETERS params) override; virtual bool isHardwareAccelerated() override; + virtual bool isAlwaysFullScreen() override; virtual int getDecoderCapabilities() override; virtual int getDecoderColorspace() override; virtual int submitDecodeUnit(PDECODE_UNIT du) override; diff --git a/app/streaming/video/slvid.cpp b/app/streaming/video/slvid.cpp index f8423884..8aca6590 100644 --- a/app/streaming/video/slvid.cpp +++ b/app/streaming/video/slvid.cpp @@ -25,6 +25,11 @@ SLVideoDecoder::isHardwareAccelerated() return true; } +bool SLVideoDecoder::isAlwaysFullScreen() +{ + return true; +} + int SLVideoDecoder::getDecoderCapabilities() { diff --git a/app/streaming/video/slvid.h b/app/streaming/video/slvid.h index dc6796d0..961269e3 100644 --- a/app/streaming/video/slvid.h +++ b/app/streaming/video/slvid.h @@ -11,6 +11,7 @@ public: virtual ~SLVideoDecoder(); virtual bool initialize(PDECODER_PARAMETERS params); virtual bool isHardwareAccelerated(); + virtual bool isAlwaysFullScreen(); virtual int getDecoderCapabilities(); virtual int getDecoderColorspace(); virtual int submitDecodeUnit(PDECODE_UNIT du);