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 *****************************************************************************/
31 extern "C" const GUID CLSID_VLCPlugin;
32 extern "C" const GUID CLSID_VLCPlugin2;
33 extern "C" const GUID LIBID_AXVLC;
34 extern "C" 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 inline void setShowToolbar(BOOL showtoolbar)
116 _b_toolbar = showtoolbar;
119 inline BOOL getShowToolbar(void) { return _b_toolbar;};
121 void setVolume(int volume);
122 int getVolume(void) { return _i_volume; };
124 void setBackColor(OLE_COLOR backcolor);
125 OLE_COLOR getBackColor(void) { return _i_backcolor; };
127 void setVisible(BOOL fVisible);
128 BOOL getVisible(void) { return _b_visible; };
129 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
131 inline void setStartTime(int time)
136 inline int getStartTime(void) { return _i_time; };
138 void setTime(int time);
139 int getTime(void) { return _i_time; };
141 void setBaseURL(BSTR url)
143 SysFreeString(_bstr_baseurl);
144 _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
147 const BSTR getBaseURL(void) { return _bstr_baseurl; };
149 // control size in HIMETRIC
150 inline void setExtent(const SIZEL& extent)
155 const SIZEL& getExtent(void) { return _extent; };
157 // transient properties
158 inline void setMute(BOOL mute) { _b_mute = mute; };
160 inline void setPicture(LPPICTURE pict)
162 if( NULL != _p_pict )
169 inline LPPICTURE getPicture(void)
171 if( NULL != _p_pict )
177 void setFocus(BOOL fFocus);
179 inline UINT getCodePage(void) { return _i_codepage; };
180 inline void setCodePage(UINT cp)
182 // accept new codepage only if it works on this system
183 size_t mblen = WideCharToMultiByte(cp,
184 0, L"test", -1, NULL, 0, NULL, NULL);
189 inline BOOL isUserMode(void) { return _b_usermode; };
190 inline void setUserMode(BOOL um) { _b_usermode = um; };
192 inline BOOL isDirty(void) { return _b_dirty; };
193 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
195 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
196 HRESULT getVLC(libvlc_instance_t** p_vlc);
197 void setErrorInfo(REFIID riid, const char *description);
199 // control geometry within container
200 RECT getPosRect(void) { return _posRect; };
201 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
202 BOOL isInPlaceActive(void);
207 HRESULT onInit(void);
208 HRESULT onLoad(void);
209 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
210 HRESULT onInPlaceDeactivate(void);
211 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
212 HRESULT onClose(DWORD dwSaveOption);
213 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
214 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
215 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
216 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
221 void freezeEvents(BOOL freeze);
222 void firePropChangedEvent(DISPID dispid);
223 void fireOnPlayEvent(void);
224 void fireOnPauseEvent(void);
225 void fireOnStopEvent(void);
227 // controlling IUnknown interface
232 virtual ~VLCPlugin();
236 //implemented interfaces
237 class VLCOleObject *vlcOleObject;
238 class VLCOleControl *vlcOleControl;
239 class VLCOleInPlaceObject *vlcOleInPlaceObject;
240 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
241 class VLCPersistStreamInit *vlcPersistStreamInit;
242 class VLCPersistStorage *vlcPersistStorage;
243 class VLCPersistPropertyBag *vlcPersistPropertyBag;
244 class VLCProvideClassInfo *vlcProvideClassInfo;
245 class VLCConnectionPointContainer *vlcConnectionPointContainer;
246 class VLCObjectSafety *vlcObjectSafety;
247 class VLCControl *vlcControl;
248 class VLCControl2 *vlcControl2;
249 class VLCViewObject *vlcViewObject;
250 class VLCDataObject *vlcDataObject;
251 class VLCSupportErrorInfo *vlcSupportErrorInfo;
253 // in place activated window (Plugin window)
256 VLCPluginClass* _p_class;
259 libvlc_instance_t* _p_libvlc;
265 // persistable properties
276 OLE_COLOR _i_backcolor;
277 // indicates whether properties needs persisting