[vlc-commits] es_out: add ES_OUT_SET_VOUT_MOUSE_EVENT
Thomas Guillem
git at videolan.org
Fri Jul 20 09:37:23 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Jul 16 15:47:45 2018 +0200| [bf23d4d7c44602a3597e25beadc923745e4addae] | committer: Thomas Guillem
es_out: add ES_OUT_SET_VOUT_MOUSE_EVENT
This a new preferred method to get mouse events from demuxers (instead of
registering to "intf-event" from the p_input and registering to mouse events
from any vouts).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bf23d4d7c44602a3597e25beadc923745e4addae
---
include/vlc_es_out.h | 4 ++++
src/input/decoder.c | 37 ++++++++++++++++++++++++++++++++++++-
src/input/decoder.h | 3 +++
src/input/es_out.c | 26 ++++++++++++++++++++++++++
src/input/es_out_timeshift.c | 9 +++++++++
5 files changed, 78 insertions(+), 1 deletion(-)
diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h
index 7ed544022b..6fc28115bc 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_VOUT_SET_MOUSE_EVENT, /* arg1= es_out_id_t* (video es),
+ arg2=vlc_mouse_event, arg3=void *(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..9d066a4aff 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 *opaque;
};
/* Pictures which are DECODER_BOGUS_VIDEO_DELAY or more in advance probably have
@@ -279,6 +284,17 @@ static void DecoderUpdateFormatLocked( decoder_t *p_dec )
p_owner->b_fmt_description = true;
}
+static void MouseEvent( 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( newmouse, owner->opaque);
+ vlc_mutex_unlock( &owner->mouse_lock );
+}
+
/*****************************************************************************
* Buffers allocation callbacks for the decoders
*****************************************************************************/
@@ -521,7 +537,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 +1747,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->opaque = NULL;
+
es_format_Init( &p_owner->fmt, fmt->i_cat, 0 );
/* decoder fifo */
@@ -1742,6 +1761,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 +1928,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 +2467,17 @@ void input_DecoderGetObjects( decoder_t *p_dec,
vlc_object_hold( p_owner->p_aout ) : NULL;
vlc_mutex_unlock( &p_owner->lock );
}
+
+void input_DecoderSetVoutMouseEvent( decoder_t *dec, vlc_mouse_event mouse_event,
+ void *user_data )
+{
+ struct decoder_owner *owner = dec_get_owner( dec );
+ assert( dec->fmt_out.i_cat == VIDEO_ES );
+
+ vlc_mutex_lock( &owner->mouse_lock );
+
+ owner->mouse_event = mouse_event;
+ owner->opaque = user_data;
+
+ vlc_mutex_unlock( &owner->mouse_lock );
+}
diff --git a/src/input/decoder.h b/src/input/decoder.h
index 2cfda8cc54..acf5ba7617 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 ** );
+void input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
+
#endif
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 948bb4407f..d437dd1b07 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -110,6 +110,9 @@ struct es_out_id_t
int i_meta_id;
struct vlc_list node;
+
+ vlc_mouse_event mouse_event_cb;
+ void* mouse_event_userdata;
};
typedef struct
@@ -1625,6 +1628,8 @@ static es_out_id_t *EsOutAddSlaveLocked( es_out_t *out, const es_format_t *fmt,
es->cc.type = 0;
es->cc.i_bitmap = 0;
es->p_master = p_master;
+ es->mouse_event_cb = NULL;
+ es->mouse_event_userdata = NULL;
vlc_list_append(&es->node, es->p_master ? &p_sys->es_slaves : &p_sys->es);
@@ -1693,6 +1698,10 @@ static void EsCreateDecoder( es_out_t *out, es_out_id_t *p_es )
if( p_es->p_dec_record && p_sys->b_buffering )
input_DecoderStartWait( p_es->p_dec_record );
}
+
+ if( p_es->mouse_event_cb && p_es->fmt.i_cat == VIDEO_ES )
+ input_DecoderSetVoutMouseEvent( dec, p_es->mouse_event_cb,
+ p_es->mouse_event_userdata );
}
p_es->p_dec = dec;
@@ -2916,6 +2925,23 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_SUCCESS;
}
+ case ES_OUT_VOUT_SET_MOUSE_EVENT:
+ {
+ es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+
+ if( !p_es || p_es->fmt.i_cat != VIDEO_ES )
+ return VLC_EGENERIC;
+
+ p_es->mouse_event_cb = va_arg( args, vlc_mouse_event );
+ p_es->mouse_event_userdata = va_arg( args, void * );
+
+ if( p_es->p_dec )
+ input_DecoderSetVoutMouseEvent( p_es->p_dec,
+ p_es->mouse_event_cb, p_es->mouse_event_userdata );
+
+ return VLC_SUCCESS;
+ }
+
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 552b896132..3795ac9d05 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_VOUT_SET_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_VOUT_SET_MOUSE_EVENT,
+ p_es->p_es, cb, user_data );
+ }
/* Special internal input control */
case ES_OUT_GET_EMPTY:
{
More information about the vlc-commits
mailing list