Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pkg_check_modules(AVDEVICE REQUIRED libavdevice>=57.0)
pkg_check_modules(AVFORMAT REQUIRED libavformat>=57.0)
pkg_check_modules(AVUTIL REQUIRED libavutil>=56.0)
pkg_check_modules(SWSCALE REQUIRED libswscale>=5.0)
pkg_check_modules(SWRESAMPLE REQUIRED libswresample>=4.0)
set_property(GLOBAL APPEND PROPERTY PACKAGES_FOUND FFMpeg)
elseif(${USE_OIIO})
pkg_check_modules(OPENIMAGEIO REQUIRED OpenImageIO>=2.1)
Expand All @@ -130,7 +131,7 @@ if(NOT WIN32)
if(NOT ${USE_ASAN})
add_compile_definitions(_FORTIFY_SOURCE=2)
endif()
add_compile_options(-Wformat -Werror=format-security)
add_compile_options(-Wformat -Werror=format-security -Werror)
endif()
if(MSVC)
add_compile_options(/W4)
Expand Down Expand Up @@ -320,6 +321,9 @@ endif()
############################################################################
# libnotcurses (multimedia shared library+static library)
file(GLOB NCSRCS CONFIGURE_DEPENDS src/media/*.c src/media/*.cpp)
# Exclude audio-output.c from libnotcurses to avoid SDL2 being loaded at library load time
# audio-output.c will be compiled separately for ncplayer only
list(REMOVE_ITEM NCSRCS "${CMAKE_SOURCE_DIR}/src/media/audio-output.c")
add_library(notcurses SHARED ${NCSRCS} ${COMPATSRC})
if(${USE_STATIC})
# can't build binaries against static notcurses until ffmpeg linking issues
Expand Down Expand Up @@ -378,6 +382,7 @@ target_include_directories(notcurses
"${AVFORMAT_INCLUDE_DIRS}"
"${AVUTIL_INCLUDE_DIRS}"
"${SWSCALE_INCLUDE_DIRS}"
"${SWRESAMPLE_INCLUDE_DIRS}"
)
target_include_directories(notcurses-static
PRIVATE
Expand All @@ -386,13 +391,15 @@ target_include_directories(notcurses-static
"${AVFORMAT_STATIC_INCLUDE_DIRS}"
"${AVUTIL_STATIC_INCLUDE_DIRS}"
"${SWSCALE_STATIC_INCLUDE_DIRS}"
"${SWRESAMPLE_STATIC_INCLUDE_DIRS}"
)
target_link_libraries(notcurses
PRIVATE
"${AVCODEC_LIBRARIES}"
"${AVDEVICE_LIBRARIES}"
"${AVFORMAT_LIBRARIES}"
"${SWSCALE_LIBRARIES}"
"${SWRESAMPLE_LIBRARIES}"
"${AVUTIL_LIBRARIES}"
)
target_link_libraries(notcurses-static
Expand All @@ -401,6 +408,7 @@ target_link_libraries(notcurses-static
"${AVDEVICE_STATIC_LIBRARIES}"
"${AVFORMAT_STATIC_LIBRARIES}"
"${SWSCALE_STATIC_LIBRARIES}"
"${SWRESAMPLE_STATIC_LIBRARIES}"
"${AVUTIL_STATIC_LIBRARIES}"
)
target_link_directories(notcurses
Expand All @@ -409,6 +417,7 @@ target_link_directories(notcurses
"${AVDEVICE_LIBRARY_DIRS}"
"${AVFORMAT_LIBRARY_DIRS}"
"${SWSCALE_LIBRARY_DIRS}"
"${SWRESAMPLE_LIBRARY_DIRS}"
"${AVUTIL_LIBRARY_DIRS}"
)
target_link_directories(notcurses-static
Expand All @@ -417,6 +426,7 @@ target_link_directories(notcurses-static
"${AVDEVICE_STATIC_LIBRARY_DIRS}"
"${AVFORMAT_STATIC_LIBRARY_DIRS}"
"${SWSCALE_STATIC_LIBRARY_DIRS}"
"${SWRESAMPLE_STATIC_LIBRARY_DIRS}"
"${AVUTIL_STATIC_LIBRARY_DIRS}"
)
elseif(${USE_OIIO})
Expand Down Expand Up @@ -851,10 +861,23 @@ target_include_directories(ncplayer
"${CMAKE_REQUIRED_INCLUDES}"
"${PROJECT_BINARY_DIR}/include"
)
if(${USE_FFMPEG})
target_sources(ncplayer PRIVATE "${CMAKE_SOURCE_DIR}/src/media/audio-output.c")
endif()
target_link_libraries(ncplayer
PRIVATE
notcurses++
notcurses
)
if(${USE_FFMPEG})
target_link_libraries(ncplayer
PRIVATE
"${AVCODEC_LIBRARIES}"
"${AVFORMAT_LIBRARIES}"
"${AVUTIL_LIBRARIES}"
"${SWRESAMPLE_LIBRARIES}"
)
endif()
endif()
endif()
else()
Expand Down
10 changes: 10 additions & 0 deletions include/ncpp/Visual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ namespace ncpp
return error_guard (ncvisual_simple_streamer (visual, vopts, tspec, curry), -1);
}

bool seek (double seconds) const NOEXCEPT_MAYBE
{
return error_guard (ncvisual_seek (visual, seconds), -1);
}

int64_t frame_index () const NOEXCEPT_MAYBE
{
return ncvisual_frame_index (visual);
}

int polyfill (int y, int x, uint32_t rgba) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncvisual_polyfill_yx (visual, y, x, rgba), -1);
Expand Down
9 changes: 9 additions & 0 deletions include/notcurses/api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifdef API
#undef API
#endif

#ifdef __MINGW32__
# define API __declspec(dllexport)
#else
# define API __attribute__((visibility("default")))
#endif
6 changes: 1 addition & 5 deletions include/notcurses/direct.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define NOTCURSES_DIRECT

#include <notcurses/notcurses.h>
#include <notcurses/api.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -11,11 +12,6 @@ extern "C" {
#define static API
#endif

#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
#endif
#define ALLOC __attribute__((malloc)) __attribute__((warn_unused_result))

// ncdirect_init() will call setlocale() to inspect the current locale. If
Expand Down
6 changes: 1 addition & 5 deletions include/notcurses/nckeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stdint.h>
#include <stdbool.h>
#include <notcurses/api.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -12,11 +13,6 @@ extern "C" {
#define static API
#endif

#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
#endif
#define ALLOC __attribute__((malloc)) __attribute__((warn_unused_result))

// Synthesized input events, i.e. any input event we can report that isn't
Expand Down
15 changes: 10 additions & 5 deletions include/notcurses/notcurses.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <notcurses/ncport.h>
#include <notcurses/nckeys.h>
#include <notcurses/ncseqs.h>
#include <notcurses/api.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -28,11 +29,6 @@ extern "C" {
#define static API
#endif

#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
#endif
#define ALLOC __attribute__((malloc)) __attribute__((warn_unused_result))

// Get a human-readable string describing the running Notcurses version.
Expand Down Expand Up @@ -3435,6 +3431,15 @@ API int ncvisual_decode(struct ncvisual* nc)
API int ncvisual_decode_loop(struct ncvisual* nc)
__attribute__ ((nonnull (1)));

// Seek within a visual by the provided number of seconds. Positive values move
// forward, negative backwards. Not all backends support seeking.
API int ncvisual_seek(struct ncvisual* n, double seconds)
__attribute__ ((nonnull (1)));

// Return zero-based index of last decoded frame, or -1 if unavailable
API int64_t ncvisual_frame_index(const struct ncvisual* n)
__attribute__ ((nonnull (1)));

// Rotate the visual 'rads' radians. Only M_PI/2 and -M_PI/2 are supported at
// the moment, but this might change in the future.
API int ncvisual_rotate(struct ncvisual* n, double rads)
Expand Down
3 changes: 2 additions & 1 deletion src/lib/debug.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "internal.h"
#include <notcurses/api.h>

ncloglevel_e loglevel = NCLOGLEVEL_SILENT;
API ncloglevel_e loglevel = NCLOGLEVEL_SILENT;

void notcurses_debug(const notcurses* nc, FILE* debugfp){
fbuf f;
Expand Down
8 changes: 3 additions & 5 deletions src/lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "notcurses/ncport.h"
#include "notcurses/notcurses.h"
#include "notcurses/direct.h"
#include <notcurses/api.h>
// KEY_EVENT is defined by both ncurses.h (prior to 6.3) and wincon.h. since we
// don't use either definition, kill it before inclusion of ncurses.h.
#undef KEY_EVENT
Expand Down Expand Up @@ -38,11 +39,6 @@
#include "lib/gpm.h"


#ifndef __MINGW32__
#define API __attribute__((visibility("default")))
#else
#define API __declspec(dllexport)
#endif
#define ALLOC __attribute__((malloc)) __attribute__((warn_unused_result))

#ifdef __cplusplus
Expand Down Expand Up @@ -1807,6 +1803,8 @@ typedef struct ncvisual_implementation {
int rowalign; // rowstride base, can be 0 for no padding
// do a persistent resize, changing the ncv itself
int (*visual_resize)(struct ncvisual* ncv, unsigned rows, unsigned cols);
int (*visual_seek)(struct ncvisual* ncv, double seconds);
int64_t (*visual_frame_index)(const struct ncvisual* ncv);
void (*visual_destroy)(struct ncvisual* ncv);
bool canopen_images;
bool canopen_videos;
Expand Down
14 changes: 14 additions & 0 deletions src/lib/visual.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ int ncvisual_decode_loop(ncvisual* nc){
return visual_implementation->visual_decode_loop(nc);
}

int ncvisual_seek(ncvisual* nc, double seconds){
if(!visual_implementation->visual_seek){
return -1;
}
return visual_implementation->visual_seek(nc, seconds);
}

int64_t ncvisual_frame_index(const ncvisual* nc){
if(!visual_implementation->visual_frame_index){
return -1;
}
return visual_implementation->visual_frame_index(nc);
}

ncvisual* ncvisual_from_file(const char* filename){
if(!visual_implementation->visual_from_file){
return NULL;
Expand Down
Loading