]> git.sesse.net Git - vlc/blob - activex/plugin.h
Port new URL tests to test/
[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/vlc.h>
30
31 extern const GUID CLSID_VLCPlugin; 
32 extern const GUID LIBID_AXVLC; 
33 extern const GUID DIID_DVLCEvents; 
34
35 class VLCPluginClass : public IClassFactory
36 {
37
38 public:
39
40     VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance);
41
42     /* IUnknown methods */
43     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
44     STDMETHODIMP_(ULONG) AddRef(void);
45     STDMETHODIMP_(ULONG) Release(void);
46
47     /* IClassFactory methods */
48     STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
49     STDMETHODIMP LockServer(BOOL fLock);
50
51     LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
52     LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };
53     HINSTANCE getHInstance(void) const { return _hinstance; };
54     LPPICTURE getInPlacePict(void) const
55         { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
56
57 protected:
58
59     virtual ~VLCPluginClass();
60
61 private:
62
63     LPLONG      _p_class_ref;
64     HINSTANCE   _hinstance;
65     ATOM        _inplace_wndclass_atom;
66     ATOM        _video_wndclass_atom;
67     LPPICTURE   _inplace_picture;
68 };
69
70 class VLCPlugin : public IUnknown
71 {
72
73 public:
74
75     VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
76
77     /* IUnknown methods */
78     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
79     STDMETHODIMP_(ULONG) AddRef(void);
80     STDMETHODIMP_(ULONG) Release(void);
81
82     /* custom methods */
83     HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
84     REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
85     REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
86
87     /*
88     ** persistant properties
89     */
90     void setMRL(BSTR mrl)
91     {
92         SysFreeString(_bstr_mrl);
93         _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
94         setDirty(TRUE);
95     };
96     const BSTR getMRL(void) { return _bstr_mrl; };
97
98     inline void setAutoPlay(BOOL autoplay)
99     {
100         _b_autoplay = autoplay;
101         setDirty(TRUE);
102     };
103     inline BOOL getAutoPlay(void) { return _b_autoplay; };
104
105     inline void setAutoLoop(BOOL autoloop) 
106     {
107         _b_autoloop = autoloop;
108         setDirty(TRUE);
109     };
110     inline BOOL getAutoLoop(void) { return _b_autoloop;};
111
112     void setVolume(int volume);
113     int getVolume(void) { return _i_volume; };
114
115     void setVisible(BOOL fVisible);
116     BOOL getVisible(void) { return _b_visible; };
117     BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
118
119     void setTime(int time);
120     int  getTime(void) { return _i_time; };
121
122     // control size in HIMETRIC
123     inline void setExtent(const SIZEL& extent)
124     {
125         _extent = extent;
126         setDirty(TRUE);
127     };
128     const SIZEL& getExtent(void) { return _extent; };
129
130     // transient properties 
131     inline void setMute(BOOL mute) { _b_mute = mute; };
132
133     inline void setPicture(LPPICTURE pict)
134     {
135         if( NULL != _p_pict )
136             _p_pict->Release();
137         if( NULL != pict )
138             _p_pict->AddRef();
139         _p_pict = pict;
140     };
141
142     inline LPPICTURE getPicture(void)
143     {
144         if( NULL != _p_pict )
145             _p_pict->AddRef();
146         return _p_pict;
147     };
148     
149     BOOL hasFocus(void);
150     void setFocus(BOOL fFocus);
151
152     inline UINT getCodePage(void) { return _i_codepage; };
153     inline void setCodePage(UINT cp)
154     {
155         // accept new codepage only if it works on this system
156         size_t mblen = WideCharToMultiByte(cp,
157                 0, L"test", -1, NULL, 0, NULL, NULL);
158         if( mblen > 0 )
159             _i_codepage = cp;
160     };
161
162     inline BOOL isUserMode(void) { return _b_usermode; };
163     inline void setUserMode(BOOL um) { _b_usermode = um; };
164
165     inline BOOL isDirty(void) { return _b_dirty; };
166     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
167
168     inline BOOL isRunning(void) { return 0 != _i_vlc; };
169     HRESULT getVLCObject(int *i_vlc);
170
171
172     // control geometry within container
173     RECT getPosRect(void) { return _posRect; }; 
174     inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
175     BOOL isInPlaceActive(void);
176
177     /*
178     ** container events
179     */
180     HRESULT onInit(void);
181     HRESULT onLoad(void);
182     HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
183     HRESULT onInPlaceDeactivate(void);
184     HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
185     HRESULT onClose(DWORD dwSaveOption);
186     void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
187     void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
188             HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
189     void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
190
191     /*
192     ** control events
193     */
194     void freezeEvents(BOOL freeze);
195     void firePropChangedEvent(DISPID dispid);
196     void fireOnPlayEvent(void);
197     void fireOnPauseEvent(void);
198     void fireOnStopEvent(void);
199
200     // controlling IUnknown interface
201     LPUNKNOWN pUnkOuter;
202
203 protected:
204
205     virtual ~VLCPlugin();
206
207 private:
208
209     //implemented interfaces
210     class VLCOleObject *vlcOleObject;
211     class VLCOleControl *vlcOleControl;
212     class VLCOleInPlaceObject *vlcOleInPlaceObject;
213     class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
214     class VLCPersistStreamInit *vlcPersistStreamInit;
215     class VLCPersistStorage *vlcPersistStorage;
216     class VLCPersistPropertyBag *vlcPersistPropertyBag;
217     class VLCProvideClassInfo *vlcProvideClassInfo;
218     class VLCConnectionPointContainer *vlcConnectionPointContainer;
219     class VLCObjectSafety *vlcObjectSafety;
220     class VLCControl *vlcControl;
221     class VLCViewObject *vlcViewObject;
222     class VLCDataObject *vlcDataObject;
223
224     // in place activated window (Clipping window)
225     HWND _inplacewnd;
226     // video window (Drawing window)
227     HWND _videownd;
228
229     VLCPluginClass *_p_class;
230     ULONG _i_ref;
231
232     UINT _i_codepage;
233     BOOL _b_usermode;
234     int  _i_vlc;
235     RECT _posRect;
236
237     // persistable properties
238     BSTR _bstr_mrl;
239     BOOL _b_autoplay;
240     BOOL _b_autoloop;
241     BOOL _b_visible;
242     BOOL _b_mute;
243     int  _i_volume;
244     int  _i_time;
245     SIZEL _extent;
246     LPPICTURE _p_pict;
247     // indicates whether properties needs persisting
248     BOOL _b_dirty;
249 };
250
251 #endif
252