diff --git a/RetroFE/Source/CMakeLists.txt b/RetroFE/Source/CMakeLists.txt index 224d20f..c63a625 100644 --- a/RetroFE/Source/CMakeLists.txt +++ b/RetroFE/Source/CMakeLists.txt @@ -37,8 +37,12 @@ endif() endif() if(WIN32) + +if(NOT NO_VIDEO) find_package(Glib2 REQUIRED) find_package(GStreamer REQUIRED) +endif() + find_package(SDL2 REQUIRED) find_package(SDL2_image REQUIRED) find_package(SDL2_mixer REQUIRED) @@ -51,8 +55,12 @@ else() pkg_search_module(SDL2_MIXER REQUIRED SDL2_mixer) pkg_search_module(SDL2_TTF REQUIRED SDL2_ttf) pkg_search_module(ZLIB REQUIRED zlib) + +if(NOT NO_VIDEO) pkg_search_module(GSTREAMER REQUIRED gstreamer-1.0 gstbase-1.0) pkg_search_module(Glib2 REQUIRED glib-2.0 gobject-2.0 gthread-2.0 gmodule-2.0) +endif() + find_package(Threads REQUIRED) endif() @@ -73,8 +81,6 @@ LIST(APPEND RETROFE_INCLUDE_DIRS "${DIRENT_INCLUDE_DIR}") endif() set(RETROFE_LIBRARIES - ${GLIB2_LIBRARIES} - ${GSTREAMER_LIBRARIES} ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${SDL2_MIXER_LIBRARIES} @@ -82,6 +88,13 @@ set(RETROFE_LIBRARIES ${ZLIB_LIBRARIES} ) +if(NOT NO_VIDEO) + list(APPEND RETROFE_LIBRARIES + ${GLIB2_LIBRARIES} + ${GSTREAMER_LIBRARIES} + ) +endif() + if(NOT WIN32) LIST(APPEND RETROFE_LIBRARIES ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) endif() @@ -122,7 +135,6 @@ set(RETROFE_HEADERS "${RETROFE_DIR}/Source/Utility/Log.h" "${RETROFE_DIR}/Source/Utility/Utils.h" "${RETROFE_DIR}/Source/Video/IVideo.h" - "${RETROFE_DIR}/Source/Video/GStreamerVideo.h" "${RETROFE_DIR}/Source/Video/VideoFactory.h" "${RETROFE_DIR}/Source/Graphics/ComponentItemBindingBuilder.h" "${RETROFE_DIR}/Source/Graphics/ViewInfo.h" @@ -166,7 +178,6 @@ set(RETROFE_SOURCES "${RETROFE_DIR}/Source/Sound/Sound.cpp" "${RETROFE_DIR}/Source/Utility/Log.cpp" "${RETROFE_DIR}/Source/Utility/Utils.cpp" - "${RETROFE_DIR}/Source/Video/GStreamerVideo.cpp" "${RETROFE_DIR}/Source/Video/VideoFactory.cpp" "${RETROFE_DIR}/Source/Main.cpp" "${RETROFE_DIR}/Source/RetroFE.cpp" @@ -175,6 +186,13 @@ set(RETROFE_SOURCES "${SQLITE3_ROOT}/sqlite3.c" ) +if(NO_VIDEO) +set(RETROFE_HEADERS ${RETROFE_HEADERS} "${RETROFE_DIR}/Source/Video/NullVideo.h") +set(RETROFE_SOURCES ${RETROFE_SOURCES} "${RETROFE_DIR}/Source/Video/NullVideo.cpp") +else() +set(RETROFE_HEADERS ${RETROFE_HEADERS} "${RETROFE_DIR}/Source/Video/GStreamerVideo.h") +set(RETROFE_SOURCES ${RETROFE_SOURCES} "${RETROFE_DIR}/Source/Video/GStreamerVideo.cpp") +endif() set(EXECUTABLE_OUTPUT_PATH "${RETROFE_DIR}/Build" CACHE PATH "Build directory" FORCE) set(LIBRARY_OUTPUT_PATH "${RETROFE_DIR}/Build" CACHE PATH "Build directory" FORCE) @@ -192,6 +210,9 @@ add_definitions(-DRETROFE_VERSION_MAJOR=${VERSION_MAJOR}) add_definitions(-DRETROFE_VERSION_MINOR=${VERSION_MINOR}) add_definitions(-DRETROFE_VERSION_BUILD=${VERSION_BUILD}) +if(NO_VIDEO) +add_definitions(-DNO_VIDEO) +endif() if(MSVC) set(CMAKE_DEBUG_POSTFIX "d") diff --git a/RetroFE/Source/Video/NullVideo.cpp b/RetroFE/Source/Video/NullVideo.cpp new file mode 100644 index 0000000..a1459af --- /dev/null +++ b/RetroFE/Source/Video/NullVideo.cpp @@ -0,0 +1,79 @@ +/* This file is part of RetroFE. + * + * RetroFE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RetroFE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RetroFE. If not, see . + */ +#include "NullVideo.h" +#include "../Utility/Log.h" +#include "../SDL.h" +#include +#include +#include +#include +#include + +NullVideo::NullVideo() +{ +} +NullVideo::~NullVideo() +{ +} + +void NullVideo::SetNumLoops(int n) +{ +} + +SDL_Texture *NullVideo::GetTexture() const +{ + return NULL; +} + +bool NullVideo::Initialize() +{ + return true; +} + +bool NullVideo::DeInitialize() +{ + return true; +} + +bool NullVideo::Stop() +{ + return true; +} + +bool NullVideo::Play(std::string file) +{ + return true; +} + +int NullVideo::GetHeight() +{ + return 0; +} + +int NullVideo::GetWidth() +{ + return 0; +} + + +void NullVideo::Draw() +{ +} + +void NullVideo::Update(float dt) +{ +} + diff --git a/RetroFE/Source/Video/NullVideo.h b/RetroFE/Source/Video/NullVideo.h new file mode 100644 index 0000000..525cd7f --- /dev/null +++ b/RetroFE/Source/Video/NullVideo.h @@ -0,0 +1,36 @@ +/* This file is part of RetroFE. + * + * RetroFE is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * RetroFE is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with RetroFE. If not, see . + */ +#pragma once + +#include "IVideo.h" + +class NullVideo : public IVideo +{ +public: + NullVideo(); + ~NullVideo(); + bool Initialize(); + bool Play(std::string file); + bool Stop(); + bool DeInitialize(); + SDL_Texture *GetTexture() const; + void Update(float dt); + void Draw(); + void SetNumLoops(int n); + void FreeElements(); + int GetHeight(); + int GetWidth(); +}; diff --git a/RetroFE/Source/Video/VideoFactory.cpp b/RetroFE/Source/Video/VideoFactory.cpp index 4c655ca..d16969a 100644 --- a/RetroFE/Source/Video/VideoFactory.cpp +++ b/RetroFE/Source/Video/VideoFactory.cpp @@ -16,7 +16,12 @@ #include "VideoFactory.h" #include "IVideo.h" + +#ifdef NO_VIDEO +#include "NullVideo.h" +#else #include "GStreamerVideo.h" +#endif bool VideoFactory::Enabled = true; int VideoFactory::NumLoops = 0; @@ -27,9 +32,16 @@ IVideo *VideoFactory::CreateVideo() if(Enabled && !Instance) { +#ifdef NO_VIDEO + Instance = new NullVideo(); +#else Instance = new GStreamerVideo(); +#endif Instance->Initialize(); + +#ifndef NO_VIDEO ((GStreamerVideo *)(Instance))->SetNumLoops(NumLoops); +#endif } return Instance;