[vlc-devel] [PATCH 09/12] bluray: Handle mouse event.

Hugo Beauzée-Luyssen beauze.h at gmail.com
Sun Jan 22 00:31:04 CET 2012


---
 modules/access/bluray.c |   69 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index fe43556..2e8ff88 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -37,6 +37,7 @@
 #include <vlc_vout.h>
 
 #include <libbluray/bluray.h>
+#include <libbluray/keys.h>
 #include <libbluray/meta_data.h>
 #include <libbluray/overlay.h>
 
@@ -104,6 +105,9 @@ static void    blurayHandleEvents( demux_t *p_demux );
 
 static void    blurayOverlayProc( void *ptr, const BD_OVERLAY * const overlay );
 
+static int     onMouseEvent( vlc_object_t *p_vout, const char *psz_var, vlc_value_t old,
+                                vlc_value_t val, void *p_data );
+
 #define FROM_TICKS(a) (a*CLOCK_FREQ / INT64_C(90000))
 #define TO_TICKS(a)   (a*INT64_C(90000)/CLOCK_FREQ)
 #define CUR_LENGTH    p_sys->pp_title[p_demux->info.i_title]->i_length
@@ -274,6 +278,10 @@ static void blurayClose( vlc_object_t *object )
     free(p_sys);
 }
 
+/*****************************************************************************
+ * libbluray overlay handling:
+ *****************************************************************************/
+
 static void blurayDeleteOverlaySubPic( demux_t *p_demux, int i_plane )
 {
     demux_sys_t     *p_sys = p_demux->p_sys;
@@ -296,12 +304,14 @@ static void blurayCloseOverlay( demux_t *p_demux )
     p_demux->p_sys->current_overlay = -1;
     if ( p_sys->p_vout != NULL )
     {
+        var_DelCallback( p_sys->p_vout, "mouse-moved", &onMouseEvent, p_demux );
+        var_DelCallback( p_sys->p_vout, "mouse-clicked", &onMouseEvent, p_demux );
         vlc_object_release( p_sys->p_vout );
         p_sys->p_vout = NULL;
     }
 }
 
-static void blurayDisplayOverlay( demux_t *p_demux, const BD_OVERLAY* const ov )
+static void blurayActivateOverlay( demux_t *p_demux, const BD_OVERLAY* const ov )
 {
     demux_sys_t     *p_sys = p_demux->p_sys;
     /*
@@ -403,7 +413,7 @@ static void blurayOverlayProc( void *ptr, const BD_OVERLAY *const overlay )
             break ;
         case BD_OVERLAY_FLUSH:
             msg_Info( p_demux, "Displaying overlay" );
-            blurayDisplayOverlay( p_demux, overlay );
+            blurayActivateOverlay( p_demux, overlay );
             break ;
         case BD_OVERLAY_DRAW:
             blurayDrawOverlay( p_demux, overlay );
@@ -414,6 +424,54 @@ static void blurayOverlayProc( void *ptr, const BD_OVERLAY *const overlay )
     }
 }
 
+/*****************************************************************************
+ * overlay display and events:
+ *****************************************************************************/
+
+static int  onMouseEvent( vlc_object_t *p_vout, const char *psz_var, vlc_value_t old,
+                          vlc_value_t val, void *p_data )
+{
+    demux_t     *p_demux = (demux_t*)p_data;
+    demux_sys_t *p_sys = p_demux->p_sys;
+    VLC_UNUSED( old );
+    VLC_UNUSED( p_vout );
+
+    if ( psz_var[6] == 'm' ) //Mouse moved
+        bd_mouse_select( p_sys->bluray, mdate(), val.coords.x, val.coords.y );
+    else if ( psz_var[6] == 'c' )
+    {
+        int64_t     now = mdate();
+        bd_mouse_select( p_sys->bluray, now, val.coords.x, val.coords.y );
+        bd_user_input( p_sys->bluray, now, BD_VK_MOUSE_ACTIVATE );
+    }
+    else
+    {
+        msg_Warn( p_demux, "Unknown mouse event: %s", psz_var );
+        return VLC_EGENERIC;
+    }
+    return VLC_SUCCESS;
+}
+
+static void blurayDisplayOverlay( demux_t *p_demux )
+{
+    demux_sys_t *p_sys = p_demux->p_sys;
+
+    //Sending subpicture to vout:
+    p_sys->p_pic[p_sys->current_overlay]->i_start =
+            p_sys->p_pic[p_sys->current_overlay]->i_stop = mdate();
+    p_sys->p_pic[p_sys->current_overlay]->i_channel =
+            vout_RegisterSubpictureChannel( p_sys->p_vout );
+    vout_PutSubpicture( p_sys->p_vout, p_sys->p_pic[p_sys->current_overlay] );
+    p_sys->current_overlay = -1;
+    //Activating vout events handling:
+    var_AddCallback( p_sys->p_vout, "mouse-moved", &onMouseEvent, p_demux );
+    var_AddCallback( p_sys->p_vout, "mouse-clicked", &onMouseEvent, p_demux );
+}
+
+/*****************************************************************************
+ * Titles management:
+ *****************************************************************************/
+
 static int blurayInitTitles(demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
@@ -729,12 +787,7 @@ static int blurayDemuxMenu( demux_t *p_demux )
             p_sys->p_vout = input_GetVout( p_sys->p_input );
         if ( p_sys->p_vout != NULL )
         {
-            p_sys->p_pic[p_sys->current_overlay]->i_start =
-                    p_sys->p_pic[p_sys->current_overlay]->i_stop = mdate();
-            p_sys->p_pic[p_sys->current_overlay]->i_channel =
-                    vout_RegisterSubpictureChannel( p_sys->p_vout );
-            vout_PutSubpicture( p_sys->p_vout, p_sys->p_pic[p_sys->current_overlay] );
-            p_sys->current_overlay = -1;
+            blurayDisplayOverlay( p_demux );
         }
     }
     stream_DemuxSend( p_sys->p_parser, p_block );
-- 
1.7.8.4




More information about the vlc-devel mailing list