capabilities testing for fade/ffmpeg

pull/232/head
nick black 5 years ago
parent 3544bd86e2
commit 132793211c
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -264,6 +264,12 @@ unsigned notcurses_supported_styles(const struct notcurses* nc);
// there is no color support. Note that several terminal emulators advertise
// more colors than they actually support, downsampling internally.
int notcurses_palette_size(const struct notcurses* nc);
// Can we fade? Fading requires either the "rgb" or "ccc" terminfo capability.
bool notcurses_canfade(const struct notcurses* nc);
// Can we load images/videos? This requires being built against FFmpeg.
bool notcurses_canopen(const struct notcurses* nc);
```
### Input

@ -330,6 +330,14 @@ API unsigned notcurses_supported_styles(const struct notcurses* nc);
// more colors than they actually support, downsampling internally.
API int notcurses_palette_size(const struct notcurses* nc);
// Capabilities
// Can we fade? Fading requires either the "rgb" or "ccc" terminfo capability.
API bool notcurses_canfade(const struct notcurses* nc);
// Can we load images/videos? This requires being built against FFmpeg.
API bool notcurses_canopen(const struct notcurses* nc);
typedef struct ncstats {
uint64_t renders; // number of successful notcurses_render() runs
uint64_t failed_renders; // number of aborted renders, should be 0

@ -33,6 +33,10 @@ void ncvisual_destroy(ncvisual* ncv){
}
#ifndef DISABLE_FFMPEG
bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){
return true;
}
static ncvisual*
ncvisual_create(void){
ncvisual* ret = malloc(sizeof(*ret));
@ -400,6 +404,9 @@ int ncvisual_init(void){
}
#else
// built without ffmpeg
bool notcurses_canopen(const notcurses* nc __attribute__ ((unused))){
return false;
}
struct AVFrame* ncvisual_decode(ncvisual* nc, int* averr){
(void)nc;

@ -1598,3 +1598,7 @@ int notcurses_mouse_disable(notcurses* n){
/*SET_FOCUS_EVENT_MOUSE ";" */SET_SGR_MODE_MOUSE "l",
n->ttyfp, true);
}
bool notcurses_canfade(const notcurses* nc){
return nc->CCCflag || nc->RGBflag;
}

@ -15,6 +15,9 @@ class FadeTest : public :: testing::Test {
ASSERT_NE(nullptr, outfp_);
nc_ = notcurses_init(&nopts, outfp_);
ASSERT_NE(nullptr, nc_);
if(!notcurses_canfade(nc_)){
GTEST_SKIP();
}
n_ = notcurses_stdplane(nc_);
ASSERT_NE(nullptr, n_);
ASSERT_EQ(0, ncplane_cursor_move_yx(n_, 0, 0));

@ -2,10 +2,6 @@
#include "version.h"
#include "main.h"
#ifndef DISABLE_FFMPEG
#include <libavutil/pixdesc.h>
#include <libavutil/avconfig.h>
#include <libavcodec/avcodec.h> // ffmpeg doesn't reliably "C"-guard itself
class LibavTest : public :: testing::Test {
protected:
void SetUp() override {
@ -38,6 +34,19 @@ class LibavTest : public :: testing::Test {
FILE* outfp_{};
};
#ifdef DISABLE_FFMPEG
TEST_F(LibavTest, LibavDisabled){
ASSERT_FALSE(notcurses_canopen(nc_);
}
#else
#include <libavutil/pixdesc.h>
#include <libavutil/avconfig.h>
#include <libavcodec/avcodec.h> // ffmpeg doesn't reliably "C"-guard itself
TEST_F(LibavTest, LibavEnabled){
ASSERT_TRUE(notcurses_canopen(nc_));
}
TEST_F(LibavTest, LoadImage) {
int averr;
int dimy, dimx;

Loading…
Cancel
Save