Commit 181f3d45 authored by Damien Fouilleul's avatar Damien Fouilleul

- activex: future proofing the APIs and some misc fixes

parent bbf771f9
...@@ -284,7 +284,7 @@ library AXVLC ...@@ -284,7 +284,7 @@ library AXVLC
[ [
odl, odl,
uuid(6C5CE55D-2D6C-4AAD-8299-C62D2371F106), uuid(6C5CE55D-2D6C-4AAD-8299-C62D2371F106),
helpstring("VLC Log APIs"), helpstring("VLC Log Messages Collection."),
dual, dual,
oleautomation oleautomation
] ]
...@@ -321,6 +321,25 @@ library AXVLC ...@@ -321,6 +321,25 @@ library AXVLC
HRESULT verbosity([in] long level); HRESULT verbosity([in] long level);
}; };
[
odl,
uuid(FD37FE32-82BC-4A25-B056-315F4DBB194D),
helpstring("VLC Playlist Items collection"),
dual,
oleautomation
]
interface IVLCPlaylistItems : IDispatch
{
[propget, helpstring("Returns number of items in playlist.")]
HRESULT count([out, retval] long* count);
[helpstring("Remove all items from playlist.")]
HRESULT clear();
[helpstring("remove item from playlist.")]
HRESULT remove([in] long itemId);
};
[ [
odl, odl,
uuid(54613049-40BF-4035-9E70-0A9312C0188D), uuid(54613049-40BF-4035-9E70-0A9312C0188D),
...@@ -330,20 +349,20 @@ library AXVLC ...@@ -330,20 +349,20 @@ library AXVLC
] ]
interface IVLCPlaylist : IDispatch interface IVLCPlaylist : IDispatch
{ {
[propget, helpstring("Returns number of items in playlist.")] [hidden, propget, helpstring("Returns number of items in playlist. (deprecated)")]
HRESULT itemCount([out, retval] long* count); HRESULT itemCount([out, retval] long* count);
[propget, helpstring("Returns whether playback displays video.")] [propget, helpstring("Returns whether playback displays video.")]
HRESULT isPlaying([out, retval] VARIANT_BOOL* playing); HRESULT isPlaying([out, retval] VARIANT_BOOL* playing);
[helpstring("Add a playlist item.")] [helpstring("Add a playlist item.")]
HRESULT add([in] BSTR uri, [in, optional] VARIANT name, [in, optional] VARIANT options, [out, retval] long* item); HRESULT add([in] BSTR uri, [in, optional] VARIANT name, [in, optional] VARIANT options, [out, retval] long* itemId);
[helpstring("Play/Resume the playlist.")] [helpstring("Play/Resume the playlist.")]
HRESULT play(); HRESULT play();
[helpstring("Play item in playlist.")] [helpstring("Play item in playlist.")]
HRESULT playItem([in] long item); HRESULT playItem([in] long itemId);
[helpstring("Play/Pause current clip.")] [helpstring("Play/Pause current clip.")]
HRESULT togglePause(); HRESULT togglePause();
...@@ -357,11 +376,14 @@ library AXVLC ...@@ -357,11 +376,14 @@ library AXVLC
[helpstring("Advance to previous item in playlist.")] [helpstring("Advance to previous item in playlist.")]
HRESULT prev(); HRESULT prev();
[helpstring("Remove all items from playlist.")] [hidden, helpstring("Remove all items from playlist. (deprecated)")]
HRESULT clear(); HRESULT clear();
[helpstring("remove item from playlist.")] [hidden, helpstring("Remove item from playlist. (deprecated)")]
HRESULT removeItem([in] long item); HRESULT removeItem([in] long item);
[propget, helpstring("Returns the playlist items collection object.")]
HRESULT items([out, retval] IVLCPlaylistItems** obj);
}; };
[ [
......
No preview for this file type
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
/* File created by MIDL compiler version 6.00.0361 */ /* File created by MIDL compiler version 6.00.0361 */
/* at Thu Nov 16 09:55:42 2006 /* at Mon Nov 27 17:47:26 2006
*/ */
/* Compiler settings for axvlc.idl: /* Compiler settings for axvlc.idl:
Oicf, W1, Zp8, env=Win32 (32b run) Oicf, W1, Zp8, env=Win32 (32b run)
...@@ -106,6 +106,9 @@ MIDL_DEFINE_GUID(IID, IID_IVLCControl2,0x2D719729,0x5333,0x406C,0xBF,0x12,0x8D,0 ...@@ -106,6 +106,9 @@ MIDL_DEFINE_GUID(IID, IID_IVLCControl2,0x2D719729,0x5333,0x406C,0xBF,0x12,0x8D,0
MIDL_DEFINE_GUID(IID, DIID_DVLCEvents,0xDF48072F,0x5EF8,0x434e,0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F); MIDL_DEFINE_GUID(IID, DIID_DVLCEvents,0xDF48072F,0x5EF8,0x434e,0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F);
MIDL_DEFINE_GUID(IID, IID_IVLCPlaylistItems,0xFD37FE32,0x82BC,0x4A25,0xB0,0x56,0x31,0x5F,0x4D,0xBB,0x19,0x4D);
MIDL_DEFINE_GUID(CLSID, CLSID_VLCPlugin,0xE23FE9C6,0x778E,0x49D4,0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8); MIDL_DEFINE_GUID(CLSID, CLSID_VLCPlugin,0xE23FE9C6,0x778E,0x49D4,0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8);
......
This diff is collapsed.
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include <windows.h> #include <windows.h>
#include <shlwapi.h> #include <shlwapi.h>
#include <guiddef.h>
using namespace std; using namespace std;
#define COMPANY_STR "VideoLAN" #define COMPANY_STR "VideoLAN"
...@@ -43,10 +45,11 @@ using namespace std; ...@@ -43,10 +45,11 @@ using namespace std;
#define GUID_STRLEN 39 #define GUID_STRLEN 39
/* /*
** MingW headers do not declare those ** MingW headers & libs do not declare those
*/ */
extern const CATID CATID_SafeForInitializing; static DEFINE_GUID(_CATID_InternetAware, 0x0DE86A58, 0x2BAA, 0x11CF, 0xA2, 0x29, 0x00,0xAA,0x00,0x3D,0x73,0x52);
extern const CATID CATID_SafeForScripting; static DEFINE_GUID(_CATID_SafeForInitializing, 0x7DD95802, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
static DEFINE_GUID(_CATID_SafeForScripting, 0x7DD95801, 0x9882, 0x11CF, 0x9F, 0xA9, 0x00,0xAA,0x00,0x6C,0x42,0xC4);
static LONG i_class_ref= 0; static LONG i_class_ref= 0;
static HINSTANCE h_instance= 0; static HINSTANCE h_instance= 0;
...@@ -150,8 +153,9 @@ STDAPI DllUnregisterServer(VOID) ...@@ -150,8 +153,9 @@ STDAPI DllUnregisterServer(VOID)
CATID implCategories[] = { CATID implCategories[] = {
CATID_Control, CATID_Control,
CATID_PersistsToPropertyBag, CATID_PersistsToPropertyBag,
CATID_SafeForInitializing, _CATID_InternetAware,
CATID_SafeForScripting, _CATID_SafeForInitializing,
_CATID_SafeForScripting,
}; };
pcr->UnRegisterClassImplCategories(CLSID_VLCPlugin, pcr->UnRegisterClassImplCategories(CLSID_VLCPlugin,
...@@ -318,8 +322,9 @@ STDAPI DllRegisterServer(VOID) ...@@ -318,8 +322,9 @@ STDAPI DllRegisterServer(VOID)
CATID implCategories[] = { CATID implCategories[] = {
CATID_Control, CATID_Control,
CATID_PersistsToPropertyBag, CATID_PersistsToPropertyBag,
CATID_SafeForInitializing, _CATID_InternetAware,
CATID_SafeForScripting, _CATID_SafeForInitializing,
_CATID_SafeForScripting,
}; };
pcr->RegisterClassImplCategories(CLSID_VLCPlugin, pcr->RegisterClassImplCategories(CLSID_VLCPlugin,
...@@ -459,3 +464,4 @@ STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved ) ...@@ -459,3 +464,4 @@ STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )
}; };
#endif #endif
...@@ -37,6 +37,7 @@ STDMETHODIMP VLCSupportErrorInfo::InterfaceSupportsErrorInfo(REFIID riid) ...@@ -37,6 +37,7 @@ STDMETHODIMP VLCSupportErrorInfo::InterfaceSupportsErrorInfo(REFIID riid)
|| (riid == IID_IVLCMessageIterator) || (riid == IID_IVLCMessageIterator)
|| (riid == IID_IVLCMessages) || (riid == IID_IVLCMessages)
|| (riid == IID_IVLCPlaylist) || (riid == IID_IVLCPlaylist)
|| (riid == IID_IVLCPlaylistItems)
|| (riid == IID_IVLCVideo) || (riid == IID_IVLCVideo)
|| (riid == IID_IVLCControl2) ) || (riid == IID_IVLCControl2) )
{ {
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "utils.h" #include "utils.h"
#include <shlwapi.h>
#include <wininet.h>
using namespace std; using namespace std;
VLCAudio::~VLCAudio() VLCAudio::~VLCAudio()
...@@ -581,6 +584,7 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout) ...@@ -581,6 +584,7 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
VLCLog::~VLCLog() VLCLog::~VLCLog()
{ {
delete _p_vlcmessages;
if( _p_log ) if( _p_log )
libvlc_log_close(_p_log, NULL); libvlc_log_close(_p_log, NULL);
...@@ -1202,8 +1206,157 @@ STDMETHODIMP VLCMessage::get_message(BSTR* message) ...@@ -1202,8 +1206,157 @@ STDMETHODIMP VLCMessage::get_message(BSTR* message)
/*******************************************************************************/ /*******************************************************************************/
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_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
*count = libvlc_playlist_items_count(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylistItems,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
STDMETHODIMP VLCPlaylistItems::clear()
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_clear(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylistItems,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
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);
libvlc_playlist_delete_item(p_libvlc, item, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylistItems,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
}
return hr;
};
/*******************************************************************************/
VLCPlaylist::~VLCPlaylist() VLCPlaylist::~VLCPlaylist()
{ {
delete _p_vlcplaylistitems;
if( _p_typeinfo ) if( _p_typeinfo )
_p_typeinfo->Release(); _p_typeinfo->Release();
}; };
...@@ -1344,18 +1497,49 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite ...@@ -1344,18 +1497,49 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
char *psz_uri = NULL;
if( SysStringLen(_p_instance->getBaseURL()) > 0 )
{
DWORD len = INTERNET_MAX_URL_LENGTH;
LPOLESTR abs_url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*len);
if( NULL != abs_url )
{
/*
** if the MRL a relative URL, we should end up with an absolute URL
*/
if( SUCCEEDED(UrlCombineW(_p_instance->getBaseURL(), uri, abs_url, &len,
URL_ESCAPE_UNSAFE|URL_PLUGGABLE_PROTOCOL)) )
{
psz_uri = CStrFromBSTR(CP_UTF8, abs_url);
}
else
{
psz_uri = CStrFromBSTR(CP_UTF8, uri);
}
CoTaskMemFree(abs_url);
}
}
else
{
/*
** baseURL is empty, assume MRL is absolute
*/
psz_uri = CStrFromBSTR(CP_UTF8, uri);
}
if( NULL == psz_uri )
{
return E_OUTOFMEMORY;
}
int i_options; int i_options;
char **ppsz_options; char **ppsz_options;
hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options); hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
if( FAILED(hr) ) if( FAILED(hr) )
return hr;
char *psz_uri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == psz_uri )
{ {
VLCControl::FreeTargetOptions(ppsz_options, i_options); CoTaskMemFree(psz_uri);
return E_OUTOFMEMORY; return hr;
} }
char *psz_name = NULL; char *psz_name = NULL;
...@@ -1566,6 +1750,20 @@ STDMETHODIMP VLCPlaylist::removeItem(long item) ...@@ -1566,6 +1750,20 @@ STDMETHODIMP VLCPlaylist::removeItem(long item)
return hr; return hr;
}; };
STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
{
if( NULL == obj )
return E_POINTER;
*obj = _p_vlcplaylistitems;
if( NULL != _p_vlcplaylistitems )
{
_p_vlcplaylistitems->AddRef();
return NOERROR;
}
return E_OUTOFMEMORY;
};
/*******************************************************************************/ /*******************************************************************************/
VLCVideo::~VLCVideo() VLCVideo::~VLCVideo()
...@@ -1826,7 +2024,7 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect) ...@@ -1826,7 +2024,7 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
libvlc_input_free(p_input); libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCVideo,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
......
...@@ -318,7 +318,8 @@ public: ...@@ -318,7 +318,8 @@ public:
VLCLog(VLCPlugin *p_instance) : VLCLog(VLCPlugin *p_instance) :
_p_log(NULL), _p_log(NULL),
_p_instance(p_instance), _p_instance(p_instance),
_p_typeinfo(NULL) _p_typeinfo(NULL),
_p_vlcmessages(NULL)
{ {
_p_vlcmessages = new VLCMessages(p_instance, this); _p_vlcmessages = new VLCMessages(p_instance, this);
}; };
...@@ -367,11 +368,63 @@ private: ...@@ -367,11 +368,63 @@ private:
VLCMessages* _p_vlcmessages; VLCMessages* _p_vlcmessages;
}; };
class VLCPlaylistItems : public 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*);
// IVLCPlaylistItems methods
STDMETHODIMP get_count(long*);
STDMETHODIMP clear();
STDMETHODIMP remove(long);
protected:
HRESULT loadTypeInfo();
private:
VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo;
};
class VLCPlaylist : public IVLCPlaylist class VLCPlaylist : public IVLCPlaylist
{ {
public: public:
VLCPlaylist(VLCPlugin *p_instance) : VLCPlaylist(VLCPlugin *p_instance) :
_p_instance(p_instance), _p_typeinfo(NULL) {}; _p_instance(p_instance),
_p_typeinfo(NULL),
_p_vlcplaylistitems(NULL)
{
_p_vlcplaylistitems = new VLCPlaylistItems(p_instance);
};
virtual ~VLCPlaylist(); virtual ~VLCPlaylist();
// IUnknown methods // IUnknown methods
...@@ -412,6 +465,7 @@ public: ...@@ -412,6 +465,7 @@ public:
STDMETHODIMP prev(); STDMETHODIMP prev();
STDMETHODIMP clear(); STDMETHODIMP clear();
STDMETHODIMP removeItem(long); STDMETHODIMP removeItem(long);
STDMETHODIMP get_items(IVLCPlaylistItems**);
protected: protected:
HRESULT loadTypeInfo(); HRESULT loadTypeInfo();
...@@ -420,6 +474,7 @@ private: ...@@ -420,6 +474,7 @@ private:
VLCPlugin* _p_instance; VLCPlugin* _p_instance;
ITypeInfo* _p_typeinfo; ITypeInfo* _p_typeinfo;
VLCPlaylistItems* _p_vlcplaylistitems;
}; };
class VLCVideo : public IVLCVideo class VLCVideo : public IVLCVideo
......
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