Commit 47808d9b authored by JP Dinger's avatar JP Dinger Committed by Rémi Denis-Courmont

De-deprecate activex plugin.

Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 6395b3e5
...@@ -206,6 +206,9 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : ...@@ -206,6 +206,9 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_p_class(p_class), _p_class(p_class),
_i_ref(1UL), _i_ref(1UL),
_p_libvlc(NULL), _p_libvlc(NULL),
_p_mlist(NULL),
_p_mplayer(NULL),
_i_midx(-1),
_i_codepage(CP_ACP), _i_codepage(CP_ACP),
_b_usermode(TRUE) _b_usermode(TRUE)
{ {
...@@ -267,6 +270,10 @@ VLCPlugin::~VLCPlugin() ...@@ -267,6 +270,10 @@ VLCPlugin::~VLCPlugin()
SysFreeString(_bstr_mrl); SysFreeString(_bstr_mrl);
SysFreeString(_bstr_baseurl); SysFreeString(_bstr_baseurl);
if( _p_mplayer ) { libvlc_media_player_release(_p_mplayer); _p_mplayer=NULL; }
if( _p_mlist ) { libvlc_media_list_release(_p_mlist); _p_mlist=NULL; }
if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; }
_p_class->Release(); _p_class->Release();
}; };
...@@ -411,138 +418,137 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -411,138 +418,137 @@ HRESULT VLCPlugin::onLoad(void)
return S_OK; return S_OK;
}; };
HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
void VLCPlugin::initVLC()
{ {
extern HMODULE DllGetModule(); extern HMODULE DllGetModule();
if( ! isRunning() ) /*
{ ** default initialization options
/* */
** default initialization options const char *ppsz_argv[32] = { };
*/ int ppsz_argc = 0;
const char *ppsz_argv[32] = { };
int ppsz_argc = 0;
char p_progpath[MAX_PATH]; char p_progpath[MAX_PATH];
{
TCHAR w_progpath[MAX_PATH];
DWORD len = GetModuleFileName(DllGetModule(), w_progpath, MAX_PATH);
if( len > 0 )
{ {
TCHAR w_progpath[MAX_PATH]; len = WideCharToMultiByte(CP_UTF8, 0, w_progpath, len, p_progpath,
DWORD len = GetModuleFileName(DllGetModule(), w_progpath, MAX_PATH); sizeof(p_progpath)-1, NULL, NULL);
if( len > 0 ) if( len > 0 )
{ {
len = WideCharToMultiByte(CP_UTF8, 0, w_progpath, len, p_progpath, p_progpath[len] = '\0';
sizeof(p_progpath)-1, NULL, NULL); ppsz_argv[0] = p_progpath;
if( len > 0 )
{
p_progpath[len] = '\0';
ppsz_argv[0] = p_progpath;
}
} }
} }
}
ppsz_argv[ppsz_argc++] = "-vv"; ppsz_argv[ppsz_argc++] = "-vv";
HKEY h_key; HKEY h_key;
char p_pluginpath[MAX_PATH]; char p_pluginpath[MAX_PATH];
if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Software\\VideoLAN\\VLC"), if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, TEXT("Software\\VideoLAN\\VLC"),
0, KEY_READ, &h_key ) == ERROR_SUCCESS ) 0, KEY_READ, &h_key ) == ERROR_SUCCESS )
{
DWORD i_type, i_data = MAX_PATH;
TCHAR w_pluginpath[MAX_PATH];
if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type,
(LPBYTE)w_pluginpath, &i_data ) == ERROR_SUCCESS )
{ {
DWORD i_type, i_data = MAX_PATH; if( i_type == REG_SZ )
TCHAR w_pluginpath[MAX_PATH];
if( RegQueryValueEx( h_key, TEXT("InstallDir"), 0, &i_type,
(LPBYTE)w_pluginpath, &i_data ) == ERROR_SUCCESS )
{ {
if( i_type == REG_SZ ) if( WideCharToMultiByte(CP_UTF8, 0, w_pluginpath, -1, p_pluginpath,
sizeof(p_pluginpath)-sizeof("\\plugins")+1, NULL, NULL) )
{ {
if( WideCharToMultiByte(CP_UTF8, 0, w_pluginpath, -1, p_pluginpath, strcat( p_pluginpath, "\\plugins" );
sizeof(p_pluginpath)-sizeof("\\plugins")+1, NULL, NULL) ) ppsz_argv[ppsz_argc++] = "--plugin-path";
{ ppsz_argv[ppsz_argc++] = p_pluginpath;
strcat( p_pluginpath, "\\plugins" );
ppsz_argv[ppsz_argc++] = "--plugin-path";
ppsz_argv[ppsz_argc++] = p_pluginpath;
}
} }
} }
RegCloseKey( h_key );
} }
RegCloseKey( h_key );
}
// make sure plugin isn't affected with VLC single instance mode // make sure plugin isn't affected with VLC single instance mode
ppsz_argv[ppsz_argc++] = "--no-one-instance"; ppsz_argv[ppsz_argc++] = "--no-one-instance";
/* 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++] = "--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";
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
_p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex); _p_libvlc = libvlc_new(ppsz_argc, ppsz_argv, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ return;
*pp_libvlc = NULL;
libvlc_exception_clear(&ex);
return E_FAIL;
}
// initial volume setting _p_mlist = libvlc_media_list_new(_p_libvlc, &ex);
libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL); if( libvlc_exception_raised(&ex) )
if( _b_mute ) {
{ libvlc_release(_p_libvlc);
libvlc_audio_set_mute(_p_libvlc, TRUE, NULL); return;
} }
// initial playlist item // initial volume setting
if( SysStringLen(_bstr_mrl) > 0 ) libvlc_audio_set_volume(_p_libvlc, _i_volume, NULL);
{ if( _b_mute )
char *psz_mrl = NULL; {
libvlc_audio_set_mute(_p_libvlc, TRUE, NULL);
}
if( SysStringLen(_bstr_baseurl) > 0 ) // initial playlist item
if( SysStringLen(_bstr_mrl) > 0 )
{
char *psz_mrl = NULL;
if( SysStringLen(_bstr_baseurl) > 0 )
{
/*
** if the MRL a relative URL, we should end up with an absolute URL
*/
LPWSTR abs_url = CombineURL(_bstr_baseurl, _bstr_mrl);
if( NULL != abs_url )
{ {
/* psz_mrl = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
** if the MRL a relative URL, we should end up with an absolute URL CoTaskMemFree(abs_url);
*/
LPWSTR abs_url = CombineURL(_bstr_baseurl, _bstr_mrl);
if( NULL != abs_url )
{
psz_mrl = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
CoTaskMemFree(abs_url);
}
else
{
psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
}
} }
else else
{ {
/*
** baseURL is empty, assume MRL is absolute
*/
psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl); psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
} }
if( NULL != psz_mrl ) }
{ else
const char *options[1]; {
int i_options = 0; /*
** baseURL is empty, assume MRL is absolute
*/
psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
}
if( NULL != psz_mrl )
{
const char *options[1];
int i_options = 0;
char timeBuffer[32]; char timeBuffer[32];
if( _i_time ) if( _i_time )
{ {
snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time); snprintf(timeBuffer, sizeof(timeBuffer), ":start-time=%d", _i_time);
options[i_options++] = timeBuffer; options[i_options++] = timeBuffer;
}
// add default target to playlist
libvlc_playlist_add_extended_untrusted(_p_libvlc, psz_mrl, NULL, i_options, options, NULL);
CoTaskMemFree(psz_mrl);
} }
// add default target to playlist
playlist_add_extended_untrusted(psz_mrl, i_options, options, NULL);
CoTaskMemFree(psz_mrl);
} }
} }
*pp_libvlc = _p_libvlc;
return S_OK;
}; };
void VLCPlugin::setErrorInfo(REFIID riid, const char *description) void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
...@@ -729,16 +735,10 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -729,16 +735,10 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
libvlc_video_set_parent(p_libvlc, libvlc_video_set_parent(p_libvlc,
reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL); reinterpret_cast<libvlc_drawable_t>(_inplacewnd), NULL);
if( _b_autoplay ) if( _b_autoplay && playlist_select(0,NULL) )
{ {
libvlc_playlist_lock(p_libvlc); libvlc_media_player_play(_p_mplayer,NULL);
unsigned count = libvlc_playlist_items_count(p_libvlc, &ex); fireOnPlayEvent();
if( count > 0 )
{
libvlc_playlist_play(p_libvlc, 0, 0, NULL, NULL);
fireOnPlayEvent();
}
libvlc_playlist_unlock(p_libvlc);
} }
} }
...@@ -750,9 +750,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc ...@@ -750,9 +750,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
HRESULT VLCPlugin::onInPlaceDeactivate(void) HRESULT VLCPlugin::onInPlaceDeactivate(void)
{ {
if( isRunning() ) if( isPlaying(NULL) )
{ {
libvlc_playlist_stop(_p_libvlc, NULL); playlist_stop(NULL);
fireOnStopEvent(); fireOnStopEvent();
} }
...@@ -817,14 +817,9 @@ void VLCPlugin::setTime(int seconds) ...@@ -817,14 +817,9 @@ void VLCPlugin::setTime(int seconds)
if( seconds != _i_time ) if( seconds != _i_time )
{ {
setStartTime(_i_time); setStartTime(_i_time);
if( isRunning() ) if( NULL != _p_mplayer )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(_p_libvlc, NULL); libvlc_media_player_set_time(_p_mplayer, _i_time, NULL);
if( NULL != p_md )
{
libvlc_media_player_set_time(p_md, _i_time, NULL);
libvlc_media_player_release(p_md);
}
} }
} }
}; };
...@@ -1036,3 +1031,77 @@ void VLCPlugin::fireOnStopEvent(void) ...@@ -1036,3 +1031,77 @@ void VLCPlugin::fireOnStopEvent(void)
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs);
}; };
bool VLCPlugin::playlist_select( int idx, libvlc_exception_t *ex )
{
libvlc_media_t *p_m = NULL;
libvlc_media_list_lock(_p_mlist);
int count = libvlc_media_list_count(_p_mlist,ex);
if( libvlc_exception_raised(ex) )
goto bad_unlock;
if( idx<0||idx>=count )
goto bad_unlock;
_i_midx = idx;
p_m = libvlc_media_list_item_at_index(_p_mlist,_i_midx,ex);
libvlc_media_list_unlock(_p_mlist);
if( libvlc_exception_raised(ex) )
return false;
if( _p_mplayer )
{
libvlc_media_player_release( _p_mplayer );
_p_mplayer = NULL;
}
_p_mplayer = libvlc_media_player_new_from_media(p_m,ex);
if( _p_mplayer )
set_player_window(ex);
libvlc_media_release( p_m );
return !libvlc_exception_raised(ex);
bad_unlock:
libvlc_media_list_unlock(_p_mlist);
return false;
}
void VLCPlugin::set_player_window(libvlc_exception_t *ex)
{
// XXX FIXME no idea if this is correct or not
libvlc_media_player_set_hwnd(_p_mplayer,getInPlaceWindow(),ex);
}
int VLCPlugin::playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv, libvlc_exception_t *ex)
{
int item = -1;
libvlc_media_t *p_m = libvlc_media_new(_p_libvlc,mrl,ex);
if( libvlc_exception_raised(ex) )
return -1;
for( int i = 0; i < optc; ++i )
{
libvlc_media_add_option_untrusted(p_m, optv[i],ex);
if( libvlc_exception_raised(ex) )
{
libvlc_media_release(p_m);
return -1;
}
}
libvlc_media_list_lock(_p_mlist);
libvlc_media_list_add_media(_p_mlist,p_m,ex);
if( !libvlc_exception_raised(ex) )
item = libvlc_media_list_count(_p_mlist,ex)-1;
libvlc_media_list_unlock(_p_mlist);
libvlc_media_release(p_m);
return item;
}
...@@ -193,7 +193,20 @@ public: ...@@ -193,7 +193,20 @@ 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 getVLC(libvlc_instance_t** p_vlc);
HRESULT getVLC(libvlc_instance_t** pp_libvlc)
{
if( !isRunning() )
initVLC();
*pp_libvlc = _p_libvlc;
return _p_libvlc?S_OK:E_FAIL;
}
HRESULT getMD(libvlc_media_player_t **pp_md)
{
*pp_md = _p_mplayer;
return _p_mplayer?S_OK:E_FAIL;
}
void setErrorInfo(REFIID riid, const char *description); void setErrorInfo(REFIID riid, const char *description);
// control geometry within container // control geometry within container
...@@ -227,11 +240,81 @@ public: ...@@ -227,11 +240,81 @@ public:
// controlling IUnknown interface // controlling IUnknown interface
LPUNKNOWN pUnkOuter; LPUNKNOWN pUnkOuter;
/*
** libvlc interface
*/
bool isPlaying(libvlc_exception_t *ex)
{
return _p_mplayer && libvlc_media_player_is_playing(_p_mplayer,ex);
}
int playlist_get_current_index(libvlc_exception_t *) { return _i_midx; }
int playlist_add_extended_untrusted(const char *, int, const char **, libvlc_exception_t *);
void playlist_delete_item(int idx, libvlc_exception_t *ex)
{
if( _p_mlist )
libvlc_media_list_remove_index(_p_mlist,idx,ex);
}
void playlist_clear(libvlc_exception_t *ex)
{
if( !_p_libvlc )
return;
if( _p_mlist )
libvlc_media_list_release(_p_mlist);
_p_mlist = libvlc_media_list_new(_p_libvlc,ex);
}
int playlist_count(libvlc_exception_t *ex)
{
int r = 0;
if( !_p_mlist )
return 0;
libvlc_media_list_lock(_p_mlist);
r = libvlc_media_list_count(_p_mlist,ex);
libvlc_media_list_unlock(_p_mlist);
return r;
}
void playlist_pause(libvlc_exception_t *ex)
{
if( isPlaying(ex) )
libvlc_media_player_pause(_p_mplayer,ex);
}
void playlist_play(libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( _p_mplayer||playlist_select(0,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_play_item(int idx,libvlc_exception_t *ex)
{
if( !_p_libvlc )
initVLC();
if( playlist_select(idx,ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_stop(libvlc_exception_t *ex)
{
if( _p_mplayer )
libvlc_media_player_stop(_p_mplayer,ex);
}
void playlist_next(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx+1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
void playlist_prev(libvlc_exception_t *ex)
{
if( playlist_select( _i_midx-1, ex) )
libvlc_media_player_play(_p_mplayer,ex);
}
protected: protected:
virtual ~VLCPlugin(); virtual ~VLCPlugin();
private: private:
void initVLC();
bool playlist_select(int i,libvlc_exception_t *);
void set_player_window(libvlc_exception_t *);
//implemented interfaces //implemented interfaces
class VLCOleObject *vlcOleObject; class VLCOleObject *vlcOleObject;
...@@ -256,7 +339,11 @@ private: ...@@ -256,7 +339,11 @@ private:
VLCPluginClass* _p_class; VLCPluginClass* _p_class;
ULONG _i_ref; ULONG _i_ref;
libvlc_instance_t* _p_libvlc; libvlc_instance_t *_p_libvlc;
libvlc_media_list_t *_p_mlist;
libvlc_media_player_t *_p_mplayer;
int _i_midx;
UINT _i_codepage; UINT _i_codepage;
BOOL _b_usermode; BOOL _b_usermode;
RECT _posRect; RECT _posRect;
......
...@@ -124,37 +124,31 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible) ...@@ -124,37 +124,31 @@ STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)
STDMETHODIMP VLCControl::play(void) STDMETHODIMP VLCControl::play(void)
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT result = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex); _p_instance->playlist_play(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
_p_instance->fireOnPlayEvent();
return NOERROR;
} }
return result; _p_instance->fireOnPlayEvent();
return NOERROR;
}; };
STDMETHODIMP VLCControl::pause(void) STDMETHODIMP VLCControl::pause(void)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t* p_md;
HRESULT result = _p_instance->getVLC(&p_libvlc); HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_pause(p_libvlc, &ex); libvlc_media_player_pause(p_md, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
...@@ -170,14 +164,14 @@ STDMETHODIMP VLCControl::pause(void) ...@@ -170,14 +164,14 @@ STDMETHODIMP VLCControl::pause(void)
STDMETHODIMP VLCControl::stop(void) STDMETHODIMP VLCControl::stop(void)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getVLC(&p_libvlc); HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_stop(p_libvlc, &ex); libvlc_media_player_stop(p_md, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
...@@ -196,21 +190,13 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) ...@@ -196,21 +190,13 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
if( NULL == isPlaying ) if( NULL == isPlaying )
return E_POINTER; return E_POINTER;
HRESULT result = NOERROR; libvlc_media_player_t *p_md;
if( _p_instance->isRunning() ) HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{ {
libvlc_instance_t *p_libvlc; *isPlaying = libvlc_media_player_is_playing(p_md, NULL) ?
result = _p_instance->getVLC(&p_libvlc); VARIANT_TRUE : VARIANT_FALSE;
if( SUCCEEDED(result) ) return NOERROR;
{
libvlc_playlist_lock( p_libvlc );
if( libvlc_playlist_isplaying(p_libvlc, NULL) )
*isPlaying = VARIANT_TRUE;
else
*isPlaying = VARIANT_FALSE;
libvlc_playlist_unlock( p_libvlc );
return NOERROR;
}
} }
*isPlaying = VARIANT_FALSE; *isPlaying = VARIANT_FALSE;
return result; return result;
...@@ -222,24 +208,17 @@ STDMETHODIMP VLCControl::get_Position(float *position) ...@@ -222,24 +208,17 @@ STDMETHODIMP VLCControl::get_Position(float *position)
return E_POINTER; return E_POINTER;
*position = 0.0f; *position = 0.0f;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT result = E_UNEXPECTED; HRESULT result = _p_instance->getMD(&p_md);
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *position = libvlc_media_player_get_position(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); if( ! libvlc_exception_raised(&ex) )
if( !libvlc_exception_raised(&ex) )
{ {
*position = libvlc_media_player_get_position(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -251,24 +230,17 @@ STDMETHODIMP VLCControl::get_Position(float *position) ...@@ -251,24 +230,17 @@ STDMETHODIMP VLCControl::get_Position(float *position)
STDMETHODIMP VLCControl::put_Position(float position) STDMETHODIMP VLCControl::put_Position(float position)
{ {
HRESULT result = E_UNEXPECTED; libvlc_media_player_t *p_md;
libvlc_instance_t* p_libvlc; HRESULT result = _p_instance->getMD(&p_md);
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; libvlc_media_player_set_position(p_md, position, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_position(p_md, position, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -284,23 +256,17 @@ STDMETHODIMP VLCControl::get_Time(int *seconds) ...@@ -284,23 +256,17 @@ STDMETHODIMP VLCControl::get_Time(int *seconds)
return E_POINTER; return E_POINTER;
*seconds = 0; *seconds = 0;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getVLC(&p_libvlc); HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *seconds = libvlc_media_player_get_time(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*seconds = libvlc_media_player_get_time(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -319,24 +285,18 @@ STDMETHODIMP VLCControl::put_Time(int seconds) ...@@ -319,24 +285,18 @@ STDMETHODIMP VLCControl::put_Time(int seconds)
STDMETHODIMP VLCControl::shuttle(int seconds) STDMETHODIMP VLCControl::shuttle(int seconds)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getVLC(&p_libvlc); HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; if( seconds < 0 ) seconds = 0;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
if( seconds < 0 ) seconds = 0; return NOERROR;
libvlc_media_player_set_time(p_md, (int64_t)seconds, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -349,27 +309,13 @@ STDMETHODIMP VLCControl::shuttle(int seconds) ...@@ -349,27 +309,13 @@ STDMETHODIMP VLCControl::shuttle(int seconds)
STDMETHODIMP VLCControl::fullscreen(void) STDMETHODIMP VLCControl::fullscreen(void)
{ {
HRESULT result = E_UNEXPECTED; libvlc_media_player_t *p_md;
if( _p_instance->isRunning() ) HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) )
{ {
libvlc_instance_t *p_libvlc; if( libvlc_media_player_is_playing(p_md, NULL) )
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{ {
bool b_playing; libvlc_toggle_fullscreen(p_md, NULL);
libvlc_playlist_lock( p_libvlc );
b_playing = libvlc_playlist_isplaying(p_libvlc, NULL);
libvlc_playlist_unlock( p_libvlc );
if( b_playing )
{
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;
...@@ -381,23 +327,17 @@ STDMETHODIMP VLCControl::get_Length(int *seconds) ...@@ -381,23 +327,17 @@ STDMETHODIMP VLCControl::get_Length(int *seconds)
return E_POINTER; return E_POINTER;
*seconds = 0; *seconds = 0;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT result = _p_instance->getVLC(&p_libvlc); HRESULT result = _p_instance->getMD(&p_md);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *seconds = (double)libvlc_media_player_get_length(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*seconds = (double)libvlc_media_player_get_length(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -412,23 +352,17 @@ STDMETHODIMP VLCControl::playFaster(void) ...@@ -412,23 +352,17 @@ STDMETHODIMP VLCControl::playFaster(void)
{ {
int32_t rate = 2; int32_t rate = 2;
HRESULT result = E_UNEXPECTED; libvlc_media_player_t *p_md;
if( !_p_instance->isRunning() ) HRESULT result = _p_instance->getMD(&p_md);
return result;
libvlc_instance_t* p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_rate(p_md, rate, &ex); libvlc_media_player_set_rate(p_md, rate, &ex);
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
return NOERROR; return NOERROR;
...@@ -446,27 +380,17 @@ STDMETHODIMP VLCControl::playSlower(void) ...@@ -446,27 +380,17 @@ STDMETHODIMP VLCControl::playSlower(void)
{ {
float rate = 0.5; float rate = 0.5;
HRESULT result = E_UNEXPECTED; libvlc_media_player_t *p_md;
if( !_p_instance->isRunning() ) HRESULT result = _p_instance->getMD(&p_md);
return result;
libvlc_instance_t* p_libvlc;
result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) ) if( SUCCEEDED(result) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; libvlc_media_player_set_rate(p_md, rate, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_rate(p_md, rate, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -880,10 +804,8 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo ...@@ -880,10 +804,8 @@ STDMETHODIMP VLCControl::addTarget(BSTR uri, VARIANT options, enum VLCPlaylistMo
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
position = libvlc_playlist_add_extended(p_libvlc, cUri, cUri, position = _p_instance->playlist_add_extended_untrusted(cUri,
cOptionsCount, cOptionsCount, const_cast<const char**>(cOptions), &ex);
const_cast<const char**>(cOptions),
&ex);
FreeTargetOptions(cOptions, cOptionsCount); FreeTargetOptions(cOptions, cOptionsCount);
CoTaskMemFree(cUri); CoTaskMemFree(cUri);
...@@ -919,7 +841,7 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) ...@@ -919,7 +841,7 @@ STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
*index = libvlc_playlist_get_current_index(p_libvlc, &ex); *index = _p_instance->playlist_get_current_index(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
...@@ -937,27 +859,18 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count) ...@@ -937,27 +859,18 @@ STDMETHODIMP VLCControl::get_PlaylistCount(int *count)
if( NULL == count ) if( NULL == count )
return E_POINTER; return E_POINTER;
*count = 0; libvlc_exception_t ex;
libvlc_instance_t* p_libvlc; libvlc_exception_init(&ex);
HRESULT result = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(result) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_lock(p_libvlc); *count = _p_instance->playlist_count(&ex);
*count = libvlc_playlist_items_count(p_libvlc, &ex); if( libvlc_exception_raised(&ex) )
libvlc_playlist_unlock(p_libvlc); {
if( libvlc_exception_raised(&ex) ) _p_instance->setErrorInfo(IID_IVLCControl,
{ libvlc_exception_get_message(&ex));
_p_instance->setErrorInfo(IID_IVLCControl, libvlc_exception_clear(&ex);
libvlc_exception_get_message(&ex)); return E_FAIL;
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
} }
return result; return NOERROR;
}; };
STDMETHODIMP VLCControl::playlistNext(void) STDMETHODIMP VLCControl::playlistNext(void)
...@@ -969,7 +882,7 @@ STDMETHODIMP VLCControl::playlistNext(void) ...@@ -969,7 +882,7 @@ STDMETHODIMP VLCControl::playlistNext(void)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_next(p_libvlc, &ex); _p_instance->playlist_next(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
...@@ -991,7 +904,7 @@ STDMETHODIMP VLCControl::playlistPrev(void) ...@@ -991,7 +904,7 @@ STDMETHODIMP VLCControl::playlistPrev(void)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_prev(p_libvlc, &ex); _p_instance->playlist_prev(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
...@@ -1013,7 +926,7 @@ STDMETHODIMP VLCControl::playlistClear(void) ...@@ -1013,7 +926,7 @@ STDMETHODIMP VLCControl::playlistClear(void)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_clear(p_libvlc, &ex); _p_instance->playlist_clear(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCControl, _p_instance->setErrorInfo(IID_IVLCControl,
......
...@@ -211,17 +211,14 @@ STDMETHODIMP VLCAudio::get_track(long* track) ...@@ -211,17 +211,14 @@ STDMETHODIMP VLCAudio::get_track(long* track)
if( NULL == track ) if( NULL == track )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
*track = libvlc_audio_get_track(p_md, &ex); *track = libvlc_audio_get_track(p_md, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCAudio, _p_instance->setErrorInfo(IID_IVLCAudio,
...@@ -236,17 +233,14 @@ STDMETHODIMP VLCAudio::get_track(long* track) ...@@ -236,17 +233,14 @@ STDMETHODIMP VLCAudio::get_track(long* track)
STDMETHODIMP VLCAudio::put_track(long track) STDMETHODIMP VLCAudio::put_track(long track)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md;
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
libvlc_audio_set_track(p_md, track, &ex); libvlc_audio_set_track(p_md, track, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCAudio, _p_instance->setErrorInfo(IID_IVLCAudio,
...@@ -413,23 +407,17 @@ STDMETHODIMP VLCInput::get_length(double* length) ...@@ -413,23 +407,17 @@ STDMETHODIMP VLCInput::get_length(double* length)
return E_POINTER; return E_POINTER;
*length = 0; *length = 0;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *length = (double)libvlc_media_player_get_length(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*length = (double)libvlc_media_player_get_length(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -445,23 +433,17 @@ STDMETHODIMP VLCInput::get_position(double* position) ...@@ -445,23 +433,17 @@ STDMETHODIMP VLCInput::get_position(double* position)
return E_POINTER; return E_POINTER;
*position = 0.0f; *position = 0.0f;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *position = libvlc_media_player_get_position(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*position = libvlc_media_player_get_position(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -473,23 +455,17 @@ STDMETHODIMP VLCInput::get_position(double* position) ...@@ -473,23 +455,17 @@ STDMETHODIMP VLCInput::get_position(double* position)
STDMETHODIMP VLCInput::put_position(double position) STDMETHODIMP VLCInput::put_position(double position)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; libvlc_media_player_set_position(p_md, position, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_position(p_md, position, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -504,23 +480,17 @@ STDMETHODIMP VLCInput::get_time(double* time) ...@@ -504,23 +480,17 @@ STDMETHODIMP VLCInput::get_time(double* time)
if( NULL == time ) if( NULL == time )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *time = (double)libvlc_media_player_get_time(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*time = (double)libvlc_media_player_get_time(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -532,23 +502,17 @@ STDMETHODIMP VLCInput::get_time(double* time) ...@@ -532,23 +502,17 @@ STDMETHODIMP VLCInput::get_time(double* time)
STDMETHODIMP VLCInput::put_time(double time) STDMETHODIMP VLCInput::put_time(double time)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; libvlc_media_player_set_time(p_md, (int64_t)time, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_time(p_md, (int64_t)time, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -563,23 +527,17 @@ STDMETHODIMP VLCInput::get_state(long* state) ...@@ -563,23 +527,17 @@ STDMETHODIMP VLCInput::get_state(long* state)
if( NULL == state ) if( NULL == state )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *state = libvlc_media_player_get_state(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*state = libvlc_media_player_get_state(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
// don't fail, just return the idle state // don't fail, just return the idle state
...@@ -594,23 +552,17 @@ STDMETHODIMP VLCInput::get_rate(double* rate) ...@@ -594,23 +552,17 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
if( NULL == rate ) if( NULL == rate )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *rate = libvlc_media_player_get_rate(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*rate = libvlc_media_player_get_rate(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -622,23 +574,17 @@ STDMETHODIMP VLCInput::get_rate(double* rate) ...@@ -622,23 +574,17 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
STDMETHODIMP VLCInput::put_rate(double rate) STDMETHODIMP VLCInput::put_rate(double rate)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; libvlc_media_player_set_rate(p_md, rate, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_set_rate(p_md, rate, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -654,23 +600,17 @@ STDMETHODIMP VLCInput::get_fps(double* fps) ...@@ -654,23 +600,17 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
return E_POINTER; return E_POINTER;
*fps = 0.0; *fps = 0.0;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *fps = libvlc_media_player_get_fps(p_md, &ex);
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*fps = libvlc_media_player_get_fps(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -685,24 +625,18 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout) ...@@ -685,24 +625,18 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
if( NULL == hasVout ) if( NULL == hasVout )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md; *hasVout = libvlc_media_player_has_vout(p_md, &ex) ?
p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); VARIANT_TRUE : VARIANT_FALSE;
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*hasVout = libvlc_media_player_has_vout(p_md, &ex) ? return NOERROR;
VARIANT_TRUE : VARIANT_FALSE;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCInput, _p_instance->setErrorInfo(IID_IVLCInput,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
...@@ -1520,26 +1454,18 @@ STDMETHODIMP VLCPlaylistItems::get_count(long* count) ...@@ -1520,26 +1454,18 @@ STDMETHODIMP VLCPlaylistItems::get_count(long* count)
if( NULL == count ) if( NULL == count )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_lock(p_libvlc); *count = _p_instance->playlist_count(&ex);
*count = libvlc_playlist_items_count(p_libvlc, &ex); if( libvlc_exception_raised(&ex) )
libvlc_playlist_unlock(p_libvlc); {
if( libvlc_exception_raised(&ex) ) _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
{ libvlc_exception_get_message(&ex));
_p_instance->setErrorInfo(IID_IVLCPlaylistItems, libvlc_exception_clear(&ex);
libvlc_exception_get_message(&ex)); return E_FAIL;
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylistItems::clear() STDMETHODIMP VLCPlaylistItems::clear()
...@@ -1551,7 +1477,7 @@ STDMETHODIMP VLCPlaylistItems::clear() ...@@ -1551,7 +1477,7 @@ STDMETHODIMP VLCPlaylistItems::clear()
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_clear(p_libvlc, &ex); _p_instance->playlist_clear(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylistItems, _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
...@@ -1573,7 +1499,7 @@ STDMETHODIMP VLCPlaylistItems::remove(long item) ...@@ -1573,7 +1499,7 @@ STDMETHODIMP VLCPlaylistItems::remove(long item)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_delete_item(p_libvlc, item, &ex); _p_instance->playlist_delete_item(item, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylistItems, _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
...@@ -1672,26 +1598,18 @@ STDMETHODIMP VLCPlaylist::get_itemCount(long* count) ...@@ -1672,26 +1598,18 @@ STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
return E_POINTER; return E_POINTER;
*count = 0; *count = 0;
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_lock(p_libvlc); *count = _p_instance->playlist_count(&ex);
*count = libvlc_playlist_items_count(p_libvlc, &ex); if( libvlc_exception_raised(&ex) )
libvlc_playlist_unlock(p_libvlc); {
if( libvlc_exception_raised(&ex) ) _p_instance->setErrorInfo(IID_IVLCPlaylist,
{ libvlc_exception_get_message(&ex));
_p_instance->setErrorInfo(IID_IVLCPlaylist, libvlc_exception_clear(&ex);
libvlc_exception_get_message(&ex)); return E_FAIL;
libvlc_exception_clear(&ex);
return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying) STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
...@@ -1699,25 +1617,22 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying) ...@@ -1699,25 +1617,22 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
if( NULL == isPlaying ) if( NULL == isPlaying )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_lock( p_libvlc ); *isPlaying = libvlc_media_player_is_playing(p_md, &ex) ?
*isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ?
VARIANT_TRUE: VARIANT_FALSE; VARIANT_TRUE: VARIANT_FALSE;
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
libvlc_playlist_unlock( p_libvlc );
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
} }
libvlc_playlist_unlock( p_libvlc );
return NOERROR; return NOERROR;
} }
return hr; return hr;
...@@ -1789,12 +1704,8 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite ...@@ -1789,12 +1704,8 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
VariantClear(&v_name); VariantClear(&v_name);
} }
*item = libvlc_playlist_add_extended(p_libvlc, *item = _p_instance->playlist_add_extended_untrusted(psz_uri,
psz_uri, i_options, const_cast<const char **>(ppsz_options), &ex);
psz_name,
i_options,
const_cast<const char **>(ppsz_options),
&ex);
VLCControl::FreeTargetOptions(ppsz_options, i_options); VLCControl::FreeTargetOptions(ppsz_options, i_options);
CoTaskMemFree(psz_uri); CoTaskMemFree(psz_uri);
...@@ -1814,56 +1725,44 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite ...@@ -1814,56 +1725,44 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
STDMETHODIMP VLCPlaylist::play() STDMETHODIMP VLCPlaylist::play()
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex); _p_instance->playlist_play(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::playItem(long item) STDMETHODIMP VLCPlaylist::playItem(long item)
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex); _p_instance->playlist_play_item(item,&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::togglePause() STDMETHODIMP VLCPlaylist::togglePause()
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t* p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_pause(p_libvlc, &ex); libvlc_media_player_pause(p_md, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
...@@ -1878,14 +1777,14 @@ STDMETHODIMP VLCPlaylist::togglePause() ...@@ -1878,14 +1777,14 @@ STDMETHODIMP VLCPlaylist::togglePause()
STDMETHODIMP VLCPlaylist::stop() STDMETHODIMP VLCPlaylist::stop()
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_stop(p_libvlc, &ex); libvlc_media_player_stop(p_md, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
...@@ -1900,68 +1799,50 @@ STDMETHODIMP VLCPlaylist::stop() ...@@ -1900,68 +1799,50 @@ STDMETHODIMP VLCPlaylist::stop()
STDMETHODIMP VLCPlaylist::next() STDMETHODIMP VLCPlaylist::next()
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_next(p_libvlc, &ex); _p_instance->playlist_next(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::prev() STDMETHODIMP VLCPlaylist::prev()
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_prev(p_libvlc, &ex); _p_instance->playlist_prev(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::clear() STDMETHODIMP VLCPlaylist::clear()
{ {
libvlc_instance_t* p_libvlc; libvlc_exception_t ex;
HRESULT hr = _p_instance->getVLC(&p_libvlc); libvlc_exception_init(&ex);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_playlist_clear(p_libvlc, &ex); _p_instance->playlist_clear(&ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex)); libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
}
return NOERROR;
} }
return hr; return NOERROR;
}; };
STDMETHODIMP VLCPlaylist::removeItem(long item) STDMETHODIMP VLCPlaylist::removeItem(long item)
...@@ -1973,7 +1854,7 @@ STDMETHODIMP VLCPlaylist::removeItem(long item) ...@@ -1973,7 +1854,7 @@ STDMETHODIMP VLCPlaylist::removeItem(long item)
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_playlist_delete_item(p_libvlc, item, &ex); _p_instance->playlist_delete_item(item, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCPlaylist, _p_instance->setErrorInfo(IID_IVLCPlaylist,
...@@ -2084,22 +1965,17 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen) ...@@ -2084,22 +1965,17 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
if( NULL == fullscreen ) if( NULL == fullscreen )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); *fullscreen = libvlc_get_fullscreen(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*fullscreen = libvlc_get_fullscreen(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE; return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2110,22 +1986,17 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen) ...@@ -2110,22 +1986,17 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen) STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2139,22 +2010,17 @@ STDMETHODIMP VLCVideo::get_width(long* width) ...@@ -2139,22 +2010,17 @@ STDMETHODIMP VLCVideo::get_width(long* width)
if( NULL == width ) if( NULL == width )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); *width = libvlc_video_get_width(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*width = libvlc_video_get_width(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2168,22 +2034,17 @@ STDMETHODIMP VLCVideo::get_height(long* height) ...@@ -2168,22 +2034,17 @@ STDMETHODIMP VLCVideo::get_height(long* height)
if( NULL == height ) if( NULL == height )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); *height = libvlc_video_get_height(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*height = libvlc_video_get_height(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2197,32 +2058,28 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect) ...@@ -2197,32 +2058,28 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
if( NULL == aspect ) if( NULL == aspect )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex); if( NULL == psz_aspect )
return E_OUTOFMEMORY;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
if( NULL == psz_aspect )
return E_OUTOFMEMORY;
*aspect = BSTRFromCStr(CP_UTF8, psz_aspect); *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
free( psz_aspect );
psz_aspect = NULL;
return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
}
free( psz_aspect ); free( psz_aspect );
psz_aspect = NULL; psz_aspect = NULL;
return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
} }
free( psz_aspect );
psz_aspect = NULL;
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
...@@ -2238,33 +2095,28 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect) ...@@ -2238,33 +2095,28 @@ STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
if( 0 == SysStringLen(aspect) ) if( 0 == SysStringLen(aspect) )
return E_INVALIDARG; return E_INVALIDARG;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
if( ! libvlc_exception_raised(&ex) ) if( NULL == psz_aspect )
{ {
char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect); return E_OUTOFMEMORY;
if( NULL == psz_aspect ) }
{
return E_OUTOFMEMORY;
}
libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex); libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
CoTaskMemFree(psz_aspect); CoTaskMemFree(psz_aspect);
libvlc_media_player_release(p_md); if( libvlc_exception_raised(&ex) )
if( libvlc_exception_raised(&ex) ) {
{ _p_instance->setErrorInfo(IID_IVLCVideo,
_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;
}
} }
return NOERROR; return NOERROR;
} }
...@@ -2276,22 +2128,17 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu) ...@@ -2276,22 +2128,17 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
if( NULL == spu ) if( NULL == spu )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); *spu = libvlc_video_get_spu(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*spu = libvlc_video_get_spu(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2302,16 +2149,14 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu) ...@@ -2302,16 +2149,14 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
STDMETHODIMP VLCVideo::put_subtitle(long spu) STDMETHODIMP VLCVideo::put_subtitle(long spu)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
libvlc_video_set_spu(p_md, spu, &ex); libvlc_video_set_spu(p_md, spu, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
...@@ -2328,32 +2173,27 @@ STDMETHODIMP VLCVideo::get_crop(BSTR* geometry) ...@@ -2328,32 +2173,27 @@ STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
if( NULL == geometry ) if( NULL == geometry )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex); if( NULL == psz_geometry )
return E_OUTOFMEMORY;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
if( NULL == psz_geometry )
return E_OUTOFMEMORY;
*geometry = BSTRFromCStr(CP_UTF8, psz_geometry); *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
free( psz_geometry );
psz_geometry = NULL;
return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
}
free( psz_geometry ); free( psz_geometry );
psz_geometry = NULL; psz_geometry = NULL;
return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
} }
free( psz_geometry );
psz_geometry = NULL;
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return E_FAIL; return E_FAIL;
...@@ -2369,33 +2209,28 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry) ...@@ -2369,33 +2209,28 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
if( 0 == SysStringLen(geometry) ) if( 0 == SysStringLen(geometry) )
return E_INVALIDARG; return E_INVALIDARG;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
if( ! libvlc_exception_raised(&ex) ) if( NULL == psz_geometry )
{ {
char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry); return E_OUTOFMEMORY;
if( NULL == psz_geometry ) }
{
return E_OUTOFMEMORY;
}
libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex); libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
CoTaskMemFree(psz_geometry); CoTaskMemFree(psz_geometry);
libvlc_media_player_release(p_md); if( libvlc_exception_raised(&ex) )
if( libvlc_exception_raised(&ex) ) {
{ _p_instance->setErrorInfo(IID_IVLCVideo,
_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;
}
} }
return NOERROR; return NOERROR;
} }
...@@ -2407,22 +2242,17 @@ STDMETHODIMP VLCVideo::get_teletext(long* page) ...@@ -2407,22 +2242,17 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
if( NULL == page ) if( NULL == page )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); *page = libvlc_video_get_teletext(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
*page = libvlc_video_get_teletext(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2433,16 +2263,14 @@ STDMETHODIMP VLCVideo::get_teletext(long* page) ...@@ -2433,16 +2263,14 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
STDMETHODIMP VLCVideo::put_teletext(long page) STDMETHODIMP VLCVideo::put_teletext(long page)
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex);
libvlc_video_set_teletext(p_md, page, &ex); libvlc_video_set_teletext(p_md, page, &ex);
libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
...@@ -2459,100 +2287,92 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) ...@@ -2459,100 +2287,92 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
if( NULL == picture ) if( NULL == picture )
return E_POINTER; return E_POINTER;
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); static int uniqueId = 0;
if( ! libvlc_exception_raised(&ex) ) TCHAR path[MAX_PATH+1];
{
static int uniqueId = 0;
TCHAR path[MAX_PATH+1];
int pathlen = GetTempPath(MAX_PATH-24, path); int pathlen = GetTempPath(MAX_PATH-24, path);
if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) ) if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
return E_FAIL; return E_FAIL;
/* check temp directory path by openning it */ /* check temp directory path by openning it */
{
HANDLE dirHandle = CreateFile(path, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if( INVALID_HANDLE_VALUE == dirHandle )
{
_p_instance->setErrorInfo(IID_IVLCVideo,
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
return E_FAIL;
}
else
{ {
HANDLE dirHandle = CreateFile(path, BY_HANDLE_FILE_INFORMATION bhfi;
GENERIC_READ, BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, CloseHandle(dirHandle);
NULL, if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL);
if( INVALID_HANDLE_VALUE == dirHandle )
{ {
_p_instance->setErrorInfo(IID_IVLCVideo, _p_instance->setErrorInfo(IID_IVLCVideo,
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars."); "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
return E_FAIL; return E_FAIL;
} }
else
{
BY_HANDLE_FILE_INFORMATION bhfi;
BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
CloseHandle(dirHandle);
if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
_p_instance->setErrorInfo(IID_IVLCVideo,
"Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
return E_FAIL;
}
}
} }
}
TCHAR filepath[MAX_PATH+1]; TCHAR filepath[MAX_PATH+1];
_stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"), _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
path, GetCurrentProcessId(), ++uniqueId); path, GetCurrentProcessId(), ++uniqueId);
#ifdef _UNICODE #ifdef _UNICODE
/* reuse path storage for UTF8 string */ /* reuse path storage for UTF8 string */
char *psz_filepath = (char *)path; char *psz_filepath = (char *)path;
WCHAR* wpath = filepath; WCHAR* wpath = filepath;
#else #else
char *psz_filepath = path; char *psz_filepath = path;
/* first convert to unicode using current code page */ /* first convert to unicode using current code page */
WCHAR wpath[MAX_PATH+1]; WCHAR wpath[MAX_PATH+1];
if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) ) if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) )
return E_FAIL; return E_FAIL;
#endif #endif
/* convert to UTF8 */ /* convert to UTF8 */
pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL); pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL);
// fail if path is 0 or too short (i.e pathlen is the same as storage size) // fail if path is 0 or too short (i.e pathlen is the same as storage size)
if( (0 == pathlen) || (sizeof(path) == pathlen) ) if( (0 == pathlen) || (sizeof(path) == pathlen) )
return E_FAIL; return E_FAIL;
/* take snapshot into file */ /* take snapshot into file */
libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex); libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
libvlc_media_player_release(p_md); if( ! libvlc_exception_raised(&ex) )
if( ! libvlc_exception_raised(&ex) ) {
hr = E_FAIL;
/* open snapshot file */
HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
if( snapPic )
{ {
hr = E_FAIL; PICTDESC snapDesc;
/* open snapshot file */
HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE); snapDesc.cbSizeofstruct = sizeof(PICTDESC);
if( snapPic ) snapDesc.picType = PICTYPE_BITMAP;
snapDesc.bmp.hbitmap = (HBITMAP)snapPic;
snapDesc.bmp.hpal = NULL;
hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
if( FAILED(hr) )
{ {
PICTDESC snapDesc; *picture = NULL;
DeleteObject(snapPic);
snapDesc.cbSizeofstruct = sizeof(PICTDESC);
snapDesc.picType = PICTYPE_BITMAP;
snapDesc.bmp.hbitmap = (HBITMAP)snapPic;
snapDesc.bmp.hpal = NULL;
hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
if( FAILED(hr) )
{
*picture = NULL;
DeleteObject(snapPic);
}
} }
DeleteFile(filepath);
return hr;
} }
DeleteFile(filepath);
return hr;
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2563,22 +2383,17 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture) ...@@ -2563,22 +2383,17 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
STDMETHODIMP VLCVideo::toggleFullscreen() STDMETHODIMP VLCVideo::toggleFullscreen()
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); libvlc_toggle_fullscreen(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_toggle_fullscreen(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -2589,22 +2404,17 @@ STDMETHODIMP VLCVideo::toggleFullscreen() ...@@ -2589,22 +2404,17 @@ STDMETHODIMP VLCVideo::toggleFullscreen()
STDMETHODIMP VLCVideo::toggleTeletext() STDMETHODIMP VLCVideo::toggleTeletext()
{ {
libvlc_instance_t* p_libvlc; libvlc_media_player_t *p_md;
HRESULT hr = _p_instance->getVLC(&p_libvlc); HRESULT hr = _p_instance->getMD(&p_md);
if( SUCCEEDED(hr) ) if( SUCCEEDED(hr) )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_libvlc, &ex); libvlc_toggle_teletext(p_md, &ex);
if( ! libvlc_exception_raised(&ex) ) if( ! libvlc_exception_raised(&ex) )
{ {
libvlc_toggle_teletext(p_md, &ex); return NOERROR;
libvlc_media_player_release(p_md);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
} }
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex)); _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
......
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