[vlc-devel] [PATCH 2/3] libvlc: libvlc_video_set_teletext can send keys

Thomas Guillem thomas at gllm.fr
Thu Mar 23 11:31:13 CET 2017


---
 include/vlc/libvlc_media_player.h | 18 ++++++++++++++++--
 lib/video.c                       | 23 +++++++++++++++++++++--
 2 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 1c4e73916a..8214151831 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -149,6 +149,18 @@ typedef enum libvlc_position_t {
 } libvlc_position_t;
 
 /**
+ * Enumeration of teletext keys than can be passed via
+ * libvlc_video_set_teletext()
+ */
+typedef enum libvlc_teletext_key_t {
+    libvlc_teletext_key_red = 'r' << 16,
+    libvlc_teletext_key_green = 'g' << 16,
+    libvlc_teletext_key_yellow = 'y' << 16,
+    libvlc_teletext_key_blue = 'b' << 16,
+    libvlc_teletext_key_index = 'i' << 16,
+} libvlc_teletext_key_t;
+
+/**
  * Opaque equalizer handle.
  *
  * Equalizer settings can be applied to a media player.
@@ -1350,10 +1362,12 @@ LIBVLC_API int libvlc_video_get_teletext( libvlc_media_player_t *p_mi );
 /**
  * Set new teletext page to retrieve.
  *
+ * This function can also be used to send a teletext key.
+ *
  * \param p_mi the media player
  * \param i_page teletex page number requested. This value can be -1 to disable
- * teletext or a number in the range [0;1000[ to show the requested page. 100
- * is the default teletext page.
+ * teletext, a number in the range [0;1000[ to show the requested page or a
+ * teletext key. 100 is the default teletext page. \see libvlc_teletext_key_t
  */
 LIBVLC_API void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page );
 
diff --git a/lib/video.c b/lib/video.c
index db4055e790..2b9dcf877a 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -514,14 +514,31 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
     input_thread_t *p_input_thread;
     vlc_object_t *p_zvbi = NULL;
     int telx;
+    bool b_key = false;
 
     if( i_page >= 0 && i_page < 1000 )
         var_SetInteger( p_mi, "vbi-page", i_page );
-    else if( i_page != -1 )
+    else if( i_page < -1 )
     {
         libvlc_printerr("Invalid page number");
         return;
     }
+    else
+    {
+        switch (i_page)
+        {
+            case libvlc_teletext_key_red:
+            case libvlc_teletext_key_green:
+            case libvlc_teletext_key_yellow:
+            case libvlc_teletext_key_blue:
+            case libvlc_teletext_key_index:
+                b_key = true;
+                break;
+            default:
+                libvlc_printerr("Invalid key action");
+                return;
+        }
+    }
 
     p_input_thread = libvlc_get_input_thread( p_mi );
     if( !p_input_thread ) return;
@@ -548,11 +565,13 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
                 vlc_object_release( p_zvbi );
             }
         }
-        else
+        else if (!b_key)
         {
             /* the "vbi-page" will be selected on es creation */
             teletext_enable( p_input_thread, true );
         }
+        else
+            libvlc_printerr("Key action sent while the teletext is disabled");
     }
     vlc_object_release( p_input_thread );
 }
-- 
2.11.0



More information about the vlc-devel mailing list