JavaScript API to change the selected teletext page from IE ActiveX, Mozilla/Firefox...
authorJean-Paul Saman <jpsaman@videolan.org>
Fri, 6 Jul 2007 21:32:43 +0000 (21:32 +0000)
committerJean-Paul Saman <jpsaman@videolan.org>
Fri, 6 Jul 2007 21:32:43 +0000 (21:32 +0000)
activex/axvlc.idl
activex/vlccontrol2.cpp
activex/vlccontrol2.h
include/vlc/libvlc.h
mozilla/control/npolibvlc.cpp
src/control/video.c

index ed6edc8..a0edad4 100644 (file)
@@ -434,6 +434,11 @@ library AXVLC
         [propput, helpstring("Sets crop filter geometry.")]\r
         HRESULT crop([in] BSTR geometry);\r
 \r
+        [propget, helpstring("Returns teletext page used.")]\r
+        HRESULT subtitle([out, retval] long* page);\r
+        [propput, helpstring("Sets teletext page to use.")]\r
+        HRESULT subtitle([in] long page);\r
+\r
         [helpstring("toggle fullscreen/windowed state.")]\r
         HRESULT toggleFullscreen();\r
 \r
index b9970b8..f1b09d2 100644 (file)
@@ -2354,6 +2354,58 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_teletext(long* page)
+{
+    if( NULL == page )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            *page = libvlc_video_get_teletext(p_input, &ex);
+            libvlc_input_free(p_input);
+            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;
+};
+
+STDMETHODIMP VLCVideo::put_teletext(long page)
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        libvlc_video_set_teletext(p_input, page, &ex);
+        libvlc_input_free(p_input);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
 STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
 {
     if( NULL == picture )
index dd53c4d..dd67d91 100644 (file)
@@ -526,6 +526,8 @@ public:
     STDMETHODIMP put_subtitle(long);
     STDMETHODIMP get_crop(BSTR*);
     STDMETHODIMP put_crop(BSTR);
+    STDMETHODIMP get_teletext(long*);
+    STDMETHODIMP put_teletext(long);
     STDMETHODIMP takeSnapshot(LPPICTUREDISP*);
     STDMETHODIMP toggleFullscreen();
 
index f428f09..a3cb418 100644 (file)
@@ -465,6 +465,22 @@ 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 * );
 
+/**
+ * Get current teletext page requested.
+ * \param p_input the input
+ * \param p_exception an initialized exception
+ * \return the current teletext page requested.
+ */
+VLC_PUBLIC_API int libvlc_video_get_teletext( libvlc_media_instance_t *, libvlc_exception_t * );
+
+/**
+ * Set new teletext page to retrieve
+ * \param p_input the input
+ * \param i_page teletex page number requested
+ * \param p_exception an initialized exception
+ */
+VLC_PUBLIC_API void libvlc_video_set_teletext( libvlc_media_instance_t *, int, libvlc_exception_t * );
+
 /**
  * Take a snapshot of the current video window
  * \param p_input the input
index 63c8c41..2b4e336 100755 (executable)
@@ -1789,7 +1789,8 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
     "width",\r
     "aspectRatio",\r
     "subtitle",\r
-    "crop"\r
+    "crop",\r
+    "teletext"\r
 };\r
 \r
 enum LibvlcVideoNPObjectPropertyIds\r
@@ -1799,7 +1800,8 @@ enum LibvlcVideoNPObjectPropertyIds
     ID_video_width,\r
     ID_video_aspectratio,\r
     ID_video_subtitle,\r
-    ID_video_crop\r
+    ID_video_crop,\r
+    ID_video_teletext\r
 };\r
 \r
 const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);\r
@@ -1907,6 +1909,19 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
                 STRINGZ_TO_NPVARIANT(psz_geometry, result);\r
                 return INVOKERESULT_NO_ERROR;\r
             }\r
+            case ID_video_teletext:\r
+            {\r
+                int i_page = libvlc_video_get_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
+                INT32_TO_NPVARIANT(i_page, result);\r
+                return INVOKERESULT_NO_ERROR;\r
+            }\r
         }\r
         libvlc_media_instance_release(p_md);\r
     }\r
@@ -2028,6 +2043,24 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
                 }\r
                 return INVOKERESULT_NO_ERROR;\r
             }\r
+            case ID_video_teletext:\r
+            {\r
+                if( isNumberValue(value) )\r
+                {\r
+                    libvlc_video_set_teletext(p_md,\r
+                                         numberValue(value), &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
+                    return INVOKERESULT_NO_ERROR;\r
+                }\r
+                libvlc_media_instance_release(p_md);\r
+                return INVOKERESULT_INVALID_VALUE;\r
+            }\r
         }\r
         libvlc_media_instance_release(p_md);\r
     }\r
index 963c35b..90b6d8c 100644 (file)
@@ -479,6 +479,36 @@ void libvlc_video_set_crop_geometry( libvlc_media_instance_t *p_mi,
     vlc_object_release( p_vout );
 }
 
+int libvlc_video_get_teletext( libvlc_media_instance_t *p_mi,
+                               libvlc_exception_t *p_e )
+{
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    int i_ret = -1;
+
+    if( !p_vout )
+        return i_ret;
+
+    i_ret = var_GetInteger( p_vout, "vbi-page" );
+    vlc_object_release( p_vout );
+    return i_ret;
+}
+
+void libvlc_video_set_teletext( libvlc_media_instance_t *p_mi, int i_page,
+                                libvlc_exception_t *p_e )
+{
+    vout_thread_t *p_vout = GetVout( p_mi, p_e );
+    int i_ret = -1;
+
+    if( !p_vout )
+        return;
+
+    i_ret = var_SetInteger( p_vout, "vbi-page", i_page );
+    if( i_ret )
+        libvlc_exception_raise( p_e,
+                        "Unexpected error while setting teletext page" );
+    vlc_object_release( p_vout );
+}
+
 int libvlc_video_destroy( libvlc_media_instance_t *p_mi,
                           libvlc_exception_t *p_e )
 {