libvlc initial work #1101

This commit is contained in:
nick black 2020-12-18 05:06:29 -05:00
parent ec63bd80ae
commit 8dd26c4f21
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
7 changed files with 80 additions and 8 deletions

View File

@ -18,6 +18,10 @@ extern "C" {
#else
#ifdef USE_OIIO
const char* oiio_version(void);
#else
#ifdef USE_VLC
const char* vlc_version(void);
#endif
#endif
#endif

View File

@ -878,10 +878,14 @@ init_banner(const notcurses* nc){
#else
#ifdef USE_OIIO
printf(" openimageio %s\n", oiio_version());
#else
#ifdef USE_VLC
printf(" libVLC %s\n", vlc_version());
#else
term_fg_palindex(nc, stderr, nc->tcache.colors <= 88 ? 1 % nc->tcache.colors : 0xcb);
fprintf(stderr, "\n Warning! Notcurses was built without multimedia support.\n");
#endif
#endif
#endif
fflush(stdout);
term_fg_palindex(nc, stderr, nc->tcache.colors <= 88 ? 1 % nc->tcache.colors : 0xcb);

View File

@ -10,6 +10,9 @@
#ifdef USE_OIIO
#include "oiio.h"
#else
#ifdef USE_VLC
#include "vlc.h"
#else
typedef struct ncvisual_details {
} ncvisual_details;
@ -25,6 +28,7 @@ ncvisual_details_destroy(ncvisual_details* deets) -> void {
}
#endif
#endif
#endif
struct ncplane;

View File

@ -567,8 +567,9 @@ auto ncvisual_polyfill_yx(ncvisual* n, int y, int x, uint32_t rgba) -> int {
return ncvisual_polyfill_recurse(n, y, x, rgba, *pixel);
}
#ifndef USE_OIIO // built without ffmpeg or oiio
#ifndef USE_OIIO // built without a multimedia backend
#ifndef USE_FFMPEG
#ifndef USE_VLC
auto ncvisual_from_file(const char* filename) -> ncvisual* {
(void)filename;
return nullptr;
@ -643,3 +644,4 @@ auto ncvisual_resize(ncvisual* nc, int rows, int cols) -> int {
#endif
#endif
#endif

View File

@ -1,8 +1,12 @@
#include "builddef.h"
#ifdef USE_VLC
#include "ffmpeg.h"
#include "vlc.h"
#include "internal.h"
#include "visual-details.h"
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
static libvlc_instance_t* vlcctx;
bool notcurses_canopen_images(const notcurses* nc __attribute__ ((unused))) {
return true;
@ -26,7 +30,16 @@ int ncvisual_resize(ncvisual* nc, int rows, int cols) {
}
ncvisual* ncvisual_from_file(const char* filename) {
return nullptr;
ncvisual* ret = new ncvisual;
if(ret == nullptr){
return nullptr;
}
ret->details.media = libvlc_media_new_path(vlcctx, filename);
if(ret->details.media == nullptr){
delete ret;
return nullptr;
}
return ret;
}
// iterate over the decoded frames, calling streamer() with curry for each.
@ -50,7 +63,20 @@ int ncvisual_blit(ncvisual* ncv, int rows, int cols, ncplane* n,
return -1;
}
const char* vlc_version() {
return libvlc_get_version();
}
auto ncvisual_details_seed(ncvisual* ncv) -> void {
}
int ncvisual_init(int loglevel) {
return -1;
const char * const argv[] = { NULL, };
libvlc_instance_t* vlc = libvlc_new(0, argv);
if(vlc == NULL){
return -1;
}
vlcctx = vlc;
return 0;
}
#endif

30
src/lib/vlc.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef NOTCURSES_VLC
#define NOTCURSES_VLC
#include <string.h>
#include "version.h"
#ifdef USE_VLC
#include <vlc/libvlc.h>
#include <vlc/libvlc_media.h>
typedef struct ncvisual_details {
libvlc_media_t *media;
} ncvisual_details;
static inline auto
ncvisual_details_init(ncvisual_details* deets) -> int {
memset(deets, 0, sizeof(*deets));
return 0;
}
static inline auto
ncvisual_details_destroy(ncvisual_details* deets) -> void {
if(deets->media){
libvlc_media_release(deets->media);
}
}
#endif
#endif

View File

@ -1,12 +1,14 @@
// Populated by CMake; not installed
#cmakedefine DFSG_BUILD
#cmakedefine USE_QRCODEGEN
// exclusive with USE_OIIO
// exclusive with USE_OIIO, USE_VLC
#cmakedefine USE_FFMPEG
// exclusive with USE_FFMPEG
// exclusive with USE_FFMPEG, USE_VLC
#cmakedefine USE_OIIO
// set if either USE_FFMPEG || USE_OIIO
#if defined(USE_FFMPEG) || defined(USE_OIIO)
// exclusive with USE_FFMPEG, USE_OIIO
#cmakedefine USE_VLC
// set if either USE_FFMPEG || USE_OIIO || USE_VLC
#if defined(USE_FFMPEG) || defined(USE_OIIO) || defined(USE_VLC)
#define NOTCURSES_USE_MULTIMEDIA
#endif
#define NOTCURSES_SHARE "@CMAKE_INSTALL_FULL_DATADIR@/notcurses"