Commit 763b6733 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Remove VLCPlugin::getVLCObject() methond from ActiveX

parent 30b36a44
...@@ -410,21 +410,6 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -410,21 +410,6 @@ HRESULT VLCPlugin::onLoad(void)
return S_OK; return S_OK;
}; };
HRESULT VLCPlugin::getVLCObject(int* i_vlc)
{
libvlc_instance_t *p_libvlc;
HRESULT result = getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
*i_vlc = libvlc_get_vlc_id(p_libvlc);
}
else
{
*i_vlc = 0;
}
return result;
}
HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
{ {
extern HMODULE DllGetModule(); extern HMODULE DllGetModule();
...@@ -485,16 +470,21 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc) ...@@ -485,16 +470,21 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
/* common settings */ /* common settings */
ppsz_argv[ppsz_argc++] = "--no-stats"; ppsz_argv[ppsz_argc++] = "--no-stats";
ppsz_argv[ppsz_argc++] = "--no-media-library"; ppsz_argv[ppsz_argc++] = "--no-media-library";
ppsz_argv[ppsz_argc++] = "--ignore-config";
ppsz_argv[ppsz_argc++] = "--intf=dummy"; ppsz_argv[ppsz_argc++] = "--intf=dummy";
// loop mode is a configuration option only // loop mode is a configuration option only
if( _b_autoloop ) if( _b_autoloop )
ppsz_argv[ppsz_argc++] = "--loop"; ppsz_argv[ppsz_argc++] = "--loop";
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, NULL); libvlc_exception_t ex;
if( NULL == _p_libvlc ) libvlc_exception_init(&ex);
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
if( libvlc_exception_raised(&ex) )
{ {
*pp_libvlc = NULL; *pp_libvlc = NULL;
libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
} }
...@@ -668,6 +658,7 @@ HRESULT VLCPlugin::onClose(DWORD dwSaveOption) ...@@ -668,6 +658,7 @@ HRESULT VLCPlugin::onClose(DWORD dwSaveOption)
_p_libvlc = NULL; _p_libvlc = NULL;
vlcDataObject->onClose(); vlcDataObject->onClose();
if( p_libvlc )
libvlc_release(p_libvlc); libvlc_release(p_libvlc);
} }
return S_OK; return S_OK;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <olectl.h> #include <olectl.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/libvlc.h>
extern "C" const GUID CLSID_VLCPlugin; extern "C" const GUID CLSID_VLCPlugin;
extern "C" const GUID CLSID_VLCPlugin2; extern "C" const GUID CLSID_VLCPlugin2;
...@@ -194,7 +193,6 @@ public: ...@@ -194,7 +193,6 @@ public:
inline void setDirty(BOOL dirty) { _b_dirty = dirty; }; inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return NULL != _p_libvlc; }; inline BOOL isRunning(void) { return NULL != _p_libvlc; };
HRESULT getVLCObject(int *i_vlc);
HRESULT getVLC(libvlc_instance_t** p_vlc); HRESULT getVLC(libvlc_instance_t** p_vlc);
void setErrorInfo(REFIID riid, const char *description); void setErrorInfo(REFIID riid, const char *description);
......
...@@ -123,8 +123,8 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible) ...@@ -123,8 +123,8 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
STDMETHODIMP VLCControl::play(void) STDMETHODIMP VLCControl::play(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_Play(i_vlc); VLC_Play(i_vlc);
...@@ -135,8 +135,8 @@ STDMETHODIMP VLCControl::play(void) ...@@ -135,8 +135,8 @@ STDMETHODIMP VLCControl::play(void)
STDMETHODIMP VLCControl::pause(void) STDMETHODIMP VLCControl::pause(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_Pause(i_vlc); VLC_Pause(i_vlc);
...@@ -147,8 +147,8 @@ STDMETHODIMP VLCControl::pause(void) ...@@ -147,8 +147,8 @@ STDMETHODIMP VLCControl::pause(void)
STDMETHODIMP VLCControl::stop(void) STDMETHODIMP VLCControl::stop(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_Stop(i_vlc); VLC_Stop(i_vlc);
...@@ -165,11 +165,14 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) ...@@ -165,11 +165,14 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
HRESULT result = NOERROR; HRESULT result = NOERROR;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE; if( libvlc_playlist_isplaying(p_libvlc, NULL) )
*isPlaying = VARIANT_TRUE;
else
*isPlaying = VARIANT_FALSE;
return NOERROR; return NOERROR;
} }
} }
...@@ -185,8 +188,8 @@ STDMETHODIMP VLCControl::get_Position(float *position) ...@@ -185,8 +188,8 @@ STDMETHODIMP VLCControl::get_Position(float *position)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*position = VLC_PositionGet(i_vlc); *position = VLC_PositionGet(i_vlc);
...@@ -202,8 +205,8 @@ STDMETHODIMP VLCControl::put_Position(float position) ...@@ -202,8 +205,8 @@ STDMETHODIMP VLCControl::put_Position(float position)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_PositionSet(i_vlc, position); VLC_PositionSet(i_vlc, position);
...@@ -220,8 +223,8 @@ STDMETHODIMP VLCControl::get_Time(int *seconds) ...@@ -220,8 +223,8 @@ STDMETHODIMP VLCControl::get_Time(int *seconds)
HRESULT result = NOERROR; HRESULT result = NOERROR;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*seconds = VLC_TimeGet(i_vlc); *seconds = VLC_TimeGet(i_vlc);
...@@ -245,8 +248,8 @@ STDMETHODIMP VLCControl::shuttle(int seconds) ...@@ -245,8 +248,8 @@ STDMETHODIMP VLCControl::shuttle(int seconds)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_TimeSet(i_vlc, seconds, true); VLC_TimeSet(i_vlc, seconds, true);
...@@ -260,11 +263,20 @@ STDMETHODIMP VLCControl::fullscreen(void) ...@@ -260,11 +263,20 @@ STDMETHODIMP VLCControl::fullscreen(void)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_FullScreen(i_vlc); if( libvlc_playlist_isplaying(p_libvlc, NULL) )
{
libvlc_media_player_t *p_md =
libvlc_playlist_get_media_player(p_libvlc, NULL);
if( p_md )
{
libvlc_toggle_fullscreen(p_md, NULL);
libvlc_media_player_release(p_md);
}
}
} }
} }
return result; return result;
...@@ -278,8 +290,8 @@ STDMETHODIMP VLCControl::get_Length(int *seconds) ...@@ -278,8 +290,8 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
HRESULT result = NOERROR; HRESULT result = NOERROR;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*seconds = VLC_LengthGet(i_vlc); *seconds = VLC_LengthGet(i_vlc);
...@@ -295,8 +307,8 @@ STDMETHODIMP VLCControl::playFaster(void) ...@@ -295,8 +307,8 @@ STDMETHODIMP VLCControl::playFaster(void)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_SpeedFaster(i_vlc); VLC_SpeedFaster(i_vlc);
...@@ -310,8 +322,8 @@ STDMETHODIMP VLCControl::playSlower(void) ...@@ -310,8 +322,8 @@ STDMETHODIMP VLCControl::playSlower(void)
HRESULT result = E_UNEXPECTED; HRESULT result = E_UNEXPECTED;
if( _p_instance->isRunning() ) if( _p_instance->isRunning() )
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
result = _p_instance->getVLCObject(&i_vlc); result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_SpeedSlower(i_vlc); VLC_SpeedSlower(i_vlc);
...@@ -337,8 +349,8 @@ STDMETHODIMP VLCControl::put_Volume(int volume) ...@@ -337,8 +349,8 @@ STDMETHODIMP VLCControl::put_Volume(int volume)
STDMETHODIMP VLCControl::toggleMute(void) STDMETHODIMP VLCControl::toggleMute(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_VolumeMute(i_vlc); VLC_VolumeMute(i_vlc);
...@@ -351,8 +363,8 @@ STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value) ...@@ -351,8 +363,8 @@ STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
if( 0 == SysStringLen(name) ) if( 0 == SysStringLen(name) )
return E_INVALIDARG; return E_INVALIDARG;
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT hr = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
int codePage = _p_instance->getCodePage(); int codePage = _p_instance->getCodePage();
...@@ -466,8 +478,8 @@ STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value) ...@@ -466,8 +478,8 @@ STDMETHODIMP VLCControl::getVariable( BSTR name, VARIANT *value)
if( 0 == SysStringLen(name) ) if( 0 == SysStringLen(name) )
return E_INVALIDARG; return E_INVALIDARG;
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT hr = _p_instance->getVLCObject(&i_vlc); HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
UINT codePage = _p_instance->getCodePage(); UINT codePage = _p_instance->getCodePage();
...@@ -853,8 +865,8 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM ...@@ -853,8 +865,8 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
if( 0 == SysStringLen(uri) ) if( 0 == SysStringLen(uri) )
return E_INVALIDARG; return E_INVALIDARG;
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT hr = _p_instance->getVLCObject(&i_vlc); HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
char *cUri = CStrFromBSTR(CP_UTF8, uri); char *cUri = CStrFromBSTR(CP_UTF8, uri);
...@@ -891,8 +903,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) ...@@ -891,8 +903,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
if( NULL == index ) if( NULL == index )
return E_POINTER; return E_POINTER;
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*index = VLC_PlaylistIndex(i_vlc); *index = VLC_PlaylistIndex(i_vlc);
...@@ -904,8 +916,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) ...@@ -904,8 +916,8 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
STDMETHODIMP VLCControl::get_PlaylistCount(int *count) STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
*count = VLC_PlaylistNumberOfItems(i_vlc); *count = VLC_PlaylistNumberOfItems(i_vlc);
...@@ -917,8 +929,8 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count) ...@@ -917,8 +929,8 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
STDMETHODIMP VLCControl::playlistNext(void) STDMETHODIMP VLCControl::playlistNext(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_PlaylistNext(i_vlc); VLC_PlaylistNext(i_vlc);
...@@ -929,8 +941,8 @@ STDMETHODIMP VLCControl::playlistNext(void) ...@@ -929,8 +941,8 @@ STDMETHODIMP VLCControl::playlistNext(void)
STDMETHODIMP VLCControl::playlistPrev(void) STDMETHODIMP VLCControl::playlistPrev(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_PlaylistPrev(i_vlc); VLC_PlaylistPrev(i_vlc);
...@@ -941,8 +953,8 @@ STDMETHODIMP VLCControl::playlistPrev(void) ...@@ -941,8 +953,8 @@ STDMETHODIMP VLCControl::playlistPrev(void)
STDMETHODIMP VLCControl::playlistClear(void) STDMETHODIMP VLCControl::playlistClear(void)
{ {
int i_vlc; libvlc_instance_t *p_libvlc;
HRESULT result = _p_instance->getVLCObject(&i_vlc); HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
VLC_PlaylistClear(i_vlc); VLC_PlaylistClear(i_vlc);
...@@ -956,7 +968,7 @@ STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version) ...@@ -956,7 +968,7 @@ STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
if( NULL == version ) if( NULL == version )
return E_POINTER; return E_POINTER;
const char *versionStr = VLC_Version(); const char *versionStr = libvlc_get_version();
if( NULL != versionStr ) if( NULL != versionStr )
{ {
*version = BSTRFromCStr(CP_UTF8, versionStr); *version = BSTRFromCStr(CP_UTF8, versionStr);
......
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