]> git.sesse.net Git - vlc/blob - activex/plugin.h
Split libvlc.c:
[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     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; };
59
60 protected:
61
62     virtual ~VLCPluginClass();
63
64 private:
65
66     LPLONG      _p_class_ref;
67     HINSTANCE   _hinstance;
68     CLSID       _classid;
69     ATOM        _inplace_wndclass_atom;
70     ATOM        _video_wndclass_atom;
71     LPPICTURE   _inplace_picture;
72 };
73
74 class VLCPlugin : public IUnknown
75 {
76
77 public:
78
79     VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
80
81     /* IUnknown methods */
82     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
83     STDMETHODIMP_(ULONG) AddRef(void);
84     STDMETHODIMP_(ULONG) Release(void);
85
86     /* custom methods */
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; };
90
91     /*
92     ** persistant properties
93     */
94     void setMRL(BSTR mrl)
95     {
96         SysFreeString(_bstr_mrl);
97         _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
98         setDirty(TRUE);
99     };
100     const BSTR getMRL(void) { return _bstr_mrl; };
101
102     inline void setAutoPlay(BOOL autoplay)
103     {
104         _b_autoplay = autoplay;
105         setDirty(TRUE);
106     };
107     inline BOOL getAutoPlay(void) { return _b_autoplay; };
108
109     inline void setAutoLoop(BOOL autoloop) 
110     {
111         _b_autoloop = autoloop;
112         setDirty(TRUE);
113     };
114     inline BOOL getAutoLoop(void) { return _b_autoloop;};
115
116     void setVolume(int volume);
117     int getVolume(void) { return _i_volume; };
118
119     void setVisible(BOOL fVisible);
120     BOOL getVisible(void) { return _b_visible; };
121     BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
122
123     void setTime(int time);
124     int  getTime(void) { return _i_time; };
125
126     // control size in HIMETRIC
127     inline void setExtent(const SIZEL& extent)
128     {
129         _extent = extent;
130         setDirty(TRUE);
131     };
132     const SIZEL& getExtent(void) { return _extent; };
133
134     // transient properties 
135     inline void setMute(BOOL mute) { _b_mute = mute; };
136
137     inline void setPicture(LPPICTURE pict)
138     {
139         if( NULL != _p_pict )
140             _p_pict->Release();
141         if( NULL != pict )
142             _p_pict->AddRef();
143         _p_pict = pict;
144     };
145
146     inline LPPICTURE getPicture(void)
147     {
148         if( NULL != _p_pict )
149             _p_pict->AddRef();
150         return _p_pict;
151     };
152     
153     BOOL hasFocus(void);
154     void setFocus(BOOL fFocus);
155
156     inline UINT getCodePage(void) { return _i_codepage; };
157     inline void setCodePage(UINT cp)
158     {
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);
162         if( mblen > 0 )
163             _i_codepage = cp;
164     };
165
166     inline BOOL isUserMode(void) { return _b_usermode; };
167     inline void setUserMode(BOOL um) { _b_usermode = um; };
168
169     inline BOOL isDirty(void) { return _b_dirty; };
170     inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
171
172     inline BOOL isRunning(void) { return NULL != _p_libvlc; };
173     HRESULT getVLCObject(int *i_vlc);
174     HRESULT getVLC(libvlc_instance_t** p_vlc);
175
176     // control geometry within container
177     RECT getPosRect(void) { return _posRect; }; 
178     inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
179     BOOL isInPlaceActive(void);
180
181     /*
182     ** container events
183     */
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);
194
195     /*
196     ** control events
197     */
198     void freezeEvents(BOOL freeze);
199     void firePropChangedEvent(DISPID dispid);
200     void fireOnPlayEvent(void);
201     void fireOnPauseEvent(void);
202     void fireOnStopEvent(void);
203
204     // controlling IUnknown interface
205     LPUNKNOWN pUnkOuter;
206
207 protected:
208
209     virtual ~VLCPlugin();
210
211 private:
212
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;
228
229     // in place activated window (Clipping window)
230     HWND _inplacewnd;
231     // video window (Drawing window)
232     HWND _videownd;
233
234     VLCPluginClass* _p_class;
235     ULONG _i_ref;
236
237     libvlc_instance_t* _p_libvlc;
238     UINT _i_codepage;
239     BOOL _b_usermode;
240     RECT _posRect;
241
242     // persistable properties
243     BSTR _bstr_mrl;
244     BOOL _b_autoplay;
245     BOOL _b_autoloop;
246     BOOL _b_visible;
247     BOOL _b_mute;
248     int  _i_volume;
249     int  _i_time;
250     SIZEL _extent;
251     LPPICTURE _p_pict;
252     // indicates whether properties needs persisting
253     BOOL _b_dirty;
254 };
255
256 #endif
257