diff --git a/CMakeLists.txt b/CMakeLists.txt index f00292a..be4b79b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,20 +32,19 @@ pkg_check_modules(CEC libcec>=3.0.0) pkg_check_modules(EGL egl) pkg_check_modules(GLES glesv2) +set(VDPAU_FOUND FALSE) +set(SOFTWARE_FOUND FALSE) + if(AVCODEC_FOUND AND AVUTIL_FOUND) if(EGL_FOUND AND GLES_FOUND AND XLIB_FOUND) set(X11_FOUND TRUE) + if(XLIB_FOUND AND LIBVA_FOUND) + set(VDPAU_FOUND TRUE) + endif() endif() if(SDL_FOUND OR X11_FOUND) set(SOFTWARE_FOUND TRUE) - if(XLIB_FOUND AND LIBVA_FOUND) - set(VDPAU_FOUND TRUE) - else() - set(VDPAU_FOUND FALSE) - endif() endif() -else() - set(SOFTWARE_FOUND FALSE) endif() SET(MOONLIGHT_COMMON_INCLUDE_DIR ./third_party/moonlight-common-c/src) diff --git a/docs/README.pod b/docs/README.pod index 7387cd4..757a0ca 100644 --- a/docs/README.pod +++ b/docs/README.pod @@ -148,11 +148,6 @@ The default value is 'sysdefault' for ALSA and 'hdmi' for OMX on the Raspberry P Display the stream in a window instead of fullscreen. Only available when X11 or SDL platform is used. -=item B<-forcehw> - -This will enable unsupported hardware acceleration. -Currently only VDPAU when using X11 or SDL is unsupported. - =back =head1 CONFIG FILE diff --git a/src/config.c b/src/config.c index 5a08024..5e580f9 100644 --- a/src/config.c +++ b/src/config.c @@ -61,7 +61,6 @@ static struct option long_options[] = { {"windowed", no_argument, NULL, 't'}, {"surround", no_argument, NULL, 'u'}, {"fps", required_argument, NULL, 'v'}, - {"forcehw", no_argument, NULL, 'w'}, {"codec", required_argument, NULL, 'x'}, {"unsupported", no_argument, NULL, 'y'}, {0, 0, 0, 0}, @@ -193,9 +192,6 @@ static void parse_argument(int c, char* value, PCONFIGURATION config) { case 'v': config->stream.fps = atoi(value); break; - case 'w': - config->forcehw = true; - break; case 'x': if (strcasecmp(value, "auto") == 0) config->codec = CODEC_UNSPECIFIED; @@ -303,7 +299,6 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { config->localaudio = false; config->fullscreen = true; config->unsupported_version = false; - config->forcehw = false; config->codec = CODEC_UNSPECIFIED; config->inputsCount = 0; diff --git a/src/config.h b/src/config.h index bd45269..0976e7d 100644 --- a/src/config.h +++ b/src/config.h @@ -38,7 +38,6 @@ typedef struct _CONFIGURATION { bool sops; bool localaudio; bool fullscreen; - bool forcehw; bool unsupported_version; char* inputs[MAX_INPUTS]; int inputsCount; diff --git a/src/main.c b/src/main.c index 02fb0e7..e4e1ac7 100644 --- a/src/main.c +++ b/src/main.c @@ -105,9 +105,6 @@ static void stream(PSERVER_DATA server, PCONFIGURATION config, enum platform sys if (config->fullscreen) drFlags |= DISPLAY_FULLSCREEN; - if (config->forcehw) - drFlags |= FORCE_HARDWARE_ACCELERATION; - printf("Stream %d x %d, %d fps, %d kbps\n", config->stream.width, config->stream.height, config->stream.fps, config->stream.bitrate); platform_start(system); @@ -157,15 +154,14 @@ static void help() { printf("\t-surround\t\tStream 5.1 surround sound (requires GFE 2.7)\n"); printf("\t-keydir \tLoad encryption keys from directory\n"); printf("\t-mapping \t\tUse as gamepad mappings configuration file\n"); - printf("\t-platform \tSpecify system used for audio, video and input: pi/imx/aml/x11/sdl (default auto)\n"); + printf("\t-platform \tSpecify system used for audio, video and input: pi/imx/aml/x11/x11_vdpau/sdl (default auto)\n"); printf("\t-unsupported\t\tTry streaming if GFE version is unsupported\n"); #if defined(HAVE_SDL) || defined(HAVE_X11) - printf("\n Video options (SDL and X11 only)\n\n"); + printf("\n WM options (SDL and X11 only)\n\n"); printf("\t-windowed\t\tDisplay screen in a window\n"); - printf("\t-forcehw \t\tTry to use video hardware acceleration\n"); #endif #ifdef HAVE_EMBEDDED - printf("\n I/O options (PI, IMX, AML and X11 only)\n\n"); + printf("\n I/O options (Not for SDL)\n\n"); printf("\t-input \t\tUse as input. Can be used multiple times\n"); printf("\t-audio \t\tUse as audio output device\n"); #endif diff --git a/src/platform.c b/src/platform.c index 449312d..3644bdf 100644 --- a/src/platform.c +++ b/src/platform.c @@ -62,6 +62,10 @@ enum platform platform_check(char* name) { #ifdef HAVE_X11 if (std || strcmp(name, "x11") == 0) return X11; + #ifdef HAVE_VDPAU + if (std || strcmp(name, "x11_vdpau") == 0) + return X11_VDPAU; + #endif #endif #ifdef HAVE_SDL if (std || strcmp(name, "sdl") == 0) @@ -110,6 +114,10 @@ DECODER_RENDERER_CALLBACKS* platform_get_video(enum platform system) { #ifdef HAVE_X11 case X11: return &decoder_callbacks_x11; + #ifdef HAVE_VDPAU + case X11_VDPAU: + return &decoder_callbacks_x11_vdpau; + #endif #endif #ifdef HAVE_SDL case SDL: diff --git a/src/platform.h b/src/platform.h index eecd390..61a7541 100644 --- a/src/platform.h +++ b/src/platform.h @@ -26,7 +26,7 @@ #define IS_EMBEDDED(SYSTEM) SYSTEM != SDL -enum platform { NONE, SDL, X11, PI, IMX, AML, FAKE }; +enum platform { NONE, SDL, X11, X11_VDPAU, PI, IMX, AML, FAKE }; enum platform platform_check(char*); PDECODER_RENDERER_CALLBACKS platform_get_video(enum platform system); diff --git a/src/video/video.h b/src/video/video.h index 17360d6..6127414 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -20,10 +20,13 @@ #include #define DISPLAY_FULLSCREEN 1 -#define FORCE_HARDWARE_ACCELERATION 2 +#define ENABLE_HARDWARE_ACCELERATION 2 #ifdef HAVE_X11 extern DECODER_RENDERER_CALLBACKS decoder_callbacks_x11; +#ifdef HAVE_VDPAU +extern DECODER_RENDERER_CALLBACKS decoder_callbacks_x11_vdpau; +#endif #endif #ifdef HAVE_SDL extern DECODER_RENDERER_CALLBACKS decoder_callbacks_sdl; diff --git a/src/video/x11.c b/src/video/x11.c index e83033b..519ffdd 100644 --- a/src/video/x11.c +++ b/src/video/x11.c @@ -52,7 +52,7 @@ static int frame_handle(int pipefd) { int x11_setup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) { int avc_flags = SLICE_THREADING; - if (drFlags & FORCE_HARDWARE_ACCELERATION) + if (drFlags & ENABLE_HARDWARE_ACCELERATION) avc_flags |= HARDWARE_ACCELERATION; ffmpeg_buffer = malloc(DECODER_BUFFER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); @@ -113,6 +113,10 @@ int x11_setup(int videoFormat, int width, int height, int redrawRate, void* cont return 0; } +int x11_setup_vdpau(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) { + x11_setup(videoFormat, width, height, redrawRate, context, drFlags | ENABLE_HARDWARE_ACCELERATION); +} + void x11_cleanup() { ffmpeg_destroy(); egl_destroy(); @@ -147,3 +151,10 @@ DECODER_RENDERER_CALLBACKS decoder_callbacks_x11 = { .submitDecodeUnit = x11_submit_decode_unit, .capabilities = CAPABILITY_SLICES_PER_FRAME(4) | CAPABILITY_REFERENCE_FRAME_INVALIDATION_AVC | CAPABILITY_REFERENCE_FRAME_INVALIDATION_HEVC | CAPABILITY_DIRECT_SUBMIT, }; + +DECODER_RENDERER_CALLBACKS decoder_callbacks_x11_vdpau = { + .setup = x11_setup_vdpau, + .cleanup = x11_cleanup, + .submitDecodeUnit = x11_submit_decode_unit, + .capabilities = CAPABILITY_DIRECT_SUBMIT, +};