Commit 72aabd94 authored by Laurent Aimar's avatar Laurent Aimar

Added mouse support to sub-filter.

parent 5d51dfe0
...@@ -101,13 +101,18 @@ struct filter_t ...@@ -101,13 +101,18 @@ struct filter_t
struct struct
{ {
subpicture_t * (*pf_filter) ( filter_t *, mtime_t ); subpicture_t * (*pf_filter) ( filter_t *, mtime_t );
subpicture_t * (*pf_buffer_new) ( filter_t * ); subpicture_t * (*pf_buffer_new)( filter_t * );
void (*pf_buffer_del) ( filter_t *, subpicture_t * ); void (*pf_buffer_del)( filter_t *, subpicture_t * );
int (*pf_mouse) ( filter_t *,
const vlc_mouse_t *p_old,
const vlc_mouse_t *p_new,
const video_format_t * );
} sub; } sub;
#define pf_sub_filter u.sub.pf_filter #define pf_sub_filter u.sub.pf_filter
#define pf_sub_buffer_new u.sub.pf_buffer_new #define pf_sub_buffer_new u.sub.pf_buffer_new
#define pf_sub_buffer_del u.sub.pf_buffer_del #define pf_sub_buffer_del u.sub.pf_buffer_del
#define pf_sub_mouse u.sub.pf_mouse
struct struct
{ {
...@@ -370,5 +375,12 @@ VLC_EXPORT( void, filter_chain_SubFilter, ( filter_chain_t *, mtime_t ) ); ...@@ -370,5 +375,12 @@ VLC_EXPORT( void, filter_chain_SubFilter, ( filter_chain_t *, mtime_t ) );
*/ */
VLC_EXPORT( int, filter_chain_MouseFilter, ( filter_chain_t *, vlc_mouse_t *, const vlc_mouse_t * ) ); VLC_EXPORT( int, filter_chain_MouseFilter, ( filter_chain_t *, vlc_mouse_t *, const vlc_mouse_t * ) );
/**
* Inform the filter chain of mouse state.
*
* It makes sense only for a sub filter chain.
*/
VLC_EXPORT( int, filter_chain_MouseEvent, ( filter_chain_t *, const vlc_mouse_t *, const video_format_t * ) );
#endif /* _VLC_FILTER_H */ #endif /* _VLC_FILTER_H */
...@@ -131,6 +131,7 @@ filter_chain_DeleteFilter ...@@ -131,6 +131,7 @@ filter_chain_DeleteFilter
filter_chain_GetFmtOut filter_chain_GetFmtOut
filter_chain_GetLength filter_chain_GetLength
filter_chain_MouseFilter filter_chain_MouseFilter
filter_chain_MouseEvent
filter_chain_New filter_chain_New
filter_chain_Reset filter_chain_Reset
filter_chain_SubFilter filter_chain_SubFilter
......
...@@ -284,6 +284,25 @@ int filter_chain_MouseFilter( filter_chain_t *p_chain, vlc_mouse_t *p_dst, const ...@@ -284,6 +284,25 @@ int filter_chain_MouseFilter( filter_chain_t *p_chain, vlc_mouse_t *p_dst, const
return VLC_SUCCESS; return VLC_SUCCESS;
} }
int filter_chain_MouseEvent( filter_chain_t *p_chain,
const vlc_mouse_t *p_mouse,
const video_format_t *p_fmt )
{
for( chained_filter_t *f = p_chain->first; f != NULL; f = f->next )
{
filter_t *p_filter = &f->filter;
if( p_filter->pf_sub_mouse )
{
vlc_mouse_t old = *f->mouse;
*f->mouse = *p_mouse;
if( p_filter->pf_sub_mouse( p_filter, &old, p_mouse, p_fmt ) )
return VLC_EGENERIC;
}
}
return VLC_SUCCESS;
}
/* Helpers */ /* Helpers */
static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain, static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
......
...@@ -1411,6 +1411,9 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m) ...@@ -1411,6 +1411,9 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
{ {
vlc_mouse_t tmp; vlc_mouse_t tmp;
if (spu_ProcessMouse( vout->p->p_spu, m, &vout->fmt_out))
return;
vlc_mutex_lock( &vout->p->vfilter_lock ); vlc_mutex_lock( &vout->p->vfilter_lock );
if (vout->p->p_vf2_chain) { if (vout->p->p_vf2_chain) {
if (!filter_chain_MouseFilter(vout->p->p_vf2_chain, &tmp, m)) if (!filter_chain_MouseFilter(vout->p->p_vf2_chain, &tmp, m))
......
...@@ -161,5 +161,8 @@ int vout_ManageWrapper(vout_thread_t *); ...@@ -161,5 +161,8 @@ int vout_ManageWrapper(vout_thread_t *);
void vout_RenderWrapper(vout_thread_t *, picture_t *); void vout_RenderWrapper(vout_thread_t *, picture_t *);
void vout_DisplayWrapper(vout_thread_t *, picture_t *); void vout_DisplayWrapper(vout_thread_t *, picture_t *);
/* */
int spu_ProcessMouse(spu_t *, const vlc_mouse_t *, const video_format_t *);
#endif #endif
...@@ -88,6 +88,7 @@ struct spu_private_t ...@@ -88,6 +88,7 @@ struct spu_private_t
/* Subpiture filters */ /* Subpiture filters */
char *psz_chain_update; char *psz_chain_update;
vlc_mutex_t chain_lock;
filter_chain_t *p_chain; filter_chain_t *p_chain;
/* */ /* */
...@@ -226,6 +227,7 @@ spu_t *spu_Create( vlc_object_t *p_this ) ...@@ -226,6 +227,7 @@ spu_t *spu_Create( vlc_object_t *p_this )
p_sys->i_channel = 2; p_sys->i_channel = 2;
p_sys->psz_chain_update = NULL; p_sys->psz_chain_update = NULL;
vlc_mutex_init( &p_sys->chain_lock );
p_sys->p_chain = filter_chain_New( p_spu, "sub filter", false, p_sys->p_chain = filter_chain_New( p_spu, "sub filter", false,
SubFilterAllocationInit, SubFilterAllocationInit,
SubFilterAllocationClean, SubFilterAllocationClean,
...@@ -279,6 +281,7 @@ void spu_Destroy( spu_t *p_spu ) ...@@ -279,6 +281,7 @@ void spu_Destroy( spu_t *p_spu )
FilterRelease( p_sys->p_scale ); FilterRelease( p_sys->p_scale );
filter_chain_Delete( p_sys->p_chain ); filter_chain_Delete( p_sys->p_chain );
vlc_mutex_destroy( &p_sys->chain_lock );
free( p_sys->psz_chain_update ); free( p_sys->psz_chain_update );
/* Destroy all remaining subpictures */ /* Destroy all remaining subpictures */
...@@ -326,6 +329,22 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach ) ...@@ -326,6 +329,22 @@ void spu_Attach( spu_t *p_spu, vlc_object_t *p_this, bool b_attach )
} }
} }
/**
* Inform the SPU filters of mouse event
*/
int spu_ProcessMouse( spu_t *p_spu,
const vlc_mouse_t *p_mouse,
const video_format_t *p_fmt )
{
spu_private_t *p_sys = p_spu->p;
vlc_mutex_lock( &p_sys->chain_lock );
filter_chain_MouseEvent( p_sys->p_chain, p_mouse, p_fmt );
vlc_mutex_unlock( &p_sys->chain_lock );
return VLC_SUCCESS;
}
/** /**
* Display a subpicture * Display a subpicture
* *
...@@ -552,6 +571,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date, ...@@ -552,6 +571,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
p_sys->psz_chain_update = NULL; p_sys->psz_chain_update = NULL;
vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_unlock( &p_sys->lock );
vlc_mutex_lock( &p_sys->chain_lock );
if( psz_chain_update ) if( psz_chain_update )
{ {
filter_chain_Reset( p_sys->p_chain, NULL, NULL ); filter_chain_Reset( p_sys->p_chain, NULL, NULL );
...@@ -560,9 +580,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date, ...@@ -560,9 +580,9 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
free( psz_chain_update ); free( psz_chain_update );
} }
/* Run subpicture filters */ /* Run subpicture filters */
filter_chain_SubFilter( p_sys->p_chain, render_osd_date ); filter_chain_SubFilter( p_sys->p_chain, render_osd_date );
vlc_mutex_unlock( &p_sys->chain_lock );
vlc_mutex_lock( &p_sys->lock ); vlc_mutex_lock( &p_sys->lock );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment