1 /*****************************************************************************
2 * plugin.h: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
29 #include <vlc/libvlc.h>
31 extern const GUID CLSID_VLCPlugin;
32 extern const GUID CLSID_VLCPlugin2;
33 extern const GUID LIBID_AXVLC;
34 extern const GUID DIID_DVLCEvents;
36 class VLCPluginClass : public IClassFactory
41 VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid);
43 /* IUnknown methods */
44 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
45 STDMETHODIMP_(ULONG) AddRef(void);
46 STDMETHODIMP_(ULONG) Release(void);
48 /* IClassFactory methods */
49 STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
50 STDMETHODIMP LockServer(BOOL fLock);
52 REFCLSID getClassID(void) { return (REFCLSID)_classid; };
54 LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
55 HINSTANCE getHInstance(void) const { return _hinstance; };
56 LPPICTURE getInPlacePict(void) const
57 { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
61 virtual ~VLCPluginClass();
68 ATOM _inplace_wndclass_atom;
69 LPPICTURE _inplace_picture;
72 class VLCPlugin : public IUnknown
77 VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
79 /* IUnknown methods */
80 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
81 STDMETHODIMP_(ULONG) AddRef(void);
82 STDMETHODIMP_(ULONG) Release(void);
85 HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
86 REFCLSID getClassID(void) { return _p_class->getClassID(); };
87 REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
90 ** persistant properties
94 SysFreeString(_bstr_mrl);
95 _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
98 const BSTR getMRL(void) { return _bstr_mrl; };
100 inline void setAutoPlay(BOOL autoplay)
102 _b_autoplay = autoplay;
105 inline BOOL getAutoPlay(void) { return _b_autoplay; };
107 inline void setAutoLoop(BOOL autoloop)
109 _b_autoloop = autoloop;
112 inline BOOL getAutoLoop(void) { return _b_autoloop;};
114 void setVolume(int volume);
115 int getVolume(void) { return _i_volume; };
117 void setVisible(BOOL fVisible);
118 BOOL getVisible(void) { return _b_visible; };
119 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
121 inline void setStartTime(int time)
126 inline int getStartTime(void) { return _i_time; };
128 void setTime(int time);
129 int getTime(void) { return _i_time; };
131 void setBaseURL(BSTR url)
133 SysFreeString(_bstr_baseurl);
134 _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
137 const BSTR getBaseURL(void) { return _bstr_baseurl; };
139 // control size in HIMETRIC
140 inline void setExtent(const SIZEL& extent)
145 const SIZEL& getExtent(void) { return _extent; };
147 // transient properties
148 inline void setMute(BOOL mute) { _b_mute = mute; };
150 inline void setPicture(LPPICTURE pict)
152 if( NULL != _p_pict )
159 inline LPPICTURE getPicture(void)
161 if( NULL != _p_pict )
167 void setFocus(BOOL fFocus);
169 inline UINT getCodePage(void) { return _i_codepage; };
170 inline void setCodePage(UINT cp)
172 // accept new codepage only if it works on this system
173 size_t mblen = WideCharToMultiByte(cp,
174 0, L"test", -1, NULL, 0, NULL, NULL);
179 inline BOOL isUserMode(void) { return _b_usermode; };
180 inline void setUserMode(BOOL um) { _b_usermode = um; };
182 inline BOOL isDirty(void) { return _b_dirty; };
183 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
185 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
186 HRESULT getVLCObject(int *i_vlc);
187 HRESULT getVLC(libvlc_instance_t** p_vlc);
188 void setErrorInfo(REFIID riid, const char *description);
190 // control geometry within container
191 RECT getPosRect(void) { return _posRect; };
192 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
193 BOOL isInPlaceActive(void);
198 HRESULT onInit(void);
199 HRESULT onLoad(void);
200 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
201 HRESULT onInPlaceDeactivate(void);
202 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
203 HRESULT onClose(DWORD dwSaveOption);
204 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
205 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
206 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
207 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
212 void freezeEvents(BOOL freeze);
213 void firePropChangedEvent(DISPID dispid);
214 void fireOnPlayEvent(void);
215 void fireOnPauseEvent(void);
216 void fireOnStopEvent(void);
218 // controlling IUnknown interface
223 virtual ~VLCPlugin();
227 //implemented interfaces
228 class VLCOleObject *vlcOleObject;
229 class VLCOleControl *vlcOleControl;
230 class VLCOleInPlaceObject *vlcOleInPlaceObject;
231 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
232 class VLCPersistStreamInit *vlcPersistStreamInit;
233 class VLCPersistStorage *vlcPersistStorage;
234 class VLCPersistPropertyBag *vlcPersistPropertyBag;
235 class VLCProvideClassInfo *vlcProvideClassInfo;
236 class VLCConnectionPointContainer *vlcConnectionPointContainer;
237 class VLCObjectSafety *vlcObjectSafety;
238 class VLCControl *vlcControl;
239 class VLCControl2 *vlcControl2;
240 class VLCViewObject *vlcViewObject;
241 class VLCDataObject *vlcDataObject;
242 class VLCSupportErrorInfo *vlcSupportErrorInfo;
244 // in place activated window (Plugin window)
247 VLCPluginClass* _p_class;
250 libvlc_instance_t* _p_libvlc;
255 // persistable properties
266 // indicates whether properties needs persisting