properly dispatch post-split ncvisual_subtitles()

This commit is contained in:
nick black 2021-01-20 23:00:22 -05:00
parent 73834e392c
commit 86009433e3
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
4 changed files with 10 additions and 5 deletions

View File

@ -1072,6 +1072,7 @@ typedef struct ncvisual_implementation {
// have been prepared already in 'ncv'. // have been prepared already in 'ncv'.
void (*ncvisual_details_seed)(struct ncvisual* ncv); void (*ncvisual_details_seed)(struct ncvisual* ncv);
void (*ncvisual_details_destroy)(struct ncvisual_details* deets); void (*ncvisual_details_destroy)(struct ncvisual_details* deets);
char* (*ncvisual_subtitle)(const struct ncvisual* ncv);
bool canopen_images; bool canopen_images;
bool canopen_videos; bool canopen_videos;
} ncvisual_implementation; } ncvisual_implementation;

View File

@ -663,8 +663,10 @@ auto ncvisual_stream(notcurses* nc, ncvisual* ncv, float timescale,
} }
auto ncvisual_subtitle(const ncvisual* ncv) -> char* { auto ncvisual_subtitle(const ncvisual* ncv) -> char* {
(void)ncv; if(!visual_implementation){
return nullptr; return nullptr;
}
return visual_implementation->ncvisual_subtitle(ncv);
} }
auto ncvisual_resize(ncvisual* nc, int rows, int cols) -> int { auto ncvisual_resize(ncvisual* nc, int rows, int cols) -> int {

View File

@ -112,7 +112,7 @@ deass(const char* ass) {
return dup; return dup;
} }
auto ncvisual_subtitle(const ncvisual* ncv) -> char* { auto ffmpeg_subtitle(const ncvisual* ncv) -> char* {
for(unsigned i = 0 ; i < ncv->details->subtitle.num_rects ; ++i){ for(unsigned i = 0 ; i < ncv->details->subtitle.num_rects ; ++i){
const AVSubtitleRect* rect = ncv->details->subtitle.rects[i]; const AVSubtitleRect* rect = ncv->details->subtitle.rects[i];
if(rect->type == SUBTITLE_ASS){ if(rect->type == SUBTITLE_ASS){
@ -584,13 +584,14 @@ auto ncvisual_details_destroy(ncvisual_details* deets) -> void {
delete deets; delete deets;
} }
const static ncvisual_implementation ffmpeg_impl = { static const ncvisual_implementation ffmpeg_impl = {
.ncvisual_init = ffmpeg_init, .ncvisual_init = ffmpeg_init,
.ncvisual_printbanner = ncvisual_printbanner, .ncvisual_printbanner = ncvisual_printbanner,
.ncvisual_blit = ffmpeg_blit, .ncvisual_blit = ffmpeg_blit,
.ncvisual_create = ncvisual_create, .ncvisual_create = ncvisual_create,
.ncvisual_details_seed = ncvisual_details_seed, .ncvisual_details_seed = ncvisual_details_seed,
.ncvisual_details_destroy = ncvisual_details_destroy, .ncvisual_details_destroy = ncvisual_details_destroy,
.ncvisual_subtitle = ffmpeg_subtitle,
.canopen_images = true, .canopen_images = true,
.canopen_videos = true, .canopen_videos = true,
}; };

View File

@ -227,7 +227,7 @@ auto ncvisual_stream(notcurses* nc, ncvisual* ncv, float timescale,
return -1; return -1;
} }
char* ncvisual_subtitle(const ncvisual* ncv) { // no support in OIIO char* oiio_subtitle(const ncvisual* ncv) { // no support in OIIO
(void)ncv; (void)ncv;
return nullptr; return nullptr;
} }
@ -275,6 +275,7 @@ const static ncvisual_implementation oiio_impl = {
.ncvisual_create = oiio_create, .ncvisual_create = oiio_create,
.ncvisual_details_seed = oiio_details_seed, .ncvisual_details_seed = oiio_details_seed,
.ncvisual_details_destroy = oiio_details_destroy, .ncvisual_details_destroy = oiio_details_destroy,
.ncvisual_subtitle = oiio_subtitle,
.canopen_images = true, .canopen_images = true,
.canopen_videos = false, .canopen_videos = false,
}; };