Disable the window mode options for always full-screen renderers

This commit is contained in:
Cameron Gutman 2020-02-09 11:35:05 -08:00
parent 5b7e2521cc
commit 57a1c5eb76
15 changed files with 64 additions and 38 deletions

View File

@ -114,11 +114,7 @@ void SystemProperties::querySdlVideoInfo()
return; return;
} }
hasHardwareAcceleration = Session::getDecoderInfo(testWindow, hasHardwareAcceleration, rendererAlwaysFullScreen);
Session::isHardwareDecodeAvailable(testWindow,
StreamingPreferences::VDS_AUTO,
VIDEO_FORMAT_H264,
1920, 1080, 60);
SDL_DestroyWindow(testWindow); SDL_DestroyWindow(testWindow);

View File

@ -11,6 +11,7 @@ public:
SystemProperties(); SystemProperties();
Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT) Q_PROPERTY(bool hasHardwareAcceleration MEMBER hasHardwareAcceleration CONSTANT)
Q_PROPERTY(bool rendererAlwaysFullScreen MEMBER rendererAlwaysFullScreen CONSTANT)
Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT) Q_PROPERTY(bool isRunningWayland MEMBER isRunningWayland CONSTANT)
Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT) Q_PROPERTY(bool isRunningXWayland MEMBER isRunningXWayland CONSTANT)
Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT) Q_PROPERTY(bool isWow64 MEMBER isWow64 CONSTANT)
@ -30,6 +31,7 @@ private:
void querySdlVideoInfo(); void querySdlVideoInfo();
bool hasHardwareAcceleration; bool hasHardwareAcceleration;
bool rendererAlwaysFullScreen;
bool isRunningWayland; bool isRunningWayland;
bool isRunningXWayland; bool isRunningXWayland;
bool isWow64; bool isWow64;

View File

@ -340,7 +340,7 @@ Flickable {
currentIndex = 0 currentIndex = 0
if (SystemProperties.hasWindowManager) { if (SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen) {
var savedWm = StreamingPreferences.windowMode var savedWm = StreamingPreferences.windowMode
for (var i = 0; i < windowModeListModel.count; i++) { for (var i = 0; i < windowModeListModel.count; i++) {
var thisWm = windowModeListModel.get(i).val; var thisWm = windowModeListModel.get(i).val;
@ -355,7 +355,7 @@ Flickable {
} }
id: windowModeComboBox id: windowModeComboBox
enabled: SystemProperties.hasWindowManager enabled: SystemProperties.hasWindowManager && !SystemProperties.rendererAlwaysFullScreen
hoverEnabled: true hoverEnabled: true
textRole: "text" textRole: "text"
model: ListModel { model: ListModel {

View File

@ -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, bool Session::isHardwareDecodeAvailable(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds, StreamingPreferences::VideoDecoderSelection vds,
int videoFormat, int width, int height, int frameRate) int videoFormat, int width, int height, int frameRate)

View File

@ -25,9 +25,8 @@ public:
Q_INVOKABLE void exec(int displayOriginX, int displayOriginY); Q_INVOKABLE void exec(int displayOriginX, int displayOriginY);
static static
bool isHardwareDecodeAvailable(SDL_Window* window, void getDecoderInfo(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds, bool& isHardwareAccelerated, bool& isFullScreenOnly);
int videoFormat, int width, int height, int frameRate);
static Session* get() static Session* get()
{ {
@ -78,6 +77,11 @@ private:
void updateOptimalWindowDisplayMode(); void updateOptimalWindowDisplayMode();
static
bool isHardwareDecodeAvailable(SDL_Window* window,
StreamingPreferences::VideoDecoderSelection vds,
int videoFormat, int width, int height, int frameRate);
static static
bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds, bool chooseDecoder(StreamingPreferences::VideoDecoderSelection vds,
SDL_Window* window, int videoFormat, int width, int height, SDL_Window* window, int videoFormat, int width, int height,

View File

@ -43,6 +43,7 @@ public:
virtual ~IVideoDecoder() {} virtual ~IVideoDecoder() {}
virtual bool initialize(PDECODER_PARAMETERS params) = 0; virtual bool initialize(PDECODER_PARAMETERS params) = 0;
virtual bool isHardwareAccelerated() = 0; virtual bool isHardwareAccelerated() = 0;
virtual bool isAlwaysFullScreen() = 0;
virtual int getDecoderCapabilities() = 0; virtual int getDecoderCapabilities() = 0;
virtual int getDecoderColorspace() = 0; virtual int getDecoderColorspace() = 0;
virtual int submitDecodeUnit(PDECODE_UNIT du) = 0; virtual int submitDecodeUnit(PDECODE_UNIT du) = 0;

View File

@ -194,6 +194,12 @@ enum AVPixelFormat DrmRenderer::getPreferredPixelFormat(int)
return AV_PIX_FMT_DRM_PRIME; 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) void DrmRenderer::renderFrame(AVFrame* frame)
{ {
AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0]; AVDRMFrameDescriptor* drmFrame = (AVDRMFrameDescriptor*)frame->data[0];

View File

@ -13,6 +13,7 @@ public:
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override; virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) override;
virtual void renderFrame(AVFrame* frame) override; virtual void renderFrame(AVFrame* frame) override;
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override; virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
virtual int getRendererAttributes() override;
private: private:
int m_DrmFd; int m_DrmFd;

View File

@ -127,6 +127,12 @@ enum AVPixelFormat MmalRenderer::getPreferredPixelFormat(int videoFormat)
return AV_PIX_FMT_MMAL; return AV_PIX_FMT_MMAL;
} }
int MmalRenderer::getRendererAttributes()
{
// This renderer can only draw in full-screen
return RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
}
bool MmalRenderer::needsTestFrame() bool MmalRenderer::needsTestFrame()
{ {
// We won't be able to decode if the GPU memory is 64 MB or lower, // We won't be able to decode if the GPU memory is 64 MB or lower,

View File

@ -16,6 +16,7 @@ public:
virtual void renderFrame(AVFrame* frame) override; virtual void renderFrame(AVFrame* frame) override;
virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override; virtual enum AVPixelFormat getPreferredPixelFormat(int videoFormat) override;
virtual bool needsTestFrame() override; virtual bool needsTestFrame() override;
virtual int getRendererAttributes() override;
private: private:
static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer); static void InputPortCallback(MMAL_PORT_T* port, MMAL_BUFFER_HEADER_T* buffer);

View File

@ -9,14 +9,10 @@ extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
} }
#define RENDERER_ATTRIBUTE_FULLSCREEN_ONLY 0x01
class IFFmpegRenderer : public Overlay::IOverlayRenderer { class IFFmpegRenderer : public Overlay::IOverlayRenderer {
public: public:
enum FramePacingConstraint {
PACING_FORCE_OFF,
PACING_FORCE_ON,
PACING_ANY
};
virtual bool initialize(PDECODER_PARAMETERS params) = 0; virtual bool initialize(PDECODER_PARAMETERS params) = 0;
virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0; virtual bool prepareDecoderContext(AVCodecContext* context, AVDictionary** options) = 0;
virtual void renderFrame(AVFrame* frame) = 0; virtual void renderFrame(AVFrame* frame) = 0;
@ -31,16 +27,16 @@ public:
return 0; return 0;
} }
virtual int getRendererAttributes() {
// No special attributes by default
return 0;
}
virtual int getDecoderColorspace() { virtual int getDecoderColorspace() {
// Rec 601 is default // Rec 601 is default
return COLORSPACE_REC_601; return COLORSPACE_REC_601;
} }
virtual FramePacingConstraint getFramePacingConstraint() {
// No pacing preference
return PACING_ANY;
}
virtual bool isRenderThreadSupported() { virtual bool isRenderThreadSupported() {
// Render thread is supported by default // Render thread is supported by default
return true; return true;

View File

@ -45,6 +45,11 @@ bool FFmpegVideoDecoder::isHardwareAccelerated()
(m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0; (m_VideoDecoderCtx->codec->capabilities & AV_CODEC_CAP_HARDWARE) != 0;
} }
bool FFmpegVideoDecoder::isAlwaysFullScreen()
{
return m_BackendRenderer->getRendererAttributes() & RENDERER_ATTRIBUTE_FULLSCREEN_ONLY;
}
int FFmpegVideoDecoder::getDecoderCapabilities() int FFmpegVideoDecoder::getDecoderCapabilities()
{ {
int capabilities = m_BackendRenderer->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; return true;
} }

View File

@ -16,6 +16,7 @@ public:
virtual ~FFmpegVideoDecoder() override; virtual ~FFmpegVideoDecoder() override;
virtual bool initialize(PDECODER_PARAMETERS params) override; virtual bool initialize(PDECODER_PARAMETERS params) override;
virtual bool isHardwareAccelerated() override; virtual bool isHardwareAccelerated() override;
virtual bool isAlwaysFullScreen() override;
virtual int getDecoderCapabilities() override; virtual int getDecoderCapabilities() override;
virtual int getDecoderColorspace() override; virtual int getDecoderColorspace() override;
virtual int submitDecodeUnit(PDECODE_UNIT du) override; virtual int submitDecodeUnit(PDECODE_UNIT du) override;

View File

@ -25,6 +25,11 @@ SLVideoDecoder::isHardwareAccelerated()
return true; return true;
} }
bool SLVideoDecoder::isAlwaysFullScreen()
{
return true;
}
int int
SLVideoDecoder::getDecoderCapabilities() SLVideoDecoder::getDecoderCapabilities()
{ {

View File

@ -11,6 +11,7 @@ public:
virtual ~SLVideoDecoder(); virtual ~SLVideoDecoder();
virtual bool initialize(PDECODER_PARAMETERS params); virtual bool initialize(PDECODER_PARAMETERS params);
virtual bool isHardwareAccelerated(); virtual bool isHardwareAccelerated();
virtual bool isAlwaysFullScreen();
virtual int getDecoderCapabilities(); virtual int getDecoderCapabilities();
virtual int getDecoderColorspace(); virtual int getDecoderColorspace();
virtual int submitDecodeUnit(PDECODE_UNIT du); virtual int submitDecodeUnit(PDECODE_UNIT du);