Commit 967129d2 authored by Cyril Mathé's avatar Cyril Mathé Committed by Jean-Baptiste Kempf

ActiveX: Marquee JS Bindings

- 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: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 1ba9b1f2
......@@ -38,6 +38,7 @@ library AXVLC
interface IVLCAudio;
interface IVLCInput;
interface IVLCLog;
interface IVLCMarquee;
interface IVLCMessage;
interface IVLCMessageIterator;
interface IVLCMessages;
......@@ -426,6 +427,42 @@ library AXVLC
HRESULT description([in] long nameID, [out, retval] BSTR* name);
};
[
odl,
uuid(8D076AD6-9B6F-4150-A0FD-5D7E8C8CB02C),
helpstring("VLC Marquee Filter"),
dual,
oleautomation
]
interface IVLCMarquee : IDispatch
{
[helpstring("enable Marquee Filter.")]
HRESULT enable();
[helpstring("disable Marquee Filter.")]
HRESULT disable();
[helpstring("set text to Marquee Filter.")]
HRESULT text([in] BSTR text);
[helpstring("change text color.")]
HRESULT color ([in] long val);
[helpstring("change text opacity.")]
HRESULT opacity ([in] long val);
[helpstring("change text position.")]
HRESULT position ([in] long val);
[helpstring("change refresh time.")]
HRESULT refresh ([in] long val);
[helpstring("change text size.")]
HRESULT size ([in] long val);
[helpstring("change timeout.")]
HRESULT timeout ([in] long val);
[helpstring("change text abcissa.")]
HRESULT x ([in] long val);
[helpstring("change text ordinate.")]
HRESULT y ([in] long val);
};
[
odl,
uuid(0AAEDF0B-D333-4B27-A0C6-BBF31413A42E),
......@@ -480,6 +517,9 @@ library AXVLC
[helpstring("toggle teletext transparent state.")]
HRESULT toggleTeletext();
[propget, helpstring("Returns the marquee object.")]
HRESULT marquee([out, retval] IVLCMarquee** obj);
};
[
......
......@@ -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;
......
......@@ -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) :
......
......@@ -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;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment