]> git.sesse.net Git - vlc/commitdiff
Added mouse support to sub-filter.
authorLaurent Aimar <fenrir@videolan.org>
Fri, 30 Apr 2010 23:31:26 +0000 (01:31 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Sat, 1 May 2010 11:39:54 +0000 (13:39 +0200)
include/vlc_filter.h
src/libvlccore.sym
src/misc/filter_chain.c
src/video_output/display.c
src/video_output/vout_internal.h
src/video_output/vout_subpictures.c

index cdc69237498f64d36d9050f46136563cba893a33..dd5cc299cbf2e5d4f54097cb9672bbf572447fe5 100644 (file)
@@ -101,13 +101,18 @@ struct filter_t
 
         struct
         {
-            subpicture_t * (*pf_filter) ( filter_t *, mtime_t );
-            subpicture_t * (*pf_buffer_new) ( filter_t * );
-            void        (*pf_buffer_del) ( filter_t *, subpicture_t * );
+            subpicture_t * (*pf_filter)    ( filter_t *, mtime_t );
+            subpicture_t * (*pf_buffer_new)( filter_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;
 #define pf_sub_filter      u.sub.pf_filter
 #define pf_sub_buffer_new  u.sub.pf_buffer_new
 #define pf_sub_buffer_del  u.sub.pf_buffer_del
+#define pf_sub_mouse       u.sub.pf_mouse
 
         struct
         {
@@ -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 * ) );
 
+/**
+ * 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 */
 
index 2c548b644163f4729684b085b7a06165d5cd3df0..a8479ebb70bde49d2e476f9329bebb4dc4ed2bd1 100644 (file)
@@ -131,6 +131,7 @@ filter_chain_DeleteFilter
 filter_chain_GetFmtOut
 filter_chain_GetLength
 filter_chain_MouseFilter
+filter_chain_MouseEvent
 filter_chain_New
 filter_chain_Reset
 filter_chain_SubFilter
index 01e99138409e0199bb48c3dcf4329a5c69e9063a..3fd4c31991ce7e43b6a75788a436a850109cb6a9 100644 (file)
@@ -284,6 +284,25 @@ int filter_chain_MouseFilter( filter_chain_t *p_chain, vlc_mouse_t *p_dst, const
     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 */
 static filter_t *filter_chain_AppendFilterInternal( filter_chain_t *p_chain,
index 09e2d137a503bda4a8afb0aab136bbe6e52cc697..6c1d1a34baf93667fe345f8b5bbb4f45682633c4 100644 (file)
@@ -1411,6 +1411,9 @@ void vout_SendDisplayEventMouse(vout_thread_t *vout, const vlc_mouse_t *m)
 {
     vlc_mouse_t tmp;
 
+    if (spu_ProcessMouse( vout->p->p_spu, m, &vout->fmt_out))
+        return;
+
     vlc_mutex_lock( &vout->p->vfilter_lock );
     if (vout->p->p_vf2_chain) {
         if (!filter_chain_MouseFilter(vout->p->p_vf2_chain, &tmp, m))
index c23d276369164a8912d235a5ebe24f6e5af81a7e..c9b2ea3c56644b55ef3336b83d8f64519bd50006 100644 (file)
@@ -161,5 +161,8 @@ int  vout_ManageWrapper(vout_thread_t *);
 void vout_RenderWrapper(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
 
index a4e7c60e9731aecdd65751aeeeaa10180a25348c..adef7e923e45828e8ad25b60995d77d333e02a88 100644 (file)
@@ -88,6 +88,7 @@ struct spu_private_t
 
     /* Subpiture filters */
     char           *psz_chain_update;
+    vlc_mutex_t    chain_lock;
     filter_chain_t *p_chain;
 
     /* */
@@ -226,6 +227,7 @@ spu_t *spu_Create( vlc_object_t *p_this )
     p_sys->i_channel = 2;
 
     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,
                                        SubFilterAllocationInit,
                                        SubFilterAllocationClean,
@@ -279,6 +281,7 @@ void spu_Destroy( spu_t *p_spu )
         FilterRelease( p_sys->p_scale );
 
     filter_chain_Delete( p_sys->p_chain );
+    vlc_mutex_destroy( &p_sys->chain_lock );
     free( p_sys->psz_chain_update );
 
     /* Destroy all remaining subpictures */
@@ -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
  *
@@ -552,6 +571,7 @@ subpicture_t *spu_SortSubpictures( spu_t *p_spu, mtime_t render_subtitle_date,
     p_sys->psz_chain_update = NULL;
     vlc_mutex_unlock( &p_sys->lock );
 
+    vlc_mutex_lock( &p_sys->chain_lock );
     if( psz_chain_update )
     {
         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,
 
         free( psz_chain_update );
     }
-
     /* Run subpicture filters */
     filter_chain_SubFilter( p_sys->p_chain, render_osd_date );
+    vlc_mutex_unlock( &p_sys->chain_lock );
 
     vlc_mutex_lock( &p_sys->lock );