]> git.sesse.net Git - vlc/commitdiff
Implement vlc.video.toggleTeletext() JS API method
authorJean-Paul Saman <jpsaman@videolan.org>
Tue, 18 Dec 2007 09:04:24 +0000 (09:04 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Tue, 18 Dec 2007 09:04:24 +0000 (09:04 +0000)
activex/axvlc.idl
activex/vlccontrol2.cpp
activex/vlccontrol2.h
include/vlc/libvlc.h
mozilla/control/npolibvlc.cpp
src/control/video.c

index a0edad41e4bdbdc4353a81e7af6797689b59d45a..5f0f3e63ea379c5fbb1320c6cc0b36fc2806eec6 100644 (file)
@@ -444,6 +444,9 @@ library AXVLC
 \r
         [helpstring("take video snapshot and save it into picture object.")]\r
         HRESULT takeSnapshot([out, retval] IPictureDisp** picture);\r
+\r
+        [helpstring("toggle teletext transparent state.")]\r
+        HRESULT toggleTeletext();\r
     };\r
 \r
     [\r
index cba86e86d41b8e119b9c26e166ec0eed90e21c23..8d45973db4e3b45c9cb6ce31078b1cba42e4f003 100644 (file)
@@ -2539,6 +2539,32 @@ STDMETHODIMP VLCVideo::toggleFullscreen()
     return hr;
 };
 
+STDMETHODIMP VLCVideo::toggleTeletext()
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            libvlc_toggle_teletext(p_md, &ex);
+            libvlc_media_instance_release(p_md);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                return NOERROR;
+            }
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
 /*******************************************************************************/
 
 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
index 23c28539638c86abee3605aa1ce573031dfc5ac1..1e73729be04a460920daa24de0934db4b21adf72 100644 (file)
@@ -530,6 +530,7 @@ public:
     STDMETHODIMP put_teletext(long);
     STDMETHODIMP takeSnapshot(LPPICTUREDISP*);
     STDMETHODIMP toggleFullscreen();
+    STDMETHODIMP toggleTeletext();
 
 protected:
     HRESULT loadTypeInfo();
index 1e4a11e4d009b9837f5f83b896afcc3a62a9f936..339a1eb027219701f05ccf101b381d92debde64b 100644 (file)
@@ -819,6 +819,13 @@ VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_media_instance_t *,
  */
 VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_media_instance_t *, char *, libvlc_exception_t * );
 
+/**
+ * Toggle teletext transparent status on video output
+ * \param p_input the input
+ * \param p_exception an initialized exception
+ */
+VLC_PUBLIC_API void libvlc_toggle_teletext( libvlc_media_instance_t *, libvlc_exception_t * );
+
 /**
  * Get current teletext page requested.
  * \param p_input the input
index 2b4e33667a5f804091abbd107a3eff9b8f1c5c39..7ff456eae9e5336e3d6f771c007a37d9845d9e98 100755 (executable)
@@ -2070,11 +2070,13 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
 const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =\r
 {\r
     "toggleFullscreen",\r
+    "toggleTeletext"\r
 };\r
 \r
 enum LibvlcVideoNPObjectMethodIds\r
 {\r
     ID_video_togglefullscreen,\r
+    ID_video_toggleteletext\r
 };\r
 \r
 const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *);\r
@@ -2126,6 +2128,34 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar
                     return INVOKERESULT_GENERIC_ERROR;\r
                 }\r
                 return INVOKERESULT_NO_SUCH_METHOD;\r
+            case ID_video_toggleteletext:\r
+                if( argCount == 0 )\r
+                {\r
+                    libvlc_toggle_teletext(p_md, &ex);\r
+                    libvlc_media_instance_release(p_md);\r
+                    if( libvlc_exception_raised(&ex) )\r
+                    {\r
+                        NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                        libvlc_exception_clear(&ex);\r
+                        return INVOKERESULT_GENERIC_ERROR;\r
+                    }\r
+                    else\r
+                    {\r
+                        VOID_TO_NPVARIANT(result);\r
+                        return INVOKERESULT_NO_ERROR;\r
+                    }\r
+                }\r
+                else\r
+                {\r
+                    /* cannot get md, probably not playing */\r
+                    if( libvlc_exception_raised(&ex) )\r
+                    {\r
+                        NPN_SetException(this, libvlc_exception_get_message(&ex));\r
+                        libvlc_exception_clear(&ex);\r
+                    }\r
+                    return INVOKERESULT_GENERIC_ERROR;\r
+                }\r
+                return INVOKERESULT_NO_SUCH_METHOD;\r
             default:\r
                 return INVOKERESULT_NO_SUCH_METHOD;\r
         }\r
index 28f4228c298e6556454a234eb0631985d2f5fbbc..cd9355da3b7f08e4624d88618c22445b877a05bf 100644 (file)
@@ -527,6 +527,31 @@ void libvlc_video_set_teletext( libvlc_media_instance_t *p_mi, int i_page,
     vlc_object_release( p_vout );
 }
 
+void libvlc_toggle_teletext( libvlc_media_instance_t *p_mi,
+                             libvlc_exception_t *p_e )
+{
+    /* We only work on the first vout */
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    vlc_value_t val; int i_ret;
+
+    /* GetVout will raise the exception for us */
+    if( !p_vout )
+        return;
+
+    i_ret = var_Get( p_vout, "vbi-opaque", &val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while looking up teletext value" );
+
+    val.b_bool = !val.b_bool;
+    i_ret = var_Set( p_vout, "vbi-opaque", val );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting teletext value" );
+
+    vlc_object_release( p_vout );
+}
+
 int libvlc_video_destroy( libvlc_media_instance_t *p_mi,
                           libvlc_exception_t *p_e )
 {