Commit f61d8c9f authored by JP Dinger's avatar JP Dinger

activex plugin: Dedupe a lot of duplicated code.

parent d1e7a6e5
......@@ -34,113 +34,50 @@
#include "position.h"
static inline
HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
// ---------
HRESULT VLCInterfaceBase::report_exception(REFIID riid, libvlc_exception_t *ex)
{
if( libvlc_exception_raised(ex) )
{
p->setErrorInfo(riid,libvlc_errmsg());
_plug->setErrorInfo(riid,libvlc_errmsg());
libvlc_exception_clear(ex);
return E_FAIL;
}
return NOERROR;
}
#define EMIT_EXCEPTION_BRIDGE( classname ) \
HRESULT classname::exception_bridge( libvlc_exception_t *ex ) \
{ return _exception_bridge( _p_instance, IID_I##classname, 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 )
EMIT_EXCEPTION_BRIDGE( VLCLogo )
EMIT_EXCEPTION_BRIDGE( VLCPlaylistItems )
EMIT_EXCEPTION_BRIDGE( VLCPlaylist )
EMIT_EXCEPTION_BRIDGE( VLCVideo )
EMIT_EXCEPTION_BRIDGE( VLCSubtitle )
#undef EMIT_EXCEPTION_BRIDGE
VLCAudio::~VLCAudio()
HRESULT VLCInterfaceBase::loadTypeInfo(REFIID riid)
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
// if( _ti ) return NOERROR; // unnecessairy
HRESULT VLCAudio::loadTypeInfo(void)
{
HRESULT hr = NOERROR;
if( NULL == _p_typeinfo )
{
ITypeLib *p_typelib;
hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
HRESULT hr = _plug->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
if( SUCCEEDED(hr) )
{
hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCAudio, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
hr = p_typelib->GetTypeInfoOfGuid(riid, &_ti);
if( FAILED(hr) ) _ti = NULL;
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCAudio::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
}
return NOERROR;
};
#define BIND_INTERFACE( class ) \
template<> REFIID VLCInterface<class, I##class>::_riid = IID_I##class;
STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
{
if( NULL == ppTInfo )
return E_INVALIDARG;
BIND_INTERFACE( VLCAudio )
BIND_INTERFACE( VLCInput )
BIND_INTERFACE( VLCMessage )
BIND_INTERFACE( VLCMessages )
BIND_INTERFACE( VLCMessageIterator )
BIND_INTERFACE( VLCLog )
BIND_INTERFACE( VLCMarquee )
BIND_INTERFACE( VLCLogo )
BIND_INTERFACE( VLCPlaylistItems )
BIND_INTERFACE( VLCPlaylist )
BIND_INTERFACE( VLCVideo )
BIND_INTERFACE( VLCSubtitle )
if( SUCCEEDED(loadTypeInfo()) )
{
_p_typeinfo->AddRef();
*ppTInfo = _p_typeinfo;
return NOERROR;
}
*ppTInfo = NULL;
return E_NOTIMPL;
};
#undef BIND_INTERFACE
STDMETHODIMP VLCAudio::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 VLCAudio::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 VLCAudio::get_mute(VARIANT_BOOL* mute)
{
......@@ -148,7 +85,7 @@ STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
*mute = libvlc_audio_get_mute(p_libvlc) ?
VARIANT_TRUE : VARIANT_FALSE;
......@@ -158,7 +95,7 @@ STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute);
return hr;
......@@ -170,7 +107,7 @@ STDMETHODIMP VLCAudio::get_volume(long* volume)
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
*volume = libvlc_audio_get_volume(p_libvlc);
return hr;
......@@ -179,7 +116,7 @@ STDMETHODIMP VLCAudio::get_volume(long* volume)
STDMETHODIMP VLCAudio::put_volume(long volume)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -197,7 +134,7 @@ STDMETHODIMP VLCAudio::get_track(long* track)
return E_POINTER;
libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -212,7 +149,7 @@ STDMETHODIMP VLCAudio::get_track(long* track)
STDMETHODIMP VLCAudio::put_track(long track)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -230,7 +167,7 @@ STDMETHODIMP VLCAudio::get_count(long* trackNumber)
return E_POINTER;
libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -252,7 +189,7 @@ STDMETHODIMP VLCAudio::description(long trackID, BSTR* name)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
int i, i_limit;
......@@ -301,7 +238,7 @@ STDMETHODIMP VLCAudio::get_channel(long *channel)
return E_POINTER;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -316,7 +253,7 @@ STDMETHODIMP VLCAudio::get_channel(long *channel)
STDMETHODIMP VLCAudio::put_channel(long channel)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -331,7 +268,7 @@ STDMETHODIMP VLCAudio::put_channel(long channel)
STDMETHODIMP VLCAudio::toggleMute()
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
libvlc_audio_toggle_mute(p_libvlc);
return hr;
......@@ -339,83 +276,6 @@ STDMETHODIMP VLCAudio::toggleMute()
/****************************************************************************/
VLCInput::~VLCInput()
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCInput::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_IVLCInput, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCInput::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCInput::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 VLCInput::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 VLCInput::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 VLCInput::get_length(double* length)
{
if( NULL == length )
......@@ -423,7 +283,7 @@ STDMETHODIMP VLCInput::get_length(double* length)
*length = 0;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -442,7 +302,7 @@ STDMETHODIMP VLCInput::get_position(double* position)
*position = 0.0f;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -457,7 +317,7 @@ STDMETHODIMP VLCInput::get_position(double* position)
STDMETHODIMP VLCInput::put_position(double position)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -475,7 +335,7 @@ STDMETHODIMP VLCInput::get_time(double* time)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -490,7 +350,7 @@ STDMETHODIMP VLCInput::get_time(double* time)
STDMETHODIMP VLCInput::put_time(double time)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -508,7 +368,7 @@ STDMETHODIMP VLCInput::get_state(long* state)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -531,7 +391,7 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -546,7 +406,7 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
STDMETHODIMP VLCInput::put_rate(double rate)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -565,7 +425,7 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
*fps = 0.0;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -583,7 +443,7 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -603,81 +463,7 @@ VLCLog::~VLCLog()
delete _p_vlcmessages;
if( _p_log )
libvlc_log_close(_p_log);
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCLog::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_IVLCLog, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCLog::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCLog::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 VLCLog::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 VLCLog::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 VLCLog::get_messages(IVLCMessages** obj)
{
......@@ -701,7 +487,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
if( _p_log )
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
*level = libvlc_get_log_verbosity(p_libvlc);
return hr;
......@@ -717,7 +503,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
STDMETHODIMP VLCLog::put_verbosity(long verbosity)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -746,124 +532,47 @@ STDMETHODIMP VLCLog::put_verbosity(long verbosity)
/****************************************************************************/
VLCMarquee::~VLCMarquee()
HRESULT VLCMarquee::do_put_int(unsigned idx, LONG val)
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
libvlc_media_player_t *p_md;
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_video_set_marquee_int(p_md, idx, val, &ex);
hr = exception_bridge(&ex);
}
return hr;
}
HRESULT VLCMarquee::loadTypeInfo(void)
HRESULT VLCMarquee::do_get_int(unsigned idx, LONG *val)
{
HRESULT hr = NOERROR;
if( NULL == _p_typeinfo )
{
ITypeLib *p_typelib;
if( NULL == val )
return E_POINTER;
hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
libvlc_media_player_t *p_md;
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMarquee, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*val = libvlc_video_get_marquee_int(p_md, idx, &ex);
hr = exception_bridge(&ex);
}
return hr;
};
}
STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo)
STDMETHODIMP VLCMarquee::get_position(BSTR* val)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( NULL == val )
return E_POINTER;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
LONG i;
HRESULT hr = do_get_int(libvlc_marquee_Position, &i);
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;
};
HRESULT VLCMarquee::do_put_int(unsigned idx, 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_int(p_md, idx, val, &ex);
hr = exception_bridge(&ex);
}
return hr;
}
HRESULT VLCMarquee::do_get_int(unsigned idx, LONG *val)
{
if( NULL == val )
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*val = libvlc_video_get_marquee_int(p_md, idx, &ex);
hr = exception_bridge(&ex);
}
return hr;
}
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::get_position(BSTR* val)
{
if( NULL == val )
return E_POINTER;
LONG i;
HRESULT hr = do_get_int(libvlc_marquee_Position, &i);
if(SUCCEEDED(hr))
*val = BSTRFromCStr(CP_UTF8, position_bynumber(i));
if(SUCCEEDED(hr))
*val = BSTRFromCStr(CP_UTF8, position_bynumber(i));
return hr;
}
......@@ -891,7 +600,7 @@ STDMETHODIMP VLCMarquee::get_text(BSTR *val)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -909,7 +618,7 @@ STDMETHODIMP VLCMarquee::get_text(BSTR *val)
STDMETHODIMP VLCMarquee::put_text(BSTR val)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1008,84 +717,7 @@ private:
IVLCMessage* msg;
};
////////////////////////////////////////////////////////////////////////////////////////////////////////////
VLCMessages::~VLCMessages()
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCMessages::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_IVLCMessages, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCMessages::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCMessages::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 VLCMessages::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 VLCMessages::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 VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
{
......@@ -1127,121 +759,30 @@ STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
if( NULL == iter )
return E_POINTER;
*iter = new VLCMessageIterator(_p_instance, _p_vlclog);
*iter = new VLCMessageIterator(Instance(), _p_vlclog);
return *iter ? S_OK : E_OUTOFMEMORY;
};
/****************************************************************************/
VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
_p_instance(p_instance),
_p_typeinfo(NULL),
VLCMessageIterator::VLCMessageIterator(VLCPlugin *p, VLCLog* p_vlclog ):
VLCInterface<VLCMessageIterator,IVLCMessageIterator>(p),
_refcount(1),
_p_vlclog(p_vlclog)
{
if( p_vlclog->_p_log )
{
_p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
}
else
_p_iter = NULL;
};
VLCMessageIterator::~VLCMessageIterator()
{
if( _p_iter )
libvlc_log_iterator_free(_p_iter);
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCMessageIterator::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_IVLCMessageIterator, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCMessageIterator::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 VLCMessageIterator::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 VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
_p_vlclog(p_vlclog),
_p_iter(_p_vlclog && _p_vlclog->_p_log ?
libvlc_log_get_iterator(_p_vlclog->_p_log, NULL) : NULL)
{
if( SUCCEEDED(loadTypeInfo()) )
{
return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
pVarResult, pExcepInfo, puArgErr);
}
return E_NOTIMPL;
};
}
STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
{
if( NULL == hasNext )
return E_POINTER;
if( _p_iter && _p_vlclog->_p_log )
{
*hasNext = libvlc_log_iterator_has_next(_p_iter) ?
*hasNext = (_p_iter && _p_vlclog->_p_log &&
libvlc_log_iterator_has_next(_p_iter)) ?
VARIANT_TRUE : VARIANT_FALSE;
}
else
{
*hasNext = VARIANT_FALSE;
}
return S_OK;
};
......@@ -1262,7 +803,7 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
libvlc_exception_init(&ex);
libvlc_log_iterator_next(_p_iter, &buffer, &ex);
*message = new VLCMessage(_p_instance, buffer);
*message = new VLCMessage(Instance(), buffer);
if( !message )
hr = E_OUTOFMEMORY;
}
......@@ -1271,83 +812,6 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
/****************************************************************************/
VLCMessage::~VLCMessage()
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCMessage::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_IVLCMessage, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCMessage::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 VLCMessage::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 VLCMessage::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;
};
inline const char *msgSeverity(int sev)
{
switch( sev )
......@@ -1419,211 +883,56 @@ STDMETHODIMP VLCMessage::get_header(BSTR* header)
return NOERROR;
};
STDMETHODIMP VLCMessage::get_message(BSTR* message)
{
if( NULL == message )
return E_POINTER;
*message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
return NOERROR;
};
/****************************************************************************/
VLCPlaylistItems::~VLCPlaylistItems()
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCPlaylistItems::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_IVLCPlaylistItems, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCPlaylistItems::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 VLCPlaylistItems::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 VLCPlaylistItems::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 VLCPlaylistItems::get_count(long* count)
{
if( NULL == count )
return E_POINTER;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*count = _p_instance->playlist_count(&ex);
return exception_bridge(&ex);
};
STDMETHODIMP VLCPlaylistItems::clear()
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_clear(&ex);
return exception_bridge(&ex);
};
STDMETHODIMP VLCPlaylistItems::remove(long item)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_delete_item(item, &ex);
hr = exception_bridge(&ex);
}
return hr;
};
/****************************************************************************/
VLCPlaylist::~VLCPlaylist()
{
delete _p_vlcplaylistitems;
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCPlaylist::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_IVLCPlaylist, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCPlaylist::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
STDMETHODIMP VLCMessage::get_message(BSTR* message)
{
if( NULL == ppTInfo )
return E_INVALIDARG;
if( NULL == message )
return E_POINTER;
*message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
if( SUCCEEDED(loadTypeInfo()) )
{
_p_typeinfo->AddRef();
*ppTInfo = _p_typeinfo;
return NOERROR;
}
*ppTInfo = NULL;
return E_NOTIMPL;
};
STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
UINT cNames, LCID lcid, DISPID* rgDispID)
/****************************************************************************/
STDMETHODIMP VLCPlaylistItems::get_count(long* count)
{
if( SUCCEEDED(loadTypeInfo()) )
{
return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
}
return E_NOTIMPL;
if( NULL == count )
return E_POINTER;
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*count = Instance()->playlist_count(&ex);
return exception_bridge(&ex);
};
STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
STDMETHODIMP VLCPlaylistItems::clear()
{
if( SUCCEEDED(loadTypeInfo()) )
libvlc_exception_t ex;
libvlc_exception_init(&ex);
Instance()->playlist_clear(&ex);
return exception_bridge(&ex);
};
STDMETHODIMP VLCPlaylistItems::remove(long item)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
pVarResult, pExcepInfo, puArgErr);
libvlc_exception_t ex;
libvlc_exception_init(&ex);
Instance()->playlist_delete_item(item, &ex);
hr = exception_bridge(&ex);
}
return E_NOTIMPL;
return hr;
};
/****************************************************************************/
STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
{
if( NULL == count )
......@@ -1633,7 +942,7 @@ STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*count = _p_instance->playlist_count(&ex);
*count = Instance()->playlist_count(&ex);
return exception_bridge(&ex);
};
......@@ -1643,7 +952,7 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1665,19 +974,19 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
return E_INVALIDARG;
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
char *psz_uri = NULL;
if( SysStringLen(_p_instance->getBaseURL()) > 0 )
if( SysStringLen(Instance()->getBaseURL()) > 0 )
{
/*
** if the MRL a relative URL, we should end up with an absolute URL
*/
LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
LPWSTR abs_url = CombineURL(Instance()->getBaseURL(), uri);
if( NULL != abs_url )
{
psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
......@@ -1722,7 +1031,7 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
VariantClear(&v_name);
}
*item = _p_instance->playlist_add_extended_untrusted(psz_uri,
*item = Instance()->playlist_add_extended_untrusted(psz_uri,
i_options, const_cast<const char **>(ppsz_options), &ex);
VLCControl::FreeTargetOptions(ppsz_options, i_options);
......@@ -1739,7 +1048,7 @@ STDMETHODIMP VLCPlaylist::play()
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_play(&ex);
Instance()->playlist_play(&ex);
return exception_bridge(&ex);
};
......@@ -1748,14 +1057,14 @@ STDMETHODIMP VLCPlaylist::playItem(long item)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_play_item(item,&ex);
Instance()->playlist_play_item(item,&ex);
return exception_bridge(&ex);;
};
STDMETHODIMP VLCPlaylist::togglePause()
{
libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1770,7 +1079,7 @@ STDMETHODIMP VLCPlaylist::togglePause()
STDMETHODIMP VLCPlaylist::stop()
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1787,7 +1096,7 @@ STDMETHODIMP VLCPlaylist::next()
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_next(&ex);
Instance()->playlist_next(&ex);
return exception_bridge(&ex);;
};
......@@ -1796,7 +1105,7 @@ STDMETHODIMP VLCPlaylist::prev()
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_prev(&ex);
Instance()->playlist_prev(&ex);
return exception_bridge(&ex);;
};
......@@ -1805,20 +1114,20 @@ STDMETHODIMP VLCPlaylist::clear()
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_clear(&ex);
Instance()->playlist_clear(&ex);
return exception_bridge(&ex);;
};
STDMETHODIMP VLCPlaylist::removeItem(long item)
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
HRESULT hr = getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
_p_instance->playlist_delete_item(item, &ex);
Instance()->playlist_delete_item(item, &ex);
hr = exception_bridge(&ex);;
}
return hr;
......@@ -1840,90 +1149,13 @@ STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
/****************************************************************************/
VLCSubtitle::~VLCSubtitle()
{
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCSubtitle::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_IVLCSubtitle, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCSubtitle::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::get_track(long* spu)
{
if( NULL == spu )
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1938,7 +1170,7 @@ STDMETHODIMP VLCSubtitle::get_track(long* spu)
STDMETHODIMP VLCSubtitle::put_track(long spu)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1956,7 +1188,7 @@ STDMETHODIMP VLCSubtitle::get_count(long* spuNumber)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -1978,7 +1210,7 @@ STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
libvlc_exception_t ex;
libvlc_exception_init(&ex);
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
int i, i_limit;
......@@ -2023,92 +1255,13 @@ STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
/****************************************************************************/
VLCVideo::~VLCVideo()
{
delete _p_vlcmarquee;
delete _p_vlclogo;
if( _p_typeinfo )
_p_typeinfo->Release();
};
HRESULT VLCVideo::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_IVLCVideo, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
};
STDMETHODIMP VLCVideo::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
};
STDMETHODIMP VLCVideo::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 VLCVideo::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 VLCVideo::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 VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
{
if( NULL == fullscreen )
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2124,7 +1277,7 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2142,7 +1295,7 @@ STDMETHODIMP VLCVideo::get_width(long* width)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2160,7 +1313,7 @@ STDMETHODIMP VLCVideo::get_height(long* height)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2178,7 +1331,7 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2204,7 +1357,7 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2230,7 +1383,7 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2245,7 +1398,7 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
STDMETHODIMP VLCVideo::put_subtitle(long spu)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2263,7 +1416,7 @@ STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2291,7 +1444,7 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
return E_INVALIDARG;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2317,7 +1470,7 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2332,7 +1485,7 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
STDMETHODIMP VLCVideo::put_teletext(long page)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2347,7 +1500,7 @@ STDMETHODIMP VLCVideo::put_teletext(long page)
STDMETHODIMP VLCVideo::deinterlaceDisable()
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2362,7 +1515,7 @@ STDMETHODIMP VLCVideo::deinterlaceDisable()
STDMETHODIMP VLCVideo::deinterlaceEnable(BSTR mode)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2383,7 +1536,7 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2403,7 +1556,7 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if( INVALID_HANDLE_VALUE == dirHandle )
{
_p_instance->setErrorInfo(IID_IVLCVideo,
Instance()->setErrorInfo(IID_IVLCVideo,
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
return E_FAIL;
}
......@@ -2414,7 +1567,7 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
CloseHandle(dirHandle);
if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
_p_instance->setErrorInfo(IID_IVLCVideo,
Instance()->setErrorInfo(IID_IVLCVideo,
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
return E_FAIL;
}
......@@ -2481,7 +1634,7 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
STDMETHODIMP VLCVideo::toggleFullscreen()
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2496,7 +1649,7 @@ STDMETHODIMP VLCVideo::toggleFullscreen()
STDMETHODIMP VLCVideo::toggleTeletext()
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2539,80 +1692,10 @@ STDMETHODIMP VLCVideo::get_logo(IVLCLogo** obj)
/****************************************************************************/
HRESULT VLCLogo::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_IVLCLogo, &_p_typeinfo);
if( FAILED(hr) )
{
_p_typeinfo = NULL;
}
p_typelib->Release();
}
}
return hr;
}
STDMETHODIMP VLCLogo::GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
if( SUCCEEDED(loadTypeInfo()) )
*pctInfo = 1;
else
*pctInfo = 0;
return NOERROR;
}
STDMETHODIMP VLCLogo::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 VLCLogo::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 VLCLogo::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;
}
HRESULT VLCLogo::do_put_int(unsigned idx, LONG val)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2629,7 +1712,7 @@ HRESULT VLCLogo::do_get_int(unsigned idx, LONG *val)
return E_POINTER;
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
......@@ -2643,7 +1726,7 @@ HRESULT VLCLogo::do_get_int(unsigned idx, LONG *val)
STDMETHODIMP VLCLogo::file(BSTR fname)
{
libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getMD(&p_md);
HRESULT hr = getMD(&p_md);
char *n = CStrFromBSTR(CP_UTF8, fname);
if( !n ) hr = E_OUTOFMEMORY;
......
......@@ -29,38 +29,116 @@
#include <vlc/libvlc.h>
#include <ole2.h>
class VLCAudio : public IVLCAudio
class VLCInterfaceBase {
public:
VLCInterfaceBase(VLCPlugin *p): _plug(p), _ti(NULL) { }
virtual ~VLCInterfaceBase() { if( _ti ) _ti->Release(); }
VLCPlugin *Instance() const { return _plug; }
HRESULT getVLC(libvlc_instance_t **pp) const { return _plug->getVLC(pp); }
HRESULT getMD(libvlc_media_player_t **pp) const { return _plug->getMD(pp); }
protected:
HRESULT report_exception(REFIID riid, libvlc_exception_t *ex);
HRESULT loadTypeInfo(REFIID riid);
ITypeInfo *TypeInfo() const { return _ti; }
STDMETHODIMP_(ULONG) AddRef(void) { return _plug->pUnkOuter->AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return _plug->pUnkOuter->Release(); };
private:
VLCPlugin *_plug;
ITypeInfo *_ti;
};
template<class T,class I>
class VLCInterface: public I, private VLCInterfaceBase
{
private:
typedef VLCInterfaceBase Base;
T *This() { return static_cast< T *>(this); }
const T *This() const { return static_cast<const T *>(this); }
HRESULT loadTypeInfo()
{
return TypeInfo() ? NOERROR : Base::loadTypeInfo(_riid);
}
public:
VLCAudio(VLCPlugin *p_instance) :
_p_instance(p_instance), _p_typeinfo(NULL) {};
virtual ~VLCAudio();
VLCInterface(VLCPlugin *p): Base(p) { }
VLCPlugin *Instance() const { return Base::Instance(); }
HRESULT getVLC(libvlc_instance_t **pp) const { return Base::getVLC(pp); }
HRESULT getMD(libvlc_media_player_t **pp) const { return Base::getMD(pp); }
HRESULT exception_bridge(libvlc_exception_t *ex)
{
return libvlc_exception_raised(ex) ?
Base::report_exception(_riid,ex) : NOERROR;
}
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( NULL == ppv ) return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCAudio == riid) )
|| (_riid == riid) )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
This()->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(); };
STDMETHODIMP GetTypeInfoCount(UINT* pctInfo)
{
if( NULL == pctInfo )
return E_INVALIDARG;
*pctInfo = SUCCEEDED(loadTypeInfo()) ? 1 : 0;
return NOERROR;
}
STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
{
if( NULL == ppTInfo )
return E_INVALIDARG;
// 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*);
if( SUCCEEDED(loadTypeInfo()) )
{
(*ppTInfo = TypeInfo())->AddRef();
return NOERROR;
}
*ppTInfo = NULL;
return E_NOTIMPL;
}
STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
UINT cNames, LCID lcid, DISPID* rgDispID)
{
return FAILED(loadTypeInfo()) ? E_NOTIMPL :
DispGetIDsOfNames(TypeInfo(), rgszNames, cNames, rgDispID);
}
STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
{
return FAILED(loadTypeInfo()) ? E_NOTIMPL :
DispInvoke(This(), TypeInfo(), dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
}
STDMETHODIMP_(ULONG) AddRef(void) { return Base::AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return Base::Release(); };
private:
static REFIID _riid;
};
class VLCAudio : public VLCInterface<VLCAudio,IVLCAudio>
{
public:
VLCAudio(VLCPlugin *p): VLCInterface<VLCAudio,IVLCAudio>(p) { }
// IVLCAudio methods
STDMETHODIMP get_mute(VARIANT_BOOL*);
......@@ -74,50 +152,12 @@ public:
STDMETHODIMP put_channel(long);
STDMETHODIMP toggleMute();
STDMETHODIMP description(long, BSTR*);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCInput : public IVLCInput
class VLCInput: public VLCInterface<VLCInput,IVLCInput>
{
public:
VLCInput(VLCPlugin *p_instance) :
_p_instance(p_instance), _p_typeinfo(NULL) {};
virtual ~VLCInput();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCInput == 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*);
VLCInput(VLCPlugin *p): VLCInterface<VLCInput,IVLCInput>(p) { }
// IVLCInput methods
STDMETHODIMP get_length(double*);
......@@ -130,46 +170,19 @@ public:
STDMETHODIMP put_rate(double);
STDMETHODIMP get_fps(double*);
STDMETHODIMP get_hasVout(VARIANT_BOOL*);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCMessage: public IVLCMessage
class VLCMessage: public VLCInterface<VLCMessage,IVLCMessage>
{
public:
VLCMessage(VLCPlugin *p_instance, struct libvlc_log_message_t &msg) :
_p_instance(p_instance),
_p_typeinfo(NULL),
VLCMessage(VLCPlugin *p, struct libvlc_log_message_t &msg):
VLCInterface<VLCMessage,IVLCMessage>(p),
_refcount(1),
_msg(msg) {};
virtual ~VLCMessage();
_msg(msg) { }
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCMessage == riid) )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
}
// behaves as a standalone object
return E_NOINTERFACE;
};
STDMETHODIMP_(ULONG) AddRef(void)
{ return InterlockedIncrement(&_refcount); }
STDMETHODIMP_(ULONG) AddRef(void) { return InterlockedIncrement(&_refcount); };
STDMETHODIMP_(ULONG) Release(void)
{
ULONG refcount = InterlockedDecrement(&_refcount);
......@@ -181,12 +194,6 @@ public:
return refcount;
};
// 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*);
// IVLCMessage methods
STDMETHODIMP get__Value(VARIANT *);
STDMETHODIMP get_severity(long *);
......@@ -195,12 +202,7 @@ public:
STDMETHODIMP get_header(BSTR *);
STDMETHODIMP get_message(BSTR *);
protected:
HRESULT loadTypeInfo();
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
LONG _refcount;
struct libvlc_log_message_t _msg;
......@@ -208,31 +210,15 @@ private:
class VLCLog;
class VLCMessageIterator : public IVLCMessageIterator
class VLCMessageIterator: public
VLCInterface<VLCMessageIterator,IVLCMessageIterator>
{
public:
VLCMessageIterator(VLCPlugin *p, VLCLog *p_vlclog );
~VLCMessageIterator() { if( _p_iter ) libvlc_log_iterator_free(_p_iter); }
VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog);
virtual ~VLCMessageIterator();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCMessageIterator == riid) )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
}
// behaves as a standalone object
return E_NOINTERFACE;
};
STDMETHODIMP_(ULONG) AddRef(void) { return InterlockedIncrement(&_refcount); };
STDMETHODIMP_(ULONG) AddRef(void)
{ return InterlockedIncrement(&_refcount); };
STDMETHODIMP_(ULONG) Release(void)
{
ULONG refcount = InterlockedDecrement(&_refcount);
......@@ -242,66 +228,26 @@ public:
return 0;
}
return refcount;
};
// 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*);
}
// IVLCMessageIterator methods
STDMETHODIMP get_hasNext(VARIANT_BOOL*);
STDMETHODIMP next(IVLCMessage**);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
LONG _refcount;
VLCLog* _p_vlclog;
libvlc_log_iterator_t* _p_iter;
};
class VLCMessages : public IVLCMessages
class VLCMessages: public VLCInterface<VLCMessages,IVLCMessages>
{
public:
VLCMessages(VLCPlugin *p_instance, VLCLog *p_vlclog) :
_p_vlclog(p_vlclog),
_p_instance(p_instance),
_p_typeinfo(NULL) {}
virtual ~VLCMessages();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCMessages == 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*);
VLCMessages(VLCPlugin *p, VLCLog *p_vlclog):
VLCInterface<VLCMessages,IVLCMessages>(p),
_p_vlclog(p_vlclog) { }
// IVLCMessages methods
STDMETHODIMP get__NewEnum(LPUNKNOWN*);
......@@ -310,109 +256,34 @@ public:
STDMETHODIMP iterator(IVLCMessageIterator**);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
VLCLog* _p_vlclog;
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCLog : public IVLCLog
class VLCLog: public VLCInterface<VLCLog,IVLCLog>
{
public:
friend class VLCMessages;
friend class VLCMessageIterator;
VLCLog(VLCPlugin *p_instance) :
_p_log(NULL),
_p_instance(p_instance),
_p_typeinfo(NULL),
_p_vlcmessages(NULL)
{
_p_vlcmessages = new VLCMessages(p_instance, this);
};
VLCLog(VLCPlugin *p): VLCInterface<VLCLog,IVLCLog>(p), _p_log(NULL),
_p_vlcmessages(new VLCMessages(p, this)) { }
virtual ~VLCLog();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCLog == 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*);
// IVLCLog methods
STDMETHODIMP get_messages(IVLCMessages**);
STDMETHODIMP get_verbosity(long *);
STDMETHODIMP put_verbosity(long);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
libvlc_log_t *_p_log;
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
VLCMessages* _p_vlcmessages;
};
class VLCMarquee : public IVLCMarquee
class VLCMarquee: public VLCInterface<VLCMarquee,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*);
VLCMarquee(VLCPlugin *p): VLCInterface<VLCMarquee,IVLCMarquee>(p) { }
// IVLCMarquee methods
STDMETHODIMP enable() { return do_put_int(libvlc_marquee_Enable, true); }
......@@ -437,49 +308,16 @@ public:
#undef PROP_INT
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
HRESULT do_put_int(unsigned idx, LONG val);
HRESULT do_get_int(unsigned idx, LONG *val);
};
class VLCLogo : public IVLCLogo
class VLCLogo: public VLCInterface<VLCLogo,IVLCLogo>
{
public:
VLCLogo(VLCPlugin *p): _p_instance(p), _p_typeinfo(NULL) { }
virtual ~VLCLogo() { if( _p_typeinfo ) _p_typeinfo->Release(); }
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCLogo == 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*);
VLCLogo(VLCPlugin *p): VLCInterface<VLCLogo,IVLCLogo>(p) { }
STDMETHODIMP enable() { return do_put_int(libvlc_logo_enable, true); }
STDMETHODIMP disable() { return do_put_int(libvlc_logo_enable, false); }
......@@ -503,103 +341,30 @@ public:
STDMETHODIMP get_position(BSTR* val);
STDMETHODIMP put_position(BSTR val);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
HRESULT do_put_int(unsigned idx, LONG val);
HRESULT do_get_int(unsigned idx, LONG *val);
};
class VLCPlaylistItems : public IVLCPlaylistItems
class VLCPlaylistItems: public VLCInterface<VLCPlaylistItems,IVLCPlaylistItems>
{
public:
VLCPlaylistItems(VLCPlugin *p_instance) :
_p_instance(p_instance), _p_typeinfo(NULL) {};
virtual ~VLCPlaylistItems();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCPlaylistItems == 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*);
VLCPlaylistItems(VLCPlugin *p):
VLCInterface<VLCPlaylistItems,IVLCPlaylistItems>(p) { }
// IVLCPlaylistItems methods
STDMETHODIMP get_count(long*);
STDMETHODIMP clear();
STDMETHODIMP remove(long);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCPlaylist : public IVLCPlaylist
class VLCPlaylist: public VLCInterface<VLCPlaylist,IVLCPlaylist>
{
public:
VLCPlaylist(VLCPlugin *p_instance) :
_p_instance(p_instance),
_p_typeinfo(NULL),
_p_vlcplaylistitems(NULL)
{
_p_vlcplaylistitems = new VLCPlaylistItems(p_instance);
};
virtual ~VLCPlaylist();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCPlaylist == 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*);
VLCPlaylist(VLCPlugin *p):
VLCInterface<VLCPlaylist,IVLCPlaylist>(p),
_p_vlcplaylistitems(new VLCPlaylistItems(p)) { }
virtual ~VLCPlaylist() { delete _p_vlcplaylistitems; }
// IVLCPlaylist methods
STDMETHODIMP get_itemCount(long*);
......@@ -615,101 +380,28 @@ public:
STDMETHODIMP removeItem(long);
STDMETHODIMP get_items(IVLCPlaylistItems**);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
VLCPlaylistItems* _p_vlcplaylistitems;
};
class VLCSubtitle : public IVLCSubtitle
class VLCSubtitle: public VLCInterface<VLCSubtitle,IVLCSubtitle>
{
public:
VLCSubtitle(VLCPlugin *p_instance) :
_p_instance(p_instance), _p_typeinfo(NULL) {};
virtual ~VLCSubtitle();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCSubtitle == 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*);
VLCSubtitle(VLCPlugin *p): VLCInterface<VLCSubtitle,IVLCSubtitle>(p) { }
// IVLCSubtitle methods
STDMETHODIMP get_track(long*);
STDMETHODIMP put_track(long);
STDMETHODIMP get_count(long*);
STDMETHODIMP description(long, BSTR*);
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCVideo : public IVLCVideo
class VLCVideo: public VLCInterface<VLCVideo,IVLCVideo>
{
public:
VLCVideo(VLCPlugin *p_instance) :
_p_instance(p_instance),
_p_typeinfo(NULL),
_p_vlcmarquee(new VLCMarquee(p_instance)),
_p_vlclogo(new VLCLogo(p_instance)) { }
virtual ~VLCVideo();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_IDispatch == riid)
|| (IID_IVLCVideo == 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*);
VLCVideo(VLCPlugin *p): VLCInterface<VLCVideo,IVLCVideo>(p),
_p_vlcmarquee(new VLCMarquee(p)), _p_vlclogo(new VLCLogo(p)) { }
virtual ~VLCVideo() { delete _p_vlcmarquee; delete _p_vlclogo; }
// IVLCVideo methods
STDMETHODIMP get_fullscreen(VARIANT_BOOL*);
......@@ -732,13 +424,7 @@ public:
STDMETHODIMP toggleFullscreen();
STDMETHODIMP toggleTeletext();
protected:
HRESULT loadTypeInfo();
HRESULT exception_bridge(libvlc_exception_t *ex);
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
VLCMarquee* _p_vlcmarquee;
VLCLogo* _p_vlclogo;
};
......
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