Page 1 of 1

Programmatically requiring module of cap "video filter2"

Posted: 28 Sep 2012 21:11
by Vaselinessa
I'm trying to require a video filter module from an interface module.
  • Is there a better function for this than module_need? (I have tried to understand alternatives. See notes *)
  • What callback trigger is appropriate for triggering said function? (I have made attempts. See notes **)
  • Had I better module_unneed the filter module at any time?
TMI:

* I have looked at the possibility of using filter_chain_AppendFilter or a related function, but I don't see how to get a hold of the pointer to the current video filter chain. Any instruction is welcome.

** I tried attaching attaching a callback to the playlist using var_AddCallback( p_playlist, "item-current", PlaylistChangeCallback, p_intf ), then in the callback requiring the video filter module if playlist_CurrentInput( p_playlist ) returned a valid pointer, but that appears to be insufficient: when the video filter module opens, it holds an unrecognizeable input chroma code. This problem does not arise when I load the filter with a command line option (--video-filter my_video_filter). When I use the command line option, the input chroma is x30323449, whereas it is x5 when I use module_need in the callback function described above.

Re: Programmatically requiring module of cap "video filter2"

Posted: 28 Sep 2012 21:52
by Rémi Denis-Courmont
If you use module_need(), you are responsible for initializing the structure. module_need() does no magic whatsoever, the capability string is just a token.

filter_chain_AppendFilter() is probably better if you want to chain multiple filters. You will of course need to create your own filter chain first,

Re: Programmatically requiring module of cap "video filter2"

Posted: 28 Sep 2012 23:20
by Vaselinessa
Thanks, Remi.

Can you (or anyone) tell me what the owner (p_this) arg of filter_chain_New should be?

(If it can be just any vlc_object_t*, then is there a function which I must call to ensure that my filter chain be applied to the video output stream?)

(if the owner must be the output stream itself, can you say how I can request a pointer to it from my interface module?)

Re: Programmatically requiring module of cap "video filter2"

Posted: 29 Sep 2012 09:21
by Rémi Denis-Courmont
I don't think you can push a filter chain into the video output externally.

For that, you'd need to change the video-filter object variable on the video output object.

Re: Programmatically requiring module of cap "video filter2"

Posted: 30 Sep 2012 03:09
by Vaselinessa
Thanks, Remi. If I have interpreted your last instruction correctly, I am to make concern myself with the filter chain pointer on a vout_thread_t:

Code: Select all

p_vout->p->filter.chain_interactive
Therefore, I am looking for a callback that will fire when the current input is ready with a vout_thread_t, but I don't see a callback that will work. I tried to use:

Code: Select all

var_AddCallback( p_playlist, "item-current", PlaylistChangeCallback, p_intf );
...but when it fired, no vout thread existed on the current input thread.
I also tried adding the following in my PlaylistChangeCallback function:

Code: Select all

var_AddCallback( p_input, "state", InputChangeCallback, p_data );
...but this callback seems not to fire when the video begins. I can only get it to fire when play/pause happens.

Do you (or does anybody) know of a callback that will work?

Re: Programmatically requiring module of cap "video filter2"

Posted: 01 Oct 2012 17:12
by Vaselinessa
What I have tried latest is attaching a callback to the playlist's "item-change" event, using it to check for a vout, then removing that callback as soon as a vout is available. However, I may have constructed the deletion of the callback incorrectly, but the player stops painting the video, and the application won't close correctly.

Is the problem that I'm trying to delete the callback while it's firing?

Code: Select all

static int InputChangeCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { // Add callback to item-change var_AddCallback( p_playlist, "item-change", ItemChangeCallback, NULL ); //needs to be added elsewhere return 0; } static int ItemChangeCallback( vlc_object_t *p_this, const char *psz_var, vlc_value_t oldval, vlc_value_t newval, void *p_data ) { if (p_input) { // p_input is a global var // Get vout threads on curren tinput size_t n_vout; vout_thread_t **pp_vout; input_Control( p_input, INPUT_GET_VOUTS, &pp_vout, &n_vout ); if (n_vout) { // Unattach this callback from playlist var_DelCallback( p_playlist, "item-change", ItemChangeCallback, NULL ); } } return 0; }