[vlc-devel] commit: libvlc: restore Teletext functionality (Jean-Paul Saman )

git version control git at videolan.org
Fri Feb 5 12:59:47 CET 2010


vlc | branch: master | Jean-Paul Saman <jean-paul.saman at m2x.nl> | Thu Feb  4 15:37:24 2010 +0100| [9e4c658667947afd76237804c3a97a11050b5d09] | committer: Jean-Paul Saman 

libvlc: restore Teletext functionality

Reverts part of 7db94f4d2fc742537828fbe0c8eb5a and rewrite the code.

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

 include/vlc/libvlc_media_player.h      |   19 ++++++++++-
 projects/activex/vlccontrol2.cpp       |   14 ++-----
 projects/mozilla/control/npolibvlc.cpp |   10 ++----
 src/control/video.c                    |   57 ++++++++++++++++++++++++++++++++
 src/libvlc.sym                         |    2 +
 5 files changed, 84 insertions(+), 18 deletions(-)

diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 178b01d..f14ef90 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * libvlc_media_player.h:  libvlc_media_player external API
  *****************************************************************************
- * Copyright (C) 1998-2009 the VideoLAN team
+ * Copyright (C) 1998-2010 the VideoLAN team
  * $Id$
  *
  * Authors: Clément Stenac <zorglub at videolan.org>
@@ -713,6 +713,23 @@ VLC_PUBLIC_API
 void libvlc_video_set_crop_geometry( libvlc_media_player_t *, const char * );
 
 /**
+ * Get current teletext page requested.
+ *
+ * \param p_mediaplayer the media player
+ * \return the current teletext page requested.
+ */
+VLC_PUBLIC_API int libvlc_video_get_teletext( libvlc_media_player_t * );
+
+/**
+ * Set new teletext page to retrieve.
+ *
+ * \param p_mediaplayer the media player
+ * \param i_page teletex page number requested
+ * \param p_e an initialized exception pointer
+ */
+VLC_PUBLIC_API void libvlc_video_set_teletext( libvlc_media_player_t *, int, libvlc_exception_t * );
+
+/**
  * Toggle teletext transparent status on video output.
  *
  * \param p_mediaplayer the media player
diff --git a/projects/activex/vlccontrol2.cpp b/projects/activex/vlccontrol2.cpp
index 9fa4f5e..7b0ceda 100644
--- a/projects/activex/vlccontrol2.cpp
+++ b/projects/activex/vlccontrol2.cpp
@@ -1180,34 +1180,28 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
 
     libvlc_media_player_t *p_md;
     HRESULT hr = getMD(&p_md);
-#if 0
+
     if( SUCCEEDED(hr) )
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
         *page = libvlc_video_get_teletext(p_md);
-        hr = exception_bridge(&ex);
     }
-#endif
+
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_teletext(long page)
 {
-#warning Broken
     libvlc_media_player_t *p_md;
     HRESULT hr = getMD(&p_md);
-#if 0
+
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_video_set_teletext(p_md, page);
+        libvlc_video_set_teletext(p_md, page, &ex);
         hr = exception_bridge(&ex);
     }
-#endif
     return hr;
 };
 
diff --git a/projects/mozilla/control/npolibvlc.cpp b/projects/mozilla/control/npolibvlc.cpp
index 9f6a982..8722498 100644
--- a/projects/mozilla/control/npolibvlc.cpp
+++ b/projects/mozilla/control/npolibvlc.cpp
@@ -1381,12 +1381,11 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
             }
             case ID_video_teletext:
             {
-/*                int i_page = libvlc_video_get_teletext(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_page = libvlc_video_get_teletext(p_md);
+                if( i_page < 0 )
+                    return INVOKERESULT_GENERIC_ERROR;
                 INT32_TO_NPVARIANT(i_page, result);
                 return INVOKERESULT_NO_ERROR;
-*/
-                return INVOKERESULT_NO_SUCH_METHOD;
             }
             case ID_video_marquee:
             {
@@ -1491,13 +1490,10 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
             {
                 if( isNumberValue(value) )
                 {
-/*
                     libvlc_video_set_teletext(p_md, numberValue(value), &ex);
                     RETURN_ON_EXCEPTION(this,ex);
 
                     return INVOKERESULT_NO_ERROR;
-*/
-                    return INVOKERESULT_NO_SUCH_METHOD;
                 }
                 return INVOKERESULT_INVALID_VALUE;
             }
diff --git a/src/control/video.c b/src/control/video.c
index 8956c23..286ae18 100644
--- a/src/control/video.c
+++ b/src/control/video.c
@@ -388,6 +388,63 @@ void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi,
     free (pp_vouts);
 }
 
+int libvlc_video_get_teletext( libvlc_media_player_t *p_mi )
+{
+    input_thread_t *p_input_thread;
+    vlc_object_t *p_zvbi = NULL;
+    int i_ret = -1, telx;
+
+    p_input_thread = libvlc_get_input_thread( p_mi );
+    if( !p_input_thread ) return i_ret;
+
+    if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
+    {
+        vlc_object_release( p_input_thread );
+        return i_ret;
+    }
+
+    telx = var_GetInteger( p_input_thread, "teletext-es" );
+    if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
+        != VLC_SUCCESS )
+    {
+        i_ret = var_GetInteger( p_zvbi, "vbi-page" );
+        vlc_object_release( p_zvbi );
+    }
+    vlc_object_release( p_input_thread );
+    return i_ret;
+}
+
+void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page,
+                                libvlc_exception_t *p_e )
+{
+    input_thread_t *p_input_thread;
+    vlc_object_t *p_zvbi = NULL;
+    int telx;
+
+    p_input_thread = libvlc_get_input_thread( p_mi );
+    if( !p_input_thread ) return;
+
+    if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
+    {
+        vlc_object_release( p_input_thread );
+        return;
+    }
+
+    telx = var_GetInteger( p_input_thread, "teletext-es" );
+    if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
+        != VLC_SUCCESS )
+    {
+        int i_ret = var_SetInteger( p_zvbi, "vbi-page", i_page );
+        vlc_object_release( p_zvbi );
+        if( i_ret )
+        {
+            libvlc_exception_raise( p_e );
+            libvlc_printerr( "Unexpected error while setting teletext page" );
+        }
+    }
+    vlc_object_release( p_input_thread );
+}
+
 void libvlc_toggle_teletext( libvlc_media_player_t *p_mi )
 {
     input_thread_t *p_input_thread;
diff --git a/src/libvlc.sym b/src/libvlc.sym
index 46530f0..88ce19f 100644
--- a/src/libvlc.sym
+++ b/src/libvlc.sym
@@ -176,6 +176,7 @@ libvlc_video_get_scale
 libvlc_video_get_spu
 libvlc_video_get_spu_count
 libvlc_video_get_spu_description
+libvlc_video_get_teletext
 libvlc_video_get_title_description
 libvlc_video_get_track
 libvlc_video_get_track_count
@@ -193,6 +194,7 @@ libvlc_video_set_mouse_input
 libvlc_video_set_scale
 libvlc_video_set_spu
 libvlc_video_set_subtitle_file
+libvlc_video_set_teletext
 libvlc_video_set_track
 libvlc_video_take_snapshot
 libvlc_vlm_add_broadcast




More information about the vlc-devel mailing list