Commit 982015df 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 b7e4ce7d
......@@ -66,10 +66,6 @@ library AXVLC
]
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.")]
HRESULT Visible([out, retval] VARIANT_BOOL* visible);
[id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")]
......@@ -88,9 +84,9 @@ library AXVLC
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.")]
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);
[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);
[helpstring("Advance or backtrack playback time, relative to current time.")]
HRESULT shuttle([in] int seconds);
......@@ -108,6 +104,10 @@ library AXVLC
HRESULT Volume([in] int volume);
[helpstring("Mute/unmute playback sound volume.")]
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.")]
/*
......
No preview for this file type
......@@ -5,7 +5,7 @@
/* 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:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......
......@@ -2,7 +2,7 @@
/* 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:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......@@ -110,12 +110,6 @@ EXTERN_C const IID IID_IVLCControl;
IVLCControl : public IDispatch
{
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(
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0;
......@@ -140,10 +134,10 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position(
/* [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;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Time(
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_Time(
/* [in] */ int seconds) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle(
......@@ -166,6 +160,14 @@ EXTERN_C const IID IID_IVLCControl;
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(
/* [in] */ BSTR uri,
/* [in] */ VARIANT options,
......@@ -235,14 +237,6 @@ EXTERN_C const IID IID_IVLCControl;
/* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,
/* [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 )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);
......@@ -276,11 +270,11 @@ EXTERN_C const IID IID_IVLCControl;
IVLCControl __RPC_FAR * This,
/* [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,
/* [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,
/* [in] */ int seconds);
......@@ -312,6 +306,16 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )(
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 )(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR uri,
......@@ -376,12 +380,6 @@ EXTERN_C const IID IID_IVLCControl;
(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) \
(This)->lpVtbl -> get_Visible(This,visible)
......@@ -439,6 +437,12 @@ EXTERN_C const IID IID_IVLCControl;
#define IVLCControl_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) \
(This)->lpVtbl -> addTarget(This,uri,options,mode,position)
......@@ -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(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);
......@@ -596,7 +576,7 @@ void __RPC_STUB IVLCControl_put_Position_Stub(
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,
/* [retval][out] */ int __RPC_FAR *seconds);
......@@ -608,7 +588,7 @@ void __RPC_STUB IVLCControl_get_Time_Stub(
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,
/* [in] */ int seconds);
......@@ -712,6 +692,32 @@ void __RPC_STUB IVLCControl_toggleMute_Stub(
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(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR uri,
......
......@@ -307,6 +307,12 @@ STDAPI DllRegisterServer(VOID)
// register type lib into the registry
ITypeLib *typeLib;
#ifdef BUILD_LOCALSERVER
// replace .exe by .tlb
strcpy(DllPath+DllPathLen-4, ".tlb");
#endif
#ifndef OLE2ANSI
size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, -1, NULL, 0);
if( typeLibPathLen > 0 )
......@@ -314,8 +320,10 @@ STDAPI DllRegisterServer(VOID)
LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen);
if( FAILED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) )
#ifndef BUILD_LOCALSERVER
return SELFREG_E_TYPELIB;
typeLib->Release();
#endif
CoTaskMemFree((void *)typeLibPath);
}
#else
......
......@@ -60,13 +60,17 @@ STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
LPADVISESINK *ppAdviseSink)
{
if( NULL != pdwAspect )
*pdwAspect = 0;
*pdwAspect = _dwAspect;
if( NULL != padvf )
*padvf = 0;
*padvf = _advf;
if( NULL != ppAdviseSink )
*ppAdviseSink = NULL;
{
*ppAdviseSink = _pAdvSink;
if( NULL != _pAdvSink )
_pAdvSink->AddRef();
}
return S_OK;
};
......@@ -80,7 +84,22 @@ STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
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)
......
......@@ -30,7 +30,8 @@ class VLCViewObject : public IViewObject2
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() {};
// IUnknown methods
......@@ -65,6 +66,11 @@ public:
private:
VLCPlugin *_p_instance;
// Advise Sink support
DWORD _dwAspect;
DWORD _advf;
LPADVISESINK _pAdvSink;
};
#endif
......
......@@ -25,6 +25,8 @@
#include "utils.h"
using namespace std;
VLCControl::~VLCControl()
{
if( _p_typeinfo )
......@@ -102,37 +104,12 @@ STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,
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)
{
if( NULL == isVisible )
return E_POINTER;
*isVisible = _p_instance->getVisible();
*isVisible = _p_instance->getVisible() ? VARIANT_TRUE : VARIANT_FALSE;
return NOERROR;
};
......@@ -363,6 +340,130 @@ STDMETHODIMP VLCControl::toggleMute(void)
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)
{
// clean up
......@@ -579,8 +680,18 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG;
VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position);
hr = NOERROR;
if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
{
hr = NOERROR;
if( mode & VLCPlayListGo )
_p_instance->fireOnPlayEvent();
}
else
{
hr = E_FAIL;
if( mode & VLCPlayListGo )
_p_instance->fireOnStopEvent();
}
freeTargetOptions(cOptions, cOptionsCount);
free(cUri);
......
......@@ -58,8 +58,6 @@ public:
STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);
// IVLCControl methods
STDMETHODIMP get_Value(VARIANT *pvarValue);
STDMETHODIMP put_Value(VARIANT pvarValue);
STDMETHODIMP play(void);
STDMETHODIMP get_Visible(VARIANT_BOOL *visible);
STDMETHODIMP put_Visible(VARIANT_BOOL visible);
......@@ -79,6 +77,8 @@ public:
STDMETHODIMP get_Volume(int *volume);
STDMETHODIMP put_Volume(int volume);
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 get_PlaylistIndex(int *index);
STDMETHODIMP get_PlaylistCount(int *count);
......
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