[vlc-devel] [V3 PATCH 2/3] es_out: add ES_OUT_SET_VOUT_MOUSE_EVENT

Thomas Guillem thomas at gllm.fr
Mon Jul 16 15:57:22 CEST 2018


---
 include/vlc_es_out.h         |  4 ++++
 src/input/decoder.c          | 36 +++++++++++++++++++++++++++++++++++-
 src/input/decoder.h          |  3 +++
 src/input/es_out.c           | 10 ++++++++++
 src/input/es_out_timeshift.c |  9 +++++++++
 5 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h
index c2a4212130..edb2b63fa6 100644
--- a/include/vlc_es_out.h
+++ b/include/vlc_es_out.h
@@ -98,6 +98,10 @@ enum es_out_query_e
 
     ES_OUT_POST_SUBNODE, /* arg1=input_item_node_t *, res=can fail */
 
+    ES_OUT_SET_VOUT_MOUSE_EVENT, /* arg1= es_out_id_t*
+                                    arg2=vlc_mouse_event,
+                                    arg3=user_data, res=can fail */
+
     /* First value usable for private control */
     ES_OUT_PRIVATE_START = 0x10000,
 };
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 6af9ca8479..b553c892a2 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -141,6 +141,11 @@ struct decoder_owner
 
     /* Delay */
     vlc_tick_t i_ts_delay;
+
+    /* Mouse event */
+    vlc_mutex_t     mouse_lock;
+    vlc_mouse_event mouse_event;
+    void           *mouse_data;
 };
 
 /* Pictures which are DECODER_BOGUS_VIDEO_DELAY or more in advance probably have
@@ -279,6 +284,18 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
     p_owner->b_fmt_description = true;
 }
 
+static void MouseEvent( const vlc_mouse_t *oldmouse, const vlc_mouse_t *newmouse,
+                        void *user_data )
+{
+    decoder_t *dec = user_data;
+    struct decoder_owner *owner = dec_get_owner( dec );
+
+    vlc_mutex_lock( &owner->mouse_lock );
+    if( owner->mouse_event )
+        owner->mouse_event( oldmouse, newmouse, owner->mouse_data);
+    vlc_mutex_unlock( &owner->mouse_lock );
+}
+
 /*****************************************************************************
  * Buffers allocation callbacks for the decoders
  *****************************************************************************/
@@ -521,7 +538,7 @@ static int vout_update_format( decoder_t *p_dec )
                                              p_vout, &fmt,
                                              dpb_size +
                                              p_dec->i_extra_picture_buffers + 1,
-                                             NULL, NULL, true );
+                                             MouseEvent, p_dec, true );
         vlc_mutex_lock( &p_owner->lock );
         p_owner->p_vout = p_vout;
 
@@ -1731,6 +1748,9 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     atomic_init( &p_owner->reload, RELOAD_NO_REQUEST );
     p_owner->b_idle = false;
 
+    p_owner->mouse_event = NULL;
+    p_owner->mouse_data = NULL;
+
     es_format_Init( &p_owner->fmt, fmt->i_cat, 0 );
 
     /* decoder fifo */
@@ -1742,6 +1762,7 @@ static decoder_t * CreateDecoder( vlc_object_t *p_parent,
     }
 
     vlc_mutex_init( &p_owner->lock );
+    vlc_mutex_init( &p_owner->mouse_lock );
     vlc_cond_init( &p_owner->wait_request );
     vlc_cond_init( &p_owner->wait_acknowledge );
     vlc_cond_init( &p_owner->wait_fifo );
@@ -1908,6 +1929,7 @@ static void DeleteDecoder( decoder_t * p_dec )
     vlc_cond_destroy( &p_owner->wait_acknowledge );
     vlc_cond_destroy( &p_owner->wait_request );
     vlc_mutex_destroy( &p_owner->lock );
+    vlc_mutex_destroy( &p_owner->mouse_lock );
 
     vlc_object_release( p_dec );
 }
@@ -2446,3 +2468,15 @@ void input_DecoderGetObjects( decoder_t *p_dec,
             vlc_object_hold( p_owner->p_aout ) : NULL;
     vlc_mutex_unlock( &p_owner->lock );
 }
+
+int input_DecoderSetVoutMouseEvent( decoder_t *dec, vlc_mouse_event mouse_event,
+                                    void *user_data )
+{
+    struct decoder_owner *owner = dec_get_owner( dec );
+
+    vlc_mutex_lock( &owner->mouse_lock );
+    owner->mouse_event = mouse_event;
+    owner->mouse_data = user_data;
+    vlc_mutex_unlock( &owner->mouse_lock );
+    return VLC_EGENERIC;
+}
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 2cfda8cc54..e7db86842e 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -27,6 +27,7 @@
 
 #include <vlc_common.h>
 #include <vlc_codec.h>
+#include <vlc_mouse.h>
 
 decoder_t *input_DecoderNew( input_thread_t *, es_format_t *, input_clock_t *,
                              sout_instance_t * ) VLC_USED;
@@ -116,4 +117,6 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec );
  */
 void input_DecoderGetObjects( decoder_t *, vout_thread_t **, audio_output_t ** );
 
+int  input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
+
 #endif
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 676e1816ce..64598d8d51 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2876,6 +2876,16 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
         return VLC_SUCCESS;
     }
 
+    case ES_OUT_SET_VOUT_MOUSE_EVENT:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        vlc_mouse_event cb = va_arg( args, vlc_mouse_event );
+        void *user_data = va_arg( args, void * );
+        if( p_es && p_es->p_dec )
+            return input_DecoderSetVoutMouseEvent( p_es->p_dec, cb, user_data );
+        return VLC_EGENERIC;
+    }
+
     default:
         msg_Err( p_sys->p_input, "unknown query 0x%x in %s", i_query,
                  __func__  );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index d17a8f8f2b..a9d5d47a1b 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -40,6 +40,7 @@
 
 #include <vlc_common.h>
 #include <vlc_fs.h>
+#include <vlc_mouse.h>
 #ifdef _WIN32
 #  include <vlc_charset.h>
 #endif
@@ -652,6 +653,14 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
         }
         return es_out_Control( p_sys->p_out, ES_OUT_GET_ES_STATE, p_es->p_es, pb_enabled );
     }
+    case ES_OUT_SET_VOUT_MOUSE_EVENT:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        vlc_mouse_event cb = va_arg( args, vlc_mouse_event );
+        void *user_data = va_arg( args, void * );
+        return es_out_Control( p_sys->p_out, ES_OUT_SET_VOUT_MOUSE_EVENT,
+                               p_es->p_es, cb, user_data );
+    }
     /* Special internal input control */
     case ES_OUT_GET_EMPTY:
     {
-- 
2.18.0



More information about the vlc-devel mailing list