1 /*****************************************************************************
2 * plugin.h: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
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.
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.
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 *****************************************************************************/
31 extern "C" const GUID CLSID_VLCPlugin;
32 extern "C" const GUID CLSID_VLCPlugin2;
33 extern "C" const GUID LIBID_AXVLC;
34 extern "C" const GUID DIID_DVLCEvents;
36 class VLCPluginClass : public IClassFactory
41 VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid);
43 /* IUnknown methods */
44 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
45 STDMETHODIMP_(ULONG) AddRef(void);
46 STDMETHODIMP_(ULONG) Release(void);
48 /* IClassFactory methods */
49 STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
50 STDMETHODIMP LockServer(BOOL fLock);
52 REFCLSID getClassID(void) { return (REFCLSID)_classid; };
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; };
61 virtual ~VLCPluginClass();
68 ATOM _inplace_wndclass_atom;
69 LPPICTURE _inplace_picture;
72 class VLCPlugin : public IUnknown
77 VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
79 /* IUnknown methods */
80 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
81 STDMETHODIMP_(ULONG) AddRef(void);
82 STDMETHODIMP_(ULONG) Release(void);
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; };
90 ** persistant properties
94 SysFreeString(_bstr_mrl);
95 _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
98 const BSTR getMRL(void) { return _bstr_mrl; };
100 inline void setAutoPlay(BOOL autoplay)
102 _b_autoplay = autoplay;
105 inline BOOL getAutoPlay(void) { return _b_autoplay; };
107 inline void setAutoLoop(BOOL autoloop)
109 _b_autoloop = autoloop;
112 inline BOOL getAutoLoop(void) { return _b_autoloop;};
114 inline void setShowToolbar(BOOL showtoolbar)
116 _b_toolbar = showtoolbar;
119 inline BOOL getShowToolbar(void) { return _b_toolbar;};
121 void setVolume(int volume);
122 int getVolume(void) { return _i_volume; };
124 void setBackColor(OLE_COLOR backcolor);
125 OLE_COLOR getBackColor(void) { return _i_backcolor; };
127 void setVisible(BOOL fVisible);
128 BOOL getVisible(void) { return _b_visible; };
129 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
131 inline void setStartTime(int time)
136 inline int getStartTime(void) { return _i_time; };
138 void setTime(int time);
139 int getTime(void) { return _i_time; };
141 void setBaseURL(BSTR url)
143 SysFreeString(_bstr_baseurl);
144 _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
147 const BSTR getBaseURL(void) { return _bstr_baseurl; };
149 // control size in HIMETRIC
150 inline void setExtent(const SIZEL& extent)
155 const SIZEL& getExtent(void) { return _extent; };
157 // transient properties
158 inline void setMute(BOOL mute) { _b_mute = mute; };
160 inline void setPicture(LPPICTURE pict)
162 if( NULL != _p_pict )
169 inline LPPICTURE getPicture(void)
171 if( NULL != _p_pict )
177 void setFocus(BOOL fFocus);
179 inline UINT getCodePage(void) { return _i_codepage; };
180 inline void setCodePage(UINT cp)
182 // accept new codepage only if it works on this system
183 size_t mblen = WideCharToMultiByte(cp,
184 0, L"test", -1, NULL, 0, NULL, NULL);
189 inline BOOL isUserMode(void) { return _b_usermode; };
190 inline void setUserMode(BOOL um) { _b_usermode = um; };
192 inline BOOL isDirty(void) { return _b_dirty; };
193 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
195 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
197 HRESULT getVLC(libvlc_instance_t** pp_libvlc)
201 *pp_libvlc = _p_libvlc;
202 return _p_libvlc?S_OK:E_FAIL;
204 HRESULT getMD(libvlc_media_player_t **pp_md)
207 return _p_mplayer?S_OK:E_FAIL;
210 void setErrorInfo(REFIID riid, const char *description);
212 // control geometry within container
213 RECT getPosRect(void) { return _posRect; };
214 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
215 BOOL isInPlaceActive(void);
220 HRESULT onInit(void);
221 HRESULT onLoad(void);
222 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
223 HRESULT onInPlaceDeactivate(void);
224 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
225 HRESULT onClose(DWORD dwSaveOption);
226 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
227 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
228 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
229 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
234 void freezeEvents(BOOL freeze);
235 void firePropChangedEvent(DISPID dispid);
236 void fireOnPlayEvent(void);
237 void fireOnPauseEvent(void);
238 void fireOnStopEvent(void);
240 // controlling IUnknown interface
246 bool isPlaying(libvlc_exception_t *ex)
248 return _p_mplayer && libvlc_media_player_is_playing(_p_mplayer);
250 int playlist_get_current_index(libvlc_exception_t *) { return _i_midx; }
251 int playlist_add_extended_untrusted(const char *, int, const char **, libvlc_exception_t *);
252 void playlist_delete_item(int idx, libvlc_exception_t *ex)
255 libvlc_media_list_remove_index(_p_mlist,idx,ex);
257 void playlist_clear(libvlc_exception_t *ex)
262 libvlc_media_list_release(_p_mlist);
263 _p_mlist = libvlc_media_list_new(_p_libvlc);
265 int playlist_count(libvlc_exception_t *ex)
270 libvlc_media_list_lock(_p_mlist);
271 r = libvlc_media_list_count(_p_mlist);
272 libvlc_media_list_unlock(_p_mlist);
275 void playlist_pause(libvlc_exception_t *ex)
278 libvlc_media_player_pause(_p_mplayer,ex);
280 void playlist_play(libvlc_exception_t *ex)
284 if( _p_mplayer||playlist_select(0,ex) )
285 libvlc_media_player_play(_p_mplayer,ex);
287 void playlist_play_item(int idx,libvlc_exception_t *ex)
291 if( playlist_select(idx,ex) )
292 libvlc_media_player_play(_p_mplayer,ex);
294 void playlist_stop(libvlc_exception_t *ex)
297 libvlc_media_player_stop(_p_mplayer);
299 void playlist_next(libvlc_exception_t *ex)
301 if( playlist_select( _i_midx+1, ex) )
302 libvlc_media_player_play(_p_mplayer,ex);
304 void playlist_prev(libvlc_exception_t *ex)
306 if( playlist_select( _i_midx-1, ex) )
307 libvlc_media_player_play(_p_mplayer,ex);
312 virtual ~VLCPlugin();
316 bool playlist_select(int i,libvlc_exception_t *);
317 void set_player_window(libvlc_exception_t *);
319 //implemented interfaces
320 class VLCOleObject *vlcOleObject;
321 class VLCOleControl *vlcOleControl;
322 class VLCOleInPlaceObject *vlcOleInPlaceObject;
323 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
324 class VLCPersistStreamInit *vlcPersistStreamInit;
325 class VLCPersistStorage *vlcPersistStorage;
326 class VLCPersistPropertyBag *vlcPersistPropertyBag;
327 class VLCProvideClassInfo *vlcProvideClassInfo;
328 class VLCConnectionPointContainer *vlcConnectionPointContainer;
329 class VLCObjectSafety *vlcObjectSafety;
330 class VLCControl *vlcControl;
331 class VLCControl2 *vlcControl2;
332 class VLCViewObject *vlcViewObject;
333 class VLCDataObject *vlcDataObject;
334 class VLCSupportErrorInfo *vlcSupportErrorInfo;
336 // in place activated window (Plugin window)
339 VLCPluginClass* _p_class;
342 libvlc_instance_t *_p_libvlc;
343 libvlc_media_list_t *_p_mlist;
344 libvlc_media_player_t *_p_mplayer;
352 // persistable properties
363 OLE_COLOR _i_backcolor;
364 // indicates whether properties needs persisting