Commit 83974ced authored by Damien Fouilleul's avatar Damien Fouilleul

src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to...

src/libvlc.c,include/vlc/vlc.h, include/variables.h: added a new a API to libvlc called VLC_VariableType, this API allows to retrieve the type of a VLC variable. this API is very useful for binding with highlevel languages, such as javascript, VBScript, etc... which allow for weakly typed variables such as Javascript. in order to support the VLC_VariableType API, i've had to move the variable type definitions from variables.h to vlc/vlc.h

vlccontrol.cpp, axvlc.idl, axvlc.tlb, axvlc_idl.h: added a getVariable and setVariable to provide support for VLC_GetVariable and VLC_SetVariable respectively,and requires the new VLC_VariableType API.

main.cpp, viewobject.h, viewobject.cpp: support for advise on viewobject
parent 29e2c8a4
...@@ -66,10 +66,6 @@ library AXVLC ...@@ -66,10 +66,6 @@ library AXVLC
] ]
interface IVLCControl : IDispatch { interface IVLCControl : IDispatch {
[id(0), bindable, defaultbind, propget, helpstring("Specifies current target in playlist")]
HRESULT Value([out, retval] VARIANT* pvarValue);
[id(0), bindable, defaultbind, propput, helpstring("Specifies current target in playlist")]
HRESULT Value([in] VARIANT pvarValue);
[id(DISPID_Visible), propget, bindable, helpstring("Shows or hides plugin.")] [id(DISPID_Visible), propget, bindable, helpstring("Shows or hides plugin.")]
HRESULT Visible([out, retval] VARIANT_BOOL* visible); HRESULT Visible([out, retval] VARIANT_BOOL* visible);
[id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")] [id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")]
...@@ -88,9 +84,9 @@ library AXVLC ...@@ -88,9 +84,9 @@ library AXVLC
HRESULT Position([out, retval] float* position); HRESULT Position([out, retval] float* position);
[id(DISPID_Position), bindable, propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")] [id(DISPID_Position), bindable, propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([in] float position); HRESULT Position([in] float position);
[id(DISPID_Time), bindable, propget, helpstring("Specifies playback time relative to the start of current target in playlist.")] [id(DISPID_Time), propget, helpstring("Specifies playback time relative to the start of current target in playlist.")]
HRESULT Time([out, retval] int* seconds); HRESULT Time([out, retval] int* seconds);
[id(DISPID_Time), bindable, propput, helpstring("Specifies playback time relative to the start of current target in playlist.")] [id(DISPID_Time), propput, helpstring("Specifies playback time relative to the start of current target in playlist.")]
HRESULT Time([in] int seconds); HRESULT Time([in] int seconds);
[helpstring("Advance or backtrack playback time, relative to current time.")] [helpstring("Advance or backtrack playback time, relative to current time.")]
HRESULT shuttle([in] int seconds); HRESULT shuttle([in] int seconds);
...@@ -108,6 +104,10 @@ library AXVLC ...@@ -108,6 +104,10 @@ library AXVLC
HRESULT Volume([in] int volume); HRESULT Volume([in] int volume);
[helpstring("Mute/unmute playback sound volume.")] [helpstring("Mute/unmute playback sound volume.")]
HRESULT toggleMute(); HRESULT toggleMute();
[helpstring("Set a value to a VLC variable.")]
HRESULT setVariable([in] BSTR name, [in] VARIANT value);
[helpstring("Retrieve the value of a VLC variable.")]
HRESULT getVariable([in] BSTR name, [out, retval] VARIANT *value);
[helpstring("Add a target to the current playlist.")] [helpstring("Add a target to the current playlist.")]
/* /*
......
No preview for this file type
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* File created by MIDL compiler version 5.01.0164 */ /* File created by MIDL compiler version 5.01.0164 */
/* at Thu Feb 17 09:25:54 2005 /* at Tue May 10 21:24:51 2005
*/ */
/* Compiler settings for axvlc.idl: /* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* File created by MIDL compiler version 5.01.0164 */ /* File created by MIDL compiler version 5.01.0164 */
/* at Thu Feb 17 09:25:54 2005 /* at Tue May 10 21:24:51 2005
*/ */
/* Compiler settings for axvlc.idl: /* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
...@@ -110,12 +110,6 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -110,12 +110,6 @@ EXTERN_C const IID IID_IVLCControl;
IVLCControl : public IDispatch IVLCControl : public IDispatch
{ {
public: public:
virtual /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Value(
/* [retval][out] */ VARIANT __RPC_FAR *pvarValue) = 0;
virtual /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Value(
/* [in] */ VARIANT pvarValue) = 0;
virtual /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE get_Visible( virtual /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE get_Visible(
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0; /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0;
...@@ -140,10 +134,10 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -140,10 +134,10 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position( virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position(
/* [in] */ float position) = 0; /* [in] */ float position) = 0;
virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Time( virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Time(
/* [retval][out] */ int __RPC_FAR *seconds) = 0; /* [retval][out] */ int __RPC_FAR *seconds) = 0;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Time( virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_Time(
/* [in] */ int seconds) = 0; /* [in] */ int seconds) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle( virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle(
...@@ -166,6 +160,14 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -166,6 +160,14 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0; virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE setVariable(
/* [in] */ BSTR name,
/* [in] */ VARIANT value) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE getVariable(
/* [in] */ BSTR name,
/* [retval][out] */ VARIANT __RPC_FAR *value) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE addTarget( virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE addTarget(
/* [in] */ BSTR uri, /* [in] */ BSTR uri,
/* [in] */ VARIANT options, /* [in] */ VARIANT options,
...@@ -235,14 +237,6 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -235,14 +237,6 @@ EXTERN_C const IID IID_IVLCControl;
/* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
/* [out] */ UINT __RPC_FAR *puArgErr); /* [out] */ UINT __RPC_FAR *puArgErr);
/* [helpstring][propget][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT __RPC_FAR *pvarValue);
/* [helpstring][propput][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT pvarValue);
/* [helpstring][bindable][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Visible )( /* [helpstring][bindable][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Visible )(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);
...@@ -276,11 +270,11 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -276,11 +270,11 @@ EXTERN_C const IID IID_IVLCControl;
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [in] */ float position); /* [in] */ float position);
/* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Time )( /* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Time )(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [retval][out] */ int __RPC_FAR *seconds); /* [retval][out] */ int __RPC_FAR *seconds);
/* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Time )( /* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Time )(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [in] */ int seconds); /* [in] */ int seconds);
...@@ -312,6 +306,16 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -312,6 +306,16 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )( /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )(
IVLCControl __RPC_FAR * This); IVLCControl __RPC_FAR * This);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *setVariable )(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR name,
/* [in] */ VARIANT value);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *getVariable )(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR name,
/* [retval][out] */ VARIANT __RPC_FAR *value);
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *addTarget )( /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *addTarget )(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [in] */ BSTR uri, /* [in] */ BSTR uri,
...@@ -376,12 +380,6 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -376,12 +380,6 @@ EXTERN_C const IID IID_IVLCControl;
(This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)
#define IVLCControl_get_Value(This,pvarValue) \
(This)->lpVtbl -> get_Value(This,pvarValue)
#define IVLCControl_put_Value(This,pvarValue) \
(This)->lpVtbl -> put_Value(This,pvarValue)
#define IVLCControl_get_Visible(This,visible) \ #define IVLCControl_get_Visible(This,visible) \
(This)->lpVtbl -> get_Visible(This,visible) (This)->lpVtbl -> get_Visible(This,visible)
...@@ -439,6 +437,12 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -439,6 +437,12 @@ EXTERN_C const IID IID_IVLCControl;
#define IVLCControl_toggleMute(This) \ #define IVLCControl_toggleMute(This) \
(This)->lpVtbl -> toggleMute(This) (This)->lpVtbl -> toggleMute(This)
#define IVLCControl_setVariable(This,name,value) \
(This)->lpVtbl -> setVariable(This,name,value)
#define IVLCControl_getVariable(This,name,value) \
(This)->lpVtbl -> getVariable(This,name,value)
#define IVLCControl_addTarget(This,uri,options,mode,position) \ #define IVLCControl_addTarget(This,uri,options,mode,position) \
(This)->lpVtbl -> addTarget(This,uri,options,mode,position) (This)->lpVtbl -> addTarget(This,uri,options,mode,position)
...@@ -467,30 +471,6 @@ EXTERN_C const IID IID_IVLCControl; ...@@ -467,30 +471,6 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Value_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT __RPC_FAR *pvarValue);
void __RPC_STUB IVLCControl_get_Value_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Value_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT pvarValue);
void __RPC_STUB IVLCControl_put_Value_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Visible_Proxy( /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Visible_Proxy(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);
...@@ -596,7 +576,7 @@ void __RPC_STUB IVLCControl_put_Position_Stub( ...@@ -596,7 +576,7 @@ void __RPC_STUB IVLCControl_put_Position_Stub(
DWORD *_pdwStubPhase); DWORD *_pdwStubPhase);
/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Time_Proxy( /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Time_Proxy(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [retval][out] */ int __RPC_FAR *seconds); /* [retval][out] */ int __RPC_FAR *seconds);
...@@ -608,7 +588,7 @@ void __RPC_STUB IVLCControl_get_Time_Stub( ...@@ -608,7 +588,7 @@ void __RPC_STUB IVLCControl_get_Time_Stub(
DWORD *_pdwStubPhase); DWORD *_pdwStubPhase);
/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Time_Proxy( /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Time_Proxy(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [in] */ int seconds); /* [in] */ int seconds);
...@@ -712,6 +692,32 @@ void __RPC_STUB IVLCControl_toggleMute_Stub( ...@@ -712,6 +692,32 @@ void __RPC_STUB IVLCControl_toggleMute_Stub(
DWORD *_pdwStubPhase); DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_setVariable_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR name,
/* [in] */ VARIANT value);
void __RPC_STUB IVLCControl_setVariable_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_getVariable_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR name,
/* [retval][out] */ VARIANT __RPC_FAR *value);
void __RPC_STUB IVLCControl_getVariable_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_addTarget_Proxy( /* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_addTarget_Proxy(
IVLCControl __RPC_FAR * This, IVLCControl __RPC_FAR * This,
/* [in] */ BSTR uri, /* [in] */ BSTR uri,
......
...@@ -307,6 +307,12 @@ STDAPI DllRegisterServer(VOID) ...@@ -307,6 +307,12 @@ STDAPI DllRegisterServer(VOID)
// register type lib into the registry // register type lib into the registry
ITypeLib *typeLib; ITypeLib *typeLib;
#ifdef BUILD_LOCALSERVER
// replace .exe by .tlb
strcpy(DllPath+DllPathLen-4, ".tlb");
#endif
#ifndef OLE2ANSI #ifndef OLE2ANSI
size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, -1, NULL, 0); size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, -1, NULL, 0);
if( typeLibPathLen > 0 ) if( typeLibPathLen > 0 )
...@@ -314,8 +320,10 @@ STDAPI DllRegisterServer(VOID) ...@@ -314,8 +320,10 @@ STDAPI DllRegisterServer(VOID)
LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t)); LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen); MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen);
if( FAILED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) ) if( FAILED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) )
#ifndef BUILD_LOCALSERVER
return SELFREG_E_TYPELIB; return SELFREG_E_TYPELIB;
typeLib->Release(); typeLib->Release();
#endif
CoTaskMemFree((void *)typeLibPath); CoTaskMemFree((void *)typeLibPath);
} }
#else #else
......
...@@ -60,13 +60,17 @@ STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf, ...@@ -60,13 +60,17 @@ STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
LPADVISESINK *ppAdviseSink) LPADVISESINK *ppAdviseSink)
{ {
if( NULL != pdwAspect ) if( NULL != pdwAspect )
*pdwAspect = 0; *pdwAspect = _dwAspect;
if( NULL != padvf ) if( NULL != padvf )
*padvf = 0; *padvf = _advf;
if( NULL != ppAdviseSink ) if( NULL != ppAdviseSink )
*ppAdviseSink = NULL; {
*ppAdviseSink = _pAdvSink;
if( NULL != _pAdvSink )
_pAdvSink->AddRef();
}
return S_OK; return S_OK;
}; };
...@@ -80,7 +84,22 @@ STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex, ...@@ -80,7 +84,22 @@ STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf, STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
LPADVISESINK pAdvSink) LPADVISESINK pAdvSink)
{ {
return OLE_E_ADVISENOTSUPPORTED; _dwAspect = dwAspect;
_advf = advf;
if( NULL != _pAdvSink )
_pAdvSink->Release();
_pAdvSink = pAdvSink;
if( NULL != pAdvSink )
{
pAdvSink->AddRef();
if( dwAspect & DVASPECT_CONTENT )
{
pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
}
}
return S_OK;
}; };
STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze) STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
......
...@@ -30,7 +30,8 @@ class VLCViewObject : public IViewObject2 ...@@ -30,7 +30,8 @@ class VLCViewObject : public IViewObject2
public: public:
VLCViewObject(VLCPlugin *p_instance) : _p_instance(p_instance) {}; VLCViewObject(VLCPlugin *p_instance) : _p_instance(p_instance),
_dwAspect(0), _advf(0), _pAdvSink(NULL) {};
virtual ~VLCViewObject() {}; virtual ~VLCViewObject() {};
// IUnknown methods // IUnknown methods
...@@ -65,6 +66,11 @@ public: ...@@ -65,6 +66,11 @@ public:
private: private:
VLCPlugin *_p_instance; VLCPlugin *_p_instance;
// Advise Sink support
DWORD _dwAspect;
DWORD _advf;
LPADVISESINK _pAdvSink;
}; };
#endif #endif
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include "utils.h" #include "utils.h"
using namespace std;
VLCControl::~VLCControl() VLCControl::~VLCControl()
{ {
if( _p_typeinfo ) if( _p_typeinfo )
...@@ -102,37 +104,12 @@ STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid, ...@@ -102,37 +104,12 @@ STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,
return E_NOTIMPL; return E_NOTIMPL;
}; };
STDMETHODIMP VLCControl::get_Value(VARIANT *pvarValue)
{
if( NULL == pvarValue )
return E_POINTER;
V_VT(pvarValue) = VT_BOOL;
return get_Playing(&V_BOOL(pvarValue));
};
STDMETHODIMP VLCControl::put_Value(VARIANT pvarValue)
{
if( VT_BOOL != V_VT(&pvarValue) )
{
VARIANT boolValue;
HRESULT hr = VariantChangeType(&boolValue, &pvarValue, 0, VT_BOOL);
if( SUCCEEDED(hr) )
{
hr = get_Playing(&V_BOOL(&pvarValue));
//VariantClear(&boolValue);
}
return hr;
}
return get_Playing(&V_BOOL(&pvarValue));
};
STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible) STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)
{ {
if( NULL == isVisible ) if( NULL == isVisible )
return E_POINTER; return E_POINTER;
*isVisible = _p_instance->getVisible(); *isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
return NOERROR; return NOERROR;
}; };
...@@ -363,6 +340,130 @@ STDMETHODIMP VLCControl::toggleMute(void) ...@@ -363,6 +340,130 @@ STDMETHODIMP VLCControl::toggleMute(void)
return E_UNEXPECTED; return E_UNEXPECTED;
}; };
STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
{
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
int codePage = _p_instance->getCodePage();
char *psz_varname = CStrFromBSTR(codePage, name);
if( NULL == psz_varname )
return E_OUTOFMEMORY;
HRESULT hr = E_INVALIDARG;
int i_type;
if( VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type) )
{
VARIANT arg;
VariantInit(&arg);
vlc_value_t val;
hr = DISP_E_TYPEMISMATCH;
switch( i_type )
{
case VLC_VAR_BOOL:
hr = VariantChangeType(&value, &arg, 0, VT_BOOL);
if( SUCCEEDED(hr) )
val.b_bool = (VARIANT_TRUE == V_BOOL(&arg)) ? VLC_TRUE : VLC_FALSE;
break;
case VLC_VAR_INTEGER:
hr = VariantChangeType(&value, &arg, 0, VT_I4);
if( SUCCEEDED(hr) )
val.i_int = V_I4(&arg);
break;
case VLC_VAR_FLOAT:
hr = VariantChangeType(&value, &arg, 0, VT_R4);
if( SUCCEEDED(hr) )
val.f_float = V_R4(&arg);
break;
case VLC_VAR_STRING:
hr = VariantChangeType(&value, &arg, 0, VT_BSTR);
if( SUCCEEDED(hr) )
val.psz_string = CStrFromBSTR(codePage, V_BSTR(&arg));
break;
}
if( SUCCEEDED(hr) )
{
VariantClear(&arg);
hr = (VLC_SUCCESS == VLC_VariableSet(i_vlc, psz_varname, val)) ? NOERROR : E_FAIL;
if( (VLC_VAR_STRING == i_type) && (NULL != val.psz_string) )
free(val.psz_string);
}
}
free(psz_varname);
return hr;
}
return E_UNEXPECTED;
};
STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
{
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
if( NULL == value )
return E_POINTER;
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
int codePage = _p_instance->getCodePage();
char *psz_varname = CStrFromBSTR(codePage, name);
if( NULL == psz_varname )
return E_OUTOFMEMORY;
HRESULT hr = E_INVALIDARG;
vlc_value_t val;
int i_type;
if( (VLC_SUCCESS == VLC_VariableGet(i_vlc, psz_varname, &val))
&& (VLC_SUCCESS == VLC_VariableType(i_vlc, psz_varname, &i_type)) )
{
hr = NOERROR;
switch( i_type )
{
case VLC_VAR_BOOL:
V_VT(value) = VT_BOOL;
V_BOOL(value) = val.b_bool ? VARIANT_TRUE : VARIANT_FALSE;
break;
case VLC_VAR_INTEGER:
V_VT(value) = VT_I4;
V_I4(value) = val.i_int;
break;
case VLC_VAR_FLOAT:
V_VT(value) = VT_R4;
V_R4(value) = val.f_float;
break;
case VLC_VAR_STRING:
V_VT(value) = VT_BSTR;
V_BSTR(value) = BSTRFromCStr(codePage, val.psz_string);
free(val.psz_string);
break;
default:
hr = DISP_E_TYPEMISMATCH;
}
}
free(psz_varname);
return hr;
}
return E_UNEXPECTED;
};
static void freeTargetOptions(char **cOptions, int cOptionCount) static void freeTargetOptions(char **cOptions, int cOptionCount)
{ {
// clean up // clean up
...@@ -579,8 +680,18 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM ...@@ -579,8 +680,18 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) ) if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG; return E_INVALIDARG;
VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position); if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
hr = NOERROR; {
hr = NOERROR;
if( mode & VLCPlayListGo )
_p_instance->fireOnPlayEvent();
}
else
{
hr = E_FAIL;
if( mode & VLCPlayListGo )
_p_instance->fireOnStopEvent();
}
freeTargetOptions(cOptions, cOptionsCount); freeTargetOptions(cOptions, cOptionsCount);
free(cUri); free(cUri);
......
...@@ -58,8 +58,6 @@ public: ...@@ -58,8 +58,6 @@ public:
STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*); STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
// IVLCControl methods // IVLCControl methods
STDMETHODIMP get_Value(VARIANT *pvarValue);
STDMETHODIMP put_Value(VARIANT pvarValue);
STDMETHODIMP play(void); STDMETHODIMP play(void);
STDMETHODIMP get_Visible(VARIANT_BOOL *visible); STDMETHODIMP get_Visible(VARIANT_BOOL *visible);
STDMETHODIMP put_Visible(VARIANT_BOOL visible); STDMETHODIMP put_Visible(VARIANT_BOOL visible);
...@@ -79,6 +77,8 @@ public: ...@@ -79,6 +77,8 @@ public:
STDMETHODIMP get_Volume(int *volume); STDMETHODIMP get_Volume(int *volume);
STDMETHODIMP put_Volume(int volume); STDMETHODIMP put_Volume(int volume);
STDMETHODIMP toggleMute(void); STDMETHODIMP toggleMute(void);
STDMETHODIMP setVariable( BSTR name, VARIANT value);
STDMETHODIMP getVariable( BSTR name, VARIANT *value);
STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position); STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position);
STDMETHODIMP get_PlaylistIndex(int *index); STDMETHODIMP get_PlaylistIndex(int *index);
STDMETHODIMP get_PlaylistCount(int *count); STDMETHODIMP get_PlaylistCount(int *count);
......
...@@ -87,26 +87,6 @@ struct variable_t ...@@ -87,26 +87,6 @@ struct variable_t
#define VLC_VAR_TYPE 0x00ff #define VLC_VAR_TYPE 0x00ff
#define VLC_VAR_FLAGS 0xff00 #define VLC_VAR_FLAGS 0xff00
/**
* \defgroup var_type Variable types
* These are the different types a vlc variable can have.
* @{
*/
#define VLC_VAR_VOID 0x0010
#define VLC_VAR_BOOL 0x0020
#define VLC_VAR_INTEGER 0x0030
#define VLC_VAR_HOTKEY 0x0031
#define VLC_VAR_STRING 0x0040
#define VLC_VAR_MODULE 0x0041
#define VLC_VAR_FILE 0x0042
#define VLC_VAR_DIRECTORY 0x0043
#define VLC_VAR_VARIABLE 0x0044
#define VLC_VAR_FLOAT 0x0050
#define VLC_VAR_TIME 0x0060
#define VLC_VAR_ADDRESS 0x0070
#define VLC_VAR_MUTEX 0x0080
#define VLC_VAR_LIST 0x0090
/**@}*/
/** \defgroup var_flags Additive flags /** \defgroup var_flags Additive flags
* These flags are added to the type field of the variable. Most as a result of * These flags are added to the type field of the variable. Most as a result of
* a __var_Change() call, but some may be added at creation time * a __var_Change() call, but some may be added at creation time
......
...@@ -46,6 +46,27 @@ typedef int vlc_bool_t; ...@@ -46,6 +46,27 @@ typedef int vlc_bool_t;
typedef struct vlc_list_t vlc_list_t; typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t; typedef struct vlc_object_t vlc_object_t;
/**
* \defgroup var_type Variable types
* These are the different types a vlc variable can have.
* @{
*/
#define VLC_VAR_VOID 0x0010
#define VLC_VAR_BOOL 0x0020
#define VLC_VAR_INTEGER 0x0030
#define VLC_VAR_HOTKEY 0x0031
#define VLC_VAR_STRING 0x0040
#define VLC_VAR_MODULE 0x0041
#define VLC_VAR_FILE 0x0042
#define VLC_VAR_DIRECTORY 0x0043
#define VLC_VAR_VARIABLE 0x0044
#define VLC_VAR_FLOAT 0x0050
#define VLC_VAR_TIME 0x0060
#define VLC_VAR_ADDRESS 0x0070
#define VLC_VAR_MUTEX 0x0080
#define VLC_VAR_LIST 0x0090
/**@}*/
/** /**
* VLC value structure * VLC value structure
*/ */
...@@ -254,6 +275,19 @@ int VLC_VariableSet( int, char const *, vlc_value_t ); ...@@ -254,6 +275,19 @@ int VLC_VariableSet( int, char const *, vlc_value_t );
*/ */
int VLC_VariableGet( int, char const *, vlc_value_t * ); int VLC_VariableGet( int, char const *, vlc_value_t * );
/**
* Get a VLC variable type
*
* This function gets the type of a variable of VLC
* It stores it in the p_type argument
*
* \param i_object a vlc object id
* \param psz_var a vlc variable name
* \param pi_type a pointer to an integer
* \return VLC_SUCCESS on success
*/
int VLC_VariableType( int, char const *, int * );
/** /**
* Add a target to the current playlist * Add a target to the current playlist
* *
......
...@@ -1030,6 +1030,31 @@ int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value ) ...@@ -1030,6 +1030,31 @@ int VLC_VariableGet( int i_object, char const *psz_var, vlc_value_t *p_value )
return i_ret; return i_ret;
} }
/*****************************************************************************
* VLC_VariableType: get a vlc variable type
*****************************************************************************/
int VLC_VariableType( int i_object, char const *psz_var, int *pi_type )
{
int i_type;
vlc_t *p_vlc = vlc_current_object( i_object );
if( !p_vlc )
{
return VLC_ENOOBJ;
}
i_type = VLC_VAR_TYPE & var_Type( p_vlc , psz_var );
if( i_object ) vlc_object_release( p_vlc );
if( i_type > 0 )
{
*pi_type = i_type;
return VLC_SUCCESS;
}
return VLC_ENOVAR;
}
/***************************************************************************** /*****************************************************************************
* VLC_AddTarget: adds a target for playing. * VLC_AddTarget: adds a target for playing.
***************************************************************************** *****************************************************************************
......
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