]> git.sesse.net Git - vlc/blob - activex/plugin.h
dc8220c26f99f3352d0dc3493590928864a59055
[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(IUnknown *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     HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; };
55
56 protected:
57
58     virtual ~VLCPluginClass();
59
60 private:
61
62     LPLONG      _p_class_ref;
63     HINSTANCE   _hinstance;
64     ATOM        _inplace_wndclass_atom;
65     ATOM        _video_wndclass_atom;
66     HBITMAP     _inplace_hbitmap;
67 };
68
69 class VLCPlugin : public IUnknown
70 {
71
72 public:
73
74     VLCPlugin(VLCPluginClass *p_class);
75
76     /* IUnknown methods */
77     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
78     STDMETHODIMP_(ULONG) AddRef(void);
79     STDMETHODIMP_(ULONG) Release(void);
80
81     /* custom methods */
82     HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)
83         { 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     HRESULT onInit(void);
88     HRESULT onLoad(void);
89     HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
90     HRESULT onClose(DWORD dwSaveOption);
91
92     BOOL isInPlaceActive(void);
93     HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
94     HRESULT onInPlaceDeactivate(void);
95     HWND getInPlaceWindow(void) const { return _inplacewnd; };
96
97     BOOL hasFocus(void);
98     void setFocus(BOOL fFocus);
99
100     UINT getCodePage(void) { return _codepage; };
101     void setCodePage(UINT cp) { _codepage = cp; };
102
103     int  getVLCObject(void) { return _i_vlc; };
104
105     // persistent control properties, may be overriden by HTML & javascript
106     void setSourceURL(const char *url) { _psz_src = strdup(url); };
107     void setAutoStart(BOOL autostart) { _b_autostart = autostart; };
108     void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
109     void setMute(BOOL mute) { _b_mute = mute; };
110     void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };
111     void setVisible(BOOL fVisible);
112     BOOL getVisible(void) { return _b_visible; };
113     
114     // container events
115     void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
116     void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
117
118     // control events
119     void firePropChangedEvent(DISPID dispid);
120     void fireOnPlayEvent(void);
121     void fireOnPauseEvent(void);
122     void fireOnStopEvent(void);
123
124     // control size in HIMETRIC
125     const SIZEL& getExtent(void) { return _extent; };
126     void  setExtent(const SIZEL& extent) { _extent = extent; };
127
128     // control geometry within container
129     RECT getPosRect(void) { return _posRect; }; 
130
131 protected:
132
133     virtual ~VLCPlugin();
134
135 private:
136
137     //implemented interfaces
138     class VLCOleObject *vlcOleObject;
139     class VLCOleControl *vlcOleControl;
140     class VLCOleInPlaceObject *vlcOleInPlaceObject;
141     class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
142     class VLCPersistStreamInit *vlcPersistStreamInit;
143     class VLCPersistStorage *vlcPersistStorage;
144     class VLCPersistPropertyBag *vlcPersistPropertyBag;
145     class VLCProvideClassInfo *vlcProvideClassInfo;
146     class VLCConnectionPointContainer *vlcConnectionPointContainer;
147     class VLCObjectSafety *vlcObjectSafety;
148     class VLCControl *vlcControl;
149     class VLCViewObject *vlcViewObject;
150
151     // in place activated window (Clipping window)
152     HWND _inplacewnd;
153     // video window (Drawing window)
154     HWND _videownd;
155
156     VLCPluginClass *_p_class;
157     ULONG _i_ref;
158
159     UINT _codepage;
160     char *_psz_src;
161     BOOL _b_autostart;
162     BOOL _b_loopmode;
163     BOOL _b_visible;
164     BOOL _b_mute;
165     BOOL _b_sendevents;
166     int  _i_vlc;
167
168     SIZEL _extent;
169     RECT _posRect;
170 };
171
172 #endif
173