[vlc-devel] [V4 PATCH 3/9] es_out: add ES_OUT_VOUT_ADD_OVERLAY

Thomas Guillem thomas at gllm.fr
Tue Jul 17 17:00:18 CEST 2018


This control allow demuxers to send subpicture_t directly to the vout of the
video es. This will be used by the bluray demuxer.

ES_OUT_VOUT_FLUSH allow to clear any subpictures previously sent via
ES_OUT_VOUT_ADD_OVERLAY.
---
 include/vlc_es_out.h         |  7 ++++++
 src/input/decoder.c          | 46 ++++++++++++++++++++++++++++++++++++
 src/input/decoder.h          |  3 +++
 src/input/es_out.c           | 17 +++++++++++++
 src/input/es_out_timeshift.c | 15 ++++++++++++
 5 files changed, 88 insertions(+)

diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h
index bdf5a0f046..56a014ae8b 100644
--- a/include/vlc_es_out.h
+++ b/include/vlc_es_out.h
@@ -102,6 +102,13 @@ enum es_out_query_e
                                     arg2=vlc_mouse_event, arg3=void *(user_data),
                                     res=can fail */
 
+    ES_OUT_VOUT_ADD_OVERLAY, /* arg1= es_out_id_t* (video es),
+                              * arg2= subpicture_t *,
+                              * arg3= int * (channel id), res= can fail */
+
+    ES_OUT_VOUT_FLUSH_OVERLAY, /* arg1= es_out_id_t* (video es),
+                                * arg2= int (channel id), 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 871333551f..0001078413 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2484,3 +2484,49 @@ int input_DecoderSetVoutMouseEvent( decoder_t *dec, vlc_mouse_event mouse_event,
     vlc_mutex_unlock( &owner->mouse_lock );
     return VLC_SUCCESS;
 }
+
+int input_DecoderAddVoutOverlay( decoder_t *dec, subpicture_t *sub,
+                                 int *channel )
+{
+    struct decoder_owner *owner = dec_get_owner( dec );
+    assert(sub && channel);
+
+    if( dec->fmt_out.i_cat != VIDEO_ES )
+        return VLC_EGENERIC;
+
+    vlc_mutex_lock( &owner->lock );
+
+    if( !owner->p_vout )
+    {
+        vlc_mutex_unlock( &owner->lock );
+        return VLC_EGENERIC;
+    }
+    sub->i_start = sub->i_stop = vlc_tick_now();
+    sub->i_channel = *channel = vout_RegisterSubpictureChannel( owner->p_vout );
+    sub->i_order = 0;
+    sub->b_ephemer = true;
+    vout_PutSubpicture( owner->p_vout, sub );
+
+    vlc_mutex_unlock( &owner->lock );
+    return VLC_SUCCESS;
+}
+
+int input_DecoderFlushVoutOverlay( decoder_t *dec, int channel )
+{
+    struct decoder_owner *owner = dec_get_owner( dec );
+
+    if( dec->fmt_out.i_cat != VIDEO_ES )
+        return VLC_EGENERIC;
+
+    vlc_mutex_lock( &owner->lock );
+
+    if( !owner->p_vout )
+    {
+        vlc_mutex_unlock( &owner->lock );
+        return VLC_EGENERIC;
+    }
+    vout_FlushSubpictureChannel( owner->p_vout, channel );
+
+    vlc_mutex_unlock( &owner->lock );
+    return VLC_SUCCESS;
+}
diff --git a/src/input/decoder.h b/src/input/decoder.h
index e7db86842e..50e2bf6491 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -119,4 +119,7 @@ void input_DecoderGetObjects( decoder_t *, vout_thread_t **, audio_output_t ** )
 
 int  input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
 
+int  input_DecoderAddVoutOverlay( decoder_t *, subpicture_t *, int * );
+int  input_DecoderFlushVoutOverlay( decoder_t *, int );
+
 #endif
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 75c33a4400..740b22d983 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2885,6 +2885,23 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return input_DecoderSetVoutMouseEvent( p_es->p_dec, cb, user_data );
         return VLC_EGENERIC;
     }
+    case ES_OUT_VOUT_ADD_OVERLAY:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        subpicture_t *sub = va_arg( args, subpicture_t * );
+        int *channel = va_arg( args, int * );
+        if( p_es && p_es->p_dec )
+            return input_DecoderAddVoutOverlay( p_es->p_dec, sub, channel );
+        return VLC_EGENERIC;
+    }
+    case ES_OUT_VOUT_FLUSH_OVERLAY:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        int channel = va_arg( args, int );
+        if( p_es && p_es->p_dec )
+            return input_DecoderFlushVoutOverlay( p_es->p_dec, channel );
+        return VLC_EGENERIC;
+    }
 
     default:
         msg_Err( p_sys->p_input, "unknown query 0x%x in %s", i_query,
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 1ac501beff..9aef9492e5 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -661,6 +661,21 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
         return es_out_Control( p_sys->p_out, ES_OUT_VOUT_SET_MOUSE_EVENT,
                                p_es->p_es, cb, user_data );
     }
+    case ES_OUT_VOUT_ADD_OVERLAY:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        subpicture_t *sub = va_arg( args, subpicture_t * );
+        int *channel = va_arg( args, int * );
+        return es_out_Control( p_sys->p_out, ES_OUT_VOUT_ADD_OVERLAY,
+                               p_es->p_es, sub, channel );
+    }
+    case ES_OUT_VOUT_FLUSH_OVERLAY:
+    {
+        es_out_id_t *p_es = va_arg( args, es_out_id_t * );
+        int channel = va_arg( args, int );
+        return es_out_Control( p_sys->p_out, ES_OUT_VOUT_FLUSH_OVERLAY,
+                               p_es->p_es, channel );
+    }
     /* Special internal input control */
     case ES_OUT_GET_EMPTY:
     {
-- 
2.18.0



More information about the vlc-devel mailing list