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 LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };
56 HINSTANCE getHInstance(void) const { return _hinstance; };
57 LPPICTURE getInPlacePict(void) const
58 { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
62 virtual ~VLCPluginClass();
69 ATOM _inplace_wndclass_atom;
70 ATOM _video_wndclass_atom;
71 LPPICTURE _inplace_picture;
74 class VLCPlugin : public IUnknown
79 VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
81 /* IUnknown methods */
82 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
83 STDMETHODIMP_(ULONG) AddRef(void);
84 STDMETHODIMP_(ULONG) Release(void);
87 HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
88 REFCLSID getClassID(void) { return _p_class->getClassID(); };
89 REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
92 ** persistant properties
96 SysFreeString(_bstr_mrl);
97 _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
100 const BSTR getMRL(void) { return _bstr_mrl; };
102 inline void setAutoPlay(BOOL autoplay)
104 _b_autoplay = autoplay;
107 inline BOOL getAutoPlay(void) { return _b_autoplay; };
109 inline void setAutoLoop(BOOL autoloop)
111 _b_autoloop = autoloop;
114 inline BOOL getAutoLoop(void) { return _b_autoloop;};
116 void setVolume(int volume);
117 int getVolume(void) { return _i_volume; };
119 void setVisible(BOOL fVisible);
120 BOOL getVisible(void) { return _b_visible; };
121 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
123 void setTime(int time);
124 int getTime(void) { return _i_time; };
126 // control size in HIMETRIC
127 inline void setExtent(const SIZEL& extent)
132 const SIZEL& getExtent(void) { return _extent; };
134 // transient properties
135 inline void setMute(BOOL mute) { _b_mute = mute; };
137 inline void setPicture(LPPICTURE pict)
139 if( NULL != _p_pict )
146 inline LPPICTURE getPicture(void)
148 if( NULL != _p_pict )
154 void setFocus(BOOL fFocus);
156 inline UINT getCodePage(void) { return _i_codepage; };
157 inline void setCodePage(UINT cp)
159 // accept new codepage only if it works on this system
160 size_t mblen = WideCharToMultiByte(cp,
161 0, L"test", -1, NULL, 0, NULL, NULL);
166 inline BOOL isUserMode(void) { return _b_usermode; };
167 inline void setUserMode(BOOL um) { _b_usermode = um; };
169 inline BOOL isDirty(void) { return _b_dirty; };
170 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
172 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
173 HRESULT getVLCObject(int *i_vlc);
174 HRESULT getVLC(libvlc_instance_t** p_vlc);
176 // control geometry within container
177 RECT getPosRect(void) { return _posRect; };
178 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
179 BOOL isInPlaceActive(void);
184 HRESULT onInit(void);
185 HRESULT onLoad(void);
186 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
187 HRESULT onInPlaceDeactivate(void);
188 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
189 HRESULT onClose(DWORD dwSaveOption);
190 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
191 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
192 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
193 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
198 void freezeEvents(BOOL freeze);
199 void firePropChangedEvent(DISPID dispid);
200 void fireOnPlayEvent(void);
201 void fireOnPauseEvent(void);
202 void fireOnStopEvent(void);
204 // controlling IUnknown interface
209 virtual ~VLCPlugin();
213 //implemented interfaces
214 class VLCOleObject *vlcOleObject;
215 class VLCOleControl *vlcOleControl;
216 class VLCOleInPlaceObject *vlcOleInPlaceObject;
217 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
218 class VLCPersistStreamInit *vlcPersistStreamInit;
219 class VLCPersistStorage *vlcPersistStorage;
220 class VLCPersistPropertyBag *vlcPersistPropertyBag;
221 class VLCProvideClassInfo *vlcProvideClassInfo;
222 class VLCConnectionPointContainer *vlcConnectionPointContainer;
223 class VLCObjectSafety *vlcObjectSafety;
224 class VLCControl *vlcControl;
225 class VLCControl2 *vlcControl2;
226 class VLCViewObject *vlcViewObject;
227 class VLCDataObject *vlcDataObject;
229 // in place activated window (Clipping window)
231 // video window (Drawing window)
234 VLCPluginClass* _p_class;
237 libvlc_instance_t* _p_libvlc;
242 // persistable properties
252 // indicates whether properties needs persisting