basic structure for libvlc backend #1101

This commit is contained in:
nick black 2020-12-18 03:41:21 -05:00
parent d1fdaf7614
commit ec63bd80ae
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 79 additions and 9 deletions

View File

@ -28,18 +28,21 @@ option(USE_PANDOC "Build man pages and HTML reference with pandoc" ON)
option(USE_POC "Build small, uninstalled proof-of-concept binaries" ON)
option(USE_QRCODEGEN "Disable libqrcodegen QR code support" ON)
option(USE_STATIC "Build static libraries (in addition to shared)" 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)
set(USE_MULTIMEDIA "ffmpeg" CACHE STRING "Multimedia engine, one of 'ffmpeg', 'oiio', 'vlc', or 'none'")
set_property(CACHE USE_MULTIMEDIA PROPERTY STRINGS ffmpeg oiio vlc none)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release MinSizeRel RelWithDebInfo Coverage)
############## END (additional) USER-SELECTABLE OPTIONS ##################
set(USE_FFMPEG OFF)
set(USE_OIIO OFF)
set(USE_VLC OFF)
if(${USE_MULTIMEDIA} STREQUAL "ffmpeg")
set(USE_FFMPEG ON)
elseif(${USE_MULTIMEDIA} STREQUAL "oiio")
set(USE_OIIO ON)
elseif(${USE_MULTIMEDIA} STREQUAL "vlc")
set(USE_VLC ON)
elseif(NOT ${USE_MULTIMEDIA} STREQUAL "none")
message(FATAL_ERROR "USE_MULTIMEDIA must be one of 'oiio', 'ffmpeg', 'none' (was '${USE_MULTIMEDIA}')")
message(FATAL_ERROR "USE_MULTIMEDIA must be 'oiio', 'ffmpeg', 'vlc', or 'none' (was '${USE_MULTIMEDIA}')")
endif()
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
@ -86,6 +89,9 @@ set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND FFMpeg)
elseif(${USE_OIIO})
pkg_check_modules(OIIO REQUIRED OpenImageIO>=2.1)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND OpenImageIO)
elseif(${USE_VLC})
pkg_check_modules(VLC REQUIRED libvlc>=3.0.9)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND libvlc)
endif()
find_library(MATH_LIBRARIES m)
if(${USE_DOCTEST})
@ -230,6 +236,13 @@ target_link_libraries(notcurses PRIVATE ${OIIO_LIBRARIES})
target_link_libraries(notcurses-static PRIVATE ${OIIO_STATIC_LIBRARIES})
target_link_directories(notcurses PRIVATE ${OIIO_LIBRARY_DIRS})
target_link_directories(notcurses-static PRIVATE ${OIIO_STATIC_LIBRARY_DIRS})
elseif(${USE_VLC})
target_include_directories(notcurses PUBLIC "${VLC_INCLUDE_DIRS}")
target_include_directories(notcurses-static PUBLIC "${VLC_STATIC_INCLUDE_DIRS}")
target_link_libraries(notcurses PRIVATE ${VLC_LIBRARIES})
target_link_libraries(notcurses-static PRIVATE ${VLC_STATIC_LIBRARIES})
target_link_directories(notcurses PRIVATE ${VLC_LIBRARY_DIRS})
target_link_directories(notcurses-static PRIVATE ${VLC_STATIC_LIBRARY_DIRS})
endif()
# don't want these on freebsd
@ -533,7 +546,7 @@ target_link_libraries(notcurses-tetris
)
# notcurses-view
if(${USE_FFMPEG} OR ${USE_OIIO})
if(${USE_FFMPEG} OR ${USE_OIIO} OR ${USE_VLC})
file(GLOB VIEWSRCS CONFIGURE_DEPENDS src/view/*.cpp)
add_executable(notcurses-view ${VIEWSRCS})
target_include_directories(notcurses-view
@ -668,7 +681,7 @@ install(FILES
DESTINATION ${PKGCONFIG_DIR}
)
if(${USE_FFMPEG} OR ${USE_OIIO})
if(${USE_FFMPEG} OR ${USE_OIIO} OR ${USE_VLC})
file(GLOB TESTDATA CONFIGURE_DEPENDS data/*)
# Don't install source materia for self-originated multimedia
list(FILTER TESTDATA EXCLUDE REGEX ".*xcf$")
@ -686,7 +699,7 @@ install(TARGETS notcurses-input DESTINATION bin)
install(TARGETS ncls DESTINATION bin)
install(TARGETS ncneofetch DESTINATION bin)
install(TARGETS notcurses-tetris DESTINATION bin)
if(${USE_FFMPEG} OR ${USE_OIIO})
if(${USE_FFMPEG} OR ${USE_OIIO} OR ${USE_VLC})
install(TARGETS notcurses-view DESTINATION bin)
endif()

View File

@ -119,6 +119,7 @@ that fine library.
* (OPTIONAL) (build+runtime) From QR-Code-generator: [libqrcodegen](https://github.com/nayuki/QR-Code-generator) 1.5.0+
* (OPTIONAL) (build+runtime) From [FFmpeg](https://www.ffmpeg.org/): libswscale 5.0+, libavformat 57.0+, libavutil 56.0+
* (OPTIONAL) (build+runtime) [OpenImageIO](https://github.com/OpenImageIO/oiio) 2.15.0+
* (OPTIONAL) (build+runtime) [libVLC](https://www.videolan.org/vlc/libvlc.html) 3.0.9+
* (OPTIONAL) (testing) [Doctest](https://github.com/onqtam/doctest) 2.3.5+
* (OPTIONAL) (documentation) [pandoc](https://pandoc.org/index.html) 1.19.2+
* (OPTIONAL) (python bindings): Python 3.7+, [CFFI](https://pypi.org/project/cffi/) 1.13.2+, [pypandoc](https://pypi.org/project/pypandoc/) 1.5+
@ -135,8 +136,8 @@ that fine library.
The default multimedia engine is FFmpeg. You can select a different engine
using `USE_MULTIMEDIA`. Valid values are `ffmpeg`, `oiio` (for OpenImageIO),
or `none`. Without a multimedia engine, Notcurses will be unable to decode
images and videos.
`vlc` (for libVLC), or `none`. Without a multimedia engine, Notcurses will be
unable to decode images and videos.
Run unit tests with `make test` following a successful build. If you have unit
test failures, *please* file a bug including the output of
@ -182,7 +183,7 @@ but must be `Debug` for use of `USE_COVERAGE`.
* `USE_COVERAGE`: build coverage support (for developers, requires use of Clang)
* `USE_DOCTEST`: build `notcurses-tester` with Doctest, requires `BUILD_TESTING`
* `USE_DOXYGEN`: build interlinked HTML documentation with Doxygen
* `USE_MULTIMEDIA`: `ffmpeg` for FFmpeg, `oiio` for OpenImageIO, `none` for none
* `USE_MULTIMEDIA`: `ffmpeg` for FFmpeg, `oiio` for OpenImageIO, `vlc` for libVLC, `none` for none
* `USE_PANDOC`: build man pages with pandoc
* `USE_POC`: build small, uninstalled proof-of-concept binaries
* `USE_QRCODEGEN`: build qrcode support via libqrcodegen

56
src/lib/vlc.cpp Normal file
View File

@ -0,0 +1,56 @@
#include "builddef.h"
#ifdef USE_VLC
#include "ffmpeg.h"
#include "internal.h"
#include "visual-details.h"
bool notcurses_canopen_images(const notcurses* nc __attribute__ ((unused))) {
return true;
}
bool notcurses_canopen_videos(const notcurses* nc __attribute__ ((unused))) {
return true;
}
auto ncvisual_subtitle(const ncvisual* ncv) -> char* {
return nullptr;
}
int ncvisual_decode(ncvisual* nc){
return -1;
}
// resize frame to oframe, converting to RGBA (if necessary) along the way
int ncvisual_resize(ncvisual* nc, int rows, int cols) {
return -1;
}
ncvisual* ncvisual_from_file(const char* filename) {
return nullptr;
}
// iterate over the decoded frames, calling streamer() with curry for each.
// frames carry a presentation time relative to the beginning, so we get an
// initial timestamp, and check each frame against the elapsed time to sync
// up playback.
int ncvisual_stream(notcurses* nc, ncvisual* ncv, float timescale,
streamcb streamer, const struct ncvisual_options* vopts,
void* curry) {
return -1;
}
int ncvisual_decode_loop(ncvisual* ncv){
return -1;
}
int ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
const struct blitset* bset, int placey, int placex,
int begy, int begx, int leny, int lenx,
bool blendcolors) {
return -1;
}
int ncvisual_init(int loglevel) {
return -1;
}
#endif