Added a CMake option to build with or without the VLC video player.

This commit is contained in:
Leon Styhre 2021-06-23 00:24:15 +02:00
parent badcfb0fe9
commit 337f06b428
9 changed files with 92 additions and 37 deletions

View file

@ -14,6 +14,8 @@ set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Show verbose compiler output" FORCE)
# Package type to use for CPack on Linux.
set(LINUX_CPACK_GENERATOR "DEB" CACHE STRING "CPack generator, DEB or RPM")
set(VLC_PLAYER OFF CACHE BOOL "Whether to build with the VLC video player")
# Add local find modules to the CMake path.
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utils
@ -80,7 +82,9 @@ if(NOT WIN32)
find_package(Pugixml REQUIRED)
find_package(RapidJSON REQUIRED)
find_package(SDL2 REQUIRED)
find_package(VLC REQUIRED)
if(VLC_PLAYER OR RPI)
find_package(VLC REQUIRED)
endif()
endif()
# Add libCEC support.
@ -185,8 +189,13 @@ else()
add_definitions(-DUSE_OPENGLES_10)
endif()
if (VLC_PLAYER)
add_definitions(-DBUILD_VLC_PLAYER)
endif()
if(DEFINED BCMHOST OR RPI)
add_definitions(-D_RPI_)
add_definitions(-DBUILD_VLC_PLAYER)
endif()
if(DEFINED VERO4K)
@ -230,10 +239,12 @@ set(COMMON_INCLUDE_DIRS
${PUGIXML_INCLUDE_DIRS}
${RAPIDJSON_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${VLC_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external/CImg
${CMAKE_CURRENT_SOURCE_DIR}/external/nanosvg/src
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src)
if(VLC_PLAYER OR RPI)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} ${VLC_INCLUDE_DIR})
endif()
# For Windows we need to add local include files for the dependency packages.
if(WIN32)
@ -245,7 +256,7 @@ if(WIN32)
endif()
# Temporary solution until the VLC find module has been updated to work properly on macOS.
if(APPLE)
if(APPLE AND VLC_PLAYER)
set(COMMON_INCLUDE_DIRS ${COMMON_INCLUDE_DIRS} "/Applications/VLC.app/Contents/MacOS/include")
endif()
@ -292,8 +303,10 @@ if(NOT WIN32)
${FreeImage_LIBRARIES}
${FREETYPE_LIBRARIES}
${PUGIXML_LIBRARIES}
${SDL2_LIBRARY}
${VLC_LIBRARIES})
${SDL2_LIBRARY})
if(VLC_PLAYER OR RPI)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} ${VLC_LIBRARIES})
endif()
elseif(WIN32)
if(DEFINED MSVC)
set(COMMON_LIBRARIES
@ -309,9 +322,11 @@ elseif(WIN32)
"${PROJECT_SOURCE_DIR}/freetype.lib"
"${PROJECT_SOURCE_DIR}/pugixml.lib"
"${PROJECT_SOURCE_DIR}/SDL2main.lib"
"${PROJECT_SOURCE_DIR}/libvlc.lib"
"${PROJECT_SOURCE_DIR}/SDL2.lib"
"Winmm.dll")
if(VLC_PLAYER)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "${PROJECT_SOURCE_DIR}/libvlc.lib")
endif()
else()
set(COMMON_LIBRARIES
"${PROJECT_SOURCE_DIR}/avcodec-59.dll"
@ -326,10 +341,12 @@ elseif(WIN32)
"${PROJECT_SOURCE_DIR}/libfreetype.dll"
"${PROJECT_SOURCE_DIR}/libpugixml.dll"
"${PROJECT_SOURCE_DIR}/libSDL2main.a"
"${PROJECT_SOURCE_DIR}/libvlc.dll"
"${PROJECT_SOURCE_DIR}/SDL2.dll"
"mingw32"
"Winmm.dll")
if(VLC_PLAYER)
set(COMMON_LIBRARIES ${COMMON_LIBRARIES} "${PROJECT_SOURCE_DIR}/libvlc.dll")
endif()
endif()
endif()
@ -339,9 +356,11 @@ if(APPLE)
set(CMAKE_INSTALL_PREFIX
"/Applications/EmulationStation Desktop Edition.app/Contents/Resources")
# Temporary solution until the VLC find module has been updated to work properly on macOS.
set(COMMON_LIBRARIES ${COMMON_LIBRARIES}
"/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib")
if(VLC_PLAYER)
# Required as the VLC find module doesn't work properly on macOS.
set(COMMON_LIBRARIES ${COMMON_LIBRARIES}
"/Applications/VLC.app/Contents/MacOS/lib/libvlc.dylib")
endif()
# Set the same rpath links for the install executable as for the build executable.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

View file

@ -130,17 +130,23 @@ if(WIN32)
install(FILES ../avcodec-59.dll ../avfilter-8.dll ../avformat-59.dll ../avutil-57.dll
../postproc-56.dll ../swresample-4.dll ../swscale-6.dll ../FreeImage.dll
../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll ../freetype.dll
../pugixml.dll ../libssl-1_1-x64.dll ../libvlc.dll ../libvlccore.dll ../SDL2.dll
../MSVCP140.dll ../VCOMP140.DLL ../VCRUNTIME140.dll ../VCRUNTIME140_1.dll
DESTINATION .)
../pugixml.dll ../libssl-1_1-x64.dll ../SDL2.dll ../MSVCP140.dll ../VCOMP140.DLL
../VCRUNTIME140.dll ../VCRUNTIME140_1.dll DESTINATION .)
if(VLC_PLAYER)
install(FILES ../libvlc.dll ../libvlccore.dll DESTINATION .)
endif()
else()
install(FILES ../avcodec-59.dll ../avfilter-8.dll ../avformat-59.dll ../avutil-57.dll
../postproc-56.dll ../swresample-4.dll ../swscale-6.dll ../FreeImage.dll
../glew32.dll ../libcrypto-1_1-x64.dll ../libcurl-x64.dll ../libfreetype.dll
../libpugixml.dll ../libssl-1_1-x64.dll ../libvlc.dll ../libvlccore.dll
../SDL2.dll ../vcomp140.dll DESTINATION .)
../libpugixml.dll ../libssl-1_1-x64.dll ../SDL2.dll ../vcomp140.dll DESTINATION .)
if(VLC_PLAYER)
install(FILES ../libvlc.dll ../libvlccore.dll DESTINATION .)
endif()
endif()
if(VLC_PLAYER)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins DESTINATION .)
endif()
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins DESTINATION .)
install(FILES ../LICENSE DESTINATION .)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/licenses DESTINATION .)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/themes DESTINATION .)
@ -208,12 +214,14 @@ elseif(APPLE)
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libSDL2-2.0.0.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libvlc.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libvlccore.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins
DESTINATION ../MacOS)
if(VLC_PLAYER)
install(FILES ${CMAKE_SOURCE_DIR}/libvlc.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(FILES ${CMAKE_SOURCE_DIR}/libvlccore.dylib
PERMISSIONS ${APPLE_DYLIB_PERMISSIONS} DESTINATION ../MacOS)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/plugins
DESTINATION ../MacOS)
endif()
endif()
install(FILES ${CMAKE_SOURCE_DIR}/LICENSE
DESTINATION ../Resources)
@ -326,7 +334,9 @@ else()
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://es-de.org")
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "vlc")
if(VLC_PLAYER OR RPI)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "vlc")
endif()
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
if("${LINUX_CPACK_GENERATOR}" STREQUAL "RPM")
set(CPACK_GENERATOR "RPM")
@ -334,7 +344,9 @@ else()
set(CPACK_RPM_FILE_NAME "emulationstation-de-${CPACK_PACKAGE_VERSION}-${CPU_ARCHITECTURE}.rpm")
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
set(CPACK_RPM_PACKAGE_LICENSE "MIT")
set(CPACK_RPM_PACKAGE_REQUIRES "vlc")
if(VLC_PLAYER)
set(CPACK_RPM_PACKAGE_REQUIRES "vlc")
endif()
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CMAKE_INSTALL_PREFIX}")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CMAKE_INSTALL_PREFIX}/bin")
list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CMAKE_INSTALL_PREFIX}/share")

View file

@ -9,7 +9,9 @@
#include "MediaViewer.h"
#include "components/VideoFFmpegComponent.h"
#if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h"
#endif
#include "views/ViewController.h"
#include "AudioManager.h"
#include "Sound.h"
@ -242,10 +244,14 @@ void MediaViewer::playVideo()
mDisplayingImage = false;
ViewController::get()->onStopVideo();
#if defined(BUILD_VLC_PLAYER)
if (Settings::getInstance()->getString("VideoPlayer") == "ffmpeg")
mVideo = new VideoFFmpegComponent(mWindow);
else
mVideo = new VideoVlcComponent(mWindow);
#else
mVideo = new VideoFFmpegComponent(mWindow);
#endif
mVideo->topWindow(true);
mVideo->setOrigin(0.5f, 0.5f);

View file

@ -9,11 +9,13 @@
#include "SystemScreensaver.h"
#include "components/VideoFFmpegComponent.h"
#if defined(_RPI_)
#include "components/VideoOmxComponent.h"
#endif
#include "components/VideoFFmpegComponent.h"
#if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h"
#endif
#include "resources/Font.h"
#include "utils/FileSystemUtil.h"
#include "utils/StringUtil.h"
@ -182,17 +184,16 @@ void SystemScreensaver::startScreensaver(bool generateMediaList)
if (Settings::getInstance()->getBool("ScreensaverOmxPlayer"))
mVideoScreensaver = new VideoOmxComponent(mWindow);
else if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideoScreensaver = new VideoVlcComponent(window);
else
mVideoScreensaver = new VideoFFmpegComponent(window);
else
mVideoScreensaver = new VideoVlcComponent(mWindow);
#else
else
mVideoScreensaver = new VideoFFmpegComponent(mWindow);
#elif defined(BUILD_VLC_PLAYER)
if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideoScreensaver = new VideoVlcComponent(mWindow);
else
mVideoScreensaver = new VideoFFmpegComponent(mWindow);
#else
mVideoScreensaver = new VideoFFmpegComponent(mWindow);
#endif
mVideoScreensaver->topWindow(true);
@ -436,7 +437,7 @@ void SystemScreensaver::update(int deltaTime)
else if (mState == STATE_SCREENSAVER_ACTIVE) {
// Update the timer that swaps the media, unless the swap time is set to 0 (only
// applicable for the video screensaver). This means that videos play to the end,
// at which point VideoVlcComponent will trigger a skip to the next game.
// at which point the video player will trigger a skip to the next game.
if (mMediaSwapTime != 0) {
mTimer += deltaTime;
if (mTimer > mMediaSwapTime)

View file

@ -906,6 +906,7 @@ void GuiMenu::openOtherOptions()
});
#endif
#if defined(BUILD_VLC_PLAYER)
// Video player.
auto video_player = std::make_shared<OptionListComponent<std::string>>
(mWindow, getHelpStyle(), "FULLSCREEN MODE", false);
@ -924,6 +925,7 @@ void GuiMenu::openOtherOptions()
s->setNeedsReloading();
}
});
#endif
// When to save game metadata.
auto save_gamelist_mode = std::make_shared<OptionListComponent<std::string>>
@ -1026,7 +1028,11 @@ void GuiMenu::openOtherOptions()
// Whether to upscale the video frame rate to 60 FPS.
auto video_upscale_frame_rate = std::make_shared<SwitchComponent>(mWindow);
video_upscale_frame_rate->setState(Settings::getInstance()->getBool("VideoUpscaleFrameRate"));
#if defined(BUILD_VLC_PLAYER)
s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS (FFMPEG)", video_upscale_frame_rate);
#else
s->addWithLabel("UPSCALE VIDEO FRAME RATE TO 60 FPS", video_upscale_frame_rate);
#endif
s->addSaveFunc([video_upscale_frame_rate, s] {
if (video_upscale_frame_rate->getState() !=
Settings::getInstance()->getBool("VideoUpscaleFrameRate")) {

View file

@ -9,16 +9,15 @@
#include "views/gamelist/VideoGameListView.h"
#include "animations/LambdaAnimation.h"
#include "components/VideoFFmpegComponent.h"
#if defined(_RPI_)
#include "components/VideoOmxComponent.h"
#endif
#include "components/VideoFFmpegComponent.h"
#if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h"
#endif
#include "utils/FileSystemUtil.h"
#include "views/ViewController.h"
#if defined(_RPI_)
#include "Settings.h"
#endif
#include "AudioManager.h"
#include "CollectionSystemsManager.h"
#include "SystemData.h"
@ -70,11 +69,13 @@ VideoGameListView::VideoGameListView(
mVideo = new VideoVlcComponent(window);
else
mVideo = new VideoFFmpegComponent(window);
#else
#elif defined(BUILD_VLC_PLAYER)
if (Settings::getInstance()->getString("VideoPlayer") == "vlc")
mVideo = new VideoVlcComponent(window);
else
mVideo = new VideoFFmpegComponent(window);
#else
mVideo = new VideoFFmpegComponent(window);
#endif
mList.setPosition(mSize.x() * (0.50f + padding), mList.getPosition().y());

View file

@ -232,7 +232,9 @@ void Settings::setDefaults()
#if defined (__unix__)
mStringMap["FullscreenMode"] = { "normal", "normal" };
#endif
#if defined(BUILD_VLC_PLAYER)
mStringMap["VideoPlayer"] = { "ffmpeg", "ffmpeg" };
#endif
#if defined(_RPI_)
mBoolMap["VideoOmxPlayer"] = { false, false };
// We're defaulting to OMX Player for full screen video on the Pi.

View file

@ -11,7 +11,9 @@
#include "components/HelpComponent.h"
#include "components/ImageComponent.h"
#if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h"
#endif
#include "resources/Font.h"
#include "AudioManager.h"
#include "InputManager.h"
@ -139,7 +141,9 @@ void Window::deinit()
InputManager::getInstance()->deinit();
ResourceManager::getInstance()->unloadAll();
#if defined(BUILD_VLC_PLAYER)
VideoVlcComponent::deinit();
#endif
Renderer::deinit();
}

View file

@ -6,6 +6,8 @@
// Video player based on libVLC.
//
#if defined(BUILD_VLC_PLAYER)
#include "components/VideoVlcComponent.h"
#include "renderers/Renderer.h"
@ -540,3 +542,5 @@ void VideoVlcComponent::handleLooping()
}
}
}
#endif