[vlc-commits] input: handle vbi controls and events

Thomas Guillem git at videolan.org
Thu Oct 18 13:12:44 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 16 16:05:57 2018 +0200| [0f90207feef107c84a18be4af483ccf7e002c778] | committer: Thomas Guillem

input: handle vbi controls and events

This will be used by the future player to select VBI page or transparency and
get notified when they change. These new controls need the vlc_es_id_t of the
teletext track, that will be known by the player. This will replace the hackish
function: input_GetEsObjects() that is only used by QT in order to control
teletext.

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

 include/vlc_input.h          |  8 ++++++++
 src/input/es_out.c           | 37 +++++++++++++++++++++++++++++++++++++
 src/input/es_out.h           |  6 ++++++
 src/input/es_out_timeshift.c |  2 ++
 src/input/event.h            | 17 +++++++++++++++++
 src/input/input.c            |  9 +++++++++
 src/input/input_internal.h   | 11 +++++++++++
 7 files changed, 90 insertions(+)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 8f6a7be472..3633d0121a 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -388,6 +388,10 @@ typedef enum input_event_type_e
     /* (pre-)parsing events */
     INPUT_EVENT_SUBITEMS,
 
+    /* vbi_page has changed */
+    INPUT_EVENT_VBI_PAGE,
+    /* vbi_transparent has changed */
+    INPUT_EVENT_VBI_TRANSPARENCY,
 } input_event_type_e;
 
 #define VLC_INPUT_CAPABILITIES_SEEKABLE (1<<0)
@@ -515,6 +519,10 @@ struct vlc_input_event
         struct vlc_input_event_vout vout;
         /* INPUT_EVENT_SUBITEMS */
         input_item_node_t *subitems;
+        /* INPUT_EVENT_VBI_PAGE */
+        unsigned vbi_page;
+        /* INPUT_EVENT_VBI_TRANSPARENCY */
+        bool vbi_transparent;
     };
 };
 
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 7e1480fad4..98f71b3ec0 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1852,6 +1852,18 @@ static void EsOutSelectEs( es_out_t *out, es_out_id_t *es )
 
     /* Mark it as selected */
     EsOutSendEsEvent(out, es, VLC_INPUT_ES_SELECTED);
+
+    /* 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 )
+    {
+        input_SendEventVbiPage( p_input,
+                                var_GetInteger( es->p_dec, "vbi-page" ) );
+        input_SendEventVbiTransparency( p_input,
+                                        var_GetBool( es->p_dec, "vbi-opaque" ) );
+    }
 }
 
 static void EsDeleteCCChannels( es_out_t *out, es_out_id_t *parent )
@@ -3041,7 +3053,32 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
             return input_DecoderSetSpuHighlight( p_es->p_dec, spu_hl );
         return VLC_EGENERIC;
     }
+    case ES_OUT_SET_VBI_PAGE:
+    case ES_OUT_SET_VBI_TRANSPARENCY:
+    {
+        es_out_id_t *es = va_arg( args, es_out_id_t * );
+        assert(es);
+        if( !es->p_dec || es->fmt.i_cat != SPU_ES
+          || es->fmt.i_codec != VLC_CODEC_TELETEXT )
+            return VLC_EGENERIC;
 
+        int ret;
+        if( i_query == ES_OUT_SET_VBI_PAGE )
+        {
+            unsigned page = va_arg( args, unsigned );
+            ret = var_SetInteger( es->p_dec, "vbi-page", 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 );
+            if( ret == VLC_SUCCESS )
+                input_SendEventVbiTransparency( p_sys->p_input, opaque );
+        }
+        return ret;
+    }
     default:
         msg_Err( p_sys->p_input, "unknown query 0x%x in %s", i_query,
                  __func__  );
diff --git a/src/input/es_out.h b/src/input/es_out.h
index 2976021ea1..f94a7cc516 100644
--- a/src/input/es_out.h
+++ b/src/input/es_out.h
@@ -85,6 +85,12 @@ enum es_out_query_private_e
 
     /* Set End Of Stream */
     ES_OUT_SET_EOS,                                 /* res=cannot fail */
+
+    /* Set a VBI/Teletext page */
+    ES_OUT_SET_VBI_PAGE,                            /* arg1=unsigned res=can fail */
+
+    /* Set VBI/Teletext menu transparent */
+    ES_OUT_SET_VBI_TRANSPARENCY                     /* arg1=bool res=can fail */
 };
 
 static inline void es_out_SetMode( es_out_t *p_out, int i_mode )
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index b7440da467..d051243fbf 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -747,6 +747,8 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
     case ES_OUT_START_ALL_ES:
     case ES_OUT_SET_DELAY:
     case ES_OUT_SET_RECORD_STATE:
+    case ES_OUT_SET_VBI_PAGE:
+    case ES_OUT_SET_VBI_TRANSPARENCY:
     default:
         vlc_assert_unreachable();
         return VLC_EGENERIC;
diff --git a/src/input/event.h b/src/input/event.h
index 99cc8f3faf..211be0bdcc 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -262,6 +262,23 @@ static inline void input_SendEventParsing(input_thread_t *p_input,
     });
 }
 
+static inline void input_SendEventVbiPage(input_thread_t *p_input, unsigned page)
+{
+    input_SendEvent(p_input, &(struct vlc_input_event) {
+        .type = INPUT_EVENT_VBI_PAGE,
+        .vbi_page = page,
+    });
+}
+
+static inline void input_SendEventVbiTransparency(input_thread_t *p_input,
+                                                  bool transparent)
+{
+    input_SendEvent(p_input, &(struct vlc_input_event) {
+        .type = INPUT_EVENT_VBI_TRANSPARENCY,
+        .vbi_transparent = transparent,
+    });
+}
+
 /*****************************************************************************
  * Event for resource.c
  *****************************************************************************/
diff --git a/src/input/input.c b/src/input/input.c
index eca27ad78d..a21111ff32 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2329,6 +2329,15 @@ static bool Control( input_thread_t *p_input,
 #endif
             break;
         }
+        case INPUT_CONTROL_SET_VBI_PAGE:
+            es_out_Control( priv->p_es_out_display, ES_OUT_SET_VBI_PAGE,
+                            param.vbi_page.id, param.vbi_page.page );
+            break;
+        case INPUT_CONTROL_SET_VBI_TRANSPARENCY:
+            es_out_Control( priv->p_es_out_display, ES_OUT_SET_VBI_TRANSPARENCY,
+                            param.vbi_transparency.id,
+                            param.vbi_transparency.enabled );
+            break;
 
         case INPUT_CONTROL_NAV_ACTIVATE:
         case INPUT_CONTROL_NAV_UP:
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 421b89e37c..d1eaa2911e 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -95,6 +95,14 @@ typedef union
         bool b_absolute;
         vlc_tick_t i_val;
     } delay;
+    struct {
+        vlc_es_id_t *id;
+        unsigned page;
+    } vbi_page;
+    struct {
+        vlc_es_id_t *id;
+        bool enabled;
+    } vbi_transparency;
 } input_control_param_t;
 
 typedef struct
@@ -252,6 +260,9 @@ enum input_control_e
     INPUT_CONTROL_SET_FRAME_NEXT,
 
     INPUT_CONTROL_SET_RENDERER,
+
+    INPUT_CONTROL_SET_VBI_PAGE,
+    INPUT_CONTROL_SET_VBI_TRANSPARENCY,
 };
 
 /* Internal helpers */



More information about the vlc-commits mailing list