1 /*****************************************************************************
2 * plugin.h: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005-2010 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7 * Jean-Paul Saman <jpsaman@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
32 extern "C" const GUID CLSID_VLCPlugin
;
33 extern "C" const GUID CLSID_VLCPlugin2
;
34 extern "C" const GUID LIBID_AXVLC
;
35 extern "C" const GUID DIID_DVLCEvents
;
37 class VLCPluginClass
: public IClassFactory
42 VLCPluginClass(LONG
*p_class_ref
, HINSTANCE hInstance
, REFCLSID rclsid
);
44 /* IUnknown methods */
45 STDMETHODIMP
QueryInterface(REFIID riid
, void **ppv
);
46 STDMETHODIMP_(ULONG
) AddRef(void);
47 STDMETHODIMP_(ULONG
) Release(void);
49 /* IClassFactory methods */
50 STDMETHODIMP
CreateInstance(LPUNKNOWN pUnkOuter
, REFIID riid
, void **ppv
);
51 STDMETHODIMP
LockServer(BOOL fLock
);
53 REFCLSID
getClassID(void) { return (REFCLSID
)_classid
; };
55 LPCTSTR
getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
56 HINSTANCE
getHInstance(void) const { return _hinstance
; };
57 LPPICTURE
getInPlacePict(void) const
58 { if( NULL
!= _inplace_picture
) _inplace_picture
->AddRef(); return _inplace_picture
; };
62 virtual ~VLCPluginClass();
69 ATOM _inplace_wndclass_atom
;
70 LPPICTURE _inplace_picture
;
73 class VLCPlugin
: public IUnknown
78 VLCPlugin(VLCPluginClass
*p_class
, LPUNKNOWN pUnkOuter
);
80 /* IUnknown methods */
81 STDMETHODIMP
QueryInterface(REFIID riid
, void **ppv
);
82 STDMETHODIMP_(ULONG
) AddRef(void);
83 STDMETHODIMP_(ULONG
) Release(void);
86 HRESULT
getTypeLib(LCID lcid
, ITypeLib
**pTL
) { return LoadRegTypeLib(LIBID_AXVLC
, 1, 0, lcid
, pTL
); };
87 REFCLSID
getClassID(void) { return _p_class
->getClassID(); };
88 REFIID
getDispEventID(void) { return (REFIID
)DIID_DVLCEvents
; };
91 ** persistant properties
95 SysFreeString(_bstr_mrl
);
96 _bstr_mrl
= SysAllocStringLen(mrl
, SysStringLen(mrl
));
99 const BSTR
getMRL(void) { return _bstr_mrl
; };
101 inline void setAutoPlay(BOOL autoplay
)
103 _b_autoplay
= autoplay
;
106 inline BOOL
getAutoPlay(void) { return _b_autoplay
; };
108 inline void setAutoLoop(BOOL autoloop
)
110 _b_autoloop
= autoloop
;
113 inline BOOL
getAutoLoop(void) { return _b_autoloop
;};
115 inline void setShowToolbar(BOOL showtoolbar
)
117 _b_toolbar
= showtoolbar
;
120 inline BOOL
getShowToolbar(void) { return _b_toolbar
;};
122 void setVolume(int volume
);
123 int getVolume(void) { return _i_volume
; };
125 void setBackColor(OLE_COLOR backcolor
);
126 OLE_COLOR
getBackColor(void) { return _i_backcolor
; };
128 void setVisible(BOOL fVisible
);
129 BOOL
getVisible(void) { return _b_visible
; };
130 BOOL
isVisible(void) { return _b_visible
|| (! _b_usermode
); };
132 inline void setStartTime(int time
)
137 inline int getStartTime(void) { return _i_time
; };
139 void setTime(int time
);
140 int getTime(void) { return _i_time
; };
142 void setBaseURL(BSTR url
)
144 SysFreeString(_bstr_baseurl
);
145 _bstr_baseurl
= SysAllocStringLen(url
, SysStringLen(url
));
148 const BSTR
getBaseURL(void) { return _bstr_baseurl
; };
150 // control size in HIMETRIC
151 inline void setExtent(const SIZEL
& extent
)
156 const SIZEL
& getExtent(void) { return _extent
; };
158 // transient properties
159 inline void setMute(BOOL mute
) { _b_mute
= mute
; };
161 inline void setPicture(LPPICTURE pict
)
163 if( NULL
!= _p_pict
)
170 inline LPPICTURE
getPicture(void)
172 if( NULL
!= _p_pict
)
178 void setFocus(BOOL fFocus
);
180 inline UINT
getCodePage(void) { return _i_codepage
; };
181 inline void setCodePage(UINT cp
)
183 // accept new codepage only if it works on this system
184 size_t mblen
= WideCharToMultiByte(cp
,
185 0, L
"test", -1, NULL
, 0, NULL
, NULL
);
190 inline BOOL
isUserMode(void) { return _b_usermode
; };
191 inline void setUserMode(BOOL um
) { _b_usermode
= um
; };
193 inline BOOL
isDirty(void) { return _b_dirty
; };
194 inline void setDirty(BOOL dirty
) { _b_dirty
= dirty
; };
196 inline BOOL
isRunning(void) { return NULL
!= _p_libvlc
; };
198 HRESULT
getVLC(libvlc_instance_t
** pp_libvlc
)
202 *pp_libvlc
= _p_libvlc
;
203 return _p_libvlc
? S_OK
: E_FAIL
;
205 HRESULT
getMD(libvlc_media_player_t
**pp_md
)
208 return _p_mplayer
? S_OK
: E_FAIL
;
211 void setErrorInfo(REFIID riid
, const char *description
);
213 // control geometry within container
214 RECT
getPosRect(void) { return _posRect
; };
215 inline HWND
getInPlaceWindow(void) const { return _inplacewnd
; };
216 BOOL
isInPlaceActive(void);
221 HRESULT
onInit(void);
222 HRESULT
onLoad(void);
223 HRESULT
onActivateInPlace(LPMSG lpMesg
, HWND hwndParent
, LPCRECT lprcPosRect
, LPCRECT lprcClipRect
);
224 HRESULT
onInPlaceDeactivate(void);
225 HRESULT
onAmbientChanged(LPUNKNOWN pContainer
, DISPID dispID
);
226 HRESULT
onClose(DWORD dwSaveOption
);
227 void onPositionChange(LPCRECT lprcPosRect
, LPCRECT lprcClipRect
);
228 void onDraw(DVTARGETDEVICE
* ptd
, HDC hicTargetDev
,
229 HDC hdcDraw
, LPCRECTL lprcBounds
, LPCRECTL lprcWBounds
);
230 void onPaint(HDC hdc
, const RECT
&bounds
, const RECT
&pr
);
235 void freezeEvents(BOOL freeze
);
236 void firePropChangedEvent(DISPID dispid
);
237 void fireOnPlayEvent(void);
238 void fireOnPauseEvent(void);
239 void fireOnStopEvent(void);
242 void fireOnMediaPlayerNothingSpecialEvent();
243 void fireOnMediaPlayerOpeningEvent();
244 void fireOnMediaPlayerBufferingEvent();
245 void fireOnMediaPlayerPlayingEvent();
246 void fireOnMediaPlayerPausedEvent();
247 void fireOnMediaPlayerForwardEvent();
248 void fireOnMediaPlayerBackwardEvent();
249 void fireOnMediaPlayerEncounteredErrorEvent();
250 void fireOnMediaPlayerEndReachedEvent();
251 void fireOnMediaPlayerStoppedEvent();
253 void fireOnMediaPlayerTimeChangedEvent(long time
);
254 void fireOnMediaPlayerPositionChangedEvent(long position
);
255 void fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable
);
256 void fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable
);
258 // controlling IUnknown interface
266 return _p_mplayer
&& libvlc_media_player_is_playing(_p_mplayer
);
268 int playlist_get_current_index() { return _i_midx
; }
269 int playlist_add_extended_untrusted(const char *, int, const char **);
270 void playlist_delete_item(int idx
)
274 libvlc_media_list_lock(_p_mlist
);
275 libvlc_media_list_remove_index(_p_mlist
,idx
);
276 libvlc_media_list_unlock(_p_mlist
);
279 void playlist_clear()
284 libvlc_media_list_release(_p_mlist
);
285 _p_mlist
= libvlc_media_list_new(_p_libvlc
);
292 libvlc_media_list_lock(_p_mlist
);
293 r
= libvlc_media_list_count(_p_mlist
);
294 libvlc_media_list_unlock(_p_mlist
);
297 void playlist_pause()
300 libvlc_media_player_pause(_p_mplayer
);
304 if( _p_mplayer
|| playlist_select(0) )
305 libvlc_media_player_play(_p_mplayer
);
307 void playlist_play_item(int idx
)
309 if( playlist_select(idx
) )
310 libvlc_media_player_play(_p_mplayer
);
315 libvlc_media_player_stop(_p_mplayer
);
319 if( playlist_select( _i_midx
+1 ) )
320 libvlc_media_player_play(_p_mplayer
);
324 if( playlist_select( _i_midx
-1 ) )
325 libvlc_media_player_play(_p_mplayer
);
330 virtual ~VLCPlugin();
334 bool playlist_select(int i
);
335 void set_player_window();
336 void player_register_events();
337 void player_unregister_events();
339 //implemented interfaces
340 class VLCOleObject
*vlcOleObject
;
341 class VLCOleControl
*vlcOleControl
;
342 class VLCOleInPlaceObject
*vlcOleInPlaceObject
;
343 class VLCOleInPlaceActiveObject
*vlcOleInPlaceActiveObject
;
344 class VLCPersistStreamInit
*vlcPersistStreamInit
;
345 class VLCPersistStorage
*vlcPersistStorage
;
346 class VLCPersistPropertyBag
*vlcPersistPropertyBag
;
347 class VLCProvideClassInfo
*vlcProvideClassInfo
;
348 class VLCConnectionPointContainer
*vlcConnectionPointContainer
;
349 class VLCObjectSafety
*vlcObjectSafety
;
350 class VLCControl
*vlcControl
;
351 class VLCControl2
*vlcControl2
;
352 class VLCViewObject
*vlcViewObject
;
353 class VLCDataObject
*vlcDataObject
;
354 class VLCSupportErrorInfo
*vlcSupportErrorInfo
;
356 // in place activated window (Plugin window)
359 VLCPluginClass
* _p_class
;
362 libvlc_instance_t
*_p_libvlc
;
363 libvlc_media_list_t
*_p_mlist
;
364 libvlc_media_player_t
*_p_mplayer
;
372 // persistable properties
383 OLE_COLOR _i_backcolor
;
384 // indicates whether properties needs persisting