[vlc-devel] [RFC PATCH 2/2] lib/video: toggle teletext from libvlc_video_set_teletext

Thomas Guillem thomas at gllm.fr
Tue Mar 14 10:44:28 CET 2017


Either we say in the documentation, that teletext should be enabled via
libvlc_toggle_teletext() before/after setting a page or we enable teletext
directly from this function.

I don't like the libvlc_toggle_teletext() function, I would have preferred a
set_enabled(bool) function.

For me, we have three choices:

 - What is done in this current commit: enable/disable teletext according to
   the page argument.

 - Improve documentation, tell to use libvlc_toggle_teletext().

 - Improve documentation, tell to use a newly created function
   libvlc_video_set_teletext_enabled(bool), deprecate the old one.
---
 include/vlc/libvlc_media_player.h |  3 ++-
 lib/video.c                       | 30 ++++++++++++++++++++++--------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 97069f795b..1b6a843be6 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1351,7 +1351,8 @@ LIBVLC_API int libvlc_video_get_teletext( libvlc_media_player_t *p_mi );
  * Set new teletext page to retrieve.
  *
  * \param p_mi the media player
- * \param i_page teletex page number requested
+ * \param i_page teletex page number requested, 100 for the default teletext
+ * page, 0 will disable teletext
  */
 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 6e7a446874..4bf4b0b46d 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -514,7 +514,10 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
     vlc_object_t *p_zvbi = NULL;
     int telx;
 
-    var_SetInteger (p_mi, "vbi-page", i_page);
+    if( i_page > 100 )
+        var_SetInteger( p_mi, "vbi-page", i_page );
+    else
+        var_SetInteger( p_mi, "vbi-page", 100 );
 
     p_input_thread = libvlc_get_input_thread( p_mi );
     if( !p_input_thread ) return;
@@ -525,16 +528,27 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
         return;
     }
 
-    telx = var_GetInteger( p_input_thread, "teletext-es" );
-    if( telx >= 0 )
+    if( i_page == 0 )
     {
-        if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
-            == VLC_SUCCESS )
+        teletext_enable( p_input_thread, false );
+    }
+    else
+    {
+        telx = var_GetInteger( p_input_thread, "teletext-es" );
+        if( telx >= 0 )
         {
-            var_SetInteger( p_zvbi, "vbi-page", i_page );
-            vlc_object_release( p_zvbi );
+            if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
+                == VLC_SUCCESS )
+            {
+                var_SetInteger( p_zvbi, "vbi-page", i_page );
+                vlc_object_release( p_zvbi );
+            }
+        }
+        else
+        {
+            /* the "vbi-page" will be selected on es creation */
+            teletext_enable( p_input_thread, true );
         }
-    }
     }
     vlc_object_release( p_input_thread );
 }
-- 
2.11.0



More information about the vlc-devel mailing list