Commit acb89500 authored by Damien Fouilleul's avatar Damien Fouilleul

- added support for returning custom error messages from libvlc exception messages

- added missing video.toggleFullscreen() API
parent 141dd1d8
......@@ -36,6 +36,8 @@ SOURCES_activex = \
dataobject.h \
viewobject.cpp \
viewobject.h \
supporterrorinfo.cpp \
supporterrorinfo.h \
vlccontrol.cpp \
vlccontrol.h \
vlccontrol2.cpp \
......
......@@ -179,7 +179,9 @@ library AXVLC
odl,
uuid(9E0BD17B-2D3C-4656-B94D-03084F3FD9D4),
helpstring("VLC Audio APIs"),
hidden,
dual,
nonextensible,
oleautomation
]
interface IVLCAudio : IDispatch
......@@ -202,7 +204,9 @@ library AXVLC
odl,
uuid(49E0DBD1-9440-466C-9C97-95C67190C603),
helpstring("VLC Input APIs"),
hidden,
dual,
nonextensible,
oleautomation
]
interface IVLCInput : IDispatch
......@@ -239,7 +243,9 @@ library AXVLC
odl,
uuid(54613049-40BF-4035-9E70-0A9312C0188D),
helpstring("VLC Playlist APIs"),
hidden,
dual,
nonextensible,
oleautomation
]
interface IVLCPlaylist : IDispatch
......@@ -282,7 +288,9 @@ library AXVLC
odl,
uuid(0AAEDF0B-D333-4B27-A0C6-BBF31413A42E),
helpstring("VLC Video APIs"),
hidden,
dual,
nonextensible,
oleautomation
]
interface IVLCVideo : IDispatch
......@@ -297,12 +305,16 @@ library AXVLC
[propget, helpstring("Returns video original height.")]
HRESULT height([out, retval] int* height);
[helpstring("toggle fullscreen/windowed state.")]
HRESULT toggleFullscreen();
};
[
odl,
uuid(2D719729-5333-406C-BF12-8DE787FD65E3),
helpstring("VLC Control"),
hidden,
dual,
oleautomation
]
......
No preview for this file type
......@@ -1448,6 +1448,9 @@ interface IVLCVideo : public IDispatch
virtual HRESULT STDMETHODCALLTYPE get_height(
int* height) = 0;
virtual HRESULT STDMETHODCALLTYPE toggleFullscreen(
) = 0;
};
#else
typedef struct IVLCVideoVtbl {
......@@ -1512,6 +1515,9 @@ typedef struct IVLCVideoVtbl {
IVLCVideo* This,
int* height);
HRESULT (STDMETHODCALLTYPE *toggleFullscreen)(
IVLCVideo* This);
END_INTERFACE
} IVLCVideoVtbl;
interface IVLCVideo {
......@@ -1533,6 +1539,7 @@ interface IVLCVideo {
#define IVLCVideo_put_fullscreen(p,a) (p)->lpVtbl->put_fullscreen(p,a)
#define IVLCVideo_get_width(p,a) (p)->lpVtbl->get_width(p,a)
#define IVLCVideo_get_height(p,a) (p)->lpVtbl->get_height(p,a)
#define IVLCVideo_toggleFullscreen(p) (p)->lpVtbl->toggleFullscreen(p)
#endif
#endif
......@@ -1569,6 +1576,13 @@ void __RPC_STUB IVLCVideo_get_height_Stub(
IRpcChannelBuffer* pRpcChannelBuffer,
PRPC_MESSAGE pRpcMessage,
DWORD* pdwStubPhase);
HRESULT CALLBACK IVLCVideo_toggleFullscreen_Proxy(
IVLCVideo* This);
void __RPC_STUB IVLCVideo_toggleFullscreen_Stub(
IRpcStubBuffer* This,
IRpcChannelBuffer* pRpcChannelBuffer,
PRPC_MESSAGE pRpcMessage,
DWORD* pdwStubPhase);
#endif /* __IVLCVideo_INTERFACE_DEFINED__ */
......
......@@ -36,6 +36,7 @@
#include "vlccontrol2.h"
#include "viewobject.h"
#include "dataobject.h"
#include "supporterrorinfo.h"
#include "utils.h"
......@@ -223,6 +224,7 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
vlcViewObject = new VLCViewObject(this);
vlcDataObject = new VLCDataObject(this);
vlcOleObject = new VLCOleObject(this);
vlcSupportErrorInfo = new VLCSupportErrorInfo(this);
// configure controlling IUnknown interface for implemented interfaces
this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
......@@ -236,6 +238,7 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
VLCPlugin::~VLCPlugin()
{
delete vlcSupportErrorInfo;
delete vlcOleObject;
delete vlcDataObject;
delete vlcViewObject;
......@@ -306,6 +309,8 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
*ppv = reinterpret_cast<LPVOID>(vlcViewObject);
else if( IID_IDataObject == riid )
*ppv = reinterpret_cast<LPVOID>(vlcDataObject);
else if( IID_ISupportErrorInfo == riid )
*ppv = reinterpret_cast<LPVOID>(vlcSupportErrorInfo);
else
{
*ppv = NULL;
......@@ -435,8 +440,8 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
if( i_type == REG_SZ )
{
strcat( p_data, "\\plugins" );
ppsz_argv[ppsz_argc++] = "--plugin-path";
ppsz_argv[ppsz_argc++] = p_data;
//ppsz_argv[ppsz_argc++] = "--plugin-path";
//ppsz_argv[ppsz_argc++] = p_data;
}
}
RegCloseKey( h_key );
......@@ -546,6 +551,13 @@ HRESULT VLCPlugin::getVLC(libvlc_instance_t** pp_libvlc)
return S_OK;
};
void VLCPlugin::setErrorInfo(REFIID riid, const char *description)
{
vlcSupportErrorInfo->setErrorInfo( getClassID() == CLSID_VLCPlugin2 ?
OLESTR("VideoLAN.VLCPlugin.2") : OLESTR("VideoLAN.VLCPlugin.1"),
riid, description );
};
HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
{
VARIANT v;
......@@ -933,7 +945,7 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
/* change cliprect coordinates system relative to window bounding rect */
OffsetRect(&clipRect, -lprcPosRect->left, -lprcPosRect->top);
HRGN clipRgn = CreateRectRgnIndirect(&clipRect);
SetWindowRgn(_inplacewnd, clipRgn, TRUE);
SetWindowRgn(_inplacewnd, clipRgn, FALSE);
//RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
if( isRunning() )
......
......@@ -185,6 +185,7 @@ public:
inline BOOL isRunning(void) { return NULL != _p_libvlc; };
HRESULT getVLCObject(int *i_vlc);
HRESULT getVLC(libvlc_instance_t** p_vlc);
void setErrorInfo(REFIID riid, const char *description);
// control geometry within container
RECT getPosRect(void) { return _posRect; };
......@@ -238,6 +239,7 @@ private:
class VLCControl2 *vlcControl2;
class VLCViewObject *vlcViewObject;
class VLCDataObject *vlcDataObject;
class VLCSupportErrorInfo *vlcSupportErrorInfo;
// in place activated window (Plugin window)
HWND _inplacewnd;
......
/*****************************************************************************
* supporterrorinfo.cpp: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "plugin.h"
#include "supporterrorinfo.h"
#include "utils.h"
using namespace std;
STDMETHODIMP VLCSupportErrorInfo::InterfaceSupportsErrorInfo(REFIID riid)
{
if( IID_NULL == riid )
return S_FALSE;
return riid == _riid ? S_OK : S_FALSE;
};
void VLCSupportErrorInfo::setErrorInfo(LPCOLESTR progid, REFIID riid, const char *description)
{
_riid = IID_NULL;
BSTR bstrDescription = BSTRFromCStr(CP_UTF8, description);
if( NULL != bstrDescription )
{
ICreateErrorInfo* pcerrinfo;
HRESULT hr = CreateErrorInfo(&pcerrinfo);
if( SUCCEEDED(hr) )
{
IErrorInfo* perrinfo;
pcerrinfo->SetSource((LPOLESTR)progid);
pcerrinfo->SetGUID(riid);
pcerrinfo->SetDescription((LPOLESTR)bstrDescription);
hr = pcerrinfo->QueryInterface(IID_IErrorInfo, (LPVOID*) &perrinfo);
if( SUCCEEDED(hr) )
{
_riid = riid;
::SetErrorInfo(0, perrinfo);
perrinfo->Release();
}
pcerrinfo->Release();
}
SysFreeString(bstrDescription);
}
};
/*****************************************************************************
* supporterrorinfo.h: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2006 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef __SUPPORTERRORINFO_H__
#define __SUPPORTERRORINFO_H__
#include <oaidl.h>
class VLCSupportErrorInfo : public ISupportErrorInfo
{
public:
VLCSupportErrorInfo(VLCPlugin *p_instance) :
_p_instance(p_instance),
_riid(IID_NULL)
{};
virtual ~VLCSupportErrorInfo()
{};
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
|| (IID_ISupportErrorInfo == riid) )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
}
return _p_instance->pUnkOuter->QueryInterface(riid, ppv);
};
STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->pUnkOuter->AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return _p_instance->pUnkOuter->Release(); };
// ISupportErrorInfo methods
STDMETHODIMP InterfaceSupportsErrorInfo(REFIID riid);
// VLCSupportErrorInfo methods
void setErrorInfo(LPCOLESTR progid, REFIID riid, const char *description);
private:
VLCPlugin *_p_instance;
IID _riid;
};
#endif
......@@ -120,6 +120,7 @@ STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
*mute = libvlc_audio_get_mute(p_libvlc, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -140,6 +141,7 @@ STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -163,6 +165,7 @@ STDMETHODIMP VLCAudio::get_volume(int* volume)
*volume = libvlc_audio_get_volume(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -183,6 +186,7 @@ STDMETHODIMP VLCAudio::put_volume(int volume)
libvlc_audio_set_volume(p_libvlc, volume, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -203,6 +207,7 @@ STDMETHODIMP VLCAudio::toggleMute()
libvlc_audio_toggle_mute(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -312,6 +317,7 @@ STDMETHODIMP VLCInput::get_length(double* length)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -340,6 +346,7 @@ STDMETHODIMP VLCInput::get_position(float* position)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -365,6 +372,7 @@ STDMETHODIMP VLCInput::put_position(float position)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -393,6 +401,7 @@ STDMETHODIMP VLCInput::get_time(double* time)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -418,6 +427,7 @@ STDMETHODIMP VLCInput::put_time(double time)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -476,6 +486,7 @@ STDMETHODIMP VLCInput::get_rate(float* rate)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -501,6 +512,7 @@ STDMETHODIMP VLCInput::put_rate(float rate)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -529,6 +541,7 @@ STDMETHODIMP VLCInput::get_fps(float* fps)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -557,6 +570,7 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -657,6 +671,8 @@ STDMETHODIMP VLCPlaylist::get_itemCount(int* count)
*count = libvlc_playlist_items_count(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -680,6 +696,8 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
*isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ? VARIANT_TRUE: VARIANT_FALSE;
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -741,6 +759,8 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, int* item
CoTaskMemFree(psz_name);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -781,6 +801,8 @@ STDMETHODIMP VLCPlaylist::playItem(int item)
libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -801,6 +823,8 @@ STDMETHODIMP VLCPlaylist::togglePause()
libvlc_playlist_pause(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -821,6 +845,8 @@ STDMETHODIMP VLCPlaylist::stop()
libvlc_playlist_stop(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -841,6 +867,8 @@ STDMETHODIMP VLCPlaylist::next()
libvlc_playlist_next(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -861,6 +889,8 @@ STDMETHODIMP VLCPlaylist::prev()
libvlc_playlist_prev(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -881,6 +911,8 @@ STDMETHODIMP VLCPlaylist::clear()
libvlc_playlist_clear(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -901,6 +933,8 @@ STDMETHODIMP VLCPlaylist::removeItem(int item)
libvlc_playlist_delete_item(p_libvlc, item, &ex);
if( libvlc_exception_raised(&ex) )
{
_p_instance->setErrorInfo(IID_IVLCPlaylist,
libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -1010,6 +1044,7 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -1035,6 +1070,7 @@ STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -1063,6 +1099,7 @@ STDMETHODIMP VLCVideo::get_width(int* width)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......@@ -1091,6 +1128,33 @@ STDMETHODIMP VLCVideo::get_height(int* height)
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
return hr;
};
STDMETHODIMP VLCVideo::toggleFullscreen()
{
libvlc_instance_t* p_libvlc;
HRESULT hr = _p_instance->getVLC(&p_libvlc);
if( SUCCEEDED(hr) )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
if( ! libvlc_exception_raised(&ex) )
{
libvlc_toggle_fullscreen(p_input, &ex);
libvlc_input_free(p_input);
if( ! libvlc_exception_raised(&ex) )
{
return NOERROR;
}
}
_p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return E_FAIL;
}
......
......@@ -222,6 +222,7 @@ public:
STDMETHODIMP put_fullscreen(VARIANT_BOOL);
STDMETHODIMP get_width(int*);
STDMETHODIMP get_height(int*);
STDMETHODIMP toggleFullscreen();
protected:
HRESULT loadTypeInfo();
......
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