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 LPCTSTR 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 setBackColor(OLE_COLOR backcolor);
118 OLE_COLOR getBackColor(void) { return _i_backcolor; };
120 void setVisible(BOOL fVisible);
121 BOOL getVisible(void) { return _b_visible; };
122 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
124 inline void setStartTime(int time)
129 inline int getStartTime(void) { return _i_time; };
131 void setTime(int time);
132 int getTime(void) { return _i_time; };
134 void setBaseURL(BSTR url)
136 SysFreeString(_bstr_baseurl);
137 _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
140 const BSTR getBaseURL(void) { return _bstr_baseurl; };
142 // control size in HIMETRIC
143 inline void setExtent(const SIZEL& extent)
148 const SIZEL& getExtent(void) { return _extent; };
150 // transient properties
151 inline void setMute(BOOL mute) { _b_mute = mute; };
153 inline void setPicture(LPPICTURE pict)
155 if( NULL != _p_pict )
162 inline LPPICTURE getPicture(void)
164 if( NULL != _p_pict )
170 void setFocus(BOOL fFocus);
172 inline UINT getCodePage(void) { return _i_codepage; };
173 inline void setCodePage(UINT cp)
175 // accept new codepage only if it works on this system
176 size_t mblen = WideCharToMultiByte(cp,
177 0, L"test", -1, NULL, 0, NULL, NULL);
182 inline BOOL isUserMode(void) { return _b_usermode; };
183 inline void setUserMode(BOOL um) { _b_usermode = um; };
185 inline BOOL isDirty(void) { return _b_dirty; };
186 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
188 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
189 HRESULT getVLCObject(int *i_vlc);
190 HRESULT getVLC(libvlc_instance_t** p_vlc);
191 void setErrorInfo(REFIID riid, const char *description);
193 // control geometry within container
194 RECT getPosRect(void) { return _posRect; };
195 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
196 BOOL isInPlaceActive(void);
201 HRESULT onInit(void);
202 HRESULT onLoad(void);
203 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
204 HRESULT onInPlaceDeactivate(void);
205 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
206 HRESULT onClose(DWORD dwSaveOption);
207 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
208 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
209 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
210 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
215 void freezeEvents(BOOL freeze);
216 void firePropChangedEvent(DISPID dispid);
217 void fireOnPlayEvent(void);
218 void fireOnPauseEvent(void);
219 void fireOnStopEvent(void);
221 // controlling IUnknown interface
226 virtual ~VLCPlugin();
230 //implemented interfaces
231 class VLCOleObject *vlcOleObject;
232 class VLCOleControl *vlcOleControl;
233 class VLCOleInPlaceObject *vlcOleInPlaceObject;
234 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
235 class VLCPersistStreamInit *vlcPersistStreamInit;
236 class VLCPersistStorage *vlcPersistStorage;
237 class VLCPersistPropertyBag *vlcPersistPropertyBag;
238 class VLCProvideClassInfo *vlcProvideClassInfo;
239 class VLCConnectionPointContainer *vlcConnectionPointContainer;
240 class VLCObjectSafety *vlcObjectSafety;
241 class VLCControl *vlcControl;
242 class VLCControl2 *vlcControl2;
243 class VLCViewObject *vlcViewObject;
244 class VLCDataObject *vlcDataObject;
245 class VLCSupportErrorInfo *vlcSupportErrorInfo;
247 // in place activated window (Plugin window)
250 VLCPluginClass* _p_class;
253 libvlc_instance_t* _p_libvlc;
259 // persistable properties
269 OLE_COLOR _i_backcolor;
270 // indicates whether properties needs persisting