[vlc-devel] [PATCH 3/3] libvlc: libvlc_video_set_teletext(0) to disable teletext

Thomas Guillem thomas at gllm.fr
Mon Mar 27 12:01:38 CEST 2017


Since 0 is an invalid page for the zvbi plugin.

libvlc_video_get_teletext() will now return 0 if teletext is disabled. The
teletext was already disabled by default, and libvlc_video_get_teletext() could
be misleading since it returned 100 by default.
---
 include/vlc/libvlc_media_player.h |  9 ++++++---
 lib/media_player.c                |  2 +-
 lib/video.c                       | 14 +++++++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 8214151831..a391b44df7 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1352,7 +1352,10 @@ LIBVLC_API
 void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi, const char *psz_geometry );
 
 /**
- * Get current teletext page requested.
+ * Get current teletext page requested or 0 if it's disabled.
+ *
+ * Teletext is disabled by default, call libvlc_video_set_teletext() to enable
+ * it.
  *
  * \param p_mi the media player
  * \return the current teletext page requested.
@@ -1365,8 +1368,8 @@ LIBVLC_API int libvlc_video_get_teletext( libvlc_media_player_t *p_mi );
  * 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, a number in the range [0;1000[ to show the requested page or a
+ * \param i_page teletex page number requested. This value can be 0 to disable
+ * 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/media_player.c b/lib/media_player.c
index a0ef780045..2c5aa727fb 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -648,7 +648,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "deinterlace-mode", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
 
     var_Create (mp, "vbi-page", VLC_VAR_INTEGER);
-    var_SetInteger (mp, "vbi-page", 100);
+    var_SetInteger (mp, "vbi-page", 0);
 
     var_Create (mp, "video-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create (mp, "sub-source", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
diff --git a/lib/video.c b/lib/video.c
index 2b9dcf877a..d25fadfdea 100644
--- a/lib/video.c
+++ b/lib/video.c
@@ -518,12 +518,7 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
 
     if( i_page >= 0 && i_page < 1000 )
         var_SetInteger( p_mi, "vbi-page", i_page );
-    else if( i_page < -1 )
-    {
-        libvlc_printerr("Invalid page number");
-        return;
-    }
-    else
+    else if( i_page >= 1000 )
     {
         switch (i_page)
         {
@@ -539,6 +534,11 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
                 return;
         }
     }
+    else
+    {
+        libvlc_printerr("Invalid page number");
+        return;
+    }
 
     p_input_thread = libvlc_get_input_thread( p_mi );
     if( !p_input_thread ) return;
@@ -549,7 +549,7 @@ void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
         return;
     }
 
-    if( i_page == -1 )
+    if( i_page == 0 )
     {
         teletext_enable( p_input_thread, false );
     }
-- 
2.11.0



More information about the vlc-devel mailing list