]> git.sesse.net Git - vlc/commitdiff
ActiveX: Marquee JS Bindings
authorCyril Mathé <cmathe@actech-innovation.com>
Mon, 29 Jun 2009 11:34:32 +0000 (13:34 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Wed, 1 Jul 2009 20:58:59 +0000 (22:58 +0200)
- video.marquee.enable()        : enable marquee filter
 - video.marquee.disable()       : disable marquee filter
 - video.marquee.text("my_text") : display my_text on screen
 - video.marquee.color(i_val)    : change text color
 - video.marquee.opacity(i_val)  : change text opacity
 - video.marquee.position(i_val) : change text position (center, left...)
 - video.marquee.refresh(i_val)  : change refresh time
 - video.marquee.size(i_val)     : change text size
 - video.marquee.timeout(i_val)  : change timeout
 - video.marquee.x(i_val)        : change abscissa position
 - video.marquee.y(i_val)        : change ordinate position

Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
projects/activex/axvlc.idl
projects/activex/supporterrorinfo.cpp
projects/activex/vlccontrol2.cpp
projects/activex/vlccontrol2.h

index 071fcfd7d4652b8d59a7bd4ff901bf53b19e4b80..6e131ff2ac7c8561096986255b5838d1cf0f9a28 100644 (file)
@@ -38,6 +38,7 @@ library AXVLC
     interface IVLCAudio;\r
     interface IVLCInput;\r
     interface IVLCLog;\r
+    interface IVLCMarquee;\r
     interface IVLCMessage;\r
     interface IVLCMessageIterator;\r
     interface IVLCMessages;\r
@@ -426,6 +427,42 @@ library AXVLC
         HRESULT description([in] long nameID, [out, retval] BSTR* name);\r
     };\r
 \r
+    [\r
+      odl,\r
+      uuid(8D076AD6-9B6F-4150-A0FD-5D7E8C8CB02C),\r
+      helpstring("VLC Marquee Filter"),\r
+      dual,\r
+      oleautomation\r
+    ]\r
+    interface IVLCMarquee : IDispatch\r
+    {\r
+        [helpstring("enable Marquee Filter.")]\r
+        HRESULT enable();\r
+\r
+        [helpstring("disable Marquee Filter.")]\r
+        HRESULT disable();\r
+\r
+        [helpstring("set text to Marquee Filter.")]\r
+        HRESULT text([in] BSTR text);\r
+\r
+        [helpstring("change text color.")]\r
+        HRESULT color ([in] long val);\r
+        [helpstring("change  text opacity.")]\r
+        HRESULT opacity ([in] long val);\r
+        [helpstring("change text position.")]\r
+        HRESULT position ([in] long val);\r
+        [helpstring("change refresh time.")]\r
+        HRESULT refresh ([in] long val);\r
+        [helpstring("change text size.")]\r
+        HRESULT size ([in] long val);\r
+        [helpstring("change timeout.")]\r
+        HRESULT timeout ([in] long val);\r
+        [helpstring("change text abcissa.")]\r
+        HRESULT x ([in] long val);\r
+        [helpstring("change text ordinate.")]\r
+        HRESULT y ([in] long val);\r
+    };\r
+\r
     [\r
       odl,\r
       uuid(0AAEDF0B-D333-4B27-A0C6-BBF31413A42E),\r
@@ -480,6 +517,9 @@ library AXVLC
 \r
         [helpstring("toggle teletext transparent state.")]\r
         HRESULT toggleTeletext();\r
+\r
+        [propget, helpstring("Returns the marquee object.")]\r
+        HRESULT marquee([out, retval] IVLCMarquee** obj);\r
     };\r
 \r
     [\r
index debc044cab1f542d2a7a472b278108f4496b5eff..dff5a7bb0358e0c99ed1c9439796561b0599023a 100644 (file)
@@ -33,13 +33,14 @@ STDMETHODIMP VLCSupportErrorInfo::InterfaceSupportsErrorInfo(REFIID  riid)
     if( (riid == IID_IVLCAudio)
      || (riid == IID_IVLCInput)
      || (riid == IID_IVLCLog)
+     || (riid == IID_IVLCMarquee)
      || (riid == IID_IVLCMessage)
      || (riid == IID_IVLCMessageIterator)
      || (riid == IID_IVLCMessages)
      || (riid == IID_IVLCPlaylist)
      || (riid == IID_IVLCPlaylistItems)
-     || (riid == IID_IVLCVideo)
      || (riid == IID_IVLCSubtitle)
+     || (riid == IID_IVLCVideo)
      || (riid == IID_IVLCControl2) )
     {
         return S_OK;
index 8fcacd176c8fc515fedb3daccef0634826b18478..be4fb1fca40fc8ab87c80754033f506d506a4610 100644 (file)
@@ -51,6 +51,7 @@ HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
 
 EMIT_EXCEPTION_BRIDGE( VLCAudio )
 EMIT_EXCEPTION_BRIDGE( VLCInput )
+EMIT_EXCEPTION_BRIDGE( VLCMarquee )
 EMIT_EXCEPTION_BRIDGE( VLCMessageIterator )
 EMIT_EXCEPTION_BRIDGE( VLCMessages )
 EMIT_EXCEPTION_BRIDGE( VLCLog )
@@ -773,6 +774,252 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity)
 
 /*******************************************************************************/
 
+VLCMarquee::~VLCMarquee()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMarquee::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMarquee, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMarquee::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMarquee::enable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::disable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::color(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::opacity(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::position(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::refresh(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::size(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::text(BSTR text)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        char *psz_text = CStrFromBSTR(CP_UTF8, text);
+        libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
+        hr = exception_bridge(&ex);
+        CoTaskMemFree(psz_text);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::timeout(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::x(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::y(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+/*******************************************************************************/
+
 /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
 
 class VLCMessageSTLIterator
@@ -1900,6 +2147,7 @@ STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
 
 VLCVideo::~VLCVideo()
 {
+    delete _p_vlcmarquee;
     if( _p_typeinfo )
         _p_typeinfo->Release();
 };
@@ -2381,6 +2629,20 @@ STDMETHODIMP VLCVideo::toggleTeletext()
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcmarquee;
+    if( NULL != _p_vlcmarquee )
+    {
+        _p_vlcmarquee->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 /*******************************************************************************/
 
 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
index 354ed5ca744b38357089bd6e28610a5fc5294f7b..342116ae10594272efdc1eefa13ade49e8d28569 100644 (file)
@@ -380,6 +380,62 @@ private:
     VLCMessages*    _p_vlcmessages;
 };
 
+class VLCMarquee : public IVLCMarquee
+{
+public:
+    VLCMarquee(VLCPlugin *p_instance) :
+        _p_instance(p_instance), _p_typeinfo(NULL) {};
+    virtual ~VLCMarquee();
+
+    // IUnknown methods
+    STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
+    {
+        if( NULL == ppv )
+          return E_POINTER;
+        if( (IID_IUnknown == riid)
+         || (IID_IDispatch == riid)
+         || (IID_IVLCMarquee == riid) )
+        {
+            AddRef();
+            *ppv = reinterpret_cast<LPVOID>(this);
+           return NOERROR;
+        }
+        // behaves as a standalone object
+        return E_NOINTERFACE;
+    };
+
+    STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
+    STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
+
+    // IDispatch methods
+    STDMETHODIMP GetTypeInfoCount(UINT*);
+    STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);
+    STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);
+    STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
+
+    // IVLCMarquee methods
+    STDMETHODIMP enable();
+    STDMETHODIMP disable();
+    STDMETHODIMP text(BSTR);
+    STDMETHODIMP color(long);
+    STDMETHODIMP opacity(long);
+    STDMETHODIMP position(long);
+    STDMETHODIMP refresh(long);
+    STDMETHODIMP size(long);
+    STDMETHODIMP timeout(long);
+    STDMETHODIMP x(long);
+    STDMETHODIMP y(long);
+
+protected:
+    HRESULT loadTypeInfo();
+    HRESULT exception_bridge(libvlc_exception_t *ex);
+
+private:
+    VLCPlugin*      _p_instance;
+    ITypeInfo*      _p_typeinfo;
+
+};
+
 class VLCPlaylistItems : public IVLCPlaylistItems
 {
 public:
@@ -544,7 +600,12 @@ class VLCVideo : public IVLCVideo
 {
 public:
     VLCVideo(VLCPlugin *p_instance) :
-        _p_instance(p_instance), _p_typeinfo(NULL) {};
+        _p_instance(p_instance),
+        _p_typeinfo(NULL),
+        _p_vlcmarquee(NULL)
+    {
+        _p_vlcmarquee = new VLCMarquee(p_instance);
+    };
     virtual ~VLCVideo();
 
     // IUnknown methods
@@ -586,6 +647,7 @@ public:
     STDMETHODIMP put_crop(BSTR);
     STDMETHODIMP get_teletext(long*);
     STDMETHODIMP put_teletext(long);
+    STDMETHODIMP get_marquee(IVLCMarquee**);
     STDMETHODIMP deinterlaceDisable();
     STDMETHODIMP deinterlaceEnable(BSTR);
     STDMETHODIMP takeSnapshot(LPPICTUREDISP*);
@@ -599,6 +661,7 @@ protected:
 private:
     VLCPlugin*      _p_instance;
     ITypeInfo*      _p_typeinfo;
+    VLCMarquee*     _p_vlcmarquee;
 
 };