[vlc-devel] How to monitor playlist changes in a filter module?

Peter Tap ptrtap at yahoo.com
Tue May 26 11:14:21 CEST 2015


I have a video filter module that I am using to display custom video output:

vlc_module_begin ()
  set_category( CAT_VIDEO )
  set_subcategory( SUBCAT_VIDEO_VFILTER )
  set_capability( "video filter2", 0 )

The filter works as expected. 

I now need to monitor playlist changes as well.

Here is the new code that I added in my OpenVideo() call:

static int OpenVideo(vlc_object_t *p_this) {
  filter_t *p_filter = (filter_t *)p_this;

  filter_sys_t* p_sys = p_filter->p_sys = new filter_sys_t();

  // intf_thread_t* p_intf = (intf_thread_t*)p_this; // IS THIS OKAY?
  p_sys->p_playlist = pl_Get(p_intf);
  var_AddCallback(p_sys->p_playlist, "activity", PlaylistChange, p_sys);

  p_sys->p_input = playlist_CurrentInput(p_sys->p_playlist);
  if (p_sys->p_input != NULL) {
    var_AddCallback(p_sys->p_input, "intf-event", InputEvent, p_sys);


The problem is I am not clear on how to obtain p_intf from p_this/p_filter.

Some other modules simply cast p_this to intf_thread_t type. However, I am not sure
if this is right as we already know that p_this is of filter_t type.

Even if I do force p_this to be of type intf_thread_t, I get an error that
"activity" is not a defined variable. Also, p_input always stays NULL.

Thank you in advance for your help.


More information about the vlc-devel mailing list