]> git.sesse.net Git - vlc/blob - activex/plugin.h
all: reworked ActiveX plugin, which now works properly with .NET (tested with Visual...
[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., 59 Temple Place - Suite 330, Boston, MA  02111, 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 = SysAllocString(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 setVisible(BOOL fVisible);
113     BOOL getVisible(void) { return _b_visible; };
114
115     // control size in HIMETRIC
116     inline void setExtent(const SIZEL& extent)
117     {
118         _extent = extent;
119         setDirty(TRUE);
120     };
121     const SIZEL& getExtent(void) { return _extent; };
122
123     // transient properties 
124     inline void setMute(BOOL mute) { _b_mute = mute; };
125
126     inline void setPicture(LPPICTURE pict)
127     {
128         if( NULL != _p_pict )
129             _p_pict->Release();
130         if( NULL != pict )
131             _p_pict->AddRef();
132         _p_pict = pict;
133     };
134
135     inline LPPICTURE getPicture(void)
136     {
137         if( NULL != _p_pict )
138             _p_pict->AddRef();
139         return _p_pict;
140     };
141     
142     BOOL hasFocus(void);
143     void setFocus(BOOL fFocus);
144
145     inline UINT getCodePage(void) { return _i_codepage; };
146     inline void setCodePage(UINT cp) { _i_codepage = cp; };
147
148     inline BOOL isUserMode(void) { return _b_usermode; };
149     inline void setUserMode(BOOL um) { _b_usermode = um; };
150
151     inline BOOL isDirty(void) { return _b_dirty; };
152     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
153
154     inline BOOL isRunning(void) { return 0 != _i_vlc; };
155
156     // control geometry within container
157     RECT getPosRect(void) { return _posRect; }; 
158     inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
159     BOOL isInPlaceActive(void);
160
161     inline int getVLCObject(void) const { return _i_vlc; };
162
163     /*
164     ** container events
165     */
166     HRESULT onInit(void);
167     HRESULT onLoad(void);
168     HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
169     HRESULT onInPlaceDeactivate(void);
170     HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
171     HRESULT onClose(DWORD dwSaveOption);
172     void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
173     void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
174             HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
175     void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
176
177     /*
178     ** control events
179     */
180     void freezeEvents(BOOL freeze);
181     void firePropChangedEvent(DISPID dispid);
182     void fireOnPlayEvent(void);
183     void fireOnPauseEvent(void);
184     void fireOnStopEvent(void);
185
186     // controlling IUnknown interface
187     LPUNKNOWN pUnkOuter;
188
189 protected:
190
191     virtual ~VLCPlugin();
192
193 private:
194
195     //implemented interfaces
196     class VLCOleObject *vlcOleObject;
197     class VLCOleControl *vlcOleControl;
198     class VLCOleInPlaceObject *vlcOleInPlaceObject;
199     class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
200     class VLCPersistStreamInit *vlcPersistStreamInit;
201     class VLCPersistStorage *vlcPersistStorage;
202     class VLCPersistPropertyBag *vlcPersistPropertyBag;
203     class VLCProvideClassInfo *vlcProvideClassInfo;
204     class VLCConnectionPointContainer *vlcConnectionPointContainer;
205     class VLCObjectSafety *vlcObjectSafety;
206     class VLCControl *vlcControl;
207     class VLCViewObject *vlcViewObject;
208     class VLCDataObject *vlcDataObject;
209
210     // in place activated window (Clipping window)
211     HWND _inplacewnd;
212     // video window (Drawing window)
213     HWND _videownd;
214
215     VLCPluginClass *_p_class;
216     ULONG _i_ref;
217
218     LPPICTURE _p_pict;
219     UINT _i_codepage;
220     BOOL _b_usermode;
221     BSTR _bstr_mrl;
222     BOOL _b_autoplay;
223     BOOL _b_autoloop;
224     BOOL _b_visible;
225     BOOL _b_mute;
226     BOOL _b_dirty;
227     int  _i_vlc;
228
229     SIZEL _extent;
230     RECT _posRect;
231 };
232
233 #endif
234