[vlc-commits] decoder: manage VBI from decoder.c

Thomas Guillem git at videolan.org
Thu Mar 19 09:23:35 CET 2020


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Mar 18 14:23:00 2020 +0100| [0681ee69d4aea9380a330686949f00b6946b37da] | committer: Thomas Guillem

decoder: manage VBI from decoder.c

This is the only direct usage of the decoder_t created by input_DecoderCreate().
This will allow to use a new opaque struct for the decoder_t input API.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0681ee69d4aea9380a330686949f00b6946b37da
---

 src/input/decoder.c | 28 ++++++++++++++++++++++++++++
 src/input/decoder.h |  4 ++++
 src/input/es_out.c  | 22 +++++++++++-----------
 3 files changed, 43 insertions(+), 11 deletions(-)

diff --git a/src/input/decoder.c b/src/input/decoder.c
index 20df3f2230..b6208368d6 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2583,6 +2583,34 @@ size_t input_DecoderGetFifoSize( decoder_t *p_dec )
     return block_FifoSize( p_owner->p_fifo );
 }
 
+static bool DecoderHasVbi( decoder_t *dec )
+{
+    return dec->fmt_in.i_cat == SPU_ES && dec->fmt_in.i_codec == VLC_CODEC_TELETEXT
+        && var_Type( dec, "vbi-page" ) == VLC_VAR_INTEGER;
+}
+
+int input_DecoderGetVbiPage( decoder_t *dec, bool *opaque )
+{
+    if( !DecoderHasVbi( dec ) )
+        return -1;
+    *opaque = var_GetBool( dec, "vbi-opaque" );
+    return var_GetInteger( dec, "vbi-page" );
+}
+
+int input_DecoderSetVbiPage( decoder_t *dec, unsigned page )
+{
+    if( !DecoderHasVbi( dec ) )
+        return VLC_EGENERIC;
+    return var_SetInteger( dec, "vbi-page", page );
+}
+
+int input_DecoderSetVbiOpaque( decoder_t *dec, bool opaque )
+{
+    if( !DecoderHasVbi( dec ) )
+        return VLC_EGENERIC;
+    return var_SetBool( dec, "vbi-opaque", opaque );
+}
+
 void input_DecoderSetVoutMouseEvent( decoder_t *dec, vlc_mouse_event mouse_event,
                                     void *user_data )
 {
diff --git a/src/input/decoder.h b/src/input/decoder.h
index af9f7c7bdb..216d02b053 100644
--- a/src/input/decoder.h
+++ b/src/input/decoder.h
@@ -134,6 +134,10 @@ bool input_DecoderHasFormatChanged( decoder_t *p_dec, es_format_t *p_fmt, vlc_me
  */
 size_t input_DecoderGetFifoSize( decoder_t *p_dec );
 
+int input_DecoderGetVbiPage( decoder_t *, bool *opaque );
+int input_DecoderSetVbiPage( decoder_t *, unsigned page );
+int input_DecoderSetVbiOpaque( decoder_t *, bool opaque );
+
 void input_DecoderSetVoutMouseEvent( decoder_t *, vlc_mouse_event, void * );
 int  input_DecoderAddVoutOverlay( decoder_t *, subpicture_t *, size_t * );
 int  input_DecoderDelVoutOverlay( decoder_t *, size_t );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index e4e0e460ac..3973e3e0fc 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -2313,14 +2313,15 @@ static void EsOutSelectEs( es_out_t *out, es_out_id_t *es, bool b_force )
 
     /* Special case of the zvbi decoder for teletext: send the initial selected
      * page and transparency */
-    if( !es->p_master && es->fmt.i_cat == SPU_ES
-     && es->fmt.i_codec == VLC_CODEC_TELETEXT
-     && var_Type( es->p_dec, "vbi-page" ) == VLC_VAR_INTEGER )
+    if( !es->p_master )
     {
-        input_SendEventVbiPage( p_input,
-                                var_GetInteger( es->p_dec, "vbi-page" ) );
-        input_SendEventVbiTransparency( p_input,
-                                        var_GetBool( es->p_dec, "vbi-opaque" ) );
+        bool vbi_opaque;
+        int vbi_page = input_DecoderGetVbiPage( es->p_dec, &vbi_opaque );
+        if( vbi_page >= 0 )
+        {
+            input_SendEventVbiPage( p_input, vbi_page );
+            input_SendEventVbiTransparency( p_input, vbi_opaque );
+        }
     }
 }
 
@@ -3718,22 +3719,21 @@ static int EsOutVaPrivControlLocked( es_out_t *out, int query, va_list args )
         vlc_es_id_t *es_id = va_arg( args, vlc_es_id_t * );
         es_out_id_t *es = vlc_es_id_get_out( es_id );
         assert(es);
-        if( !es->p_dec || es->fmt.i_cat != SPU_ES
-          || es->fmt.i_codec != VLC_CODEC_TELETEXT )
+        if( !es->p_dec )
             return VLC_EGENERIC;
 
         int ret;
         if( query == ES_OUT_PRIV_SET_VBI_PAGE )
         {
             unsigned page = va_arg( args, unsigned );
-            ret = var_SetInteger( es->p_dec, "vbi-page", page );
+            ret = input_DecoderSetVbiPage( es->p_dec, page );
             if( ret == VLC_SUCCESS )
                 input_SendEventVbiPage( p_sys->p_input, page );
         }
         else
         {
             bool opaque = va_arg( args, int );
-            ret = var_SetBool( es->p_dec, "vbi-opaque", opaque );
+            ret = input_DecoderSetVbiOpaque( es->p_dec, opaque );
             if( ret == VLC_SUCCESS )
                 input_SendEventVbiTransparency( p_sys->p_input, opaque );
         }



More information about the vlc-commits mailing list