]> git.sesse.net Git - vlc/blob - activex/plugin.h
- Improve DIST_SUBDIR
[vlc] / activex / plugin.h
1 /*****************************************************************************
2  * plugin.h: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
5  *
6  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7  *
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.
12  *
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.
17  *
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  *****************************************************************************/
22
23 #ifndef __PLUGIN_H__
24 #define __PLUGIN_H__
25
26 #include <ole2.h>
27 #include <olectl.h>
28
29 #include <vlc/libvlc.h>
30
31 extern const GUID CLSID_VLCPlugin; 
32 extern const GUID CLSID_VLCPlugin2; 
33 extern const GUID LIBID_AXVLC; 
34 extern const GUID DIID_DVLCEvents; 
35
36 class VLCPluginClass : public IClassFactory
37 {
38
39 public:
40
41     VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid);
42
43     /* IUnknown methods */
44     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
45     STDMETHODIMP_(ULONG) AddRef(void);
46     STDMETHODIMP_(ULONG) Release(void);
47
48     /* IClassFactory methods */
49     STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
50     STDMETHODIMP LockServer(BOOL fLock);
51
52     REFCLSID getClassID(void) { return (REFCLSID)_classid; };
53
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; };
58
59 protected:
60
61     virtual ~VLCPluginClass();
62
63 private:
64
65     LPLONG      _p_class_ref;
66     HINSTANCE   _hinstance;
67     CLSID       _classid;
68     ATOM        _inplace_wndclass_atom;
69     LPPICTURE   _inplace_picture;
70 };
71
72 class VLCPlugin : public IUnknown
73 {
74
75 public:
76
77     VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
78
79     /* IUnknown methods */
80     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
81     STDMETHODIMP_(ULONG) AddRef(void);
82     STDMETHODIMP_(ULONG) Release(void);
83
84     /* custom methods */
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; };
88
89     /*
90     ** persistant properties
91     */
92     void setMRL(BSTR mrl)
93     {
94         SysFreeString(_bstr_mrl);
95         _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
96         setDirty(TRUE);
97     };
98     const BSTR getMRL(void) { return _bstr_mrl; };
99
100     inline void setAutoPlay(BOOL autoplay)
101     {
102         _b_autoplay = autoplay;
103         setDirty(TRUE);
104     };
105     inline BOOL getAutoPlay(void) { return _b_autoplay; };
106
107     inline void setAutoLoop(BOOL autoloop) 
108     {
109         _b_autoloop = autoloop;
110         setDirty(TRUE);
111     };
112     inline BOOL getAutoLoop(void) { return _b_autoloop;};
113
114     void setVolume(int volume);
115     int getVolume(void) { return _i_volume; };
116
117     void setVisible(BOOL fVisible);
118     BOOL getVisible(void) { return _b_visible; };
119     BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
120
121     inline void setStartTime(int time)
122     {
123         _i_time = time;
124         setDirty(TRUE);
125     };
126     inline int getStartTime(void) { return _i_time; };
127
128     void setTime(int time);
129     int  getTime(void) { return _i_time; };
130
131     void setBaseURL(BSTR url)
132     {
133         SysFreeString(_bstr_baseurl);
134         _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
135         setDirty(TRUE);
136     };
137     const BSTR getBaseURL(void) { return _bstr_baseurl; };
138
139     // control size in HIMETRIC
140     inline void setExtent(const SIZEL& extent)
141     {
142         _extent = extent;
143         setDirty(TRUE);
144     };
145     const SIZEL& getExtent(void) { return _extent; };
146
147     // transient properties 
148     inline void setMute(BOOL mute) { _b_mute = mute; };
149
150     inline void setPicture(LPPICTURE pict)
151     {
152         if( NULL != _p_pict )
153             _p_pict->Release();
154         if( NULL != pict )
155             _p_pict->AddRef();
156         _p_pict = pict;
157     };
158
159     inline LPPICTURE getPicture(void)
160     {
161         if( NULL != _p_pict )
162             _p_pict->AddRef();
163         return _p_pict;
164     };
165
166     BOOL hasFocus(void);
167     void setFocus(BOOL fFocus);
168
169     inline UINT getCodePage(void) { return _i_codepage; };
170     inline void setCodePage(UINT cp)
171     {
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);
175         if( mblen > 0 )
176             _i_codepage = cp;
177     };
178
179     inline BOOL isUserMode(void) { return _b_usermode; };
180     inline void setUserMode(BOOL um) { _b_usermode = um; };
181
182     inline BOOL isDirty(void) { return _b_dirty; };
183     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
184
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);
189
190     // control geometry within container
191     RECT getPosRect(void) { return _posRect; }; 
192     inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
193     BOOL isInPlaceActive(void);
194
195     /*
196     ** container events
197     */
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);
208
209     /*
210     ** control events
211     */
212     void freezeEvents(BOOL freeze);
213     void firePropChangedEvent(DISPID dispid);
214     void fireOnPlayEvent(void);
215     void fireOnPauseEvent(void);
216     void fireOnStopEvent(void);
217
218     // controlling IUnknown interface
219     LPUNKNOWN pUnkOuter;
220
221 protected:
222
223     virtual ~VLCPlugin();
224
225 private:
226
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;
243
244     // in place activated window (Plugin window)
245     HWND _inplacewnd;
246
247     VLCPluginClass* _p_class;
248     ULONG _i_ref;
249
250     libvlc_instance_t* _p_libvlc;
251     UINT _i_codepage;
252     BOOL _b_usermode;
253     RECT _posRect;
254
255     // persistable properties
256     BSTR _bstr_baseurl;
257     BSTR _bstr_mrl;
258     BOOL _b_autoplay;
259     BOOL _b_autoloop;
260     BOOL _b_visible;
261     BOOL _b_mute;
262     int  _i_volume;
263     int  _i_time;
264     SIZEL _extent;
265     LPPICTURE _p_pict;
266     // indicates whether properties needs persisting
267     BOOL _b_dirty;
268 };
269
270 #endif