I am creating android application that uses libvlc
to play a video.
Since vlc/libvlc doesnt have any kind of event/callback for subtitles i have created my own text renderer
module in modules/text_rendere/spucallback
Module compiles, but i have two problems.:
callback.h
typedef void (*spu_cb_t)(text_segment_t *p_segment);
struct spu_cb_t {
spu_cb_t cb;
};
struct spu_cb_t *callback;
callback.c
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdlib.h>
/* VLC core API headers */
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_filter.h>
#include "callback.h"
static int Open(vlc_object_t *);
static void Close(vlc_object_t *);
static int RenderText(filter_t *,
subpicture_region_t *p_region_out,
subpicture_region_t *p_region_in,
const vlc_fourcc_t *p_chroma_list);
/* Module descriptor */
vlc_module_begin()
set_shortname(N_("SPU Callback "))
set_description(N_("SPU Callback module"))
set_capability("text renderer", 0)
set_callbacks(Open, Close)
set_category(CAT_VIDEO)
vlc_module_end ()
static int Open(vlc_object_t *p_this)
{
filter_t *p_filter = (filter_t *)p_this;
p_filter->pf_render = RenderText;
printf("spucallback:Open");
callback = (spu_cb_t*) malloc(sizeof(spu_cb_t));
if (!callback)
goto error;
return VLC_SUCCESS;
error:
free(callback);
return VLC_EGENERIC;
}
static void Close(vlc_object_t *p_this)
{
printf("spucallback:Close");
free(callback->cb);
free(callback);
}
static int RenderText(filter_t *p_filter,
subpicture_region_t *p_region_out,
subpicture_region_t *p_region_in,
const vlc_fourcc_t *p_chroma_list)
{
text_segment_t *p_segment = p_region_in->p_text;
callback->cb(p_segment);
printf("spucallback:RenderText");
return VLC_SUCCESS;
}
Code is not yet finished obviously
This log messages might be related:
[e41bfa2c] core spu text: looking for text renderer module matching "spucallback": 1 candidates
[e41bfa2c] core spu text: no suitable access module for `file:///vendor/etc/fallback_fonts.xml'
[e41bfa2c] core spu text: using text renderer module "freetype"