diff --git a/CMakeLists.txt b/CMakeLists.txt index cd7a74bf7..3e9736675 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,14 +14,23 @@ include(GNUInstallDirs) ###################### USER-SELECTABLE OPTIONS ########################### option(DFSG_BUILD "DFSG build (no non-free media/code)" OFF) option(USE_DOXYGEN "Build HTML cross reference with doxygen" OFF) -option(USE_FFMPEG "Disable FFmpeg image/video support" ON) option(USE_NETWORK "Allow cargo to use the network" OFF) option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON) option(USE_PYTHON "Build Python wrappers" ON) option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON) option(USE_RUST "Build Rust wrappers (experimental)" OFF) option(USE_TESTS "Build doctest unit tests" ON) +set(USE_MULTIMEDIA "ffmpeg" CACHE STRING "Multimedia engine, one of 'ffmpeg', 'oiio', or 'none'") +set_property(CACHE USE_MULTIMEDIA PROPERTY STRINGS ffmpeg oiio none) +message(STATUS "Requested multimedia engine: ${USE_MULTIMEDIA}") ############## END (additional) USER-SELECTABLE OPTIONS ################## +set(USE_FFMPEG OFF) +set(USE_OIIO OFF) +if(${USE_MULTIMEDIA} STREQUAL "ffmpeg") + set(USE_FFMPEG ON) +elseif(${USE_MULTIMEDIA} STREQUAL "oiio") + set(USE_OIIO ON) +endif() find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) @@ -113,29 +122,33 @@ target_link_libraries(notcurses PRIVATE "${AVCODEC_LIBRARIES}" "${AVFORMAT_LIBRARIES}" - "${AVUTIL_LIBRARIES}" "${SWSCALE_LIBRARIES}" + PUBLIC + "${AVUTIL_LIBRARIES}" ) target_link_libraries(notcurses-static PRIVATE "${AVCODEC_STATIC_LIBRARIES}" "${AVFORMAT_STATIC_LIBRARIES}" - "${AVUTIL_STATIC_LIBRARIES}" "${SWSCALE_STATIC_LIBRARIES}" + PUBLIC + "${AVUTIL_STATIC_LIBRARIES}" ) target_link_directories(notcurses - PUBLIC + PRIVATE "${AVCODEC_LIBRARY_DIRS}" "${AVFORMAT_LIBRARY_DIRS}" - "${AVUTIL_LIBRARY_DIRS}" "${SWSCALE_LIBRARY_DIRS}" + PUBLIC + "${AVUTIL_LIBRARY_DIRS}" ) target_link_directories(notcurses-static - PUBLIC + PRIVATE "${AVCODEC_STATIC_LIBRARY_DIRS}" "${AVFORMAT_STATIC_LIBRARY_DIRS}" - "${AVUTIL_STATIC_LIBRARY_DIRS}" "${SWSCALE_STATIC_LIBRARY_DIRS}" + PUBLIC + "${AVUTIL_STATIC_LIBRARY_DIRS}" ) endif() @@ -277,17 +290,17 @@ target_compile_definitions(notcurses++-static file(GLOB NOTCURSES_HEADERS CONFIGURE_DEPENDS LIST_DIRECTORIES false - ${CMAKE_SOURCE_DIR}/include/notcurses/*.h) + ${PROJECT_SOURCE_DIR}/include/notcurses/*.h) file(GLOB NCPP_HEADERS CONFIGURE_DEPENDS LIST_DIRECTORIES false - ${CMAKE_SOURCE_DIR}/include/ncpp/*.hh) + ${PROJECT_SOURCE_DIR}/include/ncpp/*.hh) file(GLOB NCPP_INTERNAL_HEADERS CONFIGURE_DEPENDS LIST_DIRECTORIES false - ${CMAKE_SOURCE_DIR}/include/ncpp/internal/*.hh) + ${PROJECT_SOURCE_DIR}/include/ncpp/internal/*.hh) install(FILES ${NOTCURSES_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/notcurses) install(FILES ${NCPP_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ncpp) @@ -388,11 +401,11 @@ if(USE_PANDOC) endforeach() foreach(m ${MANSOURCE3}) get_filename_component(me ${m} NAME_WLE) - set(MANPAGES3 ${MANPAGES3} ${CMAKE_CURRENT_BINARY_DIR}/${me}) + LIST(APPEND MANPAGES3 ${CMAKE_CURRENT_BINARY_DIR}/${me}) endforeach() foreach(m ${MANSOURCE1}) get_filename_component(me ${m} NAME_WLE) - set(MANPAGES1 ${MANPAGES1} ${CMAKE_CURRENT_BINARY_DIR}/${me}) + LIST(APPEND MANPAGES1 ${CMAKE_CURRENT_BINARY_DIR}/${me}) endforeach() endif() endif() diff --git a/src/lib/libav.c b/src/lib/libav.c index 515526d8d..2302417ca 100644 --- a/src/lib/libav.c +++ b/src/lib/libav.c @@ -553,8 +553,8 @@ int ncvisual_init(int loglevel){ // FIXME could also use av_log_set_callback() and capture the message... return 0; } -#else -// built without ffmpeg +#else // built without ffmpeg +#ifndef USE_OIIO // built without ffmpeg or oiio bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){ return false; } @@ -612,5 +612,5 @@ int ncvisual_init(int loglevel){ (void)loglevel; return 0; // allow success here } - +#endif #endif diff --git a/src/lib/oiio.cpp b/src/lib/oiio.cpp new file mode 100644 index 000000000..6486d211e --- /dev/null +++ b/src/lib/oiio.cpp @@ -0,0 +1,61 @@ +#include "internal.h" + +#ifdef USE_OIIO +bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){ + return false; +} + +struct AVFrame* ncvisual_decode(ncvisual* nc, int* averr){ + (void)nc; + (void)averr; + return NULL; +} + +int ncvisual_render(const ncvisual* ncv, int begy, int begx, int leny, int lenx){ + (void)ncv; + (void)begy; + (void)begx; + (void)leny; + (void)lenx; + return -1; +} + +int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv, int* averr, + float timespec, streamcb streamer, void* curry){ + (void)nc; + (void)ncv; + (void)averr; + (void)timespec; + (void)streamer; + (void)curry; + return -1; +} + +ncvisual* ncplane_visual_open(ncplane* nc, const char* filename, int* averr){ + (void)nc; + (void)filename; + (void)averr; + return NULL; +} + +ncvisual* ncvisual_open_plane(notcurses* nc, const char* filename, + int* averr, int y, int x, ncscale_e style){ + (void)nc; + (void)filename; + (void)averr; + (void)y; + (void)x; + (void)style; + return NULL; +} + +char* ncvisual_subtitle(const ncvisual* ncv){ + (void)ncv; + return NULL; +} + +int ncvisual_init(int loglevel){ + (void)loglevel; + return 0; // allow success here +} +#endif diff --git a/tests/visual.cpp b/tests/visual.cpp index 8defcaed1..13f5e331e 100644 --- a/tests/visual.cpp +++ b/tests/visual.cpp @@ -1,5 +1,5 @@ #include "main.h" -#ifdef USE_FFMPEG +#ifdef USE_MULTIMEDIA #include #include #include @@ -19,7 +19,7 @@ TEST_CASE("Multimedia") { ncplane* ncp_ = notcurses_stdplane(nc_); REQUIRE(ncp_); -#ifndef USE_FFMPEG +#ifndef USE_MULTIMEDIA SUBCASE("LibavDisabled"){ REQUIRE(!notcurses_canopen(nc_)); } diff --git a/tools/version.h.in b/tools/version.h.in index 9165cc963..377690eab 100644 --- a/tools/version.h.in +++ b/tools/version.h.in @@ -2,6 +2,11 @@ #define notcurses_VERSION_MINOR "@notcurses_VERSION_MINOR@" #define notcurses_VERSION_PATCH "@notcurses_VERSION_PATCH@" #cmakedefine DFSG_BUILD -#cmakedefine USE_FFMPEG #cmakedefine USE_QRCODEGEN +// exclusive with USE_OIIO +#cmakedefine USE_FFMPEG +// exclusive with USE_FFMPEG +#cmakedefine USE_OIIO +// set if either USE_FFMPEG || USE_OIIO +#cmakedefine USE_MULTIMEDIA #define NOTCURSES_SHARE "@CMAKE_INSTALL_FULL_DATADIR@/notcurses"