From 3d831e04ece115bb9ca379b9552370755453e46e Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Wed, 2 Mar 2005 16:47:31 +0000 Subject: [PATCH] Avoid \r\n problems between platforms --- activex/axvlc_idl.c | 106 +- activex/axvlc_idl.h | 1852 +++++----- activex/connectioncontainer.cpp | 574 +-- activex/connectioncontainer.h | 232 +- activex/main.cpp | 806 ++--- activex/objectsafety.cpp | 184 +- activex/objectsafety.h | 198 +- activex/olecontrol.cpp | 266 +- activex/olecontrol.h | 130 +- activex/oleinplaceactiveobject.cpp | 148 +- activex/oleinplaceactiveobject.h | 142 +- activex/oleinplaceobject.cpp | 252 +- activex/oleinplaceobject.h | 136 +- activex/oleobject.cpp | 678 ++-- activex/oleobject.h | 172 +- activex/persistpropbag.cpp | 250 +- activex/persistpropbag.h | 134 +- activex/persiststorage.cpp | 158 +- activex/persiststorage.h | 140 +- activex/persiststreaminit.cpp | 140 +- activex/persiststreaminit.h | 138 +- activex/plugin.cpp | 1548 ++++---- activex/plugin.h | 334 +- activex/provideclassinfo.cpp | 120 +- activex/provideclassinfo.h | 130 +- activex/utils.cpp | 202 +- activex/utils.h | 362 +- activex/vlccontrol.cpp | 1324 +++---- activex/vlccontrol.h | 200 +- include/beos_specific.h | 2 +- include/charset.h | 2 +- include/intf_eject.h | 2 +- include/iso_lang.h | 2 +- include/os_specific.h | 2 +- include/vlc/aout.h | 2 +- include/vlc/sout.h | 2 +- include/vlc_bits.h | 2 +- include/vlc_cpu.h | 2 +- include/vlc_error.h | 2 +- include/vlc_messages.h | 2 +- include/win32_specific.h | 2 +- modules/access/screen/beos.cpp | 2 +- modules/access/v4l/videodev_mjpeg.h | 2 +- modules/access/vcd/cdrom.c | 2 +- modules/access/vcd/cdrom.h | 2 +- modules/access/vcd/cdrom_internals.h | 2 +- modules/audio_filter/equalizer_presets.h | 2 +- modules/audio_filter/resampler/bandlimited.h | 2 +- modules/codec/ffmpeg/video.c | 1762 +++++----- modules/demux/avi/libavi.c | 2 +- modules/gui/beos/AudioOutput.cpp | 2 +- modules/gui/beos/Bitmaps.h | 2 +- modules/gui/beos/DrawingTidbits.cpp | 2 +- modules/gui/beos/DrawingTidbits.h | 2 +- modules/gui/beos/PreferencesWindow.cpp | 2 +- modules/gui/beos/PreferencesWindow.h | 2 +- modules/gui/beos/TransportButton.cpp | 2 +- modules/gui/beos/TransportButton.h | 2 +- modules/gui/gtk/common.h | 2 +- modules/gui/gtk/control.h | 2 +- modules/gui/gtk/display.h | 2 +- modules/gui/gtk/gtk_callbacks.h | 2 +- modules/gui/gtk/menu.h | 2 +- modules/gui/gtk/modules.c | 2 +- modules/gui/gtk/modules.h | 2 +- modules/gui/gtk/open.h | 2 +- modules/gui/gtk/playlist.h | 2 +- modules/gui/gtk/preferences.c | 2 +- modules/gui/gtk/preferences.h | 2 +- modules/gui/gtk/sout.c | 2 +- modules/gui/kde/QConfigItem.cpp | 2 +- modules/gui/kde/QConfigItem.h | 2 +- modules/gui/kde/info.h | 2 +- modules/gui/kde/languagemenu.cpp | 2 +- modules/gui/kde/languagemenu.h | 2 +- modules/gui/kde/messages.cpp | 2 +- modules/gui/kde/messages.h | 2 +- modules/gui/kde/pluginsbox.cpp | 2 +- modules/gui/kde/pluginsbox.h | 2 +- modules/gui/kde/preferences.cpp | 2 +- modules/gui/kde/preferences.h | 2 +- modules/gui/pda/pda.h | 2 +- modules/gui/pda/pda_callbacks.h | 2 +- modules/gui/qt/intf.h | 2 +- modules/gui/wxwindows/wizard.cpp | 3322 +++++++++--------- modules/misc/dummy/aout.c | 2 +- modules/misc/dummy/dummy.h | 2 +- modules/misc/dummy/encoder.c | 2 +- modules/misc/dummy/interface.c | 2 +- modules/misc/gtk_main.c | 2 +- modules/misc/memcpy/fastmemcpy.h | 2 +- modules/misc/testsuite/test1.c | 2 +- modules/misc/testsuite/test2.cpp | 2 +- modules/misc/testsuite/test4.c | 2 +- modules/mux/mpeg/bits.h | 2 +- modules/mux/mpeg/csa.h | 2 +- modules/stream_out/transrate/block.c | 2 +- modules/video_chroma/i420_rgb_c.h | 2 +- modules/video_filter/marq.c | 658 ++-- modules/video_output/directx/glwin32.c | 946 ++--- modules/video_output/qte/qte.h | 2 +- modules/video_output/svgalib.c | 2 +- share/newres.h | 78 +- share/resource.h | 62 +- src/input/es_out.c | 2812 +++++++-------- 105 files changed, 10417 insertions(+), 10417 deletions(-) diff --git a/activex/axvlc_idl.c b/activex/axvlc_idl.c index ae90e8b779..b339abbac5 100644 --- a/activex/axvlc_idl.c +++ b/activex/axvlc_idl.c @@ -1,53 +1,53 @@ -/* this file contains the actual definitions of */ -/* the IIDs and CLSIDs */ - -/* link this file in with the server and any clients */ - - -/* File created by MIDL compiler version 5.01.0164 */ -/* at Thu Feb 17 09:25:54 2005 - */ -/* Compiler settings for axvlc.idl: - Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data -*/ -//@@MIDL_FILE_HEADING( ) -#ifdef __cplusplus -extern "C"{ -#endif - - -#ifndef __IID_DEFINED__ -#define __IID_DEFINED__ - -typedef struct _IID -{ - unsigned long x; - unsigned short s1; - unsigned short s2; - unsigned char c[8]; -} IID; - -#endif // __IID_DEFINED__ - -#ifndef CLSID_DEFINED -#define CLSID_DEFINED -typedef IID CLSID; -#endif // CLSID_DEFINED - -const IID LIBID_AXVLC = {0xDF2BBE39,0x40A8,0x433b,{0xA2,0x79,0x07,0x3F,0x48,0xDA,0x94,0xB6}}; - - -const IID IID_IVLCControl = {0xC2FA41D0,0xB113,0x476e,{0xAC,0x8C,0x9B,0xD1,0x49,0x99,0xC1,0xC1}}; - - -const IID DIID_DVLCEvents = {0xDF48072F,0x5EF8,0x434e,{0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F}}; - - -const CLSID CLSID_VLCPlugin = {0xE23FE9C6,0x778E,0x49D4,{0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8}}; - - -#ifdef __cplusplus -} -#endif - +/* this file contains the actual definitions of */ +/* the IIDs and CLSIDs */ + +/* link this file in with the server and any clients */ + + +/* File created by MIDL compiler version 5.01.0164 */ +/* at Thu Feb 17 09:25:54 2005 + */ +/* Compiler settings for axvlc.idl: + Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data +*/ +//@@MIDL_FILE_HEADING( ) +#ifdef __cplusplus +extern "C"{ +#endif + + +#ifndef __IID_DEFINED__ +#define __IID_DEFINED__ + +typedef struct _IID +{ + unsigned long x; + unsigned short s1; + unsigned short s2; + unsigned char c[8]; +} IID; + +#endif // __IID_DEFINED__ + +#ifndef CLSID_DEFINED +#define CLSID_DEFINED +typedef IID CLSID; +#endif // CLSID_DEFINED + +const IID LIBID_AXVLC = {0xDF2BBE39,0x40A8,0x433b,{0xA2,0x79,0x07,0x3F,0x48,0xDA,0x94,0xB6}}; + + +const IID IID_IVLCControl = {0xC2FA41D0,0xB113,0x476e,{0xAC,0x8C,0x9B,0xD1,0x49,0x99,0xC1,0xC1}}; + + +const IID DIID_DVLCEvents = {0xDF48072F,0x5EF8,0x434e,{0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F}}; + + +const CLSID CLSID_VLCPlugin = {0xE23FE9C6,0x778E,0x49D4,{0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8}}; + + +#ifdef __cplusplus +} +#endif + diff --git a/activex/axvlc_idl.h b/activex/axvlc_idl.h index 545e0bdb28..719c264890 100644 --- a/activex/axvlc_idl.h +++ b/activex/axvlc_idl.h @@ -1,926 +1,926 @@ -/* this ALWAYS GENERATED file contains the definitions for the interfaces */ - - -/* File created by MIDL compiler version 5.01.0164 */ -/* at Thu Feb 17 09:25:54 2005 - */ -/* Compiler settings for axvlc.idl: - Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext - error checks: allocation ref bounds_check enum stub_data -*/ -//@@MIDL_FILE_HEADING( ) - - -/* verify that the version is high enough to compile this file*/ -#ifndef __REQUIRED_RPCNDR_H_VERSION__ -#define __REQUIRED_RPCNDR_H_VERSION__ 440 -#endif - -#include "rpc.h" -#include "rpcndr.h" - -#ifndef __axvlc_idl_h__ -#define __axvlc_idl_h__ - -#ifdef __cplusplus -extern "C"{ -#endif - -/* Forward Declarations */ - -#ifndef __IVLCControl_FWD_DEFINED__ -#define __IVLCControl_FWD_DEFINED__ -typedef interface IVLCControl IVLCControl; -#endif /* __IVLCControl_FWD_DEFINED__ */ - - -#ifndef __DVLCEvents_FWD_DEFINED__ -#define __DVLCEvents_FWD_DEFINED__ -typedef interface DVLCEvents DVLCEvents; -#endif /* __DVLCEvents_FWD_DEFINED__ */ - - -#ifndef __VLCPlugin_FWD_DEFINED__ -#define __VLCPlugin_FWD_DEFINED__ - -#ifdef __cplusplus -typedef class VLCPlugin VLCPlugin; -#else -typedef struct VLCPlugin VLCPlugin; -#endif /* __cplusplus */ - -#endif /* __VLCPlugin_FWD_DEFINED__ */ - - -void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); -void __RPC_USER MIDL_user_free( void __RPC_FAR * ); - - -#ifndef __AXVLC_LIBRARY_DEFINED__ -#define __AXVLC_LIBRARY_DEFINED__ - -/* library AXVLC */ -/* [helpstring][version][uuid] */ - - - - -enum VLCPlaylistMode - { VLCPlayListInsert = 1, - VLCPlayListReplace = 2, - VLCPlayListAppend = 4, - VLCPlayListGo = 8, - VLCPlayListCheckInsert = 16 - }; -#define VLCPlayListEnd ( -666 ) - -#define DISPID_Visible ( 1 ) - -#define DISPID_Playing ( 2 ) - -#define DISPID_Position ( 3 ) - -#define DISPID_Time ( 4 ) - -#define DISPID_Length ( 5 ) - -#define DISPID_Volume ( 6 ) - -#define DISPID_PlayEvent ( 1 ) - -#define DISPID_PauseEvent ( 2 ) - -#define DISPID_StopEvent ( 3 ) - - -EXTERN_C const IID LIBID_AXVLC; - -#ifndef __IVLCControl_INTERFACE_DEFINED__ -#define __IVLCControl_INTERFACE_DEFINED__ - -/* interface IVLCControl */ -/* [object][oleautomation][hidden][dual][helpstring][uuid] */ - - -EXTERN_C const IID IID_IVLCControl; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("C2FA41D0-B113-476e-AC8C-9BD14999C1C1") - IVLCControl : public IDispatch - { - public: - virtual /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Value( - /* [retval][out] */ VARIANT __RPC_FAR *pvarValue) = 0; - - virtual /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Value( - /* [in] */ VARIANT pvarValue) = 0; - - virtual /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE get_Visible( - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0; - - virtual /* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE put_Visible( - /* [in] */ VARIANT_BOOL visible) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE play( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE pause( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE stop( void) = 0; - - virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Playing( - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying) = 0; - - virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Playing( - /* [in] */ VARIANT_BOOL isPlaying) = 0; - - virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Position( - /* [retval][out] */ float __RPC_FAR *position) = 0; - - virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position( - /* [in] */ float position) = 0; - - virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Time( - /* [retval][out] */ int __RPC_FAR *seconds) = 0; - - virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Time( - /* [in] */ int seconds) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle( - /* [in] */ int seconds) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE fullscreen( void) = 0; - - virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Length( - /* [retval][out] */ int __RPC_FAR *seconds) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playFaster( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playSlower( void) = 0; - - virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Volume( - /* [retval][out] */ int __RPC_FAR *volume) = 0; - - virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Volume( - /* [in] */ int volume) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE addTarget( - /* [in] */ BSTR uri, - /* [in] */ VARIANT options, - /* [in] */ enum VLCPlaylistMode mode, - /* [in] */ int position) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistIndex( - /* [retval][out] */ int __RPC_FAR *index) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistCount( - /* [retval][out] */ int __RPC_FAR *index) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistNext( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistPrev( void) = 0; - - virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistClear( void) = 0; - - virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_VersionInfo( - /* [retval][out] */ BSTR __RPC_FAR *version) = 0; - - }; - -#else /* C style interface */ - - typedef struct IVLCControlVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - IVLCControl __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - IVLCControl __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - IVLCControl __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( - IVLCControl __RPC_FAR * This, - /* [out] */ UINT __RPC_FAR *pctinfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( - IVLCControl __RPC_FAR * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( - IVLCControl __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( - IVLCControl __RPC_FAR * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, - /* [out] */ VARIANT __RPC_FAR *pVarResult, - /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, - /* [out] */ UINT __RPC_FAR *puArgErr); - - /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT __RPC_FAR *pvarValue); - - /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT pvarValue); - - /* [helpstring][bindable][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Visible )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); - - /* [helpstring][bindable][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Visible )( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT_BOOL visible); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *play )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *pause )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *stop )( - IVLCControl __RPC_FAR * This); - - /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Playing )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying); - - /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Playing )( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT_BOOL isPlaying); - - /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Position )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ float __RPC_FAR *position); - - /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Position )( - IVLCControl __RPC_FAR * This, - /* [in] */ float position); - - /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Time )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *seconds); - - /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Time )( - IVLCControl __RPC_FAR * This, - /* [in] */ int seconds); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *shuttle )( - IVLCControl __RPC_FAR * This, - /* [in] */ int seconds); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *fullscreen )( - IVLCControl __RPC_FAR * This); - - /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Length )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *seconds); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playFaster )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playSlower )( - IVLCControl __RPC_FAR * This); - - /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Volume )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *volume); - - /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Volume )( - IVLCControl __RPC_FAR * This, - /* [in] */ int volume); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *addTarget )( - IVLCControl __RPC_FAR * This, - /* [in] */ BSTR uri, - /* [in] */ VARIANT options, - /* [in] */ enum VLCPlaylistMode mode, - /* [in] */ int position); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistIndex )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *index); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistCount )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *index); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistNext )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistPrev )( - IVLCControl __RPC_FAR * This); - - /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistClear )( - IVLCControl __RPC_FAR * This); - - /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_VersionInfo )( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ BSTR __RPC_FAR *version); - - END_INTERFACE - } IVLCControlVtbl; - - interface IVLCControl - { - CONST_VTBL struct IVLCControlVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define IVLCControl_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define IVLCControl_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define IVLCControl_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define IVLCControl_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define IVLCControl_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define IVLCControl_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define IVLCControl_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - - -#define IVLCControl_get_Value(This,pvarValue) \ - (This)->lpVtbl -> get_Value(This,pvarValue) - -#define IVLCControl_put_Value(This,pvarValue) \ - (This)->lpVtbl -> put_Value(This,pvarValue) - -#define IVLCControl_get_Visible(This,visible) \ - (This)->lpVtbl -> get_Visible(This,visible) - -#define IVLCControl_put_Visible(This,visible) \ - (This)->lpVtbl -> put_Visible(This,visible) - -#define IVLCControl_play(This) \ - (This)->lpVtbl -> play(This) - -#define IVLCControl_pause(This) \ - (This)->lpVtbl -> pause(This) - -#define IVLCControl_stop(This) \ - (This)->lpVtbl -> stop(This) - -#define IVLCControl_get_Playing(This,isPlaying) \ - (This)->lpVtbl -> get_Playing(This,isPlaying) - -#define IVLCControl_put_Playing(This,isPlaying) \ - (This)->lpVtbl -> put_Playing(This,isPlaying) - -#define IVLCControl_get_Position(This,position) \ - (This)->lpVtbl -> get_Position(This,position) - -#define IVLCControl_put_Position(This,position) \ - (This)->lpVtbl -> put_Position(This,position) - -#define IVLCControl_get_Time(This,seconds) \ - (This)->lpVtbl -> get_Time(This,seconds) - -#define IVLCControl_put_Time(This,seconds) \ - (This)->lpVtbl -> put_Time(This,seconds) - -#define IVLCControl_shuttle(This,seconds) \ - (This)->lpVtbl -> shuttle(This,seconds) - -#define IVLCControl_fullscreen(This) \ - (This)->lpVtbl -> fullscreen(This) - -#define IVLCControl_get_Length(This,seconds) \ - (This)->lpVtbl -> get_Length(This,seconds) - -#define IVLCControl_playFaster(This) \ - (This)->lpVtbl -> playFaster(This) - -#define IVLCControl_playSlower(This) \ - (This)->lpVtbl -> playSlower(This) - -#define IVLCControl_get_Volume(This,volume) \ - (This)->lpVtbl -> get_Volume(This,volume) - -#define IVLCControl_put_Volume(This,volume) \ - (This)->lpVtbl -> put_Volume(This,volume) - -#define IVLCControl_toggleMute(This) \ - (This)->lpVtbl -> toggleMute(This) - -#define IVLCControl_addTarget(This,uri,options,mode,position) \ - (This)->lpVtbl -> addTarget(This,uri,options,mode,position) - -#define IVLCControl_get_PlaylistIndex(This,index) \ - (This)->lpVtbl -> get_PlaylistIndex(This,index) - -#define IVLCControl_get_PlaylistCount(This,index) \ - (This)->lpVtbl -> get_PlaylistCount(This,index) - -#define IVLCControl_playlistNext(This) \ - (This)->lpVtbl -> playlistNext(This) - -#define IVLCControl_playlistPrev(This) \ - (This)->lpVtbl -> playlistPrev(This) - -#define IVLCControl_playlistClear(This) \ - (This)->lpVtbl -> playlistClear(This) - -#define IVLCControl_get_VersionInfo(This,version) \ - (This)->lpVtbl -> get_VersionInfo(This,version) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - - -/* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Value_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT __RPC_FAR *pvarValue); - - -void __RPC_STUB IVLCControl_get_Value_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Value_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT pvarValue); - - -void __RPC_STUB IVLCControl_put_Value_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Visible_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); - - -void __RPC_STUB IVLCControl_get_Visible_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Visible_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT_BOOL visible); - - -void __RPC_STUB IVLCControl_put_Visible_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_play_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_play_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_pause_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_pause_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_stop_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_stop_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Playing_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying); - - -void __RPC_STUB IVLCControl_get_Playing_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Playing_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ VARIANT_BOOL isPlaying); - - -void __RPC_STUB IVLCControl_put_Playing_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Position_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ float __RPC_FAR *position); - - -void __RPC_STUB IVLCControl_get_Position_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Position_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ float position); - - -void __RPC_STUB IVLCControl_put_Position_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Time_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *seconds); - - -void __RPC_STUB IVLCControl_get_Time_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Time_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ int seconds); - - -void __RPC_STUB IVLCControl_put_Time_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_shuttle_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ int seconds); - - -void __RPC_STUB IVLCControl_shuttle_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_fullscreen_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_fullscreen_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Length_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *seconds); - - -void __RPC_STUB IVLCControl_get_Length_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playFaster_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_playFaster_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playSlower_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_playSlower_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Volume_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *volume); - - -void __RPC_STUB IVLCControl_get_Volume_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Volume_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ int volume); - - -void __RPC_STUB IVLCControl_put_Volume_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_toggleMute_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_toggleMute_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_addTarget_Proxy( - IVLCControl __RPC_FAR * This, - /* [in] */ BSTR uri, - /* [in] */ VARIANT options, - /* [in] */ enum VLCPlaylistMode mode, - /* [in] */ int position); - - -void __RPC_STUB IVLCControl_addTarget_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistIndex_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *index); - - -void __RPC_STUB IVLCControl_get_PlaylistIndex_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistCount_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ int __RPC_FAR *index); - - -void __RPC_STUB IVLCControl_get_PlaylistCount_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistNext_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_playlistNext_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistPrev_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_playlistPrev_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistClear_Proxy( - IVLCControl __RPC_FAR * This); - - -void __RPC_STUB IVLCControl_playlistClear_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - -/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_VersionInfo_Proxy( - IVLCControl __RPC_FAR * This, - /* [retval][out] */ BSTR __RPC_FAR *version); - - -void __RPC_STUB IVLCControl_get_VersionInfo_Stub( - IRpcStubBuffer *This, - IRpcChannelBuffer *_pRpcChannelBuffer, - PRPC_MESSAGE _pRpcMessage, - DWORD *_pdwStubPhase); - - - -#endif /* __IVLCControl_INTERFACE_DEFINED__ */ - - -#ifndef __DVLCEvents_DISPINTERFACE_DEFINED__ -#define __DVLCEvents_DISPINTERFACE_DEFINED__ - -/* dispinterface DVLCEvents */ -/* [hidden][helpstring][uuid] */ - - -EXTERN_C const IID DIID_DVLCEvents; - -#if defined(__cplusplus) && !defined(CINTERFACE) - - MIDL_INTERFACE("DF48072F-5EF8-434e-9B40-E2F3AE759B5F") - DVLCEvents : public IDispatch - { - }; - -#else /* C style interface */ - - typedef struct DVLCEventsVtbl - { - BEGIN_INTERFACE - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( - DVLCEvents __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( - DVLCEvents __RPC_FAR * This); - - ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( - DVLCEvents __RPC_FAR * This); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( - DVLCEvents __RPC_FAR * This, - /* [out] */ UINT __RPC_FAR *pctinfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( - DVLCEvents __RPC_FAR * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); - - HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( - DVLCEvents __RPC_FAR * This, - /* [in] */ REFIID riid, - /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, - /* [in] */ UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); - - /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( - DVLCEvents __RPC_FAR * This, - /* [in] */ DISPID dispIdMember, - /* [in] */ REFIID riid, - /* [in] */ LCID lcid, - /* [in] */ WORD wFlags, - /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, - /* [out] */ VARIANT __RPC_FAR *pVarResult, - /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, - /* [out] */ UINT __RPC_FAR *puArgErr); - - END_INTERFACE - } DVLCEventsVtbl; - - interface DVLCEvents - { - CONST_VTBL struct DVLCEventsVtbl __RPC_FAR *lpVtbl; - }; - - - -#ifdef COBJMACROS - - -#define DVLCEvents_QueryInterface(This,riid,ppvObject) \ - (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) - -#define DVLCEvents_AddRef(This) \ - (This)->lpVtbl -> AddRef(This) - -#define DVLCEvents_Release(This) \ - (This)->lpVtbl -> Release(This) - - -#define DVLCEvents_GetTypeInfoCount(This,pctinfo) \ - (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) - -#define DVLCEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ - (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) - -#define DVLCEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ - (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) - -#define DVLCEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ - (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) - -#endif /* COBJMACROS */ - - -#endif /* C style interface */ - - -#endif /* __DVLCEvents_DISPINTERFACE_DEFINED__ */ - - -EXTERN_C const CLSID CLSID_VLCPlugin; - -#ifdef __cplusplus - -class DECLSPEC_UUID("E23FE9C6-778E-49D4-B537-38FCDE4887D8") -VLCPlugin; -#endif -#endif /* __AXVLC_LIBRARY_DEFINED__ */ - -/* Additional Prototypes for ALL interfaces */ - -/* end of Additional Prototypes */ - -#ifdef __cplusplus -} -#endif - -#endif +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + +/* File created by MIDL compiler version 5.01.0164 */ +/* at Thu Feb 17 09:25:54 2005 + */ +/* Compiler settings for axvlc.idl: + Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext + error checks: allocation ref bounds_check enum stub_data +*/ +//@@MIDL_FILE_HEADING( ) + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 440 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __axvlc_idl_h__ +#define __axvlc_idl_h__ + +#ifdef __cplusplus +extern "C"{ +#endif + +/* Forward Declarations */ + +#ifndef __IVLCControl_FWD_DEFINED__ +#define __IVLCControl_FWD_DEFINED__ +typedef interface IVLCControl IVLCControl; +#endif /* __IVLCControl_FWD_DEFINED__ */ + + +#ifndef __DVLCEvents_FWD_DEFINED__ +#define __DVLCEvents_FWD_DEFINED__ +typedef interface DVLCEvents DVLCEvents; +#endif /* __DVLCEvents_FWD_DEFINED__ */ + + +#ifndef __VLCPlugin_FWD_DEFINED__ +#define __VLCPlugin_FWD_DEFINED__ + +#ifdef __cplusplus +typedef class VLCPlugin VLCPlugin; +#else +typedef struct VLCPlugin VLCPlugin; +#endif /* __cplusplus */ + +#endif /* __VLCPlugin_FWD_DEFINED__ */ + + +void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t); +void __RPC_USER MIDL_user_free( void __RPC_FAR * ); + + +#ifndef __AXVLC_LIBRARY_DEFINED__ +#define __AXVLC_LIBRARY_DEFINED__ + +/* library AXVLC */ +/* [helpstring][version][uuid] */ + + + + +enum VLCPlaylistMode + { VLCPlayListInsert = 1, + VLCPlayListReplace = 2, + VLCPlayListAppend = 4, + VLCPlayListGo = 8, + VLCPlayListCheckInsert = 16 + }; +#define VLCPlayListEnd ( -666 ) + +#define DISPID_Visible ( 1 ) + +#define DISPID_Playing ( 2 ) + +#define DISPID_Position ( 3 ) + +#define DISPID_Time ( 4 ) + +#define DISPID_Length ( 5 ) + +#define DISPID_Volume ( 6 ) + +#define DISPID_PlayEvent ( 1 ) + +#define DISPID_PauseEvent ( 2 ) + +#define DISPID_StopEvent ( 3 ) + + +EXTERN_C const IID LIBID_AXVLC; + +#ifndef __IVLCControl_INTERFACE_DEFINED__ +#define __IVLCControl_INTERFACE_DEFINED__ + +/* interface IVLCControl */ +/* [object][oleautomation][hidden][dual][helpstring][uuid] */ + + +EXTERN_C const IID IID_IVLCControl; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("C2FA41D0-B113-476e-AC8C-9BD14999C1C1") + IVLCControl : public IDispatch + { + public: + virtual /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Value( + /* [retval][out] */ VARIANT __RPC_FAR *pvarValue) = 0; + + virtual /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Value( + /* [in] */ VARIANT pvarValue) = 0; + + virtual /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE get_Visible( + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0; + + virtual /* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE put_Visible( + /* [in] */ VARIANT_BOOL visible) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE play( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE pause( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE stop( void) = 0; + + virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Playing( + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying) = 0; + + virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Playing( + /* [in] */ VARIANT_BOOL isPlaying) = 0; + + virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Position( + /* [retval][out] */ float __RPC_FAR *position) = 0; + + virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position( + /* [in] */ float position) = 0; + + virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Time( + /* [retval][out] */ int __RPC_FAR *seconds) = 0; + + virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Time( + /* [in] */ int seconds) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle( + /* [in] */ int seconds) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE fullscreen( void) = 0; + + virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Length( + /* [retval][out] */ int __RPC_FAR *seconds) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playFaster( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playSlower( void) = 0; + + virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Volume( + /* [retval][out] */ int __RPC_FAR *volume) = 0; + + virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Volume( + /* [in] */ int volume) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE addTarget( + /* [in] */ BSTR uri, + /* [in] */ VARIANT options, + /* [in] */ enum VLCPlaylistMode mode, + /* [in] */ int position) = 0; + + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistIndex( + /* [retval][out] */ int __RPC_FAR *index) = 0; + + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistCount( + /* [retval][out] */ int __RPC_FAR *index) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistNext( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistPrev( void) = 0; + + virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistClear( void) = 0; + + virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_VersionInfo( + /* [retval][out] */ BSTR __RPC_FAR *version) = 0; + + }; + +#else /* C style interface */ + + typedef struct IVLCControlVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( + IVLCControl __RPC_FAR * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); + + ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( + IVLCControl __RPC_FAR * This); + + ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( + IVLCControl __RPC_FAR * This); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( + IVLCControl __RPC_FAR * This, + /* [out] */ UINT __RPC_FAR *pctinfo); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( + IVLCControl __RPC_FAR * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( + IVLCControl __RPC_FAR * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( + IVLCControl __RPC_FAR * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, + /* [out] */ VARIANT __RPC_FAR *pVarResult, + /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, + /* [out] */ UINT __RPC_FAR *puArgErr); + + /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT __RPC_FAR *pvarValue); + + /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT pvarValue); + + /* [helpstring][bindable][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Visible )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); + + /* [helpstring][bindable][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Visible )( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT_BOOL visible); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *play )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *pause )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *stop )( + IVLCControl __RPC_FAR * This); + + /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Playing )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying); + + /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Playing )( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT_BOOL isPlaying); + + /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Position )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ float __RPC_FAR *position); + + /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Position )( + IVLCControl __RPC_FAR * This, + /* [in] */ float position); + + /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Time )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *seconds); + + /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Time )( + IVLCControl __RPC_FAR * This, + /* [in] */ int seconds); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *shuttle )( + IVLCControl __RPC_FAR * This, + /* [in] */ int seconds); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *fullscreen )( + IVLCControl __RPC_FAR * This); + + /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Length )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *seconds); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playFaster )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playSlower )( + IVLCControl __RPC_FAR * This); + + /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Volume )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *volume); + + /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Volume )( + IVLCControl __RPC_FAR * This, + /* [in] */ int volume); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *addTarget )( + IVLCControl __RPC_FAR * This, + /* [in] */ BSTR uri, + /* [in] */ VARIANT options, + /* [in] */ enum VLCPlaylistMode mode, + /* [in] */ int position); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistIndex )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *index); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistCount )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *index); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistNext )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistPrev )( + IVLCControl __RPC_FAR * This); + + /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistClear )( + IVLCControl __RPC_FAR * This); + + /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_VersionInfo )( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ BSTR __RPC_FAR *version); + + END_INTERFACE + } IVLCControlVtbl; + + interface IVLCControl + { + CONST_VTBL struct IVLCControlVtbl __RPC_FAR *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define IVLCControl_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define IVLCControl_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define IVLCControl_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define IVLCControl_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) + +#define IVLCControl_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) + +#define IVLCControl_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) + +#define IVLCControl_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) + + +#define IVLCControl_get_Value(This,pvarValue) \ + (This)->lpVtbl -> get_Value(This,pvarValue) + +#define IVLCControl_put_Value(This,pvarValue) \ + (This)->lpVtbl -> put_Value(This,pvarValue) + +#define IVLCControl_get_Visible(This,visible) \ + (This)->lpVtbl -> get_Visible(This,visible) + +#define IVLCControl_put_Visible(This,visible) \ + (This)->lpVtbl -> put_Visible(This,visible) + +#define IVLCControl_play(This) \ + (This)->lpVtbl -> play(This) + +#define IVLCControl_pause(This) \ + (This)->lpVtbl -> pause(This) + +#define IVLCControl_stop(This) \ + (This)->lpVtbl -> stop(This) + +#define IVLCControl_get_Playing(This,isPlaying) \ + (This)->lpVtbl -> get_Playing(This,isPlaying) + +#define IVLCControl_put_Playing(This,isPlaying) \ + (This)->lpVtbl -> put_Playing(This,isPlaying) + +#define IVLCControl_get_Position(This,position) \ + (This)->lpVtbl -> get_Position(This,position) + +#define IVLCControl_put_Position(This,position) \ + (This)->lpVtbl -> put_Position(This,position) + +#define IVLCControl_get_Time(This,seconds) \ + (This)->lpVtbl -> get_Time(This,seconds) + +#define IVLCControl_put_Time(This,seconds) \ + (This)->lpVtbl -> put_Time(This,seconds) + +#define IVLCControl_shuttle(This,seconds) \ + (This)->lpVtbl -> shuttle(This,seconds) + +#define IVLCControl_fullscreen(This) \ + (This)->lpVtbl -> fullscreen(This) + +#define IVLCControl_get_Length(This,seconds) \ + (This)->lpVtbl -> get_Length(This,seconds) + +#define IVLCControl_playFaster(This) \ + (This)->lpVtbl -> playFaster(This) + +#define IVLCControl_playSlower(This) \ + (This)->lpVtbl -> playSlower(This) + +#define IVLCControl_get_Volume(This,volume) \ + (This)->lpVtbl -> get_Volume(This,volume) + +#define IVLCControl_put_Volume(This,volume) \ + (This)->lpVtbl -> put_Volume(This,volume) + +#define IVLCControl_toggleMute(This) \ + (This)->lpVtbl -> toggleMute(This) + +#define IVLCControl_addTarget(This,uri,options,mode,position) \ + (This)->lpVtbl -> addTarget(This,uri,options,mode,position) + +#define IVLCControl_get_PlaylistIndex(This,index) \ + (This)->lpVtbl -> get_PlaylistIndex(This,index) + +#define IVLCControl_get_PlaylistCount(This,index) \ + (This)->lpVtbl -> get_PlaylistCount(This,index) + +#define IVLCControl_playlistNext(This) \ + (This)->lpVtbl -> playlistNext(This) + +#define IVLCControl_playlistPrev(This) \ + (This)->lpVtbl -> playlistPrev(This) + +#define IVLCControl_playlistClear(This) \ + (This)->lpVtbl -> playlistClear(This) + +#define IVLCControl_get_VersionInfo(This,version) \ + (This)->lpVtbl -> get_VersionInfo(This,version) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + +/* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Value_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT __RPC_FAR *pvarValue); + + +void __RPC_STUB IVLCControl_get_Value_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Value_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT pvarValue); + + +void __RPC_STUB IVLCControl_put_Value_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Visible_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible); + + +void __RPC_STUB IVLCControl_get_Visible_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Visible_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT_BOOL visible); + + +void __RPC_STUB IVLCControl_put_Visible_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_play_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_play_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_pause_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_pause_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_stop_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_stop_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Playing_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying); + + +void __RPC_STUB IVLCControl_get_Playing_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Playing_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ VARIANT_BOOL isPlaying); + + +void __RPC_STUB IVLCControl_put_Playing_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Position_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ float __RPC_FAR *position); + + +void __RPC_STUB IVLCControl_get_Position_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Position_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ float position); + + +void __RPC_STUB IVLCControl_put_Position_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Time_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *seconds); + + +void __RPC_STUB IVLCControl_get_Time_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Time_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ int seconds); + + +void __RPC_STUB IVLCControl_put_Time_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_shuttle_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ int seconds); + + +void __RPC_STUB IVLCControl_shuttle_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_fullscreen_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_fullscreen_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Length_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *seconds); + + +void __RPC_STUB IVLCControl_get_Length_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playFaster_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_playFaster_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playSlower_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_playSlower_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Volume_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *volume); + + +void __RPC_STUB IVLCControl_get_Volume_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Volume_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ int volume); + + +void __RPC_STUB IVLCControl_put_Volume_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_toggleMute_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_toggleMute_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_addTarget_Proxy( + IVLCControl __RPC_FAR * This, + /* [in] */ BSTR uri, + /* [in] */ VARIANT options, + /* [in] */ enum VLCPlaylistMode mode, + /* [in] */ int position); + + +void __RPC_STUB IVLCControl_addTarget_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistIndex_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *index); + + +void __RPC_STUB IVLCControl_get_PlaylistIndex_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistCount_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ int __RPC_FAR *index); + + +void __RPC_STUB IVLCControl_get_PlaylistCount_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistNext_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_playlistNext_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistPrev_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_playlistPrev_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistClear_Proxy( + IVLCControl __RPC_FAR * This); + + +void __RPC_STUB IVLCControl_playlistClear_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + +/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_VersionInfo_Proxy( + IVLCControl __RPC_FAR * This, + /* [retval][out] */ BSTR __RPC_FAR *version); + + +void __RPC_STUB IVLCControl_get_VersionInfo_Stub( + IRpcStubBuffer *This, + IRpcChannelBuffer *_pRpcChannelBuffer, + PRPC_MESSAGE _pRpcMessage, + DWORD *_pdwStubPhase); + + + +#endif /* __IVLCControl_INTERFACE_DEFINED__ */ + + +#ifndef __DVLCEvents_DISPINTERFACE_DEFINED__ +#define __DVLCEvents_DISPINTERFACE_DEFINED__ + +/* dispinterface DVLCEvents */ +/* [hidden][helpstring][uuid] */ + + +EXTERN_C const IID DIID_DVLCEvents; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("DF48072F-5EF8-434e-9B40-E2F3AE759B5F") + DVLCEvents : public IDispatch + { + }; + +#else /* C style interface */ + + typedef struct DVLCEventsVtbl + { + BEGIN_INTERFACE + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( + DVLCEvents __RPC_FAR * This, + /* [in] */ REFIID riid, + /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject); + + ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( + DVLCEvents __RPC_FAR * This); + + ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( + DVLCEvents __RPC_FAR * This); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( + DVLCEvents __RPC_FAR * This, + /* [out] */ UINT __RPC_FAR *pctinfo); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( + DVLCEvents __RPC_FAR * This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo); + + HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( + DVLCEvents __RPC_FAR * This, + /* [in] */ REFIID riid, + /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames, + /* [in] */ UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ DISPID __RPC_FAR *rgDispId); + + /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( + DVLCEvents __RPC_FAR * This, + /* [in] */ DISPID dispIdMember, + /* [in] */ REFIID riid, + /* [in] */ LCID lcid, + /* [in] */ WORD wFlags, + /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams, + /* [out] */ VARIANT __RPC_FAR *pVarResult, + /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo, + /* [out] */ UINT __RPC_FAR *puArgErr); + + END_INTERFACE + } DVLCEventsVtbl; + + interface DVLCEvents + { + CONST_VTBL struct DVLCEventsVtbl __RPC_FAR *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define DVLCEvents_QueryInterface(This,riid,ppvObject) \ + (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) + +#define DVLCEvents_AddRef(This) \ + (This)->lpVtbl -> AddRef(This) + +#define DVLCEvents_Release(This) \ + (This)->lpVtbl -> Release(This) + + +#define DVLCEvents_GetTypeInfoCount(This,pctinfo) \ + (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo) + +#define DVLCEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \ + (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo) + +#define DVLCEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \ + (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) + +#define DVLCEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \ + (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + +#endif /* __DVLCEvents_DISPINTERFACE_DEFINED__ */ + + +EXTERN_C const CLSID CLSID_VLCPlugin; + +#ifdef __cplusplus + +class DECLSPEC_UUID("E23FE9C6-778E-49D4-B537-38FCDE4887D8") +VLCPlugin; +#endif +#endif /* __AXVLC_LIBRARY_DEFINED__ */ + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/activex/connectioncontainer.cpp b/activex/connectioncontainer.cpp index 6fd504a698..a18b0709da 100644 --- a/activex/connectioncontainer.cpp +++ b/activex/connectioncontainer.cpp @@ -1,287 +1,287 @@ -/***************************************************************************** - * connectioncontainer.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "connectioncontainer.h" - -#include "utils.h" - -using namespace std; - -//////////////////////////////////////////////////////////////////////////////////////////////// - -class VLCEnumConnections : public IEnumConnections -{ -public: - VLCEnumConnections(vector &v) : - e(VLCEnum(IID_IEnumConnections, v)) - { e.setRetainOperation((VLCEnum::retainer)&retain); }; - - VLCEnumConnections(const VLCEnumConnections &vlcEnum) : e(vlcEnum.e) {}; - - virtual ~VLCEnumConnections() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { return e.QueryInterface(riid, ppv); }; - STDMETHODIMP_(ULONG) AddRef(void) - { return e.AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) - {return e.Release(); }; - - //IEnumConnectionPoints - STDMETHODIMP Next(ULONG celt, LPCONNECTDATA rgelt, ULONG *pceltFetched) - { return e.Next(celt, rgelt, pceltFetched); }; - STDMETHODIMP Skip(ULONG celt) - { return e.Skip(celt);}; - STDMETHODIMP Reset(void) - { return e.Reset();}; - STDMETHODIMP Clone(LPENUMCONNECTIONS *ppenum) - { if( NULL == ppenum ) return E_POINTER; - *ppenum = dynamic_cast(new VLCEnumConnections(*this)); - return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY; - }; - -private: - - static void retain(CONNECTDATA cd) - { - cd.pUnk->AddRef(); - }; - - VLCEnum e; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////// - -STDMETHODIMP VLCConnectionPoint::GetConnectionInterface(IID *iid) -{ - if( NULL == iid ) - return E_POINTER; - - *iid = _iid; - return S_OK; -}; - -STDMETHODIMP VLCConnectionPoint::GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *ppCPC) -{ - if( NULL == ppCPC ) - return E_POINTER; - - _p_cpc->AddRef(); - *ppCPC = _p_cpc; - return S_OK; -}; - -STDMETHODIMP VLCConnectionPoint::Advise(IUnknown *pUnk, DWORD *pdwCookie) -{ - if( (NULL == pUnk) || (NULL == pdwCookie) ) - return E_POINTER; - - CONNECTDATA cd; - - pUnk->AddRef(); - cd.pUnk = pUnk; - *pdwCookie = cd.dwCookie = _connections.size(); - - _connections.push_back(cd); - - return S_OK; -}; - -STDMETHODIMP VLCConnectionPoint::Unadvise(DWORD pdwCookie) -{ - if( pdwCookie < _connections.size() ) - { - CONNECTDATA cd = _connections[pdwCookie]; - if( NULL != cd.pUnk ) - { - cd.pUnk->Release(); - cd.pUnk = NULL; - return S_OK; - } - } - return CONNECT_E_NOCONNECTION; -}; - -STDMETHODIMP VLCConnectionPoint::EnumConnections(IEnumConnections **ppEnum) -{ - if( NULL == ppEnum ) - return E_POINTER; - - *ppEnum = dynamic_cast(new VLCEnumConnections(_connections)); - - return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY; -}; - -void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS* pDispParams) -{ - vector::iterator end = _connections.end(); - vector::iterator iter = _connections.begin(); - - while( iter != end ) - { - CONNECTDATA cd = *iter; - if( NULL != cd.pUnk ) - { - IDispatch *pDisp; - if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp)) ) - { - pDisp->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, pDispParams, NULL, NULL, NULL); - pDisp->Release(); - } - } - ++iter; - } -}; - -void VLCConnectionPoint::firePropChangedEvent(DISPID dispId) -{ - vector::iterator end = _connections.end(); - vector::iterator iter = _connections.begin(); - - while( iter != end ) - { - CONNECTDATA cd = *iter; - if( NULL != cd.pUnk ) - { - IPropertyNotifySink *pPropSink; - if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IPropertyNotifySink, (LPVOID *)&pPropSink)) ) - { - pPropSink->OnChanged(dispId); - pPropSink->Release(); - } - } - ++iter; - } -}; - -//////////////////////////////////////////////////////////////////////////////////////////////// - -class VLCEnumConnectionPoints : public IEnumConnectionPoints -{ -public: - VLCEnumConnectionPoints(vector &v) : - e(VLCEnum(IID_IEnumConnectionPoints, v)) - { e.setRetainOperation((VLCEnum::retainer)&retain); }; - - VLCEnumConnectionPoints(const VLCEnumConnectionPoints &vlcEnum) : e(vlcEnum.e) {}; - - virtual ~VLCEnumConnectionPoints() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { return e.QueryInterface(riid, ppv); }; - STDMETHODIMP_(ULONG) AddRef(void) - { return e.AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) - {return e.Release(); }; - - //IEnumConnectionPoints - STDMETHODIMP Next(ULONG celt, LPCONNECTIONPOINT *rgelt, ULONG *pceltFetched) - { return e.Next(celt, rgelt, pceltFetched); }; - STDMETHODIMP Skip(ULONG celt) - { return e.Skip(celt);}; - STDMETHODIMP Reset(void) - { return e.Reset();}; - STDMETHODIMP Clone(LPENUMCONNECTIONPOINTS *ppenum) - { if( NULL == ppenum ) return E_POINTER; - *ppenum = dynamic_cast(new VLCEnumConnectionPoints(*this)); - return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY; - }; - -private: - - static void retain(LPCONNECTIONPOINT cp) - { - cp->AddRef(); - }; - - VLCEnum e; -}; - -//////////////////////////////////////////////////////////////////////////////////////////////// - -VLCConnectionPointContainer::VLCConnectionPointContainer(VLCPlugin *p_instance) : - _p_instance(p_instance) -{ - _p_events = new VLCConnectionPoint(dynamic_cast(this), - _p_instance->getDispEventID()); - - _v_cps.push_back(dynamic_cast(_p_events)); - - _p_props = new VLCConnectionPoint(dynamic_cast(this), - IID_IPropertyNotifySink); - - _v_cps.push_back(dynamic_cast(_p_props)); -}; - -VLCConnectionPointContainer::~VLCConnectionPointContainer() -{ - _v_cps.clear(); - delete _p_props; - delete _p_events; -}; - -STDMETHODIMP VLCConnectionPointContainer::EnumConnectionPoints(LPENUMCONNECTIONPOINTS *ppEnum) -{ - if( NULL == ppEnum ) - return E_POINTER; - - *ppEnum = dynamic_cast(new VLCEnumConnectionPoints(_v_cps)); - - return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY; -}; - -STDMETHODIMP VLCConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP) -{ - if( NULL == ppCP ) - return E_POINTER; - - *ppCP = NULL; - - if( IID_IPropertyNotifySink == riid ) - { - _p_props->AddRef(); - *ppCP = dynamic_cast(_p_props); - } - else if( _p_instance->getDispEventID() == riid ) - { - _p_events->AddRef(); - *ppCP = dynamic_cast(_p_events); - } - else - return CONNECT_E_NOCONNECTION; - - return NOERROR; -}; - -void VLCConnectionPointContainer::fireEvent(DISPID dispId, DISPPARAMS* pDispParams) -{ - _p_events->fireEvent(dispId, pDispParams); -}; - -void VLCConnectionPointContainer::firePropChangedEvent(DISPID dispId) -{ - _p_props->firePropChangedEvent(dispId); -}; - +/***************************************************************************** + * connectioncontainer.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "connectioncontainer.h" + +#include "utils.h" + +using namespace std; + +//////////////////////////////////////////////////////////////////////////////////////////////// + +class VLCEnumConnections : public IEnumConnections +{ +public: + VLCEnumConnections(vector &v) : + e(VLCEnum(IID_IEnumConnections, v)) + { e.setRetainOperation((VLCEnum::retainer)&retain); }; + + VLCEnumConnections(const VLCEnumConnections &vlcEnum) : e(vlcEnum.e) {}; + + virtual ~VLCEnumConnections() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { return e.QueryInterface(riid, ppv); }; + STDMETHODIMP_(ULONG) AddRef(void) + { return e.AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) + {return e.Release(); }; + + //IEnumConnectionPoints + STDMETHODIMP Next(ULONG celt, LPCONNECTDATA rgelt, ULONG *pceltFetched) + { return e.Next(celt, rgelt, pceltFetched); }; + STDMETHODIMP Skip(ULONG celt) + { return e.Skip(celt);}; + STDMETHODIMP Reset(void) + { return e.Reset();}; + STDMETHODIMP Clone(LPENUMCONNECTIONS *ppenum) + { if( NULL == ppenum ) return E_POINTER; + *ppenum = dynamic_cast(new VLCEnumConnections(*this)); + return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY; + }; + +private: + + static void retain(CONNECTDATA cd) + { + cd.pUnk->AddRef(); + }; + + VLCEnum e; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// + +STDMETHODIMP VLCConnectionPoint::GetConnectionInterface(IID *iid) +{ + if( NULL == iid ) + return E_POINTER; + + *iid = _iid; + return S_OK; +}; + +STDMETHODIMP VLCConnectionPoint::GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *ppCPC) +{ + if( NULL == ppCPC ) + return E_POINTER; + + _p_cpc->AddRef(); + *ppCPC = _p_cpc; + return S_OK; +}; + +STDMETHODIMP VLCConnectionPoint::Advise(IUnknown *pUnk, DWORD *pdwCookie) +{ + if( (NULL == pUnk) || (NULL == pdwCookie) ) + return E_POINTER; + + CONNECTDATA cd; + + pUnk->AddRef(); + cd.pUnk = pUnk; + *pdwCookie = cd.dwCookie = _connections.size(); + + _connections.push_back(cd); + + return S_OK; +}; + +STDMETHODIMP VLCConnectionPoint::Unadvise(DWORD pdwCookie) +{ + if( pdwCookie < _connections.size() ) + { + CONNECTDATA cd = _connections[pdwCookie]; + if( NULL != cd.pUnk ) + { + cd.pUnk->Release(); + cd.pUnk = NULL; + return S_OK; + } + } + return CONNECT_E_NOCONNECTION; +}; + +STDMETHODIMP VLCConnectionPoint::EnumConnections(IEnumConnections **ppEnum) +{ + if( NULL == ppEnum ) + return E_POINTER; + + *ppEnum = dynamic_cast(new VLCEnumConnections(_connections)); + + return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY; +}; + +void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS* pDispParams) +{ + vector::iterator end = _connections.end(); + vector::iterator iter = _connections.begin(); + + while( iter != end ) + { + CONNECTDATA cd = *iter; + if( NULL != cd.pUnk ) + { + IDispatch *pDisp; + if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp)) ) + { + pDisp->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, pDispParams, NULL, NULL, NULL); + pDisp->Release(); + } + } + ++iter; + } +}; + +void VLCConnectionPoint::firePropChangedEvent(DISPID dispId) +{ + vector::iterator end = _connections.end(); + vector::iterator iter = _connections.begin(); + + while( iter != end ) + { + CONNECTDATA cd = *iter; + if( NULL != cd.pUnk ) + { + IPropertyNotifySink *pPropSink; + if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IPropertyNotifySink, (LPVOID *)&pPropSink)) ) + { + pPropSink->OnChanged(dispId); + pPropSink->Release(); + } + } + ++iter; + } +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// + +class VLCEnumConnectionPoints : public IEnumConnectionPoints +{ +public: + VLCEnumConnectionPoints(vector &v) : + e(VLCEnum(IID_IEnumConnectionPoints, v)) + { e.setRetainOperation((VLCEnum::retainer)&retain); }; + + VLCEnumConnectionPoints(const VLCEnumConnectionPoints &vlcEnum) : e(vlcEnum.e) {}; + + virtual ~VLCEnumConnectionPoints() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { return e.QueryInterface(riid, ppv); }; + STDMETHODIMP_(ULONG) AddRef(void) + { return e.AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) + {return e.Release(); }; + + //IEnumConnectionPoints + STDMETHODIMP Next(ULONG celt, LPCONNECTIONPOINT *rgelt, ULONG *pceltFetched) + { return e.Next(celt, rgelt, pceltFetched); }; + STDMETHODIMP Skip(ULONG celt) + { return e.Skip(celt);}; + STDMETHODIMP Reset(void) + { return e.Reset();}; + STDMETHODIMP Clone(LPENUMCONNECTIONPOINTS *ppenum) + { if( NULL == ppenum ) return E_POINTER; + *ppenum = dynamic_cast(new VLCEnumConnectionPoints(*this)); + return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY; + }; + +private: + + static void retain(LPCONNECTIONPOINT cp) + { + cp->AddRef(); + }; + + VLCEnum e; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////// + +VLCConnectionPointContainer::VLCConnectionPointContainer(VLCPlugin *p_instance) : + _p_instance(p_instance) +{ + _p_events = new VLCConnectionPoint(dynamic_cast(this), + _p_instance->getDispEventID()); + + _v_cps.push_back(dynamic_cast(_p_events)); + + _p_props = new VLCConnectionPoint(dynamic_cast(this), + IID_IPropertyNotifySink); + + _v_cps.push_back(dynamic_cast(_p_props)); +}; + +VLCConnectionPointContainer::~VLCConnectionPointContainer() +{ + _v_cps.clear(); + delete _p_props; + delete _p_events; +}; + +STDMETHODIMP VLCConnectionPointContainer::EnumConnectionPoints(LPENUMCONNECTIONPOINTS *ppEnum) +{ + if( NULL == ppEnum ) + return E_POINTER; + + *ppEnum = dynamic_cast(new VLCEnumConnectionPoints(_v_cps)); + + return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY; +}; + +STDMETHODIMP VLCConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP) +{ + if( NULL == ppCP ) + return E_POINTER; + + *ppCP = NULL; + + if( IID_IPropertyNotifySink == riid ) + { + _p_props->AddRef(); + *ppCP = dynamic_cast(_p_props); + } + else if( _p_instance->getDispEventID() == riid ) + { + _p_events->AddRef(); + *ppCP = dynamic_cast(_p_events); + } + else + return CONNECT_E_NOCONNECTION; + + return NOERROR; +}; + +void VLCConnectionPointContainer::fireEvent(DISPID dispId, DISPPARAMS* pDispParams) +{ + _p_events->fireEvent(dispId, pDispParams); +}; + +void VLCConnectionPointContainer::firePropChangedEvent(DISPID dispId) +{ + _p_props->firePropChangedEvent(dispId); +}; + diff --git a/activex/connectioncontainer.h b/activex/connectioncontainer.h index 87d97dc624..4bbd696880 100644 --- a/activex/connectioncontainer.h +++ b/activex/connectioncontainer.h @@ -1,116 +1,116 @@ -/***************************************************************************** - * connectioncontainer.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __CONNECTIONCONTAINER_H__ -#define __CONNECTIONCONTAINER_H__ - -#include -#include - -using namespace std; - -class VLCConnectionPoint : public IConnectionPoint -{ - -public: - - VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) : - _iid(iid), _p_cpc(p_cpc) {}; - virtual ~VLCConnectionPoint() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( NULL == ppv ) return E_POINTER; - if( (IID_IUnknown == riid) - && (IID_IConnectionPoint == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - // must be a standalone object - return E_NOINTERFACE; - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); }; - - // IConnectionPoint methods - STDMETHODIMP GetConnectionInterface(IID *); - STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *); - STDMETHODIMP Advise(IUnknown *, DWORD *); - STDMETHODIMP Unadvise(DWORD); - STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *); - - void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams); - void firePropChangedEvent(DISPID dispId); - -private: - - REFIID _iid; - IConnectionPointContainer *_p_cpc; - vector _connections; -}; - -////////////////////////////////////////////////////////////////////////// - -class VLCConnectionPointContainer : public IConnectionPointContainer -{ - -public: - - VLCConnectionPointContainer(VLCPlugin *p_instance); - virtual ~VLCConnectionPointContainer(); - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IConnectionPointContainer == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IConnectionPointContainer methods - STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *); - STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *); - - void fireEvent(DISPID, DISPPARAMS*); - void firePropChangedEvent(DISPID dispId); - -private: - - VLCPlugin *_p_instance; - VLCConnectionPoint *_p_events; - VLCConnectionPoint *_p_props; - vector _v_cps; -}; - -#endif - +/***************************************************************************** + * connectioncontainer.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __CONNECTIONCONTAINER_H__ +#define __CONNECTIONCONTAINER_H__ + +#include +#include + +using namespace std; + +class VLCConnectionPoint : public IConnectionPoint +{ + +public: + + VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) : + _iid(iid), _p_cpc(p_cpc) {}; + virtual ~VLCConnectionPoint() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( NULL == ppv ) return E_POINTER; + if( (IID_IUnknown == riid) + && (IID_IConnectionPoint == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + // must be a standalone object + return E_NOINTERFACE; + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); }; + + // IConnectionPoint methods + STDMETHODIMP GetConnectionInterface(IID *); + STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *); + STDMETHODIMP Advise(IUnknown *, DWORD *); + STDMETHODIMP Unadvise(DWORD); + STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *); + + void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams); + void firePropChangedEvent(DISPID dispId); + +private: + + REFIID _iid; + IConnectionPointContainer *_p_cpc; + vector _connections; +}; + +////////////////////////////////////////////////////////////////////////// + +class VLCConnectionPointContainer : public IConnectionPointContainer +{ + +public: + + VLCConnectionPointContainer(VLCPlugin *p_instance); + virtual ~VLCConnectionPointContainer(); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IConnectionPointContainer == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IConnectionPointContainer methods + STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *); + STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *); + + void fireEvent(DISPID, DISPPARAMS*); + void firePropChangedEvent(DISPID dispId); + +private: + + VLCPlugin *_p_instance; + VLCConnectionPoint *_p_events; + VLCConnectionPoint *_p_props; + vector _v_cps; +}; + +#endif + diff --git a/activex/main.cpp b/activex/main.cpp index a1500da2ef..258a8abddc 100644 --- a/activex/main.cpp +++ b/activex/main.cpp @@ -1,403 +1,403 @@ -/***************************************************************************** - * main.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" - -#include -#include -#include - -using namespace std; - -#define THREADING_MODEL "Both" -#define COMPANY_STR "VideoLAN" -#define PROGRAM_STR "VLCPlugin" -#define VERSION_MAJOR_STR "1" -#define VERSION_MINOR_STR "0" -#define DESCRIPTION "VideoLAN VLC ActiveX Plugin" - -#define PROGID_STR COMPANY_STR"."PROGRAM_STR -#define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR -#define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR - -#define GUID_STRLEN 39 - -/* -** MingW headers do not declare those -*/ -extern const CATID CATID_SafeForInitializing; -extern const CATID CATID_SafeForScripting; - -static LONG i_class_ref= 0; -static HINSTANCE h_instance= 0; - -STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) -{ - HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; - - *ppv = NULL; - - if( CLSID_VLCPlugin == rclsid ) - { - VLCPluginClass *plugin = new VLCPluginClass(&i_class_ref, h_instance); - hr = plugin->QueryInterface(riid, ppv); - plugin->Release(); - } - return hr; -}; - -STDAPI DllCanUnloadNow(VOID) -{ - return (0 == i_class_ref) ? S_OK: S_FALSE; -}; - -static LPCTSTR TStrFromGUID(REFGUID clsid) { - LPOLESTR oleStr; - - if( FAILED(StringFromIID(clsid, &oleStr)) ) - return NULL; - - //check whether TCHAR and OLECHAR are both either ANSI or UNICODE - if( sizeof(TCHAR) == sizeof(OLECHAR) ) - return (LPCTSTR)oleStr; - - LPTSTR pct_CLSID = NULL; -#ifndef OLE2ANSI - size_t len = WideCharToMultiByte(CP_ACP, 0, oleStr, -1, NULL, 0, NULL, NULL); - if( len > 0 ) - { - pct_CLSID = (char *)CoTaskMemAlloc(len); - WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len, NULL, NULL); - } -#else - size_t len = MutiByteToWideChar(CP_ACP, 0, oleStr, -1, NULL, 0); - if( len > 0 ) - { - clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t)); - WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len); - } -#endif - CoTaskMemFree(oleStr); - return pct_CLSID; -}; - -static HKEY keyCreate(HKEY parentKey, LPCTSTR keyName) -{ - HKEY childKey; - if( ERROR_SUCCESS == RegCreateKeyEx(parentKey, keyName, 0, NULL, - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &childKey, NULL) ) - { - return childKey; - } - return NULL; -}; - -STDAPI DllUnregisterServer(VOID) -{ - // unregister type lib from the registry - UnRegisterTypeLib(LIBID_AXVLC, 1, 0, LOCALE_NEUTRAL, SYS_WIN32); - - // remove component categories we supports - ICatRegister *pcr; - if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, - NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) { - CATID implCategories[] = { - CATID_Control, - CATID_PersistsToPropertyBag, - CATID_SafeForInitializing, - CATID_SafeForScripting, - }; - - pcr->UnRegisterClassImplCategories(CLSID_VLCPlugin, - sizeof(implCategories)/sizeof(CATID), implCategories); - pcr->Release(); - } - - SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR)); - SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(PROGID_STR)); - - LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin); - - if( NULL == psz_CLSID ) - return E_OUTOFMEMORY; - - HKEY hClsIDKey; - if( ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_WRITE, &hClsIDKey) ) - { - SHDeleteKey(hClsIDKey, psz_CLSID); - RegCloseKey(hClsIDKey); - } - CoTaskMemFree((void *)psz_CLSID); - - return S_OK; -}; - -STDAPI DllRegisterServer(VOID) -{ - DllUnregisterServer(); - - char DllPath[MAX_PATH]; - DWORD DllPathLen= GetModuleFileName(h_instance, DllPath, sizeof(DllPath)) ; - if( 0 == DllPathLen ) - return E_FAIL; - - LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin); - - if( NULL == psz_CLSID ) - return E_OUTOFMEMORY; - - HKEY hBaseKey; - - if( ERROR_SUCCESS != RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_CREATE_SUB_KEY, &hBaseKey) ) - return E_FAIL; - - HKEY hClassKey = keyCreate(hBaseKey, psz_CLSID); - if( NULL != hClassKey ) - { - HKEY hSubKey; - - // default key value - RegSetValueEx(hClassKey, NULL, 0, REG_SZ, - (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); - - // Control key value - hSubKey = keyCreate(hClassKey, TEXT("Control")); - RegCloseKey(hSubKey); - - // InprocServer32 key value - hSubKey = keyCreate(hClassKey, TEXT("InprocServer32")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)DllPath, DllPathLen); - RegSetValueEx(hSubKey, TEXT("ThreadingModel"), 0, REG_SZ, - (const BYTE*)THREADING_MODEL, sizeof(THREADING_MODEL)); - RegCloseKey(hSubKey); - - // MiscStatus key value - hSubKey = keyCreate(hClassKey, TEXT("MiscStatus\\1")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (const BYTE*)"131473", sizeof("131473")); - RegCloseKey(hSubKey); - - // Programmable key value - hSubKey = keyCreate(hClassKey, TEXT("Programmable")); - RegCloseKey(hSubKey); - - // ProgID key value - hSubKey = keyCreate(hClassKey, TEXT("ProgID")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR)); - RegCloseKey(hSubKey); - - // VersionIndependentProgID key value - hSubKey = keyCreate(hClassKey, TEXT("VersionIndependentProgID")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)PROGID_STR, sizeof(PROGID_STR)); - RegCloseKey(hSubKey); - - // Version key value - hSubKey = keyCreate(hClassKey, TEXT("Version")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)VERSION_STR, sizeof(VERSION_STR)); - RegCloseKey(hSubKey); - - // TypeLib key value - LPCTSTR psz_LIBID = TStrFromGUID(LIBID_AXVLC); - if( NULL != psz_LIBID ) - { - hSubKey = keyCreate(hClassKey, TEXT("TypeLib")); - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)psz_LIBID, sizeof(TCHAR)*GUID_STRLEN); - RegCloseKey(hSubKey); - } - RegCloseKey(hClassKey); - } - RegCloseKey(hBaseKey); - - hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(PROGID_STR)); - if( NULL != hBaseKey ) - { - // default key value - RegSetValueEx(hBaseKey, NULL, 0, REG_SZ, - (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); - - HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID")); - if( NULL != hSubKey ) - { - // default key value - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN); - - RegCloseKey(hSubKey); - } - hSubKey = keyCreate(hBaseKey, TEXT("CurVer")); - if( NULL != hSubKey ) - { - // default key value - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR)); - - RegCloseKey(hSubKey); - } - RegCloseKey(hBaseKey); - } - - hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR)); - if( NULL != hBaseKey ) - { - // default key value - RegSetValueEx(hBaseKey, NULL, 0, REG_SZ, - (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); - - HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID")); - if( NULL != hSubKey ) - { - // default key value - RegSetValueEx(hSubKey, NULL, 0, REG_SZ, - (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN); - - RegCloseKey(hSubKey); - } - RegCloseKey(hBaseKey); - } - - // indicate which component categories we support - ICatRegister *pcr; - if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, - NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) { - CATID implCategories[] = { - CATID_Control, - CATID_PersistsToPropertyBag, - CATID_SafeForInitializing, - CATID_SafeForScripting, - }; - - pcr->RegisterClassImplCategories(CLSID_VLCPlugin, - sizeof(implCategories)/sizeof(CATID), implCategories); - pcr->Release(); - } - - // register type lib into the registry - ITypeLib *typeLib; -#ifndef OLE2ANSI - size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, NULL, 0); - if( typeLibPathLen > 0 ) - { - LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t)); - MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen); - if( SUCCEEDED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) ) - typeLib->Release(); - CoTaskMemFree((void *)typeLibPath); - } -#else - if( SUCCEEDED(LoadTypeLibEx((LPOLESTR)DllPath, REGKIND_REGISTER, &typeLib)) ) - typeLib->Release(); -#endif - - CoTaskMemFree((void *)psz_CLSID); - - return S_OK; -}; - -#ifdef BUILD_LOCALSERVER - -/* -** easier to debug an application than a DLL on cygwin GDB :) -*/ -#include - -STDAPI_(int) WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) -{ - MSG msg; - - if( FAILED(OleInitialize(NULL)) ) - { - cerr << "cannot initialize OLE" << endl; - return 1; - } - - IUnknown *classProc = NULL; - - if( FAILED(DllGetClassObject(CLSID_VLCPlugin, IID_IUnknown, (LPVOID *)&classProc)) ) - return 0; - - DWORD dwRegisterClassObject; - - if( FAILED(CoRegisterClassObject(CLSID_VLCPlugin, classProc, - CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegisterClassObject)) ) - return 0; - - DWORD dwRegisterActiveObject; - - if( FAILED(RegisterActiveObject(classProc, CLSID_VLCPlugin, - ACTIVEOBJECT_WEAK, &dwRegisterActiveObject)) ) - return 0; - - classProc->Release(); - - /* - * Polling messages from event queue - */ - while( S_FALSE == DllCanUnloadNow() ) - { - while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) - { - if( msg.message == WM_QUIT ) - break; // Leave the PeekMessage while() loop - - /*if(TranslateAccelerator(ghwndApp, ghAccel, &msg)) - continue;*/ - - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if(msg.message == WM_QUIT) - break; // Leave the for() loop - - WaitMessage(); - } - - if( SUCCEEDED(RevokeActiveObject(dwRegisterActiveObject, NULL)) ) - CoRevokeClassObject(dwRegisterClassObject); - - // Reached on WM_QUIT message - CoUninitialize(); - return ((int) msg.wParam); -}; - -#else - -STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved ) -{ - switch( fdwReason ) - { - case DLL_PROCESS_ATTACH: - h_instance = (HINSTANCE)hModule; - break; - - default: - break; - } - return TRUE; -}; - -#endif - +/***************************************************************************** + * main.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" + +#include +#include +#include + +using namespace std; + +#define THREADING_MODEL "Both" +#define COMPANY_STR "VideoLAN" +#define PROGRAM_STR "VLCPlugin" +#define VERSION_MAJOR_STR "1" +#define VERSION_MINOR_STR "0" +#define DESCRIPTION "VideoLAN VLC ActiveX Plugin" + +#define PROGID_STR COMPANY_STR"."PROGRAM_STR +#define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR +#define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR + +#define GUID_STRLEN 39 + +/* +** MingW headers do not declare those +*/ +extern const CATID CATID_SafeForInitializing; +extern const CATID CATID_SafeForScripting; + +static LONG i_class_ref= 0; +static HINSTANCE h_instance= 0; + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) +{ + HRESULT hr = CLASS_E_CLASSNOTAVAILABLE; + + *ppv = NULL; + + if( CLSID_VLCPlugin == rclsid ) + { + VLCPluginClass *plugin = new VLCPluginClass(&i_class_ref, h_instance); + hr = plugin->QueryInterface(riid, ppv); + plugin->Release(); + } + return hr; +}; + +STDAPI DllCanUnloadNow(VOID) +{ + return (0 == i_class_ref) ? S_OK: S_FALSE; +}; + +static LPCTSTR TStrFromGUID(REFGUID clsid) { + LPOLESTR oleStr; + + if( FAILED(StringFromIID(clsid, &oleStr)) ) + return NULL; + + //check whether TCHAR and OLECHAR are both either ANSI or UNICODE + if( sizeof(TCHAR) == sizeof(OLECHAR) ) + return (LPCTSTR)oleStr; + + LPTSTR pct_CLSID = NULL; +#ifndef OLE2ANSI + size_t len = WideCharToMultiByte(CP_ACP, 0, oleStr, -1, NULL, 0, NULL, NULL); + if( len > 0 ) + { + pct_CLSID = (char *)CoTaskMemAlloc(len); + WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len, NULL, NULL); + } +#else + size_t len = MutiByteToWideChar(CP_ACP, 0, oleStr, -1, NULL, 0); + if( len > 0 ) + { + clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t)); + WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len); + } +#endif + CoTaskMemFree(oleStr); + return pct_CLSID; +}; + +static HKEY keyCreate(HKEY parentKey, LPCTSTR keyName) +{ + HKEY childKey; + if( ERROR_SUCCESS == RegCreateKeyEx(parentKey, keyName, 0, NULL, + REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &childKey, NULL) ) + { + return childKey; + } + return NULL; +}; + +STDAPI DllUnregisterServer(VOID) +{ + // unregister type lib from the registry + UnRegisterTypeLib(LIBID_AXVLC, 1, 0, LOCALE_NEUTRAL, SYS_WIN32); + + // remove component categories we supports + ICatRegister *pcr; + if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, + NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) { + CATID implCategories[] = { + CATID_Control, + CATID_PersistsToPropertyBag, + CATID_SafeForInitializing, + CATID_SafeForScripting, + }; + + pcr->UnRegisterClassImplCategories(CLSID_VLCPlugin, + sizeof(implCategories)/sizeof(CATID), implCategories); + pcr->Release(); + } + + SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR)); + SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(PROGID_STR)); + + LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin); + + if( NULL == psz_CLSID ) + return E_OUTOFMEMORY; + + HKEY hClsIDKey; + if( ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_WRITE, &hClsIDKey) ) + { + SHDeleteKey(hClsIDKey, psz_CLSID); + RegCloseKey(hClsIDKey); + } + CoTaskMemFree((void *)psz_CLSID); + + return S_OK; +}; + +STDAPI DllRegisterServer(VOID) +{ + DllUnregisterServer(); + + char DllPath[MAX_PATH]; + DWORD DllPathLen= GetModuleFileName(h_instance, DllPath, sizeof(DllPath)) ; + if( 0 == DllPathLen ) + return E_FAIL; + + LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin); + + if( NULL == psz_CLSID ) + return E_OUTOFMEMORY; + + HKEY hBaseKey; + + if( ERROR_SUCCESS != RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_CREATE_SUB_KEY, &hBaseKey) ) + return E_FAIL; + + HKEY hClassKey = keyCreate(hBaseKey, psz_CLSID); + if( NULL != hClassKey ) + { + HKEY hSubKey; + + // default key value + RegSetValueEx(hClassKey, NULL, 0, REG_SZ, + (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); + + // Control key value + hSubKey = keyCreate(hClassKey, TEXT("Control")); + RegCloseKey(hSubKey); + + // InprocServer32 key value + hSubKey = keyCreate(hClassKey, TEXT("InprocServer32")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)DllPath, DllPathLen); + RegSetValueEx(hSubKey, TEXT("ThreadingModel"), 0, REG_SZ, + (const BYTE*)THREADING_MODEL, sizeof(THREADING_MODEL)); + RegCloseKey(hSubKey); + + // MiscStatus key value + hSubKey = keyCreate(hClassKey, TEXT("MiscStatus\\1")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (const BYTE*)"131473", sizeof("131473")); + RegCloseKey(hSubKey); + + // Programmable key value + hSubKey = keyCreate(hClassKey, TEXT("Programmable")); + RegCloseKey(hSubKey); + + // ProgID key value + hSubKey = keyCreate(hClassKey, TEXT("ProgID")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR)); + RegCloseKey(hSubKey); + + // VersionIndependentProgID key value + hSubKey = keyCreate(hClassKey, TEXT("VersionIndependentProgID")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)PROGID_STR, sizeof(PROGID_STR)); + RegCloseKey(hSubKey); + + // Version key value + hSubKey = keyCreate(hClassKey, TEXT("Version")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)VERSION_STR, sizeof(VERSION_STR)); + RegCloseKey(hSubKey); + + // TypeLib key value + LPCTSTR psz_LIBID = TStrFromGUID(LIBID_AXVLC); + if( NULL != psz_LIBID ) + { + hSubKey = keyCreate(hClassKey, TEXT("TypeLib")); + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)psz_LIBID, sizeof(TCHAR)*GUID_STRLEN); + RegCloseKey(hSubKey); + } + RegCloseKey(hClassKey); + } + RegCloseKey(hBaseKey); + + hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(PROGID_STR)); + if( NULL != hBaseKey ) + { + // default key value + RegSetValueEx(hBaseKey, NULL, 0, REG_SZ, + (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); + + HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID")); + if( NULL != hSubKey ) + { + // default key value + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN); + + RegCloseKey(hSubKey); + } + hSubKey = keyCreate(hBaseKey, TEXT("CurVer")); + if( NULL != hSubKey ) + { + // default key value + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR)); + + RegCloseKey(hSubKey); + } + RegCloseKey(hBaseKey); + } + + hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR)); + if( NULL != hBaseKey ) + { + // default key value + RegSetValueEx(hBaseKey, NULL, 0, REG_SZ, + (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION)); + + HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID")); + if( NULL != hSubKey ) + { + // default key value + RegSetValueEx(hSubKey, NULL, 0, REG_SZ, + (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN); + + RegCloseKey(hSubKey); + } + RegCloseKey(hBaseKey); + } + + // indicate which component categories we support + ICatRegister *pcr; + if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, + NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) { + CATID implCategories[] = { + CATID_Control, + CATID_PersistsToPropertyBag, + CATID_SafeForInitializing, + CATID_SafeForScripting, + }; + + pcr->RegisterClassImplCategories(CLSID_VLCPlugin, + sizeof(implCategories)/sizeof(CATID), implCategories); + pcr->Release(); + } + + // register type lib into the registry + ITypeLib *typeLib; +#ifndef OLE2ANSI + size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, NULL, 0); + if( typeLibPathLen > 0 ) + { + LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t)); + MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen); + if( SUCCEEDED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) ) + typeLib->Release(); + CoTaskMemFree((void *)typeLibPath); + } +#else + if( SUCCEEDED(LoadTypeLibEx((LPOLESTR)DllPath, REGKIND_REGISTER, &typeLib)) ) + typeLib->Release(); +#endif + + CoTaskMemFree((void *)psz_CLSID); + + return S_OK; +}; + +#ifdef BUILD_LOCALSERVER + +/* +** easier to debug an application than a DLL on cygwin GDB :) +*/ +#include + +STDAPI_(int) WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw) +{ + MSG msg; + + if( FAILED(OleInitialize(NULL)) ) + { + cerr << "cannot initialize OLE" << endl; + return 1; + } + + IUnknown *classProc = NULL; + + if( FAILED(DllGetClassObject(CLSID_VLCPlugin, IID_IUnknown, (LPVOID *)&classProc)) ) + return 0; + + DWORD dwRegisterClassObject; + + if( FAILED(CoRegisterClassObject(CLSID_VLCPlugin, classProc, + CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegisterClassObject)) ) + return 0; + + DWORD dwRegisterActiveObject; + + if( FAILED(RegisterActiveObject(classProc, CLSID_VLCPlugin, + ACTIVEOBJECT_WEAK, &dwRegisterActiveObject)) ) + return 0; + + classProc->Release(); + + /* + * Polling messages from event queue + */ + while( S_FALSE == DllCanUnloadNow() ) + { + while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) ) + { + if( msg.message == WM_QUIT ) + break; // Leave the PeekMessage while() loop + + /*if(TranslateAccelerator(ghwndApp, ghAccel, &msg)) + continue;*/ + + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + if(msg.message == WM_QUIT) + break; // Leave the for() loop + + WaitMessage(); + } + + if( SUCCEEDED(RevokeActiveObject(dwRegisterActiveObject, NULL)) ) + CoRevokeClassObject(dwRegisterClassObject); + + // Reached on WM_QUIT message + CoUninitialize(); + return ((int) msg.wParam); +}; + +#else + +STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved ) +{ + switch( fdwReason ) + { + case DLL_PROCESS_ATTACH: + h_instance = (HINSTANCE)hModule; + break; + + default: + break; + } + return TRUE; +}; + +#endif + diff --git a/activex/objectsafety.cpp b/activex/objectsafety.cpp index 0cfc678b66..53b40213b5 100644 --- a/activex/objectsafety.cpp +++ b/activex/objectsafety.cpp @@ -1,92 +1,92 @@ -/***************************************************************************** - * objectsafety.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "objectsafety.h" - -#include "axvlc_idl.h" - -#if 0 -const GUID IID_IObjectSafety = - {0xCB5BDC81,0x93C1,0x11cf,{0x8F,0x20,0x00,0x80,0x5F,0x2C,0xD0,0x64}}; -#endif - -STDMETHODIMP VLCObjectSafety::GetInterfaceSafetyOptions( - REFIID riid, - DWORD *pdwSupportedOptions, - DWORD *pdwEnabledOptions -) -{ - if( (NULL == pdwSupportedOptions) || (NULL == pdwEnabledOptions) ) - return E_POINTER; - - *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACESAFE_FOR_UNTRUSTED_CALLER; - - if( (IID_IDispatch == riid) - || (IID_IVLCControl == riid) ) - { - *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER; - return NOERROR; - } - else if( (IID_IPersist == riid) - || (IID_IPersistStreamInit == riid) - || (IID_IPersistStorage == riid) - || (IID_IPersistPropertyBag == riid) ) - { - *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA; - return NOERROR; - } - *pdwEnabledOptions = 0; - return E_NOINTERFACE; -}; - -STDMETHODIMP VLCObjectSafety::SetInterfaceSafetyOptions( - REFIID riid, - DWORD dwOptionSetMask, - DWORD dwEnabledOptions -) -{ - if( (IID_IDispatch == riid) - || (IID_IVLCControl == riid) ) - { - if( (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwOptionSetMask) - && (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwEnabledOptions) ) - { - return NOERROR; - } - return E_FAIL; - } - else if( (IID_IPersist == riid) - || (IID_IPersistStreamInit == riid) - || (IID_IPersistStorage == riid) - || (IID_IPersistPropertyBag == riid) ) - { - if( (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwOptionSetMask) - && (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwEnabledOptions) ) - { - return NOERROR; - } - return E_FAIL; - } - return E_FAIL; -}; - +/***************************************************************************** + * objectsafety.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "objectsafety.h" + +#include "axvlc_idl.h" + +#if 0 +const GUID IID_IObjectSafety = + {0xCB5BDC81,0x93C1,0x11cf,{0x8F,0x20,0x00,0x80,0x5F,0x2C,0xD0,0x64}}; +#endif + +STDMETHODIMP VLCObjectSafety::GetInterfaceSafetyOptions( + REFIID riid, + DWORD *pdwSupportedOptions, + DWORD *pdwEnabledOptions +) +{ + if( (NULL == pdwSupportedOptions) || (NULL == pdwEnabledOptions) ) + return E_POINTER; + + *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACESAFE_FOR_UNTRUSTED_CALLER; + + if( (IID_IDispatch == riid) + || (IID_IVLCControl == riid) ) + { + *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER; + return NOERROR; + } + else if( (IID_IPersist == riid) + || (IID_IPersistStreamInit == riid) + || (IID_IPersistStorage == riid) + || (IID_IPersistPropertyBag == riid) ) + { + *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA; + return NOERROR; + } + *pdwEnabledOptions = 0; + return E_NOINTERFACE; +}; + +STDMETHODIMP VLCObjectSafety::SetInterfaceSafetyOptions( + REFIID riid, + DWORD dwOptionSetMask, + DWORD dwEnabledOptions +) +{ + if( (IID_IDispatch == riid) + || (IID_IVLCControl == riid) ) + { + if( (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwOptionSetMask) + && (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwEnabledOptions) ) + { + return NOERROR; + } + return E_FAIL; + } + else if( (IID_IPersist == riid) + || (IID_IPersistStreamInit == riid) + || (IID_IPersistStorage == riid) + || (IID_IPersistPropertyBag == riid) ) + { + if( (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwOptionSetMask) + && (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwEnabledOptions) ) + { + return NOERROR; + } + return E_FAIL; + } + return E_FAIL; +}; + diff --git a/activex/objectsafety.h b/activex/objectsafety.h index 36440507c3..4f2f7840c4 100644 --- a/activex/objectsafety.h +++ b/activex/objectsafety.h @@ -1,99 +1,99 @@ -/***************************************************************************** - * objectsafety.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __OBJECTSAFETY_H__ -#define __OBJECTSAFETY_H__ - -#if HAVE_OBJSAFE_HEADER -/* -** at last, a version of mingw that supports this header -*/ -#include - -#else - -// {CB5BDC81-93C1-11cf-8F20-00805F2CD064} -extern "C" const IID IID_IObjectSafety; - -#define INTERFACESAFE_FOR_UNTRUSTED_CALLER 1L -#define INTERFACESAFE_FOR_UNTRUSTED_DATA 2L - -struct IObjectSafety : public IUnknown -{ - virtual STDMETHODIMP GetInterfaceSafetyOptions( - REFIID riid, - DWORD __RPC_FAR *pdwSupportedOptions, - DWORD __RPC_FAR *pdwEnabledOptions - ) = 0; - - virtual STDMETHODIMP SetInterfaceSafetyOptions( - REFIID riid, - DWORD dwSupportedOptions, - DWORD dwOptionSetMask - ) = 0; -}; - -#endif - -class VLCObjectSafety : public IObjectSafety -{ -public: - - VLCObjectSafety(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCObjectSafety() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IObjectSafety == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IUnknown methods - STDMETHODIMP GetInterfaceSafetyOptions( - REFIID riid, - DWORD *pdwSupportedOptions, - DWORD *pdwEnabledOptions - ); - - STDMETHODIMP SetInterfaceSafetyOptions( - REFIID riid, - DWORD dwOptionSetMask, - DWORD dwEnabledOptions - ); - -private: - - VLCPlugin *_p_instance; -}; - -#endif +/***************************************************************************** + * objectsafety.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __OBJECTSAFETY_H__ +#define __OBJECTSAFETY_H__ + +#if HAVE_OBJSAFE_HEADER +/* +** at last, a version of mingw that supports this header +*/ +#include + +#else + +// {CB5BDC81-93C1-11cf-8F20-00805F2CD064} +extern "C" const IID IID_IObjectSafety; + +#define INTERFACESAFE_FOR_UNTRUSTED_CALLER 1L +#define INTERFACESAFE_FOR_UNTRUSTED_DATA 2L + +struct IObjectSafety : public IUnknown +{ + virtual STDMETHODIMP GetInterfaceSafetyOptions( + REFIID riid, + DWORD __RPC_FAR *pdwSupportedOptions, + DWORD __RPC_FAR *pdwEnabledOptions + ) = 0; + + virtual STDMETHODIMP SetInterfaceSafetyOptions( + REFIID riid, + DWORD dwSupportedOptions, + DWORD dwOptionSetMask + ) = 0; +}; + +#endif + +class VLCObjectSafety : public IObjectSafety +{ +public: + + VLCObjectSafety(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCObjectSafety() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IObjectSafety == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IUnknown methods + STDMETHODIMP GetInterfaceSafetyOptions( + REFIID riid, + DWORD *pdwSupportedOptions, + DWORD *pdwEnabledOptions + ); + + STDMETHODIMP SetInterfaceSafetyOptions( + REFIID riid, + DWORD dwOptionSetMask, + DWORD dwEnabledOptions + ); + +private: + + VLCPlugin *_p_instance; +}; + +#endif diff --git a/activex/olecontrol.cpp b/activex/olecontrol.cpp index 7dde4cc74b..832613d266 100644 --- a/activex/olecontrol.cpp +++ b/activex/olecontrol.cpp @@ -1,133 +1,133 @@ -/***************************************************************************** - * olecontrol.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "olecontrol.h" - -#include "utils.h" - -using namespace std; - -STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI) -{ - if( NULL == pCI ) - return E_POINTER; - - pCI->cb = sizeof(CONTROLINFO); - pCI->hAccel = NULL; - pCI->cAccel = 0; - pCI->dwFlags = 0; - - return S_OK; -}; - -STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg) -{ - return E_NOTIMPL; -}; - -static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v) -{ - HRESULT hr; - IOleObject *oleObj; - - hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj); - if( SUCCEEDED(hr) ) - { - IOleClientSite *clientSite; - - hr = oleObj->GetClientSite(&clientSite); - if( SUCCEEDED(hr) && (NULL != clientSite) ) - { - hr = GetObjectProperty(clientSite, dispID, v); - clientSite->Release(); - } - oleObj->Release(); - } - return hr; -}; - -STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID) -{ - switch( dispID ) - { - case DISPID_AMBIENT_BACKCOLOR: - break; - case DISPID_AMBIENT_DISPLAYNAME: - break; - case DISPID_AMBIENT_FONT: - break; - case DISPID_AMBIENT_FORECOLOR: - break; - case DISPID_AMBIENT_LOCALEID: - break; - case DISPID_AMBIENT_MESSAGEREFLECT: - break; - case DISPID_AMBIENT_SCALEUNITS: - break; - case DISPID_AMBIENT_TEXTALIGN: - break; - case DISPID_AMBIENT_USERMODE: - break; - case DISPID_AMBIENT_UIDEAD: - break; - case DISPID_AMBIENT_SHOWGRABHANDLES: - break; - case DISPID_AMBIENT_SHOWHATCHING: - break; - case DISPID_AMBIENT_DISPLAYASDEFAULT: - break; - case DISPID_AMBIENT_SUPPORTSMNEMONICS: - break; - case DISPID_AMBIENT_AUTOCLIP: - break; - case DISPID_AMBIENT_APPEARANCE: - break; - case DISPID_AMBIENT_CODEPAGE: - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_I4; - if( SUCCEEDED(getAmbientProperty(*_p_instance, dispID, v)) ) - { - _p_instance->setCodePage(V_I4(&v)); - } - break; - case DISPID_AMBIENT_PALETTE: - break; - case DISPID_AMBIENT_CHARSET: - break; - case DISPID_AMBIENT_RIGHTTOLEFT: - break; - case DISPID_AMBIENT_TOPTOBOTTOM: - break; - default: - break; - } - return S_OK; -}; - -STDMETHODIMP VLCOleControl::FreezeEvents(BOOL bFreeze) -{ - _p_instance->setSendEvents(! bFreeze); - return S_OK; -}; - +/***************************************************************************** + * olecontrol.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "olecontrol.h" + +#include "utils.h" + +using namespace std; + +STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI) +{ + if( NULL == pCI ) + return E_POINTER; + + pCI->cb = sizeof(CONTROLINFO); + pCI->hAccel = NULL; + pCI->cAccel = 0; + pCI->dwFlags = 0; + + return S_OK; +}; + +STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg) +{ + return E_NOTIMPL; +}; + +static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v) +{ + HRESULT hr; + IOleObject *oleObj; + + hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj); + if( SUCCEEDED(hr) ) + { + IOleClientSite *clientSite; + + hr = oleObj->GetClientSite(&clientSite); + if( SUCCEEDED(hr) && (NULL != clientSite) ) + { + hr = GetObjectProperty(clientSite, dispID, v); + clientSite->Release(); + } + oleObj->Release(); + } + return hr; +}; + +STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID) +{ + switch( dispID ) + { + case DISPID_AMBIENT_BACKCOLOR: + break; + case DISPID_AMBIENT_DISPLAYNAME: + break; + case DISPID_AMBIENT_FONT: + break; + case DISPID_AMBIENT_FORECOLOR: + break; + case DISPID_AMBIENT_LOCALEID: + break; + case DISPID_AMBIENT_MESSAGEREFLECT: + break; + case DISPID_AMBIENT_SCALEUNITS: + break; + case DISPID_AMBIENT_TEXTALIGN: + break; + case DISPID_AMBIENT_USERMODE: + break; + case DISPID_AMBIENT_UIDEAD: + break; + case DISPID_AMBIENT_SHOWGRABHANDLES: + break; + case DISPID_AMBIENT_SHOWHATCHING: + break; + case DISPID_AMBIENT_DISPLAYASDEFAULT: + break; + case DISPID_AMBIENT_SUPPORTSMNEMONICS: + break; + case DISPID_AMBIENT_AUTOCLIP: + break; + case DISPID_AMBIENT_APPEARANCE: + break; + case DISPID_AMBIENT_CODEPAGE: + VARIANT v; + VariantInit(&v); + V_VT(&v) = VT_I4; + if( SUCCEEDED(getAmbientProperty(*_p_instance, dispID, v)) ) + { + _p_instance->setCodePage(V_I4(&v)); + } + break; + case DISPID_AMBIENT_PALETTE: + break; + case DISPID_AMBIENT_CHARSET: + break; + case DISPID_AMBIENT_RIGHTTOLEFT: + break; + case DISPID_AMBIENT_TOPTOBOTTOM: + break; + default: + break; + } + return S_OK; +}; + +STDMETHODIMP VLCOleControl::FreezeEvents(BOOL bFreeze) +{ + _p_instance->setSendEvents(! bFreeze); + return S_OK; +}; + diff --git a/activex/olecontrol.h b/activex/olecontrol.h index 7173105b15..b1603eed8d 100644 --- a/activex/olecontrol.h +++ b/activex/olecontrol.h @@ -1,65 +1,65 @@ -/***************************************************************************** - * olecontrol.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __OLECONTROL_H__ -#define __OLECONTROL_H__ - -#include - -class VLCOleControl : public IOleControl -{ - -public: - - VLCOleControl(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCOleControl() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IOleControl == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IOleControl methods - STDMETHODIMP GetControlInfo(CONTROLINFO *pCI); - STDMETHODIMP OnMnemonic(LPMSG pMsg); - STDMETHODIMP OnAmbientPropertyChange(DISPID dispID); - STDMETHODIMP FreezeEvents(BOOL bFreeze); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * olecontrol.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __OLECONTROL_H__ +#define __OLECONTROL_H__ + +#include + +class VLCOleControl : public IOleControl +{ + +public: + + VLCOleControl(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCOleControl() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IOleControl == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IOleControl methods + STDMETHODIMP GetControlInfo(CONTROLINFO *pCI); + STDMETHODIMP OnMnemonic(LPMSG pMsg); + STDMETHODIMP OnAmbientPropertyChange(DISPID dispID); + STDMETHODIMP FreezeEvents(BOOL bFreeze); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/oleinplaceactiveobject.cpp b/activex/oleinplaceactiveobject.cpp index 4239a4d1f5..fcd7f4d664 100644 --- a/activex/oleinplaceactiveobject.cpp +++ b/activex/oleinplaceactiveobject.cpp @@ -1,74 +1,74 @@ -/***************************************************************************** - * oleinplaceactiveobject.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "oleinplaceactiveobject.h" - -using namespace std; - -STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd) -{ - if( NULL == pHwnd ) - return E_INVALIDARG; - - if( _p_instance->isInPlaceActive() ) - { - if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) ) - return S_OK; - - return E_FAIL; - } - *pHwnd = NULL; - - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::TranslateAccelerator(LPMSG lpmsg) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceActiveObject::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow) -{ - return E_NOTIMPL; -}; - +/***************************************************************************** + * oleinplaceactiveobject.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "oleinplaceactiveobject.h" + +using namespace std; + +STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd) +{ + if( NULL == pHwnd ) + return E_INVALIDARG; + + if( _p_instance->isInPlaceActive() ) + { + if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) ) + return S_OK; + + return E_FAIL; + } + *pHwnd = NULL; + + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::TranslateAccelerator(LPMSG lpmsg) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceActiveObject::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow) +{ + return E_NOTIMPL; +}; + diff --git a/activex/oleinplaceactiveobject.h b/activex/oleinplaceactiveobject.h index 267e9d27e4..0b3ead3723 100644 --- a/activex/oleinplaceactiveobject.h +++ b/activex/oleinplaceactiveobject.h @@ -1,71 +1,71 @@ -/***************************************************************************** - * oleinplaceactiveobject.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __OLEINPLACEACTIVEOBJECT_H__ -#define __OLEINPLACEACTIVEOBJECT_H__ - -#include "oleidl.h" - -class VLCOleInPlaceActiveObject : public IOleInPlaceActiveObject -{ - -public: - - VLCOleInPlaceActiveObject(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCOleInPlaceActiveObject() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IOleWindow == riid) - && (IID_IOleInPlaceActiveObject == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IOleWindow methods - STDMETHODIMP GetWindow(HWND *); - STDMETHODIMP ContextSensitiveHelp(BOOL); - - // IOleInPlaceActiveObject methods - STDMETHODIMP EnableModeless(BOOL); - STDMETHODIMP TranslateAccelerator(LPMSG); - STDMETHODIMP OnFrameWindowActivate(BOOL); - STDMETHODIMP OnDocWindowActivate(BOOL); - STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * oleinplaceactiveobject.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __OLEINPLACEACTIVEOBJECT_H__ +#define __OLEINPLACEACTIVEOBJECT_H__ + +#include "oleidl.h" + +class VLCOleInPlaceActiveObject : public IOleInPlaceActiveObject +{ + +public: + + VLCOleInPlaceActiveObject(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCOleInPlaceActiveObject() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IOleWindow == riid) + && (IID_IOleInPlaceActiveObject == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IOleWindow methods + STDMETHODIMP GetWindow(HWND *); + STDMETHODIMP ContextSensitiveHelp(BOOL); + + // IOleInPlaceActiveObject methods + STDMETHODIMP EnableModeless(BOOL); + STDMETHODIMP TranslateAccelerator(LPMSG); + STDMETHODIMP OnFrameWindowActivate(BOOL); + STDMETHODIMP OnDocWindowActivate(BOOL); + STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/oleinplaceobject.cpp b/activex/oleinplaceobject.cpp index 97db7231e8..80c4a519b3 100644 --- a/activex/oleinplaceobject.cpp +++ b/activex/oleinplaceobject.cpp @@ -1,126 +1,126 @@ -/***************************************************************************** - * oleinplaceobject.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "oleinplaceobject.h" - -#include - -using namespace std; - -STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd) -{ - if( NULL == pHwnd ) - return E_INVALIDARG; - - if( _p_instance->isInPlaceActive() ) - { - if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) ) - return S_OK; - - return E_FAIL; - } - *pHwnd = NULL; - - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void) -{ - if( _p_instance->isInPlaceActive() ) - { - UIDeactivate(); - _p_instance->onInPlaceDeactivate(); - - LPOLEOBJECT p_oleObject; - if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) - { - LPOLECLIENTSITE p_clientSite; - if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) ) - { - LPOLEINPLACESITE p_inPlaceSite; - - if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) - { - p_inPlaceSite->OnInPlaceDeactivate(); - p_inPlaceSite->Release(); - } - p_clientSite->Release(); - } - p_oleObject->Release(); - } - return S_OK; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void) -{ - if( _p_instance->isInPlaceActive() ) - { - if( _p_instance->hasFocus() ) - { - _p_instance->setFocus(FALSE); - - LPOLEOBJECT p_oleObject; - if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) - { - LPOLECLIENTSITE p_clientSite; - if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) ) - { - LPOLEINPLACESITE p_inPlaceSite; - - if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) - { - p_inPlaceSite->OnUIDeactivate(FALSE); - p_inPlaceSite->Release(); - } - p_clientSite->Release(); - } - p_oleObject->Release(); - } - return S_OK; - } - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect) -{ - if( _p_instance->isInPlaceActive() ) - { - _p_instance->onPositionChange(lprcPosRect, lprcClipRect); - return S_OK; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void) -{ - return INPLACE_E_NOTUNDOABLE; -}; - +/***************************************************************************** + * oleinplaceobject.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "oleinplaceobject.h" + +#include + +using namespace std; + +STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd) +{ + if( NULL == pHwnd ) + return E_INVALIDARG; + + if( _p_instance->isInPlaceActive() ) + { + if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) ) + return S_OK; + + return E_FAIL; + } + *pHwnd = NULL; + + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void) +{ + if( _p_instance->isInPlaceActive() ) + { + UIDeactivate(); + _p_instance->onInPlaceDeactivate(); + + LPOLEOBJECT p_oleObject; + if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) + { + LPOLECLIENTSITE p_clientSite; + if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) ) + { + LPOLEINPLACESITE p_inPlaceSite; + + if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) + { + p_inPlaceSite->OnInPlaceDeactivate(); + p_inPlaceSite->Release(); + } + p_clientSite->Release(); + } + p_oleObject->Release(); + } + return S_OK; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void) +{ + if( _p_instance->isInPlaceActive() ) + { + if( _p_instance->hasFocus() ) + { + _p_instance->setFocus(FALSE); + + LPOLEOBJECT p_oleObject; + if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) + { + LPOLECLIENTSITE p_clientSite; + if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) ) + { + LPOLEINPLACESITE p_inPlaceSite; + + if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) + { + p_inPlaceSite->OnUIDeactivate(FALSE); + p_inPlaceSite->Release(); + } + p_clientSite->Release(); + } + p_oleObject->Release(); + } + return S_OK; + } + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect) +{ + if( _p_instance->isInPlaceActive() ) + { + _p_instance->onPositionChange(lprcPosRect, lprcClipRect); + return S_OK; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void) +{ + return INPLACE_E_NOTUNDOABLE; +}; + diff --git a/activex/oleinplaceobject.h b/activex/oleinplaceobject.h index 96a91f81e4..4061d9af9e 100644 --- a/activex/oleinplaceobject.h +++ b/activex/oleinplaceobject.h @@ -1,68 +1,68 @@ -/***************************************************************************** - * oleinplaceobject.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __OLEINPLACEOBJECT_H__ -#define __OLEINPLACEOBJECT_H__ - -class VLCOleInPlaceObject : public IOleInPlaceObject -{ - -public: - - VLCOleInPlaceObject(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCOleInPlaceObject() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IOleWindow == riid) - && (IID_IOleInPlaceObject == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IOleWindow methods - STDMETHODIMP GetWindow(HWND *); - STDMETHODIMP ContextSensitiveHelp(BOOL); - - // IOleInPlaceObject methods - STDMETHODIMP InPlaceDeactivate(void); - STDMETHODIMP UIDeactivate(void); - STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT); - STDMETHODIMP ReactivateAndUndo(void); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * oleinplaceobject.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __OLEINPLACEOBJECT_H__ +#define __OLEINPLACEOBJECT_H__ + +class VLCOleInPlaceObject : public IOleInPlaceObject +{ + +public: + + VLCOleInPlaceObject(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCOleInPlaceObject() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IOleWindow == riid) + && (IID_IOleInPlaceObject == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IOleWindow methods + STDMETHODIMP GetWindow(HWND *); + STDMETHODIMP ContextSensitiveHelp(BOOL); + + // IOleInPlaceObject methods + STDMETHODIMP InPlaceDeactivate(void); + STDMETHODIMP UIDeactivate(void); + STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT); + STDMETHODIMP ReactivateAndUndo(void); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/oleobject.cpp b/activex/oleobject.cpp index 750ac3ab5f..217af46d44 100644 --- a/activex/oleobject.cpp +++ b/activex/oleobject.cpp @@ -1,339 +1,339 @@ -/***************************************************************************** - * oleobject.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "oleobject.h" - -#include "utils.h" - -#include - -using namespace std; - -VLCOleObject::VLCOleObject(VLCPlugin *p_instance) : -_p_clientsite(NULL), _p_instance(p_instance) -{ - CreateOleAdviseHolder(&_p_advise_holder); -}; - -VLCOleObject::~VLCOleObject() -{ - _p_advise_holder->Release(); - SetClientSite(NULL); -}; - -STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection) -{ - return _p_advise_holder->Advise(pAdvSink, dwConnection); -}; - -STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption) -{ - _p_advise_holder->SendOnClose(); - OleFlushClipboard(); - return _p_instance->onClose(dwSaveOption); -}; - -STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, - LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect) -{ - if( 0 != lIndex ) - return DV_E_LINDEX; - - switch( iVerb ) - { - case OLEIVERB_PRIMARY: - case OLEIVERB_SHOW: - case OLEIVERB_OPEN: - case OLEIVERB_INPLACEACTIVATE: - if( NULL == hwndParent ) - return OLEOBJ_S_INVALIDHWND; - - if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) ) - return S_OK; - - return OLEOBJ_S_CANNOT_DOVERB_NOW; - - case OLEIVERB_HIDE: - _p_instance->setVisible(FALSE); - return S_OK; - - case OLEIVERB_UIACTIVATE: - return doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); - - case OLEIVERB_DISCARDUNDOSTATE: - return S_OK; - - default: - if( NULL == hwndParent ) - return OLEOBJ_S_INVALIDHWND; - - if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) ) - return OLEOBJ_S_INVALIDVERB; - - return OLEOBJ_S_CANNOT_DOVERB_NOW; - } -}; - -HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) -{ - RECT posRect; - RECT clipRect; - LPCRECT lprcClipRect = lprcPosRect; - - if( NULL != pActiveSite ) - { - // check if already activated - if( _p_instance->isInPlaceActive() ) - { - // just attempt to show object then - pActiveSite->ShowObject(); - _p_instance->setVisible(TRUE); - return S_OK; - } - - LPOLEINPLACESITE p_inPlaceSite; - - if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) - { - if( S_OK != p_inPlaceSite->CanInPlaceActivate() ) - return E_FAIL; - - LPOLEINPLACEFRAME p_inPlaceFrame; - LPOLEINPLACEUIWINDOW p_inPlaceUIWindow; - OLEINPLACEFRAMEINFO oleFrameInfo; - - if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) ) - { - lprcPosRect = &posRect; - lprcClipRect = &clipRect; - - if( NULL != p_inPlaceFrame ) - p_inPlaceFrame->Release(); - if( NULL != p_inPlaceUIWindow ) - p_inPlaceUIWindow->Release(); - } - } - - if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) ) - return E_FAIL; - - if( NULL != p_inPlaceSite ) - p_inPlaceSite->OnPosRectChange(lprcPosRect); - - pActiveSite->ShowObject(); - _p_instance->setVisible(TRUE); - - if( NULL != p_inPlaceSite ) - { - p_inPlaceSite->OnInPlaceActivate(); - p_inPlaceSite->Release(); - } - - if( NULL != lpMsg ) - { - switch( lpMsg->message ) - { - case WM_LBUTTONDOWN: - case WM_LBUTTONDBLCLK: - doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); - break; - default: - break; - } - } - return S_OK; - } - return E_FAIL; -}; - -HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) -{ - if( NULL != pActiveSite ) - { - // check if already activated - if( ! _p_instance->isInPlaceActive() ) - return OLE_E_NOT_INPLACEACTIVE; - - LPOLEINPLACESITE p_inPlaceSite; - - if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) - { - p_inPlaceSite->OnUIActivate(); - - if( NULL != lprcPosRect ) - { - p_inPlaceSite->OnPosRectChange(lprcPosRect); - } - p_inPlaceSite->Release(); - } - - pActiveSite->ShowObject(); - _p_instance->setVisible(TRUE); - _p_instance->setFocus(TRUE); - - return S_OK; - } - return E_FAIL; -}; - -STDMETHODIMP VLCOleObject::EnumAdvise(IEnumSTATDATA **ppEnumAdvise) -{ - return _p_advise_holder->EnumAdvise(ppEnumAdvise); -}; - -STDMETHODIMP VLCOleObject::EnumVerbs(IEnumOleVerb **ppEnumOleVerb) -{ - return OLE_S_USEREG; -}; - -STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite) -{ - if( NULL == ppClientSite ) - return E_POINTER; - - if( NULL != _p_clientsite ) - _p_clientsite->AddRef(); - - *ppClientSite= _p_clientsite; - return S_OK; -}; - -STDMETHODIMP VLCOleObject::GetClipboardData(DWORD dwReserved, LPDATAOBJECT *ppDataObject) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleObject::GetExtent(DWORD dwDrawAspect, SIZEL *pSizel) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleObject::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus) -{ - if( NULL != pdwStatus ) - return E_POINTER; - - switch( dwAspect ) - { - case DVASPECT_CONTENT: - *pdwStatus = OLEMISC_RECOMPOSEONRESIZE - | OLEMISC_CANTLINKINSIDE - | OLEMISC_INSIDEOUT - | OLEMISC_ACTIVATEWHENVISIBLE - | OLEMISC_SETCLIENTSITEFIRST; - break; - default: - *pdwStatus = 0; - } - - return S_OK; -}; - -STDMETHODIMP VLCOleObject::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER *ppMoniker) -{ - if( NULL != _p_clientsite ) - return _p_clientsite->GetMoniker(dwAssign,dwWhichMoniker, ppMoniker); - - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCOleObject::GetUserClassID(LPCLSID pClsid) -{ - if( NULL == pClsid ) - return E_POINTER; - - pClsid = const_cast(&_p_instance->getClassID()); - return S_OK; -}; - -STDMETHODIMP VLCOleObject::GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType) -{ - return OLE_S_USEREG; -}; - -STDMETHODIMP VLCOleObject::InitFromData(LPDATAOBJECT pDataObject, BOOL fCreation, DWORD dwReserved) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleObject::IsUpToDate(void) -{ - return S_OK; -}; - -STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite) -{ - if( NULL != _p_clientsite ) - _p_clientsite->Release(); - - if( NULL != pClientSite ) - { - pClientSite->AddRef(); - - /* - ** retrieve container ambient properties - */ - VARIANT v; - VariantInit(&v); - V_VT(&v) = VT_I4; - if( SUCCEEDED(GetObjectProperty(pClientSite, DISPID_AMBIENT_CODEPAGE, v)) ) - { - _p_instance->setCodePage(V_I4(&v)); - VariantClear(&v); - } - } - - _p_clientsite = pClientSite; - return S_OK; -}; - -STDMETHODIMP VLCOleObject::SetColorScheme(LOGPALETTE *pLogpal) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel) -{ - return E_NOTIMPL; -}; - -STDMETHODIMP VLCOleObject::SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj) -{ - return S_OK; -}; - -STDMETHODIMP VLCOleObject::SetMoniker(DWORD dwWhichMoniker, LPMONIKER pMoniker) -{ - return _p_advise_holder->SendOnRename(pMoniker); -}; - -STDMETHODIMP VLCOleObject::Unadvise(DWORD dwConnection) -{ - return _p_advise_holder->Unadvise(dwConnection); -}; - -STDMETHODIMP VLCOleObject::Update(void) -{ - return S_OK; -}; - +/***************************************************************************** + * oleobject.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "oleobject.h" + +#include "utils.h" + +#include + +using namespace std; + +VLCOleObject::VLCOleObject(VLCPlugin *p_instance) : +_p_clientsite(NULL), _p_instance(p_instance) +{ + CreateOleAdviseHolder(&_p_advise_holder); +}; + +VLCOleObject::~VLCOleObject() +{ + _p_advise_holder->Release(); + SetClientSite(NULL); +}; + +STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection) +{ + return _p_advise_holder->Advise(pAdvSink, dwConnection); +}; + +STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption) +{ + _p_advise_holder->SendOnClose(); + OleFlushClipboard(); + return _p_instance->onClose(dwSaveOption); +}; + +STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, + LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect) +{ + if( 0 != lIndex ) + return DV_E_LINDEX; + + switch( iVerb ) + { + case OLEIVERB_PRIMARY: + case OLEIVERB_SHOW: + case OLEIVERB_OPEN: + case OLEIVERB_INPLACEACTIVATE: + if( NULL == hwndParent ) + return OLEOBJ_S_INVALIDHWND; + + if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) ) + return S_OK; + + return OLEOBJ_S_CANNOT_DOVERB_NOW; + + case OLEIVERB_HIDE: + _p_instance->setVisible(FALSE); + return S_OK; + + case OLEIVERB_UIACTIVATE: + return doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); + + case OLEIVERB_DISCARDUNDOSTATE: + return S_OK; + + default: + if( NULL == hwndParent ) + return OLEOBJ_S_INVALIDHWND; + + if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) ) + return OLEOBJ_S_INVALIDVERB; + + return OLEOBJ_S_CANNOT_DOVERB_NOW; + } +}; + +HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) +{ + RECT posRect; + RECT clipRect; + LPCRECT lprcClipRect = lprcPosRect; + + if( NULL != pActiveSite ) + { + // check if already activated + if( _p_instance->isInPlaceActive() ) + { + // just attempt to show object then + pActiveSite->ShowObject(); + _p_instance->setVisible(TRUE); + return S_OK; + } + + LPOLEINPLACESITE p_inPlaceSite; + + if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) + { + if( S_OK != p_inPlaceSite->CanInPlaceActivate() ) + return E_FAIL; + + LPOLEINPLACEFRAME p_inPlaceFrame; + LPOLEINPLACEUIWINDOW p_inPlaceUIWindow; + OLEINPLACEFRAMEINFO oleFrameInfo; + + if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) ) + { + lprcPosRect = &posRect; + lprcClipRect = &clipRect; + + if( NULL != p_inPlaceFrame ) + p_inPlaceFrame->Release(); + if( NULL != p_inPlaceUIWindow ) + p_inPlaceUIWindow->Release(); + } + } + + if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) ) + return E_FAIL; + + if( NULL != p_inPlaceSite ) + p_inPlaceSite->OnPosRectChange(lprcPosRect); + + pActiveSite->ShowObject(); + _p_instance->setVisible(TRUE); + + if( NULL != p_inPlaceSite ) + { + p_inPlaceSite->OnInPlaceActivate(); + p_inPlaceSite->Release(); + } + + if( NULL != lpMsg ) + { + switch( lpMsg->message ) + { + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect); + break; + default: + break; + } + } + return S_OK; + } + return E_FAIL; +}; + +HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect) +{ + if( NULL != pActiveSite ) + { + // check if already activated + if( ! _p_instance->isInPlaceActive() ) + return OLE_E_NOT_INPLACEACTIVE; + + LPOLEINPLACESITE p_inPlaceSite; + + if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) + { + p_inPlaceSite->OnUIActivate(); + + if( NULL != lprcPosRect ) + { + p_inPlaceSite->OnPosRectChange(lprcPosRect); + } + p_inPlaceSite->Release(); + } + + pActiveSite->ShowObject(); + _p_instance->setVisible(TRUE); + _p_instance->setFocus(TRUE); + + return S_OK; + } + return E_FAIL; +}; + +STDMETHODIMP VLCOleObject::EnumAdvise(IEnumSTATDATA **ppEnumAdvise) +{ + return _p_advise_holder->EnumAdvise(ppEnumAdvise); +}; + +STDMETHODIMP VLCOleObject::EnumVerbs(IEnumOleVerb **ppEnumOleVerb) +{ + return OLE_S_USEREG; +}; + +STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite) +{ + if( NULL == ppClientSite ) + return E_POINTER; + + if( NULL != _p_clientsite ) + _p_clientsite->AddRef(); + + *ppClientSite= _p_clientsite; + return S_OK; +}; + +STDMETHODIMP VLCOleObject::GetClipboardData(DWORD dwReserved, LPDATAOBJECT *ppDataObject) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleObject::GetExtent(DWORD dwDrawAspect, SIZEL *pSizel) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleObject::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus) +{ + if( NULL != pdwStatus ) + return E_POINTER; + + switch( dwAspect ) + { + case DVASPECT_CONTENT: + *pdwStatus = OLEMISC_RECOMPOSEONRESIZE + | OLEMISC_CANTLINKINSIDE + | OLEMISC_INSIDEOUT + | OLEMISC_ACTIVATEWHENVISIBLE + | OLEMISC_SETCLIENTSITEFIRST; + break; + default: + *pdwStatus = 0; + } + + return S_OK; +}; + +STDMETHODIMP VLCOleObject::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER *ppMoniker) +{ + if( NULL != _p_clientsite ) + return _p_clientsite->GetMoniker(dwAssign,dwWhichMoniker, ppMoniker); + + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCOleObject::GetUserClassID(LPCLSID pClsid) +{ + if( NULL == pClsid ) + return E_POINTER; + + pClsid = const_cast(&_p_instance->getClassID()); + return S_OK; +}; + +STDMETHODIMP VLCOleObject::GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType) +{ + return OLE_S_USEREG; +}; + +STDMETHODIMP VLCOleObject::InitFromData(LPDATAOBJECT pDataObject, BOOL fCreation, DWORD dwReserved) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleObject::IsUpToDate(void) +{ + return S_OK; +}; + +STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite) +{ + if( NULL != _p_clientsite ) + _p_clientsite->Release(); + + if( NULL != pClientSite ) + { + pClientSite->AddRef(); + + /* + ** retrieve container ambient properties + */ + VARIANT v; + VariantInit(&v); + V_VT(&v) = VT_I4; + if( SUCCEEDED(GetObjectProperty(pClientSite, DISPID_AMBIENT_CODEPAGE, v)) ) + { + _p_instance->setCodePage(V_I4(&v)); + VariantClear(&v); + } + } + + _p_clientsite = pClientSite; + return S_OK; +}; + +STDMETHODIMP VLCOleObject::SetColorScheme(LOGPALETTE *pLogpal) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel) +{ + return E_NOTIMPL; +}; + +STDMETHODIMP VLCOleObject::SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj) +{ + return S_OK; +}; + +STDMETHODIMP VLCOleObject::SetMoniker(DWORD dwWhichMoniker, LPMONIKER pMoniker) +{ + return _p_advise_holder->SendOnRename(pMoniker); +}; + +STDMETHODIMP VLCOleObject::Unadvise(DWORD dwConnection) +{ + return _p_advise_holder->Unadvise(dwConnection); +}; + +STDMETHODIMP VLCOleObject::Update(void) +{ + return S_OK; +}; + diff --git a/activex/oleobject.h b/activex/oleobject.h index 428e7f1dce..e122542081 100644 --- a/activex/oleobject.h +++ b/activex/oleobject.h @@ -1,86 +1,86 @@ -/***************************************************************************** - * oleobject.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __OLEOBJECT_H__ -#define __OLEOBJECT_H__ - -class VLCOleObject : public IOleObject -{ - -public: - - VLCOleObject(VLCPlugin *p_instance); - virtual ~VLCOleObject(); - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IOleObject == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IOleObject methods - STDMETHODIMP Advise(IAdviseSink *, LPDWORD); - STDMETHODIMP Close(DWORD); - STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT); - STDMETHODIMP EnumAdvise(IEnumSTATDATA **); - STDMETHODIMP EnumVerbs(IEnumOleVerb **); - STDMETHODIMP GetClientSite(LPOLECLIENTSITE *); - STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *); - STDMETHODIMP GetExtent(DWORD, SIZEL *); - STDMETHODIMP GetMiscStatus(DWORD, DWORD *); - STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *); - STDMETHODIMP GetUserClassID(CLSID *); - STDMETHODIMP GetUserType(DWORD, LPOLESTR *); - STDMETHODIMP InitFromData(IDataObject *, BOOL, DWORD); - STDMETHODIMP IsUpToDate(void); - STDMETHODIMP SetClientSite(LPOLECLIENTSITE); - STDMETHODIMP SetColorScheme(LOGPALETTE *); - STDMETHODIMP SetExtent(DWORD, SIZEL *); - STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR) ; - STDMETHODIMP SetMoniker(DWORD, LPMONIKER); - STDMETHODIMP Unadvise(DWORD); - STDMETHODIMP Update(void); - -private: - - HRESULT doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect); - HRESULT doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect); - - IOleAdviseHolder *_p_advise_holder; - IOleClientSite *_p_clientsite; - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * oleobject.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __OLEOBJECT_H__ +#define __OLEOBJECT_H__ + +class VLCOleObject : public IOleObject +{ + +public: + + VLCOleObject(VLCPlugin *p_instance); + virtual ~VLCOleObject(); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IOleObject == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IOleObject methods + STDMETHODIMP Advise(IAdviseSink *, LPDWORD); + STDMETHODIMP Close(DWORD); + STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT); + STDMETHODIMP EnumAdvise(IEnumSTATDATA **); + STDMETHODIMP EnumVerbs(IEnumOleVerb **); + STDMETHODIMP GetClientSite(LPOLECLIENTSITE *); + STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *); + STDMETHODIMP GetExtent(DWORD, SIZEL *); + STDMETHODIMP GetMiscStatus(DWORD, DWORD *); + STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *); + STDMETHODIMP GetUserClassID(CLSID *); + STDMETHODIMP GetUserType(DWORD, LPOLESTR *); + STDMETHODIMP InitFromData(IDataObject *, BOOL, DWORD); + STDMETHODIMP IsUpToDate(void); + STDMETHODIMP SetClientSite(LPOLECLIENTSITE); + STDMETHODIMP SetColorScheme(LOGPALETTE *); + STDMETHODIMP SetExtent(DWORD, SIZEL *); + STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR) ; + STDMETHODIMP SetMoniker(DWORD, LPMONIKER); + STDMETHODIMP Unadvise(DWORD); + STDMETHODIMP Update(void); + +private: + + HRESULT doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect); + HRESULT doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect); + + IOleAdviseHolder *_p_advise_holder; + IOleClientSite *_p_clientsite; + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/persistpropbag.cpp b/activex/persistpropbag.cpp index 2f13ada717..e1fb0ab75b 100644 --- a/activex/persistpropbag.cpp +++ b/activex/persistpropbag.cpp @@ -1,125 +1,125 @@ -/***************************************************************************** - * persistpropbag.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "persistpropbag.h" - -#include "utils.h" - -using namespace std; - -STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID) -{ - if( NULL == pClsID ) - return E_POINTER; - - *pClsID = _p_instance->getClassID(); - - return S_OK; -}; - -STDMETHODIMP VLCPersistPropertyBag::InitNew(void) -{ - return _p_instance->onInitNew(); -}; - -STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog) -{ - if( NULL == pPropBag ) - return E_POINTER; - - HRESULT hr = _p_instance->onInitNew(); - if( FAILED(hr) ) - return hr; - - VARIANT value; - - V_VT(&value) = VT_BSTR; - if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) ) - { - char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value)); - if( NULL != src ) - { - _p_instance->setSourceURL(src); - free(src); - } - VariantClear(&value); - } - - V_VT(&value) = VT_BSTR; - if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) ) - { - char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value)); - if( NULL != src ) - { - _p_instance->setSourceURL(src); - free(src); - } - VariantClear(&value); - } - - V_VT(&value) = VT_BOOL; - if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) ) - { - _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE); - VariantClear(&value); - } - - V_VT(&value) = VT_BOOL; - if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) ) - { - _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE); - VariantClear(&value); - } - - V_VT(&value) = VT_BOOL; - if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) ) - { - _p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE); - VariantClear(&value); - } - - V_VT(&value) = VT_BOOL; - if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) ) - { - _p_instance->setMute(V_BOOL(&value) != VARIANT_FALSE); - VariantClear(&value); - } - - V_VT(&value) = VT_BOOL; - if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) ) - { - _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE); - VariantClear(&value); - } - - return S_OK; -}; - -STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties) -{ - if( NULL == pPropBag ) - return E_POINTER; - - return S_OK; -}; - +/***************************************************************************** + * persistpropbag.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "persistpropbag.h" + +#include "utils.h" + +using namespace std; + +STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID) +{ + if( NULL == pClsID ) + return E_POINTER; + + *pClsID = _p_instance->getClassID(); + + return S_OK; +}; + +STDMETHODIMP VLCPersistPropertyBag::InitNew(void) +{ + return _p_instance->onInitNew(); +}; + +STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog) +{ + if( NULL == pPropBag ) + return E_POINTER; + + HRESULT hr = _p_instance->onInitNew(); + if( FAILED(hr) ) + return hr; + + VARIANT value; + + V_VT(&value) = VT_BSTR; + if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) ) + { + char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value)); + if( NULL != src ) + { + _p_instance->setSourceURL(src); + free(src); + } + VariantClear(&value); + } + + V_VT(&value) = VT_BSTR; + if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) ) + { + char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value)); + if( NULL != src ) + { + _p_instance->setSourceURL(src); + free(src); + } + VariantClear(&value); + } + + V_VT(&value) = VT_BOOL; + if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) ) + { + _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE); + VariantClear(&value); + } + + V_VT(&value) = VT_BOOL; + if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) ) + { + _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE); + VariantClear(&value); + } + + V_VT(&value) = VT_BOOL; + if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) ) + { + _p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE); + VariantClear(&value); + } + + V_VT(&value) = VT_BOOL; + if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) ) + { + _p_instance->setMute(V_BOOL(&value) != VARIANT_FALSE); + VariantClear(&value); + } + + V_VT(&value) = VT_BOOL; + if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) ) + { + _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE); + VariantClear(&value); + } + + return S_OK; +}; + +STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties) +{ + if( NULL == pPropBag ) + return E_POINTER; + + return S_OK; +}; + diff --git a/activex/persistpropbag.h b/activex/persistpropbag.h index c042547932..1e1b440646 100644 --- a/activex/persistpropbag.h +++ b/activex/persistpropbag.h @@ -1,67 +1,67 @@ -/***************************************************************************** - * persistpropbag.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __PERSISTPROPBAG_H__ -#define __PERSISTPROPBAG_H__ - -#include - -class VLCPersistPropertyBag : public IPersistPropertyBag -{ - -public: - - VLCPersistPropertyBag(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCPersistPropertyBag() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IPersist == riid) - && (IID_IPersistPropertyBag == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IPersist methods - STDMETHODIMP GetClassID(LPCLSID); - - // IPersistPropertyBag methods - STDMETHODIMP InitNew(void); - STDMETHODIMP Load(LPPROPERTYBAG, LPERRORLOG); - STDMETHODIMP Save(LPPROPERTYBAG, BOOL, BOOL); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * persistpropbag.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __PERSISTPROPBAG_H__ +#define __PERSISTPROPBAG_H__ + +#include + +class VLCPersistPropertyBag : public IPersistPropertyBag +{ + +public: + + VLCPersistPropertyBag(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCPersistPropertyBag() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IPersist == riid) + && (IID_IPersistPropertyBag == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IPersist methods + STDMETHODIMP GetClassID(LPCLSID); + + // IPersistPropertyBag methods + STDMETHODIMP InitNew(void); + STDMETHODIMP Load(LPPROPERTYBAG, LPERRORLOG); + STDMETHODIMP Save(LPPROPERTYBAG, BOOL, BOOL); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/persiststorage.cpp b/activex/persiststorage.cpp index b1bf657725..54b17ae9f6 100644 --- a/activex/persiststorage.cpp +++ b/activex/persiststorage.cpp @@ -1,79 +1,79 @@ -/***************************************************************************** - * persiststorage.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "persiststorage.h" - -using namespace std; - -STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID) -{ - if( NULL == pClsID ) - return E_POINTER; - - *pClsID = _p_instance->getClassID(); - - return S_OK; -}; - -STDMETHODIMP VLCPersistStorage::IsDirty(void) -{ - return S_FALSE; -}; - -STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg) -{ - if( NULL == pStg ) - return E_POINTER; - - return _p_instance->onInitNew(); -}; - -STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) -{ - if( NULL == pStg ) - return E_POINTER; - - return _p_instance->onInitNew(); -}; - -STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) -{ - if( NULL == pStg ) - return E_POINTER; - - return S_OK; -}; - -STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg) -{ - if( NULL == pStg ) - return E_POINTER; - - return S_OK; -}; - -STDMETHODIMP VLCPersistStorage::HandsOffStorage(void) -{ - return S_OK; -}; - +/***************************************************************************** + * persiststorage.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "persiststorage.h" + +using namespace std; + +STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID) +{ + if( NULL == pClsID ) + return E_POINTER; + + *pClsID = _p_instance->getClassID(); + + return S_OK; +}; + +STDMETHODIMP VLCPersistStorage::IsDirty(void) +{ + return S_FALSE; +}; + +STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg) +{ + if( NULL == pStg ) + return E_POINTER; + + return _p_instance->onInitNew(); +}; + +STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg) +{ + if( NULL == pStg ) + return E_POINTER; + + return _p_instance->onInitNew(); +}; + +STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad) +{ + if( NULL == pStg ) + return E_POINTER; + + return S_OK; +}; + +STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg) +{ + if( NULL == pStg ) + return E_POINTER; + + return S_OK; +}; + +STDMETHODIMP VLCPersistStorage::HandsOffStorage(void) +{ + return S_OK; +}; + diff --git a/activex/persiststorage.h b/activex/persiststorage.h index c20599a468..792a00f143 100644 --- a/activex/persiststorage.h +++ b/activex/persiststorage.h @@ -1,70 +1,70 @@ -/***************************************************************************** - * persiststorage.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __PERSISTSTORAGE_H__ -#define __PERSISTSTORAGE_H__ - -#include - -class VLCPersistStorage : public IPersistStorage -{ - -public: - - VLCPersistStorage(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCPersistStorage() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IPersist == riid) - && (IID_IPersistStorage == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IPersist methods - STDMETHODIMP GetClassID(LPCLSID); - - // IPersistStorage methods - STDMETHODIMP IsDirty(void); - STDMETHODIMP InitNew(IStorage *); - STDMETHODIMP Load(IStorage *); - STDMETHODIMP Save(IStorage *, BOOL); - STDMETHODIMP SaveCompleted(IStorage *); - STDMETHODIMP HandsOffStorage(void); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * persiststorage.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __PERSISTSTORAGE_H__ +#define __PERSISTSTORAGE_H__ + +#include + +class VLCPersistStorage : public IPersistStorage +{ + +public: + + VLCPersistStorage(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCPersistStorage() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IPersist == riid) + && (IID_IPersistStorage == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IPersist methods + STDMETHODIMP GetClassID(LPCLSID); + + // IPersistStorage methods + STDMETHODIMP IsDirty(void); + STDMETHODIMP InitNew(IStorage *); + STDMETHODIMP Load(IStorage *); + STDMETHODIMP Save(IStorage *, BOOL); + STDMETHODIMP SaveCompleted(IStorage *); + STDMETHODIMP HandsOffStorage(void); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/persiststreaminit.cpp b/activex/persiststreaminit.cpp index 421036f24c..4d2fd55d00 100644 --- a/activex/persiststreaminit.cpp +++ b/activex/persiststreaminit.cpp @@ -1,70 +1,70 @@ -/***************************************************************************** - * persiststreaminit.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "persiststreaminit.h" - -using namespace std; - -STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID) -{ - if( NULL == pClsID ) - return E_POINTER; - - *pClsID = _p_instance->getClassID(); - - return S_OK; -}; - -STDMETHODIMP VLCPersistStreamInit::InitNew(void) -{ - return _p_instance->onInitNew(); -}; - -STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm) -{ - if( NULL == pStm ) - return E_POINTER; - - return _p_instance->onInitNew(); -}; - -STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty) -{ - if( NULL == pStm ) - return E_POINTER; - - return S_OK; -}; - -STDMETHODIMP VLCPersistStreamInit::IsDirty(void) -{ - return S_FALSE; -}; - -STDMETHODIMP VLCPersistStreamInit::GetSizeMax(ULARGE_INTEGER *pcbSize) -{ - pcbSize->QuadPart = 0ULL; - - return S_OK; -}; - +/***************************************************************************** + * persiststreaminit.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "persiststreaminit.h" + +using namespace std; + +STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID) +{ + if( NULL == pClsID ) + return E_POINTER; + + *pClsID = _p_instance->getClassID(); + + return S_OK; +}; + +STDMETHODIMP VLCPersistStreamInit::InitNew(void) +{ + return _p_instance->onInitNew(); +}; + +STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm) +{ + if( NULL == pStm ) + return E_POINTER; + + return _p_instance->onInitNew(); +}; + +STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty) +{ + if( NULL == pStm ) + return E_POINTER; + + return S_OK; +}; + +STDMETHODIMP VLCPersistStreamInit::IsDirty(void) +{ + return S_FALSE; +}; + +STDMETHODIMP VLCPersistStreamInit::GetSizeMax(ULARGE_INTEGER *pcbSize) +{ + pcbSize->QuadPart = 0ULL; + + return S_OK; +}; + diff --git a/activex/persiststreaminit.h b/activex/persiststreaminit.h index bfead1b919..8d8cc934e4 100644 --- a/activex/persiststreaminit.h +++ b/activex/persiststreaminit.h @@ -1,69 +1,69 @@ -/***************************************************************************** - * persiststreaminit.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __PERSISTSTREAMINIT_H__ -#define __PERSISTSTREAMINIT_H__ - -#include - -class VLCPersistStreamInit : public IPersistStreamInit -{ - -public: - - VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCPersistStreamInit() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IPersist == riid) - && (IID_IPersistStreamInit == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IPersist methods - STDMETHODIMP GetClassID(LPCLSID); - - // IPersistStreamInit methods - STDMETHODIMP IsDirty(void); - STDMETHODIMP InitNew(void); - STDMETHODIMP Load(LPSTREAM); - STDMETHODIMP Save(LPSTREAM, BOOL); - STDMETHODIMP GetSizeMax(ULARGE_INTEGER *); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * persiststreaminit.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __PERSISTSTREAMINIT_H__ +#define __PERSISTSTREAMINIT_H__ + +#include + +class VLCPersistStreamInit : public IPersistStreamInit +{ + +public: + + VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCPersistStreamInit() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IPersist == riid) + && (IID_IPersistStreamInit == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IPersist methods + STDMETHODIMP GetClassID(LPCLSID); + + // IPersistStreamInit methods + STDMETHODIMP IsDirty(void); + STDMETHODIMP InitNew(void); + STDMETHODIMP Load(LPSTREAM); + STDMETHODIMP Save(LPSTREAM, BOOL); + STDMETHODIMP GetSizeMax(ULARGE_INTEGER *); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/plugin.cpp b/activex/plugin.cpp index e178b3aa5d..a419037bb3 100644 --- a/activex/plugin.cpp +++ b/activex/plugin.cpp @@ -1,774 +1,774 @@ -/***************************************************************************** - * plugin.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" - -#include "oleobject.h" -#include "olecontrol.h" -#include "oleinplaceobject.h" -#include "oleinplaceactiveobject.h" -#include "persistpropbag.h" -#include "persiststreaminit.h" -#include "persiststorage.h" -#include "provideclassinfo.h" -#include "connectioncontainer.h" -#include "objectsafety.h" -#include "vlccontrol.h" - -#include "utils.h" - -#include -#include - -using namespace std; - -//////////////////////////////////////////////////////////////////////// -//class factory - -// {E23FE9C6-778E-49d4-B537-38FCDE4887D8} -//const GUID CLSID_VLCPlugin = -// { 0xe23fe9c6, 0x778e, 0x49d4, { 0xb5, 0x37, 0x38, 0xfc, 0xde, 0x48, 0x87, 0xd8 } }; - -static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch( uMsg ) - { - case WM_ERASEBKGND: - return 1L; - - case WM_PAINT: - PAINTSTRUCT ps; - if( GetUpdateRect(hWnd, NULL, FALSE) ) - { - BeginPaint(hWnd, &ps); - EndPaint(hWnd, &ps); - } - return 0L; - - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } -}; - -static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - VLCPlugin *p_instance = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); - - switch( uMsg ) - { - case WM_ERASEBKGND: - return 1L; - - case WM_PAINT: - PAINTSTRUCT ps; - RECT pr; - if( GetUpdateRect(hWnd, &pr, FALSE) ) - { - BeginPaint(hWnd, &ps); - p_instance->onPaint(ps, pr); - EndPaint(hWnd, &ps); - } - return 0L; - - default: - return DefWindowProc(hWnd, uMsg, wParam, lParam); - } -}; - -VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) : - _p_class_ref(p_class_ref), - _hinstance(hInstance) -{ - WNDCLASS wClass; - - if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) ) - { - wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS; - wClass.lpfnWndProc = VLCInPlaceClassWndProc; - wClass.cbClsExtra = 0; - wClass.cbWndExtra = 0; - wClass.hInstance = hInstance; - wClass.hIcon = NULL; - wClass.hCursor = LoadCursor(NULL, IDC_ARROW); - wClass.hbrBackground = NULL; - wClass.lpszMenuName = NULL; - wClass.lpszClassName = getInPlaceWndClassName(); - - _inplace_wndclass_atom = RegisterClass(&wClass); - } - else - { - _inplace_wndclass_atom = 0; - } - - if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) ) - { - wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW; - wClass.lpfnWndProc = VLCVideoClassWndProc; - wClass.cbClsExtra = 0; - wClass.cbWndExtra = 0; - wClass.hInstance = hInstance; - wClass.hIcon = NULL; - wClass.hCursor = LoadCursor(NULL, IDC_ARROW); - wClass.hbrBackground = NULL; - wClass.lpszMenuName = NULL; - wClass.lpszClassName = getVideoWndClassName(); - - _video_wndclass_atom = RegisterClass(&wClass); - } - else - { - _video_wndclass_atom = 0; - } - - _inplace_hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); - - AddRef(); -}; - -VLCPluginClass::~VLCPluginClass() -{ - if( 0 != _inplace_wndclass_atom ) - UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance); - - if( 0 != _video_wndclass_atom ) - UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance); - - if( NULL != _inplace_hbitmap ) - DeleteObject(_inplace_hbitmap); -}; - -STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv) -{ - if( NULL == ppv ) - return E_INVALIDARG; - - if( (IID_IUnknown == riid) || (IID_IClassFactory == riid) ) - { - AddRef(); - *ppv = reinterpret_cast(this); - - return NOERROR; - } - - *ppv = NULL; - - return E_NOINTERFACE; -}; - -STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void) -{ - return InterlockedIncrement(_p_class_ref); -}; - -STDMETHODIMP_(ULONG) VLCPluginClass::Release(void) -{ - ULONG refcount = InterlockedDecrement(_p_class_ref); - if( 0 == refcount ) - { - delete this; - return 0; - } - return refcount; -}; - -STDMETHODIMP VLCPluginClass::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv) -{ - if( NULL == ppv ) - return E_POINTER; - - *ppv = NULL; - - if( NULL != pUnkOuter ) - return CLASS_E_NOAGGREGATION; - - VLCPlugin *plugin = new VLCPlugin(this); - if( NULL != plugin ) - { - HRESULT hr = plugin->QueryInterface(riid, ppv); - plugin->Release(); - return hr; - } - return E_OUTOFMEMORY; -}; - -STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock) -{ - if( fLock ) - AddRef(); - else - Release(); - - return S_OK; -}; - -//////////////////////////////////////////////////////////////////////// - -VLCPlugin::VLCPlugin(VLCPluginClass *p_class) : - _inplacewnd(NULL), - _p_class(p_class), - _i_ref(1UL), - _codepage(CP_ACP), - _psz_src(NULL), - _b_autostart(TRUE), - _b_loopmode(FALSE), - _b_visible(TRUE), - _b_sendevents(TRUE), - _i_vlc(0) -{ - p_class->AddRef(); - - vlcOleObject = new VLCOleObject(this); - vlcOleControl = new VLCOleControl(this); - vlcOleInPlaceObject = new VLCOleInPlaceObject(this); - vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this); - vlcPersistStorage = new VLCPersistStorage(this); - vlcPersistStreamInit = new VLCPersistStreamInit(this); - vlcPersistPropertyBag = new VLCPersistPropertyBag(this); - vlcProvideClassInfo = new VLCProvideClassInfo(this); - vlcConnectionPointContainer = new VLCConnectionPointContainer(this); - vlcObjectSafety = new VLCObjectSafety(this); - vlcControl = new VLCControl(this); -}; - -VLCPlugin::~VLCPlugin() -{ - vlcOleInPlaceObject->UIDeactivate(); - vlcOleInPlaceObject->InPlaceDeactivate(); - - delete vlcControl; - delete vlcObjectSafety; - delete vlcConnectionPointContainer; - delete vlcProvideClassInfo; - delete vlcPersistPropertyBag; - delete vlcPersistStreamInit; - delete vlcPersistStorage; - delete vlcOleInPlaceActiveObject; - delete vlcOleInPlaceObject; - delete vlcOleControl; - delete vlcOleObject; - - if( _psz_src ) - free(_psz_src); - - _p_class->Release(); -}; - -STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv) -{ - if( NULL == ppv ) - return E_INVALIDARG; - - if( IID_IUnknown == riid ) - { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - else if( IID_IOleObject == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcOleObject); - return NOERROR; - } - else if( IID_IOleControl == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcOleControl); - return NOERROR; - } - else if( IID_IOleWindow == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcOleInPlaceObject); - return NOERROR; - } - else if( IID_IOleInPlaceObject == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcOleInPlaceObject); - return NOERROR; - } - else if( IID_IOleInPlaceActiveObject == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcOleInPlaceActiveObject); - return NOERROR; - } - else if( IID_IPersist == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcPersistPropertyBag); - return NOERROR; - } - else if( IID_IPersistStreamInit == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcPersistStreamInit); - return NOERROR; - } - else if( IID_IPersistStorage == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcPersistStorage); - return NOERROR; - } - else if( IID_IPersistPropertyBag == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcPersistPropertyBag); - return NOERROR; - } - else if( IID_IProvideClassInfo == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcProvideClassInfo); - return NOERROR; - } - else if( IID_IProvideClassInfo2 == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcProvideClassInfo); - return NOERROR; - } - else if( IID_IConnectionPointContainer == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcConnectionPointContainer); - return NOERROR; - } - else if( IID_IObjectSafety == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcObjectSafety); - return NOERROR; - } - else if( IID_IDispatch == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcControl); - return NOERROR; - } - else if( IID_IVLCControl == riid ) - { - AddRef(); - *ppv = reinterpret_cast(vlcControl); - return NOERROR; - } - - *ppv = NULL; - - return E_NOINTERFACE; -}; - -STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void) -{ - return InterlockedIncrement((LONG *)&_i_ref); -}; - -STDMETHODIMP_(ULONG) VLCPlugin::Release(void) -{ - if( ! InterlockedDecrement((LONG *)&_i_ref) ) - { - delete this; - return 0; - } - return _i_ref; -}; - -////////////////////////////////////// - -/* -** we use an in-place child window to represent plugin viewport, -** whose size is limited by the clipping rectangle -** all drawing within this window must follow -** cartesian coordinate system represented by _bounds. -*/ - -void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect) -{ - _bounds.right = lprPosRect->right-lprPosRect->left; - - if( lprcClipRect->left <= lprPosRect->left ) - { - // left side is not clipped out - _bounds.left = 0; - - if( lprcClipRect->right >= lprPosRect->right ) - { - // right side is not clipped out, no change - } - else if( lprcClipRect->right >= lprPosRect->left ) - { - // right side is clipped out - lprPosRect->right = lprcClipRect->right; - } - else - { - // outside of clipping rectange, not visible - lprPosRect->right = lprPosRect->left; - } - } - else - { - // left side is clipped out - _bounds.left = lprPosRect->left-lprcClipRect->left; - _bounds.right += _bounds.left; - - lprPosRect->left = lprcClipRect->left; - if( lprcClipRect->right >= lprPosRect->right ) - { - // right side is not clipped out - } - else - { - // right side is clipped out - lprPosRect->right = lprcClipRect->right; - } - } - - _bounds.bottom = lprPosRect->bottom-lprPosRect->top; - - if( lprcClipRect->top <= lprPosRect->top ) - { - // top side is not clipped out - _bounds.top = 0; - - if( lprcClipRect->bottom >= lprPosRect->bottom ) - { - // bottom side is not clipped out, no change - } - else if( lprcClipRect->bottom >= lprPosRect->top ) - { - // bottom side is clipped out - lprPosRect->bottom = lprcClipRect->bottom; - } - else - { - // outside of clipping rectange, not visible - lprPosRect->right = lprPosRect->left; - } - } - else - { - _bounds.top = lprPosRect->top-lprcClipRect->top; - _bounds.bottom += _bounds.top; - - lprPosRect->top = lprcClipRect->top; - if( lprcClipRect->bottom >= lprPosRect->bottom ) - { - // bottom side is not clipped out - } - else - { - // bottom side is clipped out - lprPosRect->bottom = lprcClipRect->bottom; - } - } -}; - -HRESULT VLCPlugin::onInitNew(void) -{ - if( 0 == _i_vlc ) - { - char *ppsz_argv[] = { "vlc", "-vv" }; - HKEY h_key; - DWORD i_type, i_data = MAX_PATH + 1; - char p_data[MAX_PATH + 1]; - if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC", - 0, KEY_READ, &h_key ) == ERROR_SUCCESS ) - { - if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type, - (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS ) - { - if( i_type == REG_SZ ) - { - strcat( p_data, "\\vlc" ); - ppsz_argv[0] = p_data; - } - } - RegCloseKey( h_key ); - } - -#if 0 - ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc"; -#endif - - _i_vlc = VLC_Create(); - - if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) ) - { - VLC_Destroy(_i_vlc); - _i_vlc = 0; - return E_FAIL; - } - return S_OK; - } - return E_UNEXPECTED; -}; - -HRESULT VLCPlugin::onClose(DWORD dwSaveOption) -{ - if( _i_vlc ) - { - if( isInPlaceActive() ) - { - onInPlaceDeactivate(); - } - - VLC_CleanUp(_i_vlc); - VLC_Destroy(_i_vlc); - _i_vlc = 0; - } - return S_OK; -}; - -BOOL VLCPlugin::isInPlaceActive(void) -{ - return (NULL != _inplacewnd); -}; - -HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect) -{ - RECT posRect = *lprcPosRect; - - calcPositionChange(&posRect, lprcClipRect); - - _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(), - "VLC Plugin In-Place Window", - WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP, - posRect.left, - posRect.top, - posRect.right-posRect.left, - posRect.bottom-posRect.top, - hwndParent, - 0, - _p_class->getHInstance(), - NULL - ); - - if( NULL == _inplacewnd ) - return E_FAIL; - - SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast(this)); - - _videownd = CreateWindow(_p_class->getVideoWndClassName(), - "VLC Plugin Video Window", - WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE, - _bounds.left, - _bounds.top, - _bounds.right-_bounds.left, - _bounds.bottom-_bounds.top, - _inplacewnd, - 0, - _p_class->getHInstance(), - NULL - ); - - if( NULL == _videownd ) - { - DestroyWindow(_inplacewnd); - return E_FAIL; - } - - SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast(this)); - - if( getVisible() ) - ShowWindow(_inplacewnd, SW_SHOWNORMAL); - - /* horrible cast there */ - vlc_value_t val; - val.i_int = reinterpret_cast(_videownd); - VLC_VariableSet(_i_vlc, "drawable", val); - - if( NULL != _psz_src ) - { - // add target to playlist - char *cOptions[1]; - int cOptionsCount = 0; - - if( _b_loopmode ) - { - cOptions[cOptionsCount++] = "loop"; - } - VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END); - - if( _b_autostart ) - { - VLC_Play(_i_vlc); - fireOnPlayEvent(); - } - } - return S_OK; -}; - -HRESULT VLCPlugin::onInPlaceDeactivate(void) -{ - VLC_Stop(_i_vlc); - fireOnStopEvent(); - - DestroyWindow(_videownd); - _videownd = NULL; - DestroyWindow(_inplacewnd); - _inplacewnd = NULL; - - return S_OK; -}; - -void VLCPlugin::setVisible(BOOL fVisible) -{ - _b_visible = fVisible; - if( isInPlaceActive() ) - ShowWindow(_inplacewnd, fVisible ? SW_SHOWNORMAL : SW_HIDE); - firePropChangedEvent(DISPID_Visible); -}; - -void VLCPlugin::setFocus(BOOL fFocus) -{ - if( fFocus ) - SetActiveWindow(_inplacewnd); -}; - -BOOL VLCPlugin::hasFocus(void) -{ - return GetActiveWindow() == _inplacewnd; -}; - -void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr) -{ - /* - ** if VLC is playing, it may not display any VIDEO content - ** hence, draw control logo - */ - int width = _bounds.right-_bounds.left; - int height = _bounds.bottom-_bounds.top; - - HBITMAP pict = _p_class->getInPlacePict(); - if( NULL != pict ) - { - HDC hdcPict = CreateCompatibleDC(ps.hdc); - if( NULL != hdcPict ) - { - BITMAP bm; - if( GetObject(pict, sizeof(BITMAPINFO), &bm) ) - { - int dstWidth = bm.bmWidth; - if( dstWidth > width-4 ) - dstWidth = width-4; - - int dstHeight = bm.bmHeight; - if( dstHeight > height-4 ) - dstHeight = height-4; - - int dstX = (width-dstWidth)/2; - int dstY = (height-dstHeight)/2; - - SelectObject(hdcPict, pict); - StretchBlt(ps.hdc, dstX, dstY, dstWidth, dstHeight, - hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); - DeleteDC(hdcPict); - ExcludeClipRect(ps.hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY); - } - } - } - - FillRect(ps.hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH)); - SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH)); - - MoveToEx(ps.hdc, 0, 0, NULL); - LineTo(ps.hdc, width-1, 0); - LineTo(ps.hdc, width-1, height-1); - LineTo(ps.hdc, 0, height-1); - LineTo(ps.hdc, 0, 0); -}; - -void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) -{ - RECT posRect = *lprcPosRect; - - calcPositionChange(&posRect, lprcClipRect); - - /* - ** change in-place window geometry to match clipping region - */ - MoveWindow(_inplacewnd, - posRect.left, - posRect.top, - posRect.right-posRect.left, - posRect.bottom-posRect.top, - FALSE); - - /* - ** change video window geometry to match object bounds within clipping region - */ - MoveWindow(_videownd, - _bounds.left, - _bounds.top, - _bounds.right-_bounds.left, - _bounds.bottom-_bounds.top, - FALSE); - - RECT updateRect; - - updateRect.left = -_bounds.left; - updateRect.top = -_bounds.top; - updateRect.right = _bounds.right-_bounds.left; - updateRect.bottom = _bounds.bottom-_bounds.top; - - ValidateRect(_videownd, NULL); - InvalidateRect(_videownd, &updateRect, FALSE); - UpdateWindow(_videownd); -}; - -void VLCPlugin::firePropChangedEvent(DISPID dispid) -{ - if( _b_sendevents ) - { - vlcConnectionPointContainer->firePropChangedEvent(dispid); - } -}; - -void VLCPlugin::fireOnPlayEvent(void) -{ - if( _b_sendevents ) - { - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs); - } -}; - -void VLCPlugin::fireOnPauseEvent(void) -{ - if( _b_sendevents ) - { - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs); - } -}; - -void VLCPlugin::fireOnStopEvent(void) -{ - if( _b_sendevents ) - { - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); - } -}; - +/***************************************************************************** + * plugin.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" + +#include "oleobject.h" +#include "olecontrol.h" +#include "oleinplaceobject.h" +#include "oleinplaceactiveobject.h" +#include "persistpropbag.h" +#include "persiststreaminit.h" +#include "persiststorage.h" +#include "provideclassinfo.h" +#include "connectioncontainer.h" +#include "objectsafety.h" +#include "vlccontrol.h" + +#include "utils.h" + +#include +#include + +using namespace std; + +//////////////////////////////////////////////////////////////////////// +//class factory + +// {E23FE9C6-778E-49d4-B537-38FCDE4887D8} +//const GUID CLSID_VLCPlugin = +// { 0xe23fe9c6, 0x778e, 0x49d4, { 0xb5, 0x37, 0x38, 0xfc, 0xde, 0x48, 0x87, 0xd8 } }; + +static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + switch( uMsg ) + { + case WM_ERASEBKGND: + return 1L; + + case WM_PAINT: + PAINTSTRUCT ps; + if( GetUpdateRect(hWnd, NULL, FALSE) ) + { + BeginPaint(hWnd, &ps); + EndPaint(hWnd, &ps); + } + return 0L; + + default: + return DefWindowProc(hWnd, uMsg, wParam, lParam); + } +}; + +static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + VLCPlugin *p_instance = reinterpret_cast(GetWindowLongPtr(hWnd, GWLP_USERDATA)); + + switch( uMsg ) + { + case WM_ERASEBKGND: + return 1L; + + case WM_PAINT: + PAINTSTRUCT ps; + RECT pr; + if( GetUpdateRect(hWnd, &pr, FALSE) ) + { + BeginPaint(hWnd, &ps); + p_instance->onPaint(ps, pr); + EndPaint(hWnd, &ps); + } + return 0L; + + default: + return DefWindowProc(hWnd, uMsg, wParam, lParam); + } +}; + +VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) : + _p_class_ref(p_class_ref), + _hinstance(hInstance) +{ + WNDCLASS wClass; + + if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) ) + { + wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS; + wClass.lpfnWndProc = VLCInPlaceClassWndProc; + wClass.cbClsExtra = 0; + wClass.cbWndExtra = 0; + wClass.hInstance = hInstance; + wClass.hIcon = NULL; + wClass.hCursor = LoadCursor(NULL, IDC_ARROW); + wClass.hbrBackground = NULL; + wClass.lpszMenuName = NULL; + wClass.lpszClassName = getInPlaceWndClassName(); + + _inplace_wndclass_atom = RegisterClass(&wClass); + } + else + { + _inplace_wndclass_atom = 0; + } + + if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) ) + { + wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW; + wClass.lpfnWndProc = VLCVideoClassWndProc; + wClass.cbClsExtra = 0; + wClass.cbWndExtra = 0; + wClass.hInstance = hInstance; + wClass.hIcon = NULL; + wClass.hCursor = LoadCursor(NULL, IDC_ARROW); + wClass.hbrBackground = NULL; + wClass.lpszMenuName = NULL; + wClass.lpszClassName = getVideoWndClassName(); + + _video_wndclass_atom = RegisterClass(&wClass); + } + else + { + _video_wndclass_atom = 0; + } + + _inplace_hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR); + + AddRef(); +}; + +VLCPluginClass::~VLCPluginClass() +{ + if( 0 != _inplace_wndclass_atom ) + UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance); + + if( 0 != _video_wndclass_atom ) + UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance); + + if( NULL != _inplace_hbitmap ) + DeleteObject(_inplace_hbitmap); +}; + +STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv) +{ + if( NULL == ppv ) + return E_INVALIDARG; + + if( (IID_IUnknown == riid) || (IID_IClassFactory == riid) ) + { + AddRef(); + *ppv = reinterpret_cast(this); + + return NOERROR; + } + + *ppv = NULL; + + return E_NOINTERFACE; +}; + +STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void) +{ + return InterlockedIncrement(_p_class_ref); +}; + +STDMETHODIMP_(ULONG) VLCPluginClass::Release(void) +{ + ULONG refcount = InterlockedDecrement(_p_class_ref); + if( 0 == refcount ) + { + delete this; + return 0; + } + return refcount; +}; + +STDMETHODIMP VLCPluginClass::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv) +{ + if( NULL == ppv ) + return E_POINTER; + + *ppv = NULL; + + if( NULL != pUnkOuter ) + return CLASS_E_NOAGGREGATION; + + VLCPlugin *plugin = new VLCPlugin(this); + if( NULL != plugin ) + { + HRESULT hr = plugin->QueryInterface(riid, ppv); + plugin->Release(); + return hr; + } + return E_OUTOFMEMORY; +}; + +STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock) +{ + if( fLock ) + AddRef(); + else + Release(); + + return S_OK; +}; + +//////////////////////////////////////////////////////////////////////// + +VLCPlugin::VLCPlugin(VLCPluginClass *p_class) : + _inplacewnd(NULL), + _p_class(p_class), + _i_ref(1UL), + _codepage(CP_ACP), + _psz_src(NULL), + _b_autostart(TRUE), + _b_loopmode(FALSE), + _b_visible(TRUE), + _b_sendevents(TRUE), + _i_vlc(0) +{ + p_class->AddRef(); + + vlcOleObject = new VLCOleObject(this); + vlcOleControl = new VLCOleControl(this); + vlcOleInPlaceObject = new VLCOleInPlaceObject(this); + vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this); + vlcPersistStorage = new VLCPersistStorage(this); + vlcPersistStreamInit = new VLCPersistStreamInit(this); + vlcPersistPropertyBag = new VLCPersistPropertyBag(this); + vlcProvideClassInfo = new VLCProvideClassInfo(this); + vlcConnectionPointContainer = new VLCConnectionPointContainer(this); + vlcObjectSafety = new VLCObjectSafety(this); + vlcControl = new VLCControl(this); +}; + +VLCPlugin::~VLCPlugin() +{ + vlcOleInPlaceObject->UIDeactivate(); + vlcOleInPlaceObject->InPlaceDeactivate(); + + delete vlcControl; + delete vlcObjectSafety; + delete vlcConnectionPointContainer; + delete vlcProvideClassInfo; + delete vlcPersistPropertyBag; + delete vlcPersistStreamInit; + delete vlcPersistStorage; + delete vlcOleInPlaceActiveObject; + delete vlcOleInPlaceObject; + delete vlcOleControl; + delete vlcOleObject; + + if( _psz_src ) + free(_psz_src); + + _p_class->Release(); +}; + +STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv) +{ + if( NULL == ppv ) + return E_INVALIDARG; + + if( IID_IUnknown == riid ) + { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + else if( IID_IOleObject == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcOleObject); + return NOERROR; + } + else if( IID_IOleControl == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcOleControl); + return NOERROR; + } + else if( IID_IOleWindow == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcOleInPlaceObject); + return NOERROR; + } + else if( IID_IOleInPlaceObject == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcOleInPlaceObject); + return NOERROR; + } + else if( IID_IOleInPlaceActiveObject == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcOleInPlaceActiveObject); + return NOERROR; + } + else if( IID_IPersist == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcPersistPropertyBag); + return NOERROR; + } + else if( IID_IPersistStreamInit == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcPersistStreamInit); + return NOERROR; + } + else if( IID_IPersistStorage == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcPersistStorage); + return NOERROR; + } + else if( IID_IPersistPropertyBag == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcPersistPropertyBag); + return NOERROR; + } + else if( IID_IProvideClassInfo == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcProvideClassInfo); + return NOERROR; + } + else if( IID_IProvideClassInfo2 == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcProvideClassInfo); + return NOERROR; + } + else if( IID_IConnectionPointContainer == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcConnectionPointContainer); + return NOERROR; + } + else if( IID_IObjectSafety == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcObjectSafety); + return NOERROR; + } + else if( IID_IDispatch == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcControl); + return NOERROR; + } + else if( IID_IVLCControl == riid ) + { + AddRef(); + *ppv = reinterpret_cast(vlcControl); + return NOERROR; + } + + *ppv = NULL; + + return E_NOINTERFACE; +}; + +STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void) +{ + return InterlockedIncrement((LONG *)&_i_ref); +}; + +STDMETHODIMP_(ULONG) VLCPlugin::Release(void) +{ + if( ! InterlockedDecrement((LONG *)&_i_ref) ) + { + delete this; + return 0; + } + return _i_ref; +}; + +////////////////////////////////////// + +/* +** we use an in-place child window to represent plugin viewport, +** whose size is limited by the clipping rectangle +** all drawing within this window must follow +** cartesian coordinate system represented by _bounds. +*/ + +void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect) +{ + _bounds.right = lprPosRect->right-lprPosRect->left; + + if( lprcClipRect->left <= lprPosRect->left ) + { + // left side is not clipped out + _bounds.left = 0; + + if( lprcClipRect->right >= lprPosRect->right ) + { + // right side is not clipped out, no change + } + else if( lprcClipRect->right >= lprPosRect->left ) + { + // right side is clipped out + lprPosRect->right = lprcClipRect->right; + } + else + { + // outside of clipping rectange, not visible + lprPosRect->right = lprPosRect->left; + } + } + else + { + // left side is clipped out + _bounds.left = lprPosRect->left-lprcClipRect->left; + _bounds.right += _bounds.left; + + lprPosRect->left = lprcClipRect->left; + if( lprcClipRect->right >= lprPosRect->right ) + { + // right side is not clipped out + } + else + { + // right side is clipped out + lprPosRect->right = lprcClipRect->right; + } + } + + _bounds.bottom = lprPosRect->bottom-lprPosRect->top; + + if( lprcClipRect->top <= lprPosRect->top ) + { + // top side is not clipped out + _bounds.top = 0; + + if( lprcClipRect->bottom >= lprPosRect->bottom ) + { + // bottom side is not clipped out, no change + } + else if( lprcClipRect->bottom >= lprPosRect->top ) + { + // bottom side is clipped out + lprPosRect->bottom = lprcClipRect->bottom; + } + else + { + // outside of clipping rectange, not visible + lprPosRect->right = lprPosRect->left; + } + } + else + { + _bounds.top = lprPosRect->top-lprcClipRect->top; + _bounds.bottom += _bounds.top; + + lprPosRect->top = lprcClipRect->top; + if( lprcClipRect->bottom >= lprPosRect->bottom ) + { + // bottom side is not clipped out + } + else + { + // bottom side is clipped out + lprPosRect->bottom = lprcClipRect->bottom; + } + } +}; + +HRESULT VLCPlugin::onInitNew(void) +{ + if( 0 == _i_vlc ) + { + char *ppsz_argv[] = { "vlc", "-vv" }; + HKEY h_key; + DWORD i_type, i_data = MAX_PATH + 1; + char p_data[MAX_PATH + 1]; + if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC", + 0, KEY_READ, &h_key ) == ERROR_SUCCESS ) + { + if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type, + (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS ) + { + if( i_type == REG_SZ ) + { + strcat( p_data, "\\vlc" ); + ppsz_argv[0] = p_data; + } + } + RegCloseKey( h_key ); + } + +#if 0 + ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc"; +#endif + + _i_vlc = VLC_Create(); + + if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) ) + { + VLC_Destroy(_i_vlc); + _i_vlc = 0; + return E_FAIL; + } + return S_OK; + } + return E_UNEXPECTED; +}; + +HRESULT VLCPlugin::onClose(DWORD dwSaveOption) +{ + if( _i_vlc ) + { + if( isInPlaceActive() ) + { + onInPlaceDeactivate(); + } + + VLC_CleanUp(_i_vlc); + VLC_Destroy(_i_vlc); + _i_vlc = 0; + } + return S_OK; +}; + +BOOL VLCPlugin::isInPlaceActive(void) +{ + return (NULL != _inplacewnd); +}; + +HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect) +{ + RECT posRect = *lprcPosRect; + + calcPositionChange(&posRect, lprcClipRect); + + _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(), + "VLC Plugin In-Place Window", + WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP, + posRect.left, + posRect.top, + posRect.right-posRect.left, + posRect.bottom-posRect.top, + hwndParent, + 0, + _p_class->getHInstance(), + NULL + ); + + if( NULL == _inplacewnd ) + return E_FAIL; + + SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast(this)); + + _videownd = CreateWindow(_p_class->getVideoWndClassName(), + "VLC Plugin Video Window", + WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE, + _bounds.left, + _bounds.top, + _bounds.right-_bounds.left, + _bounds.bottom-_bounds.top, + _inplacewnd, + 0, + _p_class->getHInstance(), + NULL + ); + + if( NULL == _videownd ) + { + DestroyWindow(_inplacewnd); + return E_FAIL; + } + + SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast(this)); + + if( getVisible() ) + ShowWindow(_inplacewnd, SW_SHOWNORMAL); + + /* horrible cast there */ + vlc_value_t val; + val.i_int = reinterpret_cast(_videownd); + VLC_VariableSet(_i_vlc, "drawable", val); + + if( NULL != _psz_src ) + { + // add target to playlist + char *cOptions[1]; + int cOptionsCount = 0; + + if( _b_loopmode ) + { + cOptions[cOptionsCount++] = "loop"; + } + VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END); + + if( _b_autostart ) + { + VLC_Play(_i_vlc); + fireOnPlayEvent(); + } + } + return S_OK; +}; + +HRESULT VLCPlugin::onInPlaceDeactivate(void) +{ + VLC_Stop(_i_vlc); + fireOnStopEvent(); + + DestroyWindow(_videownd); + _videownd = NULL; + DestroyWindow(_inplacewnd); + _inplacewnd = NULL; + + return S_OK; +}; + +void VLCPlugin::setVisible(BOOL fVisible) +{ + _b_visible = fVisible; + if( isInPlaceActive() ) + ShowWindow(_inplacewnd, fVisible ? SW_SHOWNORMAL : SW_HIDE); + firePropChangedEvent(DISPID_Visible); +}; + +void VLCPlugin::setFocus(BOOL fFocus) +{ + if( fFocus ) + SetActiveWindow(_inplacewnd); +}; + +BOOL VLCPlugin::hasFocus(void) +{ + return GetActiveWindow() == _inplacewnd; +}; + +void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr) +{ + /* + ** if VLC is playing, it may not display any VIDEO content + ** hence, draw control logo + */ + int width = _bounds.right-_bounds.left; + int height = _bounds.bottom-_bounds.top; + + HBITMAP pict = _p_class->getInPlacePict(); + if( NULL != pict ) + { + HDC hdcPict = CreateCompatibleDC(ps.hdc); + if( NULL != hdcPict ) + { + BITMAP bm; + if( GetObject(pict, sizeof(BITMAPINFO), &bm) ) + { + int dstWidth = bm.bmWidth; + if( dstWidth > width-4 ) + dstWidth = width-4; + + int dstHeight = bm.bmHeight; + if( dstHeight > height-4 ) + dstHeight = height-4; + + int dstX = (width-dstWidth)/2; + int dstY = (height-dstHeight)/2; + + SelectObject(hdcPict, pict); + StretchBlt(ps.hdc, dstX, dstY, dstWidth, dstHeight, + hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); + DeleteDC(hdcPict); + ExcludeClipRect(ps.hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY); + } + } + } + + FillRect(ps.hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH)); + SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH)); + + MoveToEx(ps.hdc, 0, 0, NULL); + LineTo(ps.hdc, width-1, 0); + LineTo(ps.hdc, width-1, height-1); + LineTo(ps.hdc, 0, height-1); + LineTo(ps.hdc, 0, 0); +}; + +void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) +{ + RECT posRect = *lprcPosRect; + + calcPositionChange(&posRect, lprcClipRect); + + /* + ** change in-place window geometry to match clipping region + */ + MoveWindow(_inplacewnd, + posRect.left, + posRect.top, + posRect.right-posRect.left, + posRect.bottom-posRect.top, + FALSE); + + /* + ** change video window geometry to match object bounds within clipping region + */ + MoveWindow(_videownd, + _bounds.left, + _bounds.top, + _bounds.right-_bounds.left, + _bounds.bottom-_bounds.top, + FALSE); + + RECT updateRect; + + updateRect.left = -_bounds.left; + updateRect.top = -_bounds.top; + updateRect.right = _bounds.right-_bounds.left; + updateRect.bottom = _bounds.bottom-_bounds.top; + + ValidateRect(_videownd, NULL); + InvalidateRect(_videownd, &updateRect, FALSE); + UpdateWindow(_videownd); +}; + +void VLCPlugin::firePropChangedEvent(DISPID dispid) +{ + if( _b_sendevents ) + { + vlcConnectionPointContainer->firePropChangedEvent(dispid); + } +}; + +void VLCPlugin::fireOnPlayEvent(void) +{ + if( _b_sendevents ) + { + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs); + } +}; + +void VLCPlugin::fireOnPauseEvent(void) +{ + if( _b_sendevents ) + { + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs); + } +}; + +void VLCPlugin::fireOnStopEvent(void) +{ + if( _b_sendevents ) + { + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); + } +}; + diff --git a/activex/plugin.h b/activex/plugin.h index cfbfba2624..7b54c02474 100644 --- a/activex/plugin.h +++ b/activex/plugin.h @@ -1,167 +1,167 @@ -/***************************************************************************** - * plugin.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __PLUGIN_H__ -#define __PLUGIN_H__ - -#include -#include - -#include - -extern const GUID CLSID_VLCPlugin; -extern const GUID LIBID_AXVLC; -extern const GUID DIID_DVLCEvents; - -class VLCPluginClass : public IClassFactory -{ - -public: - - VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance); - - /* IUnknown methods */ - STDMETHODIMP QueryInterface(REFIID riid, void **ppv); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - /* IClassFactory methods */ - STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv); - STDMETHODIMP LockServer(BOOL fLock); - - LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); }; - LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); }; - HINSTANCE getHInstance(void) const { return _hinstance; }; - HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; }; - -protected: - - virtual ~VLCPluginClass(); - -private: - - LPLONG _p_class_ref; - HINSTANCE _hinstance; - ATOM _inplace_wndclass_atom; - ATOM _video_wndclass_atom; - HBITMAP _inplace_hbitmap; -}; - -class VLCPlugin : public IUnknown -{ - -public: - - VLCPlugin(VLCPluginClass *p_class); - - /* IUnknown methods */ - STDMETHODIMP QueryInterface(REFIID riid, void **ppv); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - /* custom methods */ - HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) - { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); }; - REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; }; - REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; }; - - HRESULT onInitNew(void); - HRESULT onClose(DWORD dwSaveOption); - - BOOL isInPlaceActive(void); - HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect); - HRESULT onInPlaceDeactivate(void); - HWND getInPlaceWindow(void) const { return _inplacewnd; }; - - BOOL hasFocus(void); - void setFocus(BOOL fFocus); - - UINT getCodePage(void) { return _codepage; }; - void setCodePage(UINT cp) { _codepage = cp; }; - - int getVLCObject(void) { return _i_vlc; }; - - // control properties - void setSourceURL(const char *url) { _psz_src = strdup(url); }; - void setAutoStart(BOOL autostart) { _b_autostart = autostart; }; - void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; }; - void setMute(BOOL mute) { - if( mute && _i_vlc ) - { - VLC_VolumeMute(_i_vlc); - } - }; - void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; }; - void setVisible(BOOL fVisible); - BOOL getVisible(void) { return _b_visible; }; - - // container events - void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect); - void onPaint(PAINTSTRUCT &ps, RECT &pr); - - // control events - void firePropChangedEvent(DISPID dispid); - void fireOnPlayEvent(void); - void fireOnPauseEvent(void); - void fireOnStopEvent(void); - -protected: - - virtual ~VLCPlugin(); - -private: - - void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect); - - //implemented interfaces - class VLCOleObject *vlcOleObject; - class VLCOleControl *vlcOleControl; - class VLCOleInPlaceObject *vlcOleInPlaceObject; - class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject; - class VLCPersistStreamInit *vlcPersistStreamInit; - class VLCPersistStorage *vlcPersistStorage; - class VLCPersistPropertyBag *vlcPersistPropertyBag; - class VLCProvideClassInfo *vlcProvideClassInfo; - class VLCConnectionPointContainer *vlcConnectionPointContainer; - class VLCObjectSafety *vlcObjectSafety; - class VLCControl *vlcControl; - - // in place activated window (Clipping window) - HWND _inplacewnd; - // video window (Drawing window) - HWND _videownd; - RECT _bounds; - - VLCPluginClass *_p_class; - ULONG _i_ref; - - UINT _codepage; - char *_psz_src; - BOOL _b_autostart; - BOOL _b_loopmode; - BOOL _b_visible; - BOOL _b_sendevents; - int _i_vlc; -}; - -#endif - +/***************************************************************************** + * plugin.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __PLUGIN_H__ +#define __PLUGIN_H__ + +#include +#include + +#include + +extern const GUID CLSID_VLCPlugin; +extern const GUID LIBID_AXVLC; +extern const GUID DIID_DVLCEvents; + +class VLCPluginClass : public IClassFactory +{ + +public: + + VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance); + + /* IUnknown methods */ + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(void); + + /* IClassFactory methods */ + STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv); + STDMETHODIMP LockServer(BOOL fLock); + + LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); }; + LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); }; + HINSTANCE getHInstance(void) const { return _hinstance; }; + HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; }; + +protected: + + virtual ~VLCPluginClass(); + +private: + + LPLONG _p_class_ref; + HINSTANCE _hinstance; + ATOM _inplace_wndclass_atom; + ATOM _video_wndclass_atom; + HBITMAP _inplace_hbitmap; +}; + +class VLCPlugin : public IUnknown +{ + +public: + + VLCPlugin(VLCPluginClass *p_class); + + /* IUnknown methods */ + STDMETHODIMP QueryInterface(REFIID riid, void **ppv); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(void); + + /* custom methods */ + HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) + { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); }; + REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; }; + REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; }; + + HRESULT onInitNew(void); + HRESULT onClose(DWORD dwSaveOption); + + BOOL isInPlaceActive(void); + HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect); + HRESULT onInPlaceDeactivate(void); + HWND getInPlaceWindow(void) const { return _inplacewnd; }; + + BOOL hasFocus(void); + void setFocus(BOOL fFocus); + + UINT getCodePage(void) { return _codepage; }; + void setCodePage(UINT cp) { _codepage = cp; }; + + int getVLCObject(void) { return _i_vlc; }; + + // control properties + void setSourceURL(const char *url) { _psz_src = strdup(url); }; + void setAutoStart(BOOL autostart) { _b_autostart = autostart; }; + void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; }; + void setMute(BOOL mute) { + if( mute && _i_vlc ) + { + VLC_VolumeMute(_i_vlc); + } + }; + void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; }; + void setVisible(BOOL fVisible); + BOOL getVisible(void) { return _b_visible; }; + + // container events + void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect); + void onPaint(PAINTSTRUCT &ps, RECT &pr); + + // control events + void firePropChangedEvent(DISPID dispid); + void fireOnPlayEvent(void); + void fireOnPauseEvent(void); + void fireOnStopEvent(void); + +protected: + + virtual ~VLCPlugin(); + +private: + + void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect); + + //implemented interfaces + class VLCOleObject *vlcOleObject; + class VLCOleControl *vlcOleControl; + class VLCOleInPlaceObject *vlcOleInPlaceObject; + class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject; + class VLCPersistStreamInit *vlcPersistStreamInit; + class VLCPersistStorage *vlcPersistStorage; + class VLCPersistPropertyBag *vlcPersistPropertyBag; + class VLCProvideClassInfo *vlcProvideClassInfo; + class VLCConnectionPointContainer *vlcConnectionPointContainer; + class VLCObjectSafety *vlcObjectSafety; + class VLCControl *vlcControl; + + // in place activated window (Clipping window) + HWND _inplacewnd; + // video window (Drawing window) + HWND _videownd; + RECT _bounds; + + VLCPluginClass *_p_class; + ULONG _i_ref; + + UINT _codepage; + char *_psz_src; + BOOL _b_autostart; + BOOL _b_loopmode; + BOOL _b_visible; + BOOL _b_sendevents; + int _i_vlc; +}; + +#endif + diff --git a/activex/provideclassinfo.cpp b/activex/provideclassinfo.cpp index 4d71080f85..fdef445624 100644 --- a/activex/provideclassinfo.cpp +++ b/activex/provideclassinfo.cpp @@ -1,60 +1,60 @@ -/***************************************************************************** - * provideclassinfo.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "provideclassinfo.h" - -using namespace std; - -STDMETHODIMP VLCProvideClassInfo::GetClassInfo(ITypeInfo **ppTI) -{ - ITypeLib *p_typelib; - - if( NULL == ppTI ) - return E_POINTER; - - HRESULT hr = _p_instance->getTypeLib(LOCALE_NEUTRAL, &p_typelib); - if( SUCCEEDED(hr) ) - { - hr = p_typelib->GetTypeInfoOfGuid(_p_instance->getClassID(), ppTI); - if( FAILED(hr) ) - { - *ppTI = NULL; - } - p_typelib->Release(); - } - return hr; -}; - -STDMETHODIMP VLCProvideClassInfo::GetGUID(DWORD dwGuidKind, GUID *pGUID) -{ - if( GUIDKIND_DEFAULT_SOURCE_DISP_IID != dwGuidKind ) - return E_INVALIDARG; - - if( NULL == pGUID ) - return E_POINTER; - - *pGUID = _p_instance->getDispEventID(); - - return S_OK; -}; - +/***************************************************************************** + * provideclassinfo.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "provideclassinfo.h" + +using namespace std; + +STDMETHODIMP VLCProvideClassInfo::GetClassInfo(ITypeInfo **ppTI) +{ + ITypeLib *p_typelib; + + if( NULL == ppTI ) + return E_POINTER; + + HRESULT hr = _p_instance->getTypeLib(LOCALE_NEUTRAL, &p_typelib); + if( SUCCEEDED(hr) ) + { + hr = p_typelib->GetTypeInfoOfGuid(_p_instance->getClassID(), ppTI); + if( FAILED(hr) ) + { + *ppTI = NULL; + } + p_typelib->Release(); + } + return hr; +}; + +STDMETHODIMP VLCProvideClassInfo::GetGUID(DWORD dwGuidKind, GUID *pGUID) +{ + if( GUIDKIND_DEFAULT_SOURCE_DISP_IID != dwGuidKind ) + return E_INVALIDARG; + + if( NULL == pGUID ) + return E_POINTER; + + *pGUID = _p_instance->getDispEventID(); + + return S_OK; +}; + diff --git a/activex/provideclassinfo.h b/activex/provideclassinfo.h index 370c49f78e..4856a162a9 100644 --- a/activex/provideclassinfo.h +++ b/activex/provideclassinfo.h @@ -1,65 +1,65 @@ -/***************************************************************************** - * provideclassinfo.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __PROVIDECLASSINFO_H__ -#define __PROVIDECLASSINFO_H__ - -#include - -class VLCProvideClassInfo : public IProvideClassInfo2 -{ - -public: - - VLCProvideClassInfo(VLCPlugin *p_instance) : _p_instance(p_instance) {}; - virtual ~VLCProvideClassInfo() {}; - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IProvideClassInfo == riid) - && (IID_IProvideClassInfo2 == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IProvideClassInfo methods - STDMETHODIMP GetClassInfo(ITypeInfo **); - - // IProvideClassInfo2 methods - STDMETHODIMP GetGUID(DWORD, GUID *); - -private: - - VLCPlugin *_p_instance; -}; - -#endif - +/***************************************************************************** + * provideclassinfo.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __PROVIDECLASSINFO_H__ +#define __PROVIDECLASSINFO_H__ + +#include + +class VLCProvideClassInfo : public IProvideClassInfo2 +{ + +public: + + VLCProvideClassInfo(VLCPlugin *p_instance) : _p_instance(p_instance) {}; + virtual ~VLCProvideClassInfo() {}; + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IProvideClassInfo == riid) + && (IID_IProvideClassInfo2 == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IProvideClassInfo methods + STDMETHODIMP GetClassInfo(ITypeInfo **); + + // IProvideClassInfo2 methods + STDMETHODIMP GetGUID(DWORD, GUID *); + +private: + + VLCPlugin *_p_instance; +}; + +#endif + diff --git a/activex/utils.cpp b/activex/utils.cpp index eecba67006..d03a883518 100644 --- a/activex/utils.cpp +++ b/activex/utils.cpp @@ -1,101 +1,101 @@ -/***************************************************************************** - * utils.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "utils.h" - -/* -** conversion facilities -*/ - -using namespace std; - -char *CStrFromBSTR(int codePage, BSTR bstr) -{ - UINT len = SysStringLen(bstr); - if( len > 0 ) - { - size_t mblen = WideCharToMultiByte(codePage, - 0, bstr, len, NULL, 0, NULL, NULL); - if( mblen > 0 ) - { - char *buffer = (char *)malloc(mblen+1); - ZeroMemory(buffer, mblen+1); - if( WideCharToMultiByte(codePage, 0, bstr, len, buffer, mblen, NULL, NULL) ) - return buffer; - } - } - return NULL; -}; - -BSTR BSTRFromCStr(int codePage, const char *s) -{ - int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0); - if( wideLen ) - { - WCHAR* wideStr = (WCHAR*)malloc(wideLen*sizeof(WCHAR)); - if( NULL != wideStr ) - { - BSTR bstr; - - ZeroMemory(wideStr, wideLen*sizeof(WCHAR)); - MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen); - bstr = SysAllocString(wideStr); - free(wideStr); - - return bstr; - } - } - return NULL; -}; - -/* -** properties -*/ - -HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v) -{ - IDispatch *pDisp; - HRESULT hr = object->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp); - if( SUCCEEDED(hr) ) - { - DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; - VARIANT vres; - hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, - DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vres, NULL, NULL); - if( SUCCEEDED(hr) ) - { - if( V_VT(&v) != V_VT(&vres) ) - { - hr = VariantChangeType(&v, &vres, 0, V_VT(&v)); - VariantClear(&vres); - } - else - { - v = vres; - } - } - pDisp->Release(); - } - return hr; -}; - - +/***************************************************************************** + * utils.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "utils.h" + +/* +** conversion facilities +*/ + +using namespace std; + +char *CStrFromBSTR(int codePage, BSTR bstr) +{ + UINT len = SysStringLen(bstr); + if( len > 0 ) + { + size_t mblen = WideCharToMultiByte(codePage, + 0, bstr, len, NULL, 0, NULL, NULL); + if( mblen > 0 ) + { + char *buffer = (char *)malloc(mblen+1); + ZeroMemory(buffer, mblen+1); + if( WideCharToMultiByte(codePage, 0, bstr, len, buffer, mblen, NULL, NULL) ) + return buffer; + } + } + return NULL; +}; + +BSTR BSTRFromCStr(int codePage, const char *s) +{ + int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0); + if( wideLen ) + { + WCHAR* wideStr = (WCHAR*)malloc(wideLen*sizeof(WCHAR)); + if( NULL != wideStr ) + { + BSTR bstr; + + ZeroMemory(wideStr, wideLen*sizeof(WCHAR)); + MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen); + bstr = SysAllocString(wideStr); + free(wideStr); + + return bstr; + } + } + return NULL; +}; + +/* +** properties +*/ + +HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v) +{ + IDispatch *pDisp; + HRESULT hr = object->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp); + if( SUCCEEDED(hr) ) + { + DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0}; + VARIANT vres; + hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT, + DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vres, NULL, NULL); + if( SUCCEEDED(hr) ) + { + if( V_VT(&v) != V_VT(&vres) ) + { + hr = VariantChangeType(&v, &vres, 0, V_VT(&v)); + VariantClear(&vres); + } + else + { + v = vres; + } + } + pDisp->Release(); + } + return hr; +}; + + diff --git a/activex/utils.h b/activex/utils.h index f15282b730..58cd6557c3 100644 --- a/activex/utils.h +++ b/activex/utils.h @@ -1,181 +1,181 @@ -/***************************************************************************** - * utils.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef __UTILS_H__ -#define __UTILS_H__ - -#include - -#include - -// utilities -extern char *CStrFromBSTR(int codePage, BSTR bstr); -extern BSTR BSTRFromCStr(int codePage, const char *s); - -// properties -extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v); - -// enumeration -template class VLCEnum : IUnknown -{ - -public: - - VLCEnum(REFIID riid, std::vector &); - VLCEnum(const VLCEnum &); - virtual ~VLCEnum() {}; - - VLCEnum& operator=(const VLCEnum &t); - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **); - STDMETHODIMP_(ULONG) AddRef(void); - STDMETHODIMP_(ULONG) Release(void); - - // IEnumXXXX methods - STDMETHODIMP Next(ULONG, T *, ULONG *); - STDMETHODIMP Skip(ULONG); - STDMETHODIMP Reset(void); - // cloning is implemented by subclasses and must use copy constructor - //STDMETHODIMP Clone(VLCEnum **); - // cloning is implemented by subclasses and must use copy constructor - - typedef void (*retainer)(T); - - void setRetainOperation(retainer retain) { _retain = retain; }; - -private: - - LONG _refcount; - std::vector _v; - typename std::vector::iterator _i; - REFIID _riid; - retainer _retain; -}; - -template -VLCEnum::VLCEnum(REFIID riid, std::vector &v) : - _refcount(1), - _v(v), - _riid(riid), - _retain(NULL) -{ - _i= v.begin(); -}; - -template -VLCEnum::VLCEnum(const VLCEnum &e) : - _refcount(1), - _v(e._v), - _riid(e._riid) -{ -}; - -template -VLCEnum& VLCEnum::operator=(const VLCEnum &e) -{ - this->_refcount = 1; - this->_riid = e._riid; - this->_v = e._v; - this->_i = e._i; -}; - -template -STDMETHODIMP VLCEnum::QueryInterface(REFIID riid, void **ppv) -{ - if( NULL == ppv ) return E_POINTER; - if( (IID_IUnknown == riid) - && ( _riid == riid) ) { - AddRef(); - *ppv = reinterpret_cast(this); - return NOERROR; - } - return E_NOINTERFACE; -}; - -template -STDMETHODIMP_(ULONG) VLCEnum::AddRef(void) -{ - return InterlockedIncrement(&_refcount); -}; - -template -STDMETHODIMP_(ULONG) VLCEnum::Release(void) -{ - ULONG refcount = InterlockedDecrement(&_refcount); - if( 0 == refcount ) - { - delete this; - return 0; - } - return refcount; -}; - -template -STDMETHODIMP VLCEnum::Next(ULONG celt, T *rgelt, ULONG *pceltFetched) -{ - if( NULL == rgelt ) - return E_POINTER; - - if( (celt > 1) && (NULL == pceltFetched) ) - return E_INVALIDARG; - - ULONG c = 0; - typename std::vector::iterator end = _v.end(); - - while( (c < celt) && (_i != end) ) - { - rgelt[c] = *_i; - if( NULL != _retain ) _retain(rgelt[c]); - ++_i; - ++c; - } - - if( NULL != pceltFetched ) - *pceltFetched = c; - - return (c == celt) ? S_OK : S_FALSE; -}; - -template -STDMETHODIMP VLCEnum::Skip(ULONG celt) -{ - ULONG c = 0; - typename std::vector::iterator end = _v.end(); - - while( (c < celt) && (_i != end) ) - { - ++_i; - ++c; - } - return (c == celt) ? S_OK : S_FALSE; -}; - -template -STDMETHODIMP VLCEnum::Reset(void) -{ - _i= _v.begin(); - return S_OK; -}; - -#endif - +/***************************************************************************** + * utils.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include + +#include + +// utilities +extern char *CStrFromBSTR(int codePage, BSTR bstr); +extern BSTR BSTRFromCStr(int codePage, const char *s); + +// properties +extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v); + +// enumeration +template class VLCEnum : IUnknown +{ + +public: + + VLCEnum(REFIID riid, std::vector &); + VLCEnum(const VLCEnum &); + virtual ~VLCEnum() {}; + + VLCEnum& operator=(const VLCEnum &t); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(void); + + // IEnumXXXX methods + STDMETHODIMP Next(ULONG, T *, ULONG *); + STDMETHODIMP Skip(ULONG); + STDMETHODIMP Reset(void); + // cloning is implemented by subclasses and must use copy constructor + //STDMETHODIMP Clone(VLCEnum **); + // cloning is implemented by subclasses and must use copy constructor + + typedef void (*retainer)(T); + + void setRetainOperation(retainer retain) { _retain = retain; }; + +private: + + LONG _refcount; + std::vector _v; + typename std::vector::iterator _i; + REFIID _riid; + retainer _retain; +}; + +template +VLCEnum::VLCEnum(REFIID riid, std::vector &v) : + _refcount(1), + _v(v), + _riid(riid), + _retain(NULL) +{ + _i= v.begin(); +}; + +template +VLCEnum::VLCEnum(const VLCEnum &e) : + _refcount(1), + _v(e._v), + _riid(e._riid) +{ +}; + +template +VLCEnum& VLCEnum::operator=(const VLCEnum &e) +{ + this->_refcount = 1; + this->_riid = e._riid; + this->_v = e._v; + this->_i = e._i; +}; + +template +STDMETHODIMP VLCEnum::QueryInterface(REFIID riid, void **ppv) +{ + if( NULL == ppv ) return E_POINTER; + if( (IID_IUnknown == riid) + && ( _riid == riid) ) { + AddRef(); + *ppv = reinterpret_cast(this); + return NOERROR; + } + return E_NOINTERFACE; +}; + +template +STDMETHODIMP_(ULONG) VLCEnum::AddRef(void) +{ + return InterlockedIncrement(&_refcount); +}; + +template +STDMETHODIMP_(ULONG) VLCEnum::Release(void) +{ + ULONG refcount = InterlockedDecrement(&_refcount); + if( 0 == refcount ) + { + delete this; + return 0; + } + return refcount; +}; + +template +STDMETHODIMP VLCEnum::Next(ULONG celt, T *rgelt, ULONG *pceltFetched) +{ + if( NULL == rgelt ) + return E_POINTER; + + if( (celt > 1) && (NULL == pceltFetched) ) + return E_INVALIDARG; + + ULONG c = 0; + typename std::vector::iterator end = _v.end(); + + while( (c < celt) && (_i != end) ) + { + rgelt[c] = *_i; + if( NULL != _retain ) _retain(rgelt[c]); + ++_i; + ++c; + } + + if( NULL != pceltFetched ) + *pceltFetched = c; + + return (c == celt) ? S_OK : S_FALSE; +}; + +template +STDMETHODIMP VLCEnum::Skip(ULONG celt) +{ + ULONG c = 0; + typename std::vector::iterator end = _v.end(); + + while( (c < celt) && (_i != end) ) + { + ++_i; + ++c; + } + return (c == celt) ? S_OK : S_FALSE; +}; + +template +STDMETHODIMP VLCEnum::Reset(void) +{ + _i= _v.begin(); + return S_OK; +}; + +#endif + diff --git a/activex/vlccontrol.cpp b/activex/vlccontrol.cpp index 835f5d1166..083c64fe8e 100644 --- a/activex/vlccontrol.cpp +++ b/activex/vlccontrol.cpp @@ -1,662 +1,662 @@ -/***************************************************************************** - * vlccontrol.cpp: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "plugin.h" -#include "vlccontrol.h" - -#include "utils.h" - -VLCControl::~VLCControl() -{ - if( _p_typeinfo ) - _p_typeinfo->Release(); -}; - -HRESULT VLCControl::getTypeInfo(void) -{ - HRESULT hr = NOERROR; - if( NULL == _p_typeinfo ) - { - ITypeLib *p_typelib; - - HRESULT hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib); - if( SUCCEEDED(hr) ) - { - hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl, &_p_typeinfo); - if( FAILED(hr) ) - { - _p_typeinfo = NULL; - } - p_typelib->Release(); - } - } - return hr; -}; - -STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo) -{ - if( SUCCEEDED(getTypeInfo()) ) - *pctInfo = 1; - else - *pctInfo = 0; - - return NOERROR; -}; - -STDMETHODIMP VLCControl::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo) -{ - if( NULL == ppTInfo ) - return E_INVALIDARG; - - if( SUCCEEDED(getTypeInfo()) ) - { - _p_typeinfo->AddRef(); - *ppTInfo = _p_typeinfo; - return NO_ERROR; - } - *ppTInfo = NULL; - return E_NOTIMPL; -}; - -STDMETHODIMP VLCControl::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, - UINT cNames, LCID lcid, DISPID* rgDispID) -{ - if( SUCCEEDED(getTypeInfo()) ) - { - return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID); - } - return E_NOTIMPL; -}; - -STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid, - LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, - VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) -{ - if( SUCCEEDED(getTypeInfo()) ) - { - return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams, - pVarResult, pExcepInfo, puArgErr); - } - return E_NOTIMPL; -}; - -STDMETHODIMP VLCControl::get_Value(VARIANT *pvarValue) -{ - if( NULL == pvarValue ) - return E_INVALIDARG; - - V_VT(pvarValue) = VT_BOOL; - return get_Playing(&V_BOOL(pvarValue)); -}; - -STDMETHODIMP VLCControl::put_Value(VARIANT pvarValue) -{ - if( VT_BOOL != V_VT(&pvarValue) ) - { - VARIANT boolValue; - HRESULT hr = VariantChangeType(&boolValue, &pvarValue, 0, VT_BOOL); - if( SUCCEEDED(hr) ) - { - hr = get_Playing(&V_BOOL(&pvarValue)); - //VariantClear(&boolValue); - } - return hr; - } - return get_Playing(&V_BOOL(&pvarValue)); -}; - -STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible) -{ - if( NULL == isVisible ) - return E_INVALIDARG; - - *isVisible = _p_instance->getVisible(); - - return NOERROR; -}; - -STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible) -{ - _p_instance->setVisible(isVisible != VARIANT_FALSE); - - return NOERROR; -}; - -STDMETHODIMP VLCControl::play(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_Play(i_vlc); - _p_instance->fireOnPlayEvent(); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::pause(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_Pause(i_vlc); - _p_instance->fireOnPauseEvent(); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::stop(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_Stop(i_vlc); - _p_instance->fireOnStopEvent(); - return NOERROR; - } - return E_UNEXPECTED; -} - -STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) -{ - if( NULL == isPlaying ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE; - return NOERROR; - } - *isPlaying = VARIANT_FALSE; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::put_Playing(VARIANT_BOOL isPlaying) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - if( VARIANT_FALSE == isPlaying ) - { - if( VLC_IsPlaying(i_vlc) ) - VLC_Stop(i_vlc); - } - else - { - if( ! VLC_IsPlaying(i_vlc) ) - VLC_Play(i_vlc); - } - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_Position(float *position) -{ - if( NULL == position ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *position = VLC_PositionGet(i_vlc); - return NOERROR; - } - *position = 0.0f; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::put_Position(float position) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_PositionSet(i_vlc, position); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_Time(int *seconds) -{ - if( NULL == seconds ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *seconds = VLC_TimeGet(i_vlc); - return NOERROR; - } - *seconds = 0; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::put_Time(int seconds) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_TimeSet(i_vlc, seconds, VLC_FALSE); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::shuttle(int seconds) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_TimeSet(i_vlc, seconds, VLC_TRUE); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::fullscreen(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_FullScreen(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_Length(int *seconds) -{ - if( NULL == seconds ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *seconds = VLC_LengthGet(i_vlc); - return NOERROR; - } - *seconds = 0; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::playFaster(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_SpeedFaster(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::playSlower(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_SpeedSlower(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_Volume(int *volume) -{ - if( NULL == volume ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *volume = VLC_VolumeGet(i_vlc); - return NOERROR; - } - *volume = 0; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::put_Volume(int volume) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_VolumeSet(i_vlc, volume); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::toggleMute(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_VolumeMute(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -static void freeTargetOptions(char **cOptions, int cOptionCount) -{ - // clean up - for( long pos=0; posQueryInterface(IID_IEnumVARIANT, (LPVOID *)&enumVar); - if( SUCCEEDED(hr) ) - { - long pos = 0; - long capacity = 16; - VARIANT option; - - *cOptions = (char **)malloc(capacity*sizeof(char *)); - if( NULL != *cOptions ) - { - ZeroMemory(*cOptions, sizeof(char *)*capacity); - while( SUCCEEDED(hr) && (S_OK == enumVar->Next(1, &option, NULL)) ) - { - if( VT_BSTR == V_VT(&option) ) - { - char *cOption = CStrFromBSTR(codePage, V_BSTR(&option)); - (*cOptions)[pos] = cOption; - if( NULL != cOption ) - { - ++pos; - if( pos == capacity ) - { - char **moreOptions = (char **)realloc(*cOptions, (capacity+16)*sizeof(char *)); - if( NULL != moreOptions ) - { - ZeroMemory(moreOptions+capacity, sizeof(char *)*16); - capacity += 16; - *cOptions = moreOptions; - } - else - hr = E_OUTOFMEMORY; - } - } - else - hr = E_OUTOFMEMORY; - } - else - hr = E_INVALIDARG; - - VariantClear(&option); - } - *cOptionCount = pos; - if( FAILED(hr) ) - { - // free already processed elements - freeTargetOptions(*cOptions, *cOptionCount); - } - } - else - hr = E_OUTOFMEMORY; - enumVar->Release(); - } - } - } - else if( V_ISARRAY(options) ) - { - // array parameter - SAFEARRAY *array = V_ISBYREF(options) ? *V_ARRAYREF(options) : V_ARRAY(options); - - if( SafeArrayGetDim(array) != 1 ) - return E_INVALIDARG; - - long lBound = 0; - long uBound = 0; - SafeArrayGetLBound(array, 1, &lBound); - SafeArrayGetUBound(array, 1, &uBound); - - // have we got any options - if( uBound > lBound ) - { - VARTYPE vType; - HRESULT hr = SafeArrayGetVartype(array, &vType); - if( FAILED(hr) ) - return hr; - - long pos; - - // marshall options into an array of C strings - if( VT_VARIANT == vType ) - { - *cOptions = (char **)malloc(sizeof(char *)*(uBound-lBound)); - if( NULL != options ) - return E_OUTOFMEMORY; - - for(pos=lBound; SUCCEEDED(hr) && (posgetVLCObject(); - if( i_vlc ) - { - int codePage = _p_instance->getCodePage(); - char *cUri = CStrFromBSTR(codePage, uri); - if( NULL == cUri ) - return E_OUTOFMEMORY; - - int cOptionsCount; - char **cOptions; - - if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) ) - return E_INVALIDARG; - - VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position); - hr = NOERROR; - - freeTargetOptions(cOptions, cOptionsCount); - free(cUri); - } - return hr; -}; - -STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) -{ - if( NULL == index ) - return E_INVALIDARG; - - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *index = VLC_PlaylistIndex(i_vlc); - return NOERROR; - } - *index = 0; - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_PlaylistCount(int *count) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - *count = VLC_PlaylistNumberOfItems(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::playlistNext(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_PlaylistNext(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::playlistPrev(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_PlaylistPrev(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::playlistClear(void) -{ - int i_vlc = _p_instance->getVLCObject(); - if( i_vlc ) - { - VLC_PlaylistClear(i_vlc); - return NOERROR; - } - return E_UNEXPECTED; -}; - -STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version) -{ - if( NULL == version ) - return E_INVALIDARG; - - const char *versionStr = VLC_Version(); - if( NULL != versionStr ) - { - *version = BSTRFromCStr(_p_instance->getCodePage(), versionStr); - - return NULL == *version ? E_OUTOFMEMORY : NOERROR; - } - *version = NULL; - return E_FAIL; -}; - +/***************************************************************************** + * vlccontrol.cpp: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include "plugin.h" +#include "vlccontrol.h" + +#include "utils.h" + +VLCControl::~VLCControl() +{ + if( _p_typeinfo ) + _p_typeinfo->Release(); +}; + +HRESULT VLCControl::getTypeInfo(void) +{ + HRESULT hr = NOERROR; + if( NULL == _p_typeinfo ) + { + ITypeLib *p_typelib; + + HRESULT hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib); + if( SUCCEEDED(hr) ) + { + hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl, &_p_typeinfo); + if( FAILED(hr) ) + { + _p_typeinfo = NULL; + } + p_typelib->Release(); + } + } + return hr; +}; + +STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo) +{ + if( SUCCEEDED(getTypeInfo()) ) + *pctInfo = 1; + else + *pctInfo = 0; + + return NOERROR; +}; + +STDMETHODIMP VLCControl::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo) +{ + if( NULL == ppTInfo ) + return E_INVALIDARG; + + if( SUCCEEDED(getTypeInfo()) ) + { + _p_typeinfo->AddRef(); + *ppTInfo = _p_typeinfo; + return NO_ERROR; + } + *ppTInfo = NULL; + return E_NOTIMPL; +}; + +STDMETHODIMP VLCControl::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, + UINT cNames, LCID lcid, DISPID* rgDispID) +{ + if( SUCCEEDED(getTypeInfo()) ) + { + return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid, + LCID lcid, WORD wFlags, DISPPARAMS* pDispParams, + VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr) +{ + if( SUCCEEDED(getTypeInfo()) ) + { + return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams, + pVarResult, pExcepInfo, puArgErr); + } + return E_NOTIMPL; +}; + +STDMETHODIMP VLCControl::get_Value(VARIANT *pvarValue) +{ + if( NULL == pvarValue ) + return E_INVALIDARG; + + V_VT(pvarValue) = VT_BOOL; + return get_Playing(&V_BOOL(pvarValue)); +}; + +STDMETHODIMP VLCControl::put_Value(VARIANT pvarValue) +{ + if( VT_BOOL != V_VT(&pvarValue) ) + { + VARIANT boolValue; + HRESULT hr = VariantChangeType(&boolValue, &pvarValue, 0, VT_BOOL); + if( SUCCEEDED(hr) ) + { + hr = get_Playing(&V_BOOL(&pvarValue)); + //VariantClear(&boolValue); + } + return hr; + } + return get_Playing(&V_BOOL(&pvarValue)); +}; + +STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible) +{ + if( NULL == isVisible ) + return E_INVALIDARG; + + *isVisible = _p_instance->getVisible(); + + return NOERROR; +}; + +STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible) +{ + _p_instance->setVisible(isVisible != VARIANT_FALSE); + + return NOERROR; +}; + +STDMETHODIMP VLCControl::play(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_Play(i_vlc); + _p_instance->fireOnPlayEvent(); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::pause(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_Pause(i_vlc); + _p_instance->fireOnPauseEvent(); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::stop(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_Stop(i_vlc); + _p_instance->fireOnStopEvent(); + return NOERROR; + } + return E_UNEXPECTED; +} + +STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying) +{ + if( NULL == isPlaying ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE; + return NOERROR; + } + *isPlaying = VARIANT_FALSE; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::put_Playing(VARIANT_BOOL isPlaying) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + if( VARIANT_FALSE == isPlaying ) + { + if( VLC_IsPlaying(i_vlc) ) + VLC_Stop(i_vlc); + } + else + { + if( ! VLC_IsPlaying(i_vlc) ) + VLC_Play(i_vlc); + } + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_Position(float *position) +{ + if( NULL == position ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *position = VLC_PositionGet(i_vlc); + return NOERROR; + } + *position = 0.0f; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::put_Position(float position) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_PositionSet(i_vlc, position); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_Time(int *seconds) +{ + if( NULL == seconds ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *seconds = VLC_TimeGet(i_vlc); + return NOERROR; + } + *seconds = 0; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::put_Time(int seconds) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_TimeSet(i_vlc, seconds, VLC_FALSE); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::shuttle(int seconds) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_TimeSet(i_vlc, seconds, VLC_TRUE); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::fullscreen(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_FullScreen(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_Length(int *seconds) +{ + if( NULL == seconds ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *seconds = VLC_LengthGet(i_vlc); + return NOERROR; + } + *seconds = 0; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::playFaster(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_SpeedFaster(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::playSlower(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_SpeedSlower(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_Volume(int *volume) +{ + if( NULL == volume ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *volume = VLC_VolumeGet(i_vlc); + return NOERROR; + } + *volume = 0; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::put_Volume(int volume) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_VolumeSet(i_vlc, volume); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::toggleMute(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_VolumeMute(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +static void freeTargetOptions(char **cOptions, int cOptionCount) +{ + // clean up + for( long pos=0; posQueryInterface(IID_IEnumVARIANT, (LPVOID *)&enumVar); + if( SUCCEEDED(hr) ) + { + long pos = 0; + long capacity = 16; + VARIANT option; + + *cOptions = (char **)malloc(capacity*sizeof(char *)); + if( NULL != *cOptions ) + { + ZeroMemory(*cOptions, sizeof(char *)*capacity); + while( SUCCEEDED(hr) && (S_OK == enumVar->Next(1, &option, NULL)) ) + { + if( VT_BSTR == V_VT(&option) ) + { + char *cOption = CStrFromBSTR(codePage, V_BSTR(&option)); + (*cOptions)[pos] = cOption; + if( NULL != cOption ) + { + ++pos; + if( pos == capacity ) + { + char **moreOptions = (char **)realloc(*cOptions, (capacity+16)*sizeof(char *)); + if( NULL != moreOptions ) + { + ZeroMemory(moreOptions+capacity, sizeof(char *)*16); + capacity += 16; + *cOptions = moreOptions; + } + else + hr = E_OUTOFMEMORY; + } + } + else + hr = E_OUTOFMEMORY; + } + else + hr = E_INVALIDARG; + + VariantClear(&option); + } + *cOptionCount = pos; + if( FAILED(hr) ) + { + // free already processed elements + freeTargetOptions(*cOptions, *cOptionCount); + } + } + else + hr = E_OUTOFMEMORY; + enumVar->Release(); + } + } + } + else if( V_ISARRAY(options) ) + { + // array parameter + SAFEARRAY *array = V_ISBYREF(options) ? *V_ARRAYREF(options) : V_ARRAY(options); + + if( SafeArrayGetDim(array) != 1 ) + return E_INVALIDARG; + + long lBound = 0; + long uBound = 0; + SafeArrayGetLBound(array, 1, &lBound); + SafeArrayGetUBound(array, 1, &uBound); + + // have we got any options + if( uBound > lBound ) + { + VARTYPE vType; + HRESULT hr = SafeArrayGetVartype(array, &vType); + if( FAILED(hr) ) + return hr; + + long pos; + + // marshall options into an array of C strings + if( VT_VARIANT == vType ) + { + *cOptions = (char **)malloc(sizeof(char *)*(uBound-lBound)); + if( NULL != options ) + return E_OUTOFMEMORY; + + for(pos=lBound; SUCCEEDED(hr) && (posgetVLCObject(); + if( i_vlc ) + { + int codePage = _p_instance->getCodePage(); + char *cUri = CStrFromBSTR(codePage, uri); + if( NULL == cUri ) + return E_OUTOFMEMORY; + + int cOptionsCount; + char **cOptions; + + if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) ) + return E_INVALIDARG; + + VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position); + hr = NOERROR; + + freeTargetOptions(cOptions, cOptionsCount); + free(cUri); + } + return hr; +}; + +STDMETHODIMP VLCControl::get_PlaylistIndex(int *index) +{ + if( NULL == index ) + return E_INVALIDARG; + + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *index = VLC_PlaylistIndex(i_vlc); + return NOERROR; + } + *index = 0; + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_PlaylistCount(int *count) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + *count = VLC_PlaylistNumberOfItems(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::playlistNext(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_PlaylistNext(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::playlistPrev(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_PlaylistPrev(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::playlistClear(void) +{ + int i_vlc = _p_instance->getVLCObject(); + if( i_vlc ) + { + VLC_PlaylistClear(i_vlc); + return NOERROR; + } + return E_UNEXPECTED; +}; + +STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version) +{ + if( NULL == version ) + return E_INVALIDARG; + + const char *versionStr = VLC_Version(); + if( NULL != versionStr ) + { + *version = BSTRFromCStr(_p_instance->getCodePage(), versionStr); + + return NULL == *version ? E_OUTOFMEMORY : NOERROR; + } + *version = NULL; + return E_FAIL; +}; + diff --git a/activex/vlccontrol.h b/activex/vlccontrol.h index bf60047217..89e4dda624 100644 --- a/activex/vlccontrol.h +++ b/activex/vlccontrol.h @@ -1,100 +1,100 @@ -/***************************************************************************** - * vlccontrol.h: ActiveX control for VLC - ***************************************************************************** - * Copyright (C) 2005 VideoLAN - * - * Authors: Damien Fouilleul - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#ifndef _VLCCONTROL_H_ -#define _VLCCONTROL_H_ - -#include -#include "axvlc_idl.h" - -class VLCControl : public IVLCControl -{ - -public: - - VLCControl(VLCPlugin *p_instance) : _p_instance(p_instance), _p_typeinfo(NULL) {}; - virtual ~VLCControl(); - - // IUnknown methods - STDMETHODIMP QueryInterface(REFIID riid, void **ppv) - { - if( (NULL != ppv) - && (IID_IUnknown == riid) - && (IID_IDispatch == riid) - && (IID_IVLCControl == riid) ) { - AddRef(); - *ppv = dynamic_cast(this); - return NOERROR; - } - return _p_instance->QueryInterface(riid, ppv); - }; - - STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; - STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; - - // IDispatch methods - STDMETHODIMP GetTypeInfoCount(UINT*); - STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*); - STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*); - STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*); - - // IVLCControl methods - STDMETHODIMP get_Value(VARIANT *pvarValue); - STDMETHODIMP put_Value(VARIANT pvarValue); - STDMETHODIMP play(void); - STDMETHODIMP get_Visible(VARIANT_BOOL *visible); - STDMETHODIMP put_Visible(VARIANT_BOOL visible); - STDMETHODIMP pause(void); - STDMETHODIMP stop(void); - STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying); - STDMETHODIMP put_Playing(VARIANT_BOOL isPlaying); - STDMETHODIMP get_Position(float *position); - STDMETHODIMP put_Position(float position); - STDMETHODIMP get_Time(int *seconds); - STDMETHODIMP put_Time(int seconds); - STDMETHODIMP shuttle(int seconds); - STDMETHODIMP fullscreen(); - STDMETHODIMP get_Length(int *seconds); - STDMETHODIMP playFaster(void); - STDMETHODIMP playSlower(void); - STDMETHODIMP get_Volume(int *volume); - STDMETHODIMP put_Volume(int volume); - STDMETHODIMP toggleMute(void); - STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position); - STDMETHODIMP get_PlaylistIndex(int *index); - STDMETHODIMP get_PlaylistCount(int *count); - STDMETHODIMP playlistNext(void); - STDMETHODIMP playlistPrev(void); - STDMETHODIMP playlistClear(void); - STDMETHODIMP get_VersionInfo(BSTR *version); - -private: - - HRESULT getTypeInfo(); - - VLCPlugin *_p_instance; - ITypeInfo *_p_typeinfo; - -}; - -#endif - +/***************************************************************************** + * vlccontrol.h: ActiveX control for VLC + ***************************************************************************** + * Copyright (C) 2005 VideoLAN + * + * Authors: Damien Fouilleul + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#ifndef _VLCCONTROL_H_ +#define _VLCCONTROL_H_ + +#include +#include "axvlc_idl.h" + +class VLCControl : public IVLCControl +{ + +public: + + VLCControl(VLCPlugin *p_instance) : _p_instance(p_instance), _p_typeinfo(NULL) {}; + virtual ~VLCControl(); + + // IUnknown methods + STDMETHODIMP QueryInterface(REFIID riid, void **ppv) + { + if( (NULL != ppv) + && (IID_IUnknown == riid) + && (IID_IDispatch == riid) + && (IID_IVLCControl == riid) ) { + AddRef(); + *ppv = dynamic_cast(this); + return NOERROR; + } + return _p_instance->QueryInterface(riid, ppv); + }; + + STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); }; + STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); }; + + // IDispatch methods + STDMETHODIMP GetTypeInfoCount(UINT*); + STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*); + STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*); + STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*); + + // IVLCControl methods + STDMETHODIMP get_Value(VARIANT *pvarValue); + STDMETHODIMP put_Value(VARIANT pvarValue); + STDMETHODIMP play(void); + STDMETHODIMP get_Visible(VARIANT_BOOL *visible); + STDMETHODIMP put_Visible(VARIANT_BOOL visible); + STDMETHODIMP pause(void); + STDMETHODIMP stop(void); + STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying); + STDMETHODIMP put_Playing(VARIANT_BOOL isPlaying); + STDMETHODIMP get_Position(float *position); + STDMETHODIMP put_Position(float position); + STDMETHODIMP get_Time(int *seconds); + STDMETHODIMP put_Time(int seconds); + STDMETHODIMP shuttle(int seconds); + STDMETHODIMP fullscreen(); + STDMETHODIMP get_Length(int *seconds); + STDMETHODIMP playFaster(void); + STDMETHODIMP playSlower(void); + STDMETHODIMP get_Volume(int *volume); + STDMETHODIMP put_Volume(int volume); + STDMETHODIMP toggleMute(void); + STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position); + STDMETHODIMP get_PlaylistIndex(int *index); + STDMETHODIMP get_PlaylistCount(int *count); + STDMETHODIMP playlistNext(void); + STDMETHODIMP playlistPrev(void); + STDMETHODIMP playlistClear(void); + STDMETHODIMP get_VersionInfo(BSTR *version); + +private: + + HRESULT getTypeInfo(); + + VLCPlugin *_p_instance; + ITypeInfo *_p_typeinfo; + +}; + +#endif + diff --git a/include/beos_specific.h b/include/beos_specific.h index c8e8b4b210..04f17f0148 100644 --- a/include/beos_specific.h +++ b/include/beos_specific.h @@ -2,7 +2,7 @@ * beos_specific.h: BeOS specific features ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: beos_specific.h,v 1.9 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Authors: Jean-Marc Dressler * diff --git a/include/charset.h b/include/charset.h index 629a28f973..f1ccc00f09 100644 --- a/include/charset.h +++ b/include/charset.h @@ -2,7 +2,7 @@ * charset.h: Determine a canonical name for the current locale's character encoding. ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: charset.h,v 1.3 2004/02/21 23:15:52 gbazin Exp $ + * $Id$ * * Author: Derk-Jan Hartman * diff --git a/include/intf_eject.h b/include/intf_eject.h index 589f127cd1..84529d59bf 100644 --- a/include/intf_eject.h +++ b/include/intf_eject.h @@ -2,7 +2,7 @@ * intf_eject.h: CD/DVD-ROM ejection handling functions ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: intf_eject.h,v 1.6 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Author: Julien Blache * diff --git a/include/iso_lang.h b/include/iso_lang.h index 9eebecc047..54a8de3369 100644 --- a/include/iso_lang.h +++ b/include/iso_lang.h @@ -2,7 +2,7 @@ * iso_lang.h: function to decode language code (in dvd or a52 for instance). ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: iso_lang.h,v 1.9 2003/10/24 17:41:58 sam Exp $ + * $Id$ * * Author: Stéphane Borel * Arnaud de Bossoreille de Ribou diff --git a/include/os_specific.h b/include/os_specific.h index 87ed1535db..11f816b90b 100644 --- a/include/os_specific.h +++ b/include/os_specific.h @@ -2,7 +2,7 @@ * os_specific.h: OS specific features ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: os_specific.h,v 1.13 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Authors: Samuel Hocevar * Gildas Bazin diff --git a/include/vlc/aout.h b/include/vlc/aout.h index afa2cfad08..ba0a07bc9d 100644 --- a/include/vlc/aout.h +++ b/include/vlc/aout.h @@ -2,7 +2,7 @@ * aout.h: audio output header for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: aout.h,v 1.2 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/vlc/sout.h b/include/vlc/sout.h index 8b60518a80..6de2696a1c 100644 --- a/include/vlc/sout.h +++ b/include/vlc/sout.h @@ -2,7 +2,7 @@ * sout.h: video output header for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: sout.h,v 1.4 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/include/vlc_bits.h b/include/vlc_bits.h index 87716e0fb0..5f3414a2b9 100644 --- a/include/vlc_bits.h +++ b/include/vlc_bits.h @@ -2,7 +2,7 @@ * bits.h : ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: vlc_bits.h,v 1.1 2003/11/18 20:15:38 fenrir Exp $ + * $Id$ * * Authors: Laurent Aimar * diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h index 7b7c6001fd..3928cd2695 100644 --- a/include/vlc_cpu.h +++ b/include/vlc_cpu.h @@ -2,7 +2,7 @@ * cpu.h: CPU type detection ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: vlc_cpu.h,v 1.6 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/include/vlc_error.h b/include/vlc_error.h index 786560adc5..184c6dab12 100644 --- a/include/vlc_error.h +++ b/include/vlc_error.h @@ -2,7 +2,7 @@ * vlc_error.h: error handling routine ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: vlc_error.h,v 1.1 2003/07/01 12:56:47 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/include/vlc_messages.h b/include/vlc_messages.h index 537c624b55..576f725bdc 100644 --- a/include/vlc_messages.h +++ b/include/vlc_messages.h @@ -4,7 +4,7 @@ * interface, such as message output. ***************************************************************************** * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN - * $Id: vlc_messages.h,v 1.11 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Authors: Vincent Seguin * Samuel Hocevar diff --git a/include/win32_specific.h b/include/win32_specific.h index 28ee141725..122ab491b3 100644 --- a/include/win32_specific.h +++ b/include/win32_specific.h @@ -2,7 +2,7 @@ * win32_specific.h: Win32 specific features ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: win32_specific.h,v 1.5 2004/01/25 18:17:08 zorglub Exp $ + * $Id$ * * Authors: Samuel Hocevar * Gildas Bazin diff --git a/modules/access/screen/beos.cpp b/modules/access/screen/beos.cpp index eb850c20e0..bf309d42ca 100644 --- a/modules/access/screen/beos.cpp +++ b/modules/access/screen/beos.cpp @@ -2,7 +2,7 @@ * beos.cpp: Screen capture module. ***************************************************************************** * Copyright (C) 2004 VideoLAN - * $Id: screen.c 8284 2004-07-26 10:27:55Z gbazin $ + * $Id$ * * Authors: Eric Petit * diff --git a/modules/access/v4l/videodev_mjpeg.h b/modules/access/v4l/videodev_mjpeg.h index 8d83a65de9..5d8f32d17d 100644 --- a/modules/access/v4l/videodev_mjpeg.h +++ b/modules/access/v4l/videodev_mjpeg.h @@ -2,7 +2,7 @@ * Copyright (C) lavrec (see http://mjpeg.sourceforge.net) * ( XXX This file was get from the driver-zoran package and it is under GPL) * - * $Id: videodev_mjpeg.h,v 1.2 2003/12/22 14:32:55 sam Exp $ + * $Id$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/modules/access/vcd/cdrom.c b/modules/access/vcd/cdrom.c index 0c347e6761..d21e0d8554 100644 --- a/modules/access/vcd/cdrom.c +++ b/modules/access/vcd/cdrom.c @@ -2,7 +2,7 @@ * cdrom.c: cdrom tools ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: cdrom.c,v 1.14 2003/08/09 19:14:16 gbazin Exp $ + * $Id$ * * Authors: Johan Bilien * Gildas Bazin diff --git a/modules/access/vcd/cdrom.h b/modules/access/vcd/cdrom.h index 27cf787fa3..5eb223a239 100644 --- a/modules/access/vcd/cdrom.h +++ b/modules/access/vcd/cdrom.h @@ -2,7 +2,7 @@ * cdrom.h: cdrom tools header ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: cdrom.h,v 1.6 2003/05/18 15:44:03 gbazin Exp $ + * $Id$ * * Authors: Johan Bilien * Gildas Bazin diff --git a/modules/access/vcd/cdrom_internals.h b/modules/access/vcd/cdrom_internals.h index e6a060a7dc..2c42bd6c3c 100644 --- a/modules/access/vcd/cdrom_internals.h +++ b/modules/access/vcd/cdrom_internals.h @@ -2,7 +2,7 @@ * cdrom_internals.h: cdrom tools private header ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: cdrom_internals.h,v 1.2 2003/05/18 15:44:03 gbazin Exp $ + * $Id$ * * Authors: Johan Bilien * Gildas Bazin diff --git a/modules/audio_filter/equalizer_presets.h b/modules/audio_filter/equalizer_presets.h index 5966630cf5..d6d302feea 100644 --- a/modules/audio_filter/equalizer_presets.h +++ b/modules/audio_filter/equalizer_presets.h @@ -2,7 +2,7 @@ * equalizer_presets.h: ***************************************************************************** * Copyright (C) 2004 VideoLAN - * $Id:$ + * $Id$ * * Authors: Laurent Aimar * diff --git a/modules/audio_filter/resampler/bandlimited.h b/modules/audio_filter/resampler/bandlimited.h index f39dbe67df..4d680eb57d 100644 --- a/modules/audio_filter/resampler/bandlimited.h +++ b/modules/audio_filter/resampler/bandlimited.h @@ -2,7 +2,7 @@ * bandlimited.h : bandlimited interpolation resampler ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: bandlimited.h,v 1.1 2003/03/04 03:27:40 gbazin Exp $ + * $Id$ * * Authors: Gildas Bazin * diff --git a/modules/codec/ffmpeg/video.c b/modules/codec/ffmpeg/video.c index a6fccdda5f..146d61aa74 100644 --- a/modules/codec/ffmpeg/video.c +++ b/modules/codec/ffmpeg/video.c @@ -1,881 +1,881 @@ -/***************************************************************************** - * video.c: video decoder using the ffmpeg library - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id$ - * - * Authors: Laurent Aimar - * Gildas Bazin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include -#include - -/* ffmpeg header */ -#ifdef HAVE_FFMPEG_AVCODEC_H -# include -#else -# include -#endif - -#include "ffmpeg.h" - -/***************************************************************************** - * decoder_sys_t : decoder descriptor - *****************************************************************************/ -struct decoder_sys_t -{ - /* Common part between video and audio decoder */ - int i_cat; - int i_codec_id; - char *psz_namecodec; - - AVCodecContext *p_context; - AVCodec *p_codec; - - /* Video decoder specific part */ - mtime_t input_pts; - mtime_t input_dts; - mtime_t i_pts; - - AVFrame *p_ff_pic; - BITMAPINFOHEADER *p_format; - - /* for frame skipping algo */ - int b_hurry_up; - int i_frame_skip; - - /* how many decoded frames are late */ - int i_late_frames; - mtime_t i_late_frames_start; - - /* for direct rendering */ - int b_direct_rendering; - - vlc_bool_t b_has_b_frames; - - /* Hack to force display of still pictures */ - vlc_bool_t b_first_frame; - - int i_buffer_orig, i_buffer; - char *p_buffer_orig, *p_buffer; - - /* Postprocessing handle */ - void *p_pp; - vlc_bool_t b_pp; - vlc_bool_t b_pp_async; - vlc_bool_t b_pp_init; -}; - -/* FIXME (dummy palette for now) */ -static AVPaletteControl palette_control; - -/***************************************************************************** - * Local prototypes - *****************************************************************************/ -static void ffmpeg_CopyPicture ( decoder_t *, picture_t *, AVFrame * ); -static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame * ); -static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * ); - -static uint32_t ffmpeg_CodecTag( vlc_fourcc_t fcc ) -{ - uint8_t *p = (uint8_t*)&fcc; - return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); -} - -/***************************************************************************** - * Local Functions - *****************************************************************************/ -static uint32_t ffmpeg_PixFmtToChroma( int i_ff_chroma ) -{ - switch( i_ff_chroma ) - { - case PIX_FMT_YUV420P: - return VLC_FOURCC('I','4','2','0'); - case PIX_FMT_YUV422P: - return VLC_FOURCC('I','4','2','2'); - case PIX_FMT_YUV444P: - return VLC_FOURCC('I','4','4','4'); - - case PIX_FMT_YUV422: - return VLC_FOURCC('Y','U','Y','2'); - - case PIX_FMT_RGB555: - return VLC_FOURCC('R','V','1','5'); - case PIX_FMT_RGB565: - return VLC_FOURCC('R','V','1','6'); - case PIX_FMT_RGB24: - return VLC_FOURCC('R','V','2','4'); - case PIX_FMT_RGBA32: - return VLC_FOURCC('R','V','3','2'); - case PIX_FMT_GRAY8: - return VLC_FOURCC('G','R','E','Y'); - - case PIX_FMT_YUV410P: - case PIX_FMT_YUV411P: - case PIX_FMT_BGR24: - default: - return 0; - } -} - -/* Returns a new picture buffer */ -static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, - AVCodecContext *p_context ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - picture_t *p_pic; - - p_dec->fmt_out.video.i_width = p_context->width; - p_dec->fmt_out.video.i_height = p_context->height; - p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); - - if( !p_context->width || !p_context->height ) - { - return NULL; /* invalid display size */ - } - - if( !p_dec->fmt_out.i_codec ) - { - /* we make conversion if possible*/ - p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0'); - } - - /* If an aspect-ratio was specified in the input format then force it */ - if( p_dec->fmt_in.video.i_aspect ) - { - p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect; - } - else - { -#if LIBAVCODEC_BUILD >= 4687 - p_dec->fmt_out.video.i_aspect = - VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) * - p_context->width / p_context->height ); -#else - p_dec->fmt_out.video.i_aspect = - VOUT_ASPECT_FACTOR * p_context->aspect_ratio; -#endif - if( p_dec->fmt_out.video.i_aspect == 0 ) - { - p_dec->fmt_out.video.i_aspect = - VOUT_ASPECT_FACTOR * p_context->width / p_context->height; - } - } - - if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 ) - { - p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate; - p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base; - } - - p_pic = p_dec->pf_vout_buffer_new( p_dec ); - -#ifdef LIBAVCODEC_PP - if( p_sys->p_pp && p_sys->b_pp && !p_sys->b_pp_init ) - { - E_(InitPostproc)( p_dec, p_sys->p_pp, p_context->width, - p_context->height, p_context->pix_fmt ); - p_sys->b_pp_init = VLC_TRUE; - } -#endif - - return p_pic; -} - -/***************************************************************************** - * InitVideo: initialize the video decoder - ***************************************************************************** - * the ffmpeg codec will be opened, some memory allocated. The vout is not yet - * opened (done after the first decoded frame). - *****************************************************************************/ -int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, - AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) -{ - decoder_sys_t *p_sys; - vlc_value_t lockval; - vlc_value_t val; - - var_Get( p_dec->p_libvlc, "avcodec", &lockval ); - - /* Allocate the memory needed to store the decoder's structure */ - if( ( p_dec->p_sys = p_sys = - (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) - { - msg_Err( p_dec, "out of memory" ); - return VLC_EGENERIC; - } - - p_dec->p_sys->p_context = p_context; - p_dec->p_sys->p_codec = p_codec; - p_dec->p_sys->i_codec_id = i_codec_id; - p_dec->p_sys->psz_namecodec = psz_namecodec; - p_sys->p_ff_pic = avcodec_alloc_frame(); - - /* ***** Fill p_context with init values ***** */ - /* FIXME: remove when ffmpeg deals properly with avc1 */ - if( p_dec->fmt_in.i_codec != VLC_FOURCC('a','v','c','1') ) - /* End FIXME */ - p_sys->p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_codec ); - p_sys->p_context->width = p_dec->fmt_in.video.i_width; - p_sys->p_context->height = p_dec->fmt_in.video.i_height; - p_sys->p_context->bits_per_sample = p_dec->fmt_in.video.i_bits_per_pixel; - - /* ***** Get configuration of ffmpeg plugin ***** */ - p_sys->p_context->workaround_bugs = - config_GetInt( p_dec, "ffmpeg-workaround-bugs" ); - p_sys->p_context->error_resilience = - config_GetInt( p_dec, "ffmpeg-error-resilience" ); - - var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Get( p_dec, "grayscale", &val ); - if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY; - - var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_dec, "ffmpeg-vismv", &val ); -#if LIBAVCODEC_BUILD >= 4698 - if( val.i_int ) p_sys->p_context->debug_mv = val.i_int; -#endif - - var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_dec, "ffmpeg-lowres", &val ); -#if LIBAVCODEC_BUILD >= 4723 - if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int; -#endif - - /* ***** ffmpeg frame skipping ***** */ - var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Get( p_dec, "ffmpeg-hurry-up", &val ); - p_sys->b_hurry_up = val.b_bool; - - /* ***** ffmpeg direct rendering ***** */ - p_sys->b_direct_rendering = 0; - var_Create( p_dec, "ffmpeg-dr", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Get( p_dec, "ffmpeg-dr", &val ); - if( val.b_bool && (p_sys->p_codec->capabilities & CODEC_CAP_DR1) && - ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) && - /* Apparently direct rendering doesn't work with YUV422P */ - p_sys->p_context->pix_fmt != PIX_FMT_YUV422P && - /* H264 uses too many reference frames */ - p_sys->i_codec_id != CODEC_ID_H264 && - !(p_sys->p_context->width % 16) && !(p_sys->p_context->height % 16) && -#if LIBAVCODEC_BUILD >= 4698 - !p_sys->p_context->debug_mv ) -#else - 1 ) -#endif - { - /* Some codecs set pix_fmt only after the 1st frame has been decoded, - * so we need to do another check in ffmpeg_GetFrameBuf() */ - p_sys->b_direct_rendering = 1; - } - -#ifdef LIBAVCODEC_PP - p_sys->p_pp = NULL; - p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE; - p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async ); -#endif - - /* ffmpeg doesn't properly release old pictures when frames are skipped */ - //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0; - if( p_sys->b_direct_rendering ) - { - msg_Dbg( p_dec, "using direct rendering" ); - p_sys->p_context->flags |= CODEC_FLAG_EMU_EDGE; - } - - /* Always use our get_buffer wrapper so we can calculate the - * PTS correctly */ - p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf; - p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; - p_sys->p_context->opaque = p_dec; - - /* ***** init this codec with special data ***** */ - if( p_dec->fmt_in.i_extra ) - { - int i_size = p_dec->fmt_in.i_extra; - - if( p_sys->i_codec_id == CODEC_ID_SVQ3 ) - { - uint8_t *p; - - p_sys->p_context->extradata_size = i_size + 12; - p = p_sys->p_context->extradata = - malloc( p_sys->p_context->extradata_size ); - - memcpy( &p[0], "SVQ3", 4 ); - memset( &p[4], 0, 8 ); - memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); - - /* Now remove all atoms before the SMI one */ - if( p_sys->p_context->extradata_size > 0x5a && - strncmp( &p[0x56], "SMI ", 4 ) ) - { - uint8_t *psz = &p[0x52]; - - while( psz < &p[p_sys->p_context->extradata_size - 8] ) - { - int i_size = GetDWBE( psz ); - if( i_size <= 1 ) - { - /* FIXME handle 1 as long size */ - break; - } - if( !strncmp( &psz[4], "SMI ", 4 ) ) - { - memmove( &p[0x52], psz, - &p[p_sys->p_context->extradata_size] - psz ); - break; - } - - psz += i_size; - } - } - } - else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) || - p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) || - p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) ) - { - if( p_dec->fmt_in.i_extra == 8 ) - { - p_sys->p_context->extradata_size = 8; - p_sys->p_context->extradata = malloc( 8 ); - - memcpy( p_sys->p_context->extradata, - p_dec->fmt_in.p_extra, - p_dec->fmt_in.i_extra ); - p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; - - msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", - p_sys->p_context->sub_id ); - } - } - /* FIXME: remove when ffmpeg deals properly with avc1 */ - else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') ) - { - ; - } - /* End FIXME */ - else - { - p_sys->p_context->extradata_size = i_size; - p_sys->p_context->extradata = - malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); - memcpy( p_sys->p_context->extradata, - p_dec->fmt_in.p_extra, i_size ); - memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], - 0, FF_INPUT_BUFFER_PADDING_SIZE ); - } - } - - /* ***** misc init ***** */ - p_sys->input_pts = p_sys->input_dts = 0; - p_sys->i_pts = 0; - p_sys->b_has_b_frames = VLC_FALSE; - p_sys->b_first_frame = VLC_TRUE; - p_sys->i_late_frames = 0; - p_sys->i_buffer = 0; - p_sys->i_buffer_orig = 1; - p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig ); - - /* Set output properties */ - p_dec->fmt_out.i_cat = VIDEO_ES; - p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); - - /* Setup palette */ -#if LIBAVCODEC_BUILD >= 4688 - if( p_dec->fmt_in.video.p_palette ) - p_sys->p_context->palctrl = - (AVPaletteControl *)p_dec->fmt_in.video.p_palette; - else - p_sys->p_context->palctrl = &palette_control; -#endif - - /* ***** Open the codec ***** */ - vlc_mutex_lock( lockval.p_address ); - if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 ) - { - vlc_mutex_unlock( lockval.p_address ); - msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); - free( p_sys ); - return VLC_EGENERIC; - } - vlc_mutex_unlock( lockval.p_address ); - msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); - - - return VLC_SUCCESS; -} - -/***************************************************************************** - * DecodeVideo: Called to decode one or more frames - *****************************************************************************/ -picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - int b_drawpicture; - int b_null_size = VLC_FALSE; - block_t *p_block; - - if( !pp_block || !*pp_block ) return NULL; - - p_block = *pp_block; - - if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) - { - p_sys->i_buffer = 0; - p_sys->i_pts = 0; /* To make sure we recover properly */ - - p_sys->input_pts = p_sys->input_dts = 0; - p_sys->i_late_frames = 0; - - block_Release( p_block ); - return NULL; - } - - if( p_block->i_flags & BLOCK_FLAG_PREROLL ) - { - /* Do not care about late frames when prerolling - * TODO avoid decoding of non reference frame - * (ie all B except for H264 where it depends only on nal_ref_idc) */ - p_sys->i_late_frames = 0; - } - - if( !p_dec->b_pace_control && p_sys->i_late_frames > 0 && - mdate() - p_sys->i_late_frames_start > I64C(5000000) ) - { - if( p_sys->i_pts ) - { - msg_Err( p_dec, "more than 5 seconds of late video -> " - "dropping frame (computer too slow ?)" ); - p_sys->i_pts = 0; /* To make sure we recover properly */ - } - block_Release( p_block ); - p_sys->i_late_frames--; - return NULL; - } - - if( p_block->i_pts > 0 || p_block->i_dts > 0 ) - { - p_sys->input_pts = p_block->i_pts; - p_sys->input_dts = p_block->i_dts; - - /* Make sure we don't reuse the same timestamps twice */ - p_block->i_pts = p_block->i_dts = 0; - } - - /* TODO implement it in a better way */ - /* A good idea could be to decode all I pictures and see for the other */ - if( !p_dec->b_pace_control && - p_sys->b_hurry_up && p_sys->i_late_frames > 4 ) - { - b_drawpicture = 0; - if( p_sys->i_late_frames < 8 ) - { - p_sys->p_context->hurry_up = 2; - } - else - { - /* picture too late, won't decode - * but break picture until a new I, and for mpeg4 ...*/ - - p_sys->i_late_frames--; /* needed else it will never be decrease */ - block_Release( p_block ); - p_sys->i_buffer = 0; - return NULL; - } - } - else - { - if (!(p_block->i_flags & BLOCK_FLAG_PREROLL)) - { - b_drawpicture = 1; - p_sys->p_context->hurry_up = 0; - } - else - { - b_drawpicture = 0; - p_sys->p_context->hurry_up = 1; - } - } - - - if( p_sys->p_context->width <= 0 || p_sys->p_context->height <= 0 ) - { - p_sys->p_context->hurry_up = 5; - b_null_size = VLC_TRUE; - } - - /* - * Do the actual decoding now - */ - - /* Check if post-processing was enabled */ - p_sys->b_pp = p_sys->b_pp_async; - - /* Don't forget that ffmpeg requires a little more bytes - * that the real frame size */ - if( p_block->i_buffer > 0 ) - { - p_sys->i_buffer = p_block->i_buffer; - if( p_sys->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE > - p_sys->i_buffer_orig ) - { - free( p_sys->p_buffer_orig ); - p_sys->i_buffer_orig = - p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE; - p_sys->p_buffer_orig = malloc( p_sys->i_buffer_orig ); - } - p_sys->p_buffer = p_sys->p_buffer_orig; - p_sys->i_buffer = p_block->i_buffer; - p_dec->p_vlc->pf_memcpy( p_sys->p_buffer, p_block->p_buffer, - p_block->i_buffer ); - memset( p_sys->p_buffer + p_block->i_buffer, 0, - FF_INPUT_BUFFER_PADDING_SIZE ); - - p_block->i_buffer = 0; - } - - while( p_sys->i_buffer > 0 ) - { - int i_used, b_gotpicture; - picture_t *p_pic; - - i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, - &b_gotpicture, - p_sys->p_buffer, p_sys->i_buffer ); - if( b_null_size && p_sys->p_context->width > 0 && - p_sys->p_context->height > 0 ) - { - /* Reparse it to not drop the I frame */ - b_null_size = VLC_FALSE; - p_sys->p_context->hurry_up = 0; - i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, - &b_gotpicture, - p_sys->p_buffer, p_sys->i_buffer ); - } - - if( i_used < 0 ) - { - msg_Warn( p_dec, "cannot decode one frame (%d bytes)", - p_sys->i_buffer ); - block_Release( p_block ); - return NULL; - } - else if( i_used > p_sys->i_buffer ) - { - i_used = p_sys->i_buffer; - } - - /* Consumed bytes */ - p_sys->i_buffer -= i_used; - p_sys->p_buffer += i_used; - - /* Nothing to display */ - if( !b_gotpicture ) - { - if( i_used == 0 ) break; - continue; - } - - /* Update frame late count (except when doing preroll) */ - if( p_sys->i_pts && p_sys->i_pts <= mdate() && - !(p_block->i_flags & BLOCK_FLAG_PREROLL) ) - { - p_sys->i_late_frames++; - if( p_sys->i_late_frames == 1 ) - p_sys->i_late_frames_start = mdate(); - } - else - { - p_sys->i_late_frames = 0; - } - - if( !b_drawpicture || !p_sys->p_ff_pic->linesize[0] ) - { - /* Do not display the picture */ - continue; - } - - if( !p_sys->p_ff_pic->opaque ) - { - /* Get a new picture */ - p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context ); - if( !p_pic ) - { - block_Release( p_block ); - return NULL; - } - - /* Fill p_picture_t from AVVideoFrame and do chroma conversion - * if needed */ - ffmpeg_CopyPicture( p_dec, p_pic, p_sys->p_ff_pic ); - } - else - { - p_pic = (picture_t *)p_sys->p_ff_pic->opaque; - } - - /* Set the PTS */ - if( p_sys->p_ff_pic->pts ) p_sys->i_pts = p_sys->p_ff_pic->pts; - - /* Sanity check (seems to be needed for some streams ) */ - if( p_sys->p_ff_pic->pict_type == FF_B_TYPE ) - { - p_sys->b_has_b_frames = VLC_TRUE; - } - - /* Send decoded frame to vout */ - if( p_sys->i_pts ) - { - p_pic->date = p_sys->i_pts; - - /* interpolate the next PTS */ - if( p_sys->p_context->frame_rate > 0 ) - { - p_sys->i_pts += I64C(1000000) * - (2 + p_sys->p_ff_pic->repeat_pict) * - p_sys->p_context->frame_rate_base / - (2 * p_sys->p_context->frame_rate); - } - - if( p_sys->b_first_frame ) - { - /* Hack to force display of still pictures */ - p_sys->b_first_frame = VLC_FALSE; - p_pic->b_force = VLC_TRUE; - } - - p_pic->i_nb_fields = 2 + p_sys->p_ff_pic->repeat_pict; -#if LIBAVCODEC_BUILD >= 4685 - p_pic->b_progressive = !p_sys->p_ff_pic->interlaced_frame; - p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first; -#endif - - return p_pic; - } - else - { - p_dec->pf_vout_buffer_del( p_dec, p_pic ); - } - } - - block_Release( p_block ); - return NULL; -} - -/***************************************************************************** - * EndVideo: decoder destruction - ***************************************************************************** - * This function is called when the thread ends after a sucessful - * initialization. - *****************************************************************************/ -void E_(EndVideoDec)( decoder_t *p_dec ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - - if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic ); - -#ifdef LIBAVCODEC_PP - E_(ClosePostproc)( p_dec, p_sys->p_pp ); -#endif - - free( p_sys->p_buffer_orig ); -} - -/***************************************************************************** - * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a - * picture_t structure (when not in direct rendering mode). - *****************************************************************************/ -static void ffmpeg_CopyPicture( decoder_t *p_dec, - picture_t *p_pic, AVFrame *p_ff_pic ) -{ - decoder_sys_t *p_sys = p_dec->p_sys; - - if( ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) ) - { - int i_plane, i_size, i_line; - uint8_t *p_dst, *p_src; - int i_src_stride, i_dst_stride; - -#ifdef LIBAVCODEC_PP - if( p_sys->p_pp && p_sys->b_pp ) - E_(PostprocPict)( p_dec, p_sys->p_pp, p_pic, p_ff_pic ); - else -#endif - for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ ) - { - p_src = p_ff_pic->data[i_plane]; - p_dst = p_pic->p[i_plane].p_pixels; - i_src_stride = p_ff_pic->linesize[i_plane]; - i_dst_stride = p_pic->p[i_plane].i_pitch; - - i_size = __MIN( i_src_stride, i_dst_stride ); - for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; - i_line++ ) - { - p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_size ); - p_src += i_src_stride; - p_dst += i_dst_stride; - } - } - } - else - { - AVPicture dest_pic; - int i; - - /* we need to convert to I420 */ - switch( p_sys->p_context->pix_fmt ) - { - case PIX_FMT_YUV410P: - case PIX_FMT_YUV411P: - case PIX_FMT_PAL8: - for( i = 0; i < p_pic->i_planes; i++ ) - { - dest_pic.data[i] = p_pic->p[i].p_pixels; - dest_pic.linesize[i] = p_pic->p[i].i_pitch; - } - img_convert( &dest_pic, PIX_FMT_YUV420P, - (AVPicture *)p_ff_pic, - p_sys->p_context->pix_fmt, - p_sys->p_context->width, - p_sys->p_context->height ); - break; - default: - msg_Err( p_dec, "don't know how to convert chroma %i", - p_sys->p_context->pix_fmt ); - p_dec->b_error = 1; - break; - } - } -} - -/***************************************************************************** - * ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer. - ***************************************************************************** - * It is used for direct rendering as well as to get the right PTS for each - * decoded picture (even in indirect rendering mode). - *****************************************************************************/ -static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, - AVFrame *p_ff_pic ) -{ - decoder_t *p_dec = (decoder_t *)p_context->opaque; - decoder_sys_t *p_sys = p_dec->p_sys; - picture_t *p_pic; - - /* Set picture PTS */ - if( p_sys->input_pts ) - { - p_ff_pic->pts = p_sys->input_pts; - } - else if( p_sys->input_dts ) - { - /* Some demuxers only set the dts so let's try to find a useful - * timestamp from this */ - if( !p_context->has_b_frames || !p_sys->b_has_b_frames || - !p_ff_pic->reference || !p_sys->i_pts ) - { - p_ff_pic->pts = p_sys->input_dts; - } - else p_ff_pic->pts = 0; - } - else p_ff_pic->pts = 0; - - if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */ - { - p_sys->input_pts = p_sys->input_dts = 0; - } - - p_ff_pic->opaque = 0; - - /* Not much to do in indirect rendering mode */ - if( !p_sys->b_direct_rendering || p_sys->b_pp ) - { - return avcodec_default_get_buffer( p_context, p_ff_pic ); - } - - /* Some codecs set pix_fmt only after the 1st frame has been decoded, - * so this check is necessary. */ - if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) || - p_sys->p_context->width % 16 || p_sys->p_context->height % 16 ) - { - msg_Dbg( p_dec, "disabling direct rendering" ); - p_sys->b_direct_rendering = 0; - return avcodec_default_get_buffer( p_context, p_ff_pic ); - } - - /* Get a new picture */ - //p_sys->p_vout->render.b_allow_modify_pics = 0; - p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context ); - if( !p_pic ) - { - p_sys->b_direct_rendering = 0; - return avcodec_default_get_buffer( p_context, p_ff_pic ); - } - p_sys->p_context->draw_horiz_band = NULL; - - p_ff_pic->opaque = (void*)p_pic; - p_ff_pic->type = FF_BUFFER_TYPE_USER; - p_ff_pic->data[0] = p_pic->p[0].p_pixels; - p_ff_pic->data[1] = p_pic->p[1].p_pixels; - p_ff_pic->data[2] = p_pic->p[2].p_pixels; - p_ff_pic->data[3] = NULL; /* alpha channel but I'm not sure */ - - p_ff_pic->linesize[0] = p_pic->p[0].i_pitch; - p_ff_pic->linesize[1] = p_pic->p[1].i_pitch; - p_ff_pic->linesize[2] = p_pic->p[2].i_pitch; - p_ff_pic->linesize[3] = 0; - - if( p_ff_pic->reference != 0 ) - { - p_dec->pf_picture_link( p_dec, p_pic ); - } - - /* FIXME what is that, should give good value */ - p_ff_pic->age = 256*256*256*64; // FIXME FIXME from ffmpeg - - return 0; -} - -static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context, - AVFrame *p_ff_pic ) -{ - decoder_t *p_dec = (decoder_t *)p_context->opaque; - picture_t *p_pic; - - if( !p_ff_pic->opaque ) - { - avcodec_default_release_buffer( p_context, p_ff_pic ); - return; - } - - p_pic = (picture_t*)p_ff_pic->opaque; - - p_ff_pic->data[0] = NULL; - p_ff_pic->data[1] = NULL; - p_ff_pic->data[2] = NULL; - p_ff_pic->data[3] = NULL; - - if( p_ff_pic->reference != 0 ) - { - p_dec->pf_picture_unlink( p_dec, p_pic ); - } -} +/***************************************************************************** + * video.c: video decoder using the ffmpeg library + ***************************************************************************** + * Copyright (C) 1999-2001 VideoLAN + * $Id$ + * + * Authors: Laurent Aimar + * Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include +#include + +/* ffmpeg header */ +#ifdef HAVE_FFMPEG_AVCODEC_H +# include +#else +# include +#endif + +#include "ffmpeg.h" + +/***************************************************************************** + * decoder_sys_t : decoder descriptor + *****************************************************************************/ +struct decoder_sys_t +{ + /* Common part between video and audio decoder */ + int i_cat; + int i_codec_id; + char *psz_namecodec; + + AVCodecContext *p_context; + AVCodec *p_codec; + + /* Video decoder specific part */ + mtime_t input_pts; + mtime_t input_dts; + mtime_t i_pts; + + AVFrame *p_ff_pic; + BITMAPINFOHEADER *p_format; + + /* for frame skipping algo */ + int b_hurry_up; + int i_frame_skip; + + /* how many decoded frames are late */ + int i_late_frames; + mtime_t i_late_frames_start; + + /* for direct rendering */ + int b_direct_rendering; + + vlc_bool_t b_has_b_frames; + + /* Hack to force display of still pictures */ + vlc_bool_t b_first_frame; + + int i_buffer_orig, i_buffer; + char *p_buffer_orig, *p_buffer; + + /* Postprocessing handle */ + void *p_pp; + vlc_bool_t b_pp; + vlc_bool_t b_pp_async; + vlc_bool_t b_pp_init; +}; + +/* FIXME (dummy palette for now) */ +static AVPaletteControl palette_control; + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static void ffmpeg_CopyPicture ( decoder_t *, picture_t *, AVFrame * ); +static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame * ); +static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * ); + +static uint32_t ffmpeg_CodecTag( vlc_fourcc_t fcc ) +{ + uint8_t *p = (uint8_t*)&fcc; + return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24); +} + +/***************************************************************************** + * Local Functions + *****************************************************************************/ +static uint32_t ffmpeg_PixFmtToChroma( int i_ff_chroma ) +{ + switch( i_ff_chroma ) + { + case PIX_FMT_YUV420P: + return VLC_FOURCC('I','4','2','0'); + case PIX_FMT_YUV422P: + return VLC_FOURCC('I','4','2','2'); + case PIX_FMT_YUV444P: + return VLC_FOURCC('I','4','4','4'); + + case PIX_FMT_YUV422: + return VLC_FOURCC('Y','U','Y','2'); + + case PIX_FMT_RGB555: + return VLC_FOURCC('R','V','1','5'); + case PIX_FMT_RGB565: + return VLC_FOURCC('R','V','1','6'); + case PIX_FMT_RGB24: + return VLC_FOURCC('R','V','2','4'); + case PIX_FMT_RGBA32: + return VLC_FOURCC('R','V','3','2'); + case PIX_FMT_GRAY8: + return VLC_FOURCC('G','R','E','Y'); + + case PIX_FMT_YUV410P: + case PIX_FMT_YUV411P: + case PIX_FMT_BGR24: + default: + return 0; + } +} + +/* Returns a new picture buffer */ +static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec, + AVCodecContext *p_context ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + picture_t *p_pic; + + p_dec->fmt_out.video.i_width = p_context->width; + p_dec->fmt_out.video.i_height = p_context->height; + p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); + + if( !p_context->width || !p_context->height ) + { + return NULL; /* invalid display size */ + } + + if( !p_dec->fmt_out.i_codec ) + { + /* we make conversion if possible*/ + p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0'); + } + + /* If an aspect-ratio was specified in the input format then force it */ + if( p_dec->fmt_in.video.i_aspect ) + { + p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect; + } + else + { +#if LIBAVCODEC_BUILD >= 4687 + p_dec->fmt_out.video.i_aspect = + VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) * + p_context->width / p_context->height ); +#else + p_dec->fmt_out.video.i_aspect = + VOUT_ASPECT_FACTOR * p_context->aspect_ratio; +#endif + if( p_dec->fmt_out.video.i_aspect == 0 ) + { + p_dec->fmt_out.video.i_aspect = + VOUT_ASPECT_FACTOR * p_context->width / p_context->height; + } + } + + if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 ) + { + p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate; + p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base; + } + + p_pic = p_dec->pf_vout_buffer_new( p_dec ); + +#ifdef LIBAVCODEC_PP + if( p_sys->p_pp && p_sys->b_pp && !p_sys->b_pp_init ) + { + E_(InitPostproc)( p_dec, p_sys->p_pp, p_context->width, + p_context->height, p_context->pix_fmt ); + p_sys->b_pp_init = VLC_TRUE; + } +#endif + + return p_pic; +} + +/***************************************************************************** + * InitVideo: initialize the video decoder + ***************************************************************************** + * the ffmpeg codec will be opened, some memory allocated. The vout is not yet + * opened (done after the first decoded frame). + *****************************************************************************/ +int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context, + AVCodec *p_codec, int i_codec_id, char *psz_namecodec ) +{ + decoder_sys_t *p_sys; + vlc_value_t lockval; + vlc_value_t val; + + var_Get( p_dec->p_libvlc, "avcodec", &lockval ); + + /* Allocate the memory needed to store the decoder's structure */ + if( ( p_dec->p_sys = p_sys = + (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL ) + { + msg_Err( p_dec, "out of memory" ); + return VLC_EGENERIC; + } + + p_dec->p_sys->p_context = p_context; + p_dec->p_sys->p_codec = p_codec; + p_dec->p_sys->i_codec_id = i_codec_id; + p_dec->p_sys->psz_namecodec = psz_namecodec; + p_sys->p_ff_pic = avcodec_alloc_frame(); + + /* ***** Fill p_context with init values ***** */ + /* FIXME: remove when ffmpeg deals properly with avc1 */ + if( p_dec->fmt_in.i_codec != VLC_FOURCC('a','v','c','1') ) + /* End FIXME */ + p_sys->p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_codec ); + p_sys->p_context->width = p_dec->fmt_in.video.i_width; + p_sys->p_context->height = p_dec->fmt_in.video.i_height; + p_sys->p_context->bits_per_sample = p_dec->fmt_in.video.i_bits_per_pixel; + + /* ***** Get configuration of ffmpeg plugin ***** */ + p_sys->p_context->workaround_bugs = + config_GetInt( p_dec, "ffmpeg-workaround-bugs" ); + p_sys->p_context->error_resilience = + config_GetInt( p_dec, "ffmpeg-error-resilience" ); + + var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); + var_Get( p_dec, "grayscale", &val ); + if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY; + + var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Get( p_dec, "ffmpeg-vismv", &val ); +#if LIBAVCODEC_BUILD >= 4698 + if( val.i_int ) p_sys->p_context->debug_mv = val.i_int; +#endif + + var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); + var_Get( p_dec, "ffmpeg-lowres", &val ); +#if LIBAVCODEC_BUILD >= 4723 + if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int; +#endif + + /* ***** ffmpeg frame skipping ***** */ + var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); + var_Get( p_dec, "ffmpeg-hurry-up", &val ); + p_sys->b_hurry_up = val.b_bool; + + /* ***** ffmpeg direct rendering ***** */ + p_sys->b_direct_rendering = 0; + var_Create( p_dec, "ffmpeg-dr", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); + var_Get( p_dec, "ffmpeg-dr", &val ); + if( val.b_bool && (p_sys->p_codec->capabilities & CODEC_CAP_DR1) && + ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) && + /* Apparently direct rendering doesn't work with YUV422P */ + p_sys->p_context->pix_fmt != PIX_FMT_YUV422P && + /* H264 uses too many reference frames */ + p_sys->i_codec_id != CODEC_ID_H264 && + !(p_sys->p_context->width % 16) && !(p_sys->p_context->height % 16) && +#if LIBAVCODEC_BUILD >= 4698 + !p_sys->p_context->debug_mv ) +#else + 1 ) +#endif + { + /* Some codecs set pix_fmt only after the 1st frame has been decoded, + * so we need to do another check in ffmpeg_GetFrameBuf() */ + p_sys->b_direct_rendering = 1; + } + +#ifdef LIBAVCODEC_PP + p_sys->p_pp = NULL; + p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE; + p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async ); +#endif + + /* ffmpeg doesn't properly release old pictures when frames are skipped */ + //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0; + if( p_sys->b_direct_rendering ) + { + msg_Dbg( p_dec, "using direct rendering" ); + p_sys->p_context->flags |= CODEC_FLAG_EMU_EDGE; + } + + /* Always use our get_buffer wrapper so we can calculate the + * PTS correctly */ + p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf; + p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf; + p_sys->p_context->opaque = p_dec; + + /* ***** init this codec with special data ***** */ + if( p_dec->fmt_in.i_extra ) + { + int i_size = p_dec->fmt_in.i_extra; + + if( p_sys->i_codec_id == CODEC_ID_SVQ3 ) + { + uint8_t *p; + + p_sys->p_context->extradata_size = i_size + 12; + p = p_sys->p_context->extradata = + malloc( p_sys->p_context->extradata_size ); + + memcpy( &p[0], "SVQ3", 4 ); + memset( &p[4], 0, 8 ); + memcpy( &p[12], p_dec->fmt_in.p_extra, i_size ); + + /* Now remove all atoms before the SMI one */ + if( p_sys->p_context->extradata_size > 0x5a && + strncmp( &p[0x56], "SMI ", 4 ) ) + { + uint8_t *psz = &p[0x52]; + + while( psz < &p[p_sys->p_context->extradata_size - 8] ) + { + int i_size = GetDWBE( psz ); + if( i_size <= 1 ) + { + /* FIXME handle 1 as long size */ + break; + } + if( !strncmp( &psz[4], "SMI ", 4 ) ) + { + memmove( &p[0x52], psz, + &p[p_sys->p_context->extradata_size] - psz ); + break; + } + + psz += i_size; + } + } + } + else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) || + p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) || + p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) ) + { + if( p_dec->fmt_in.i_extra == 8 ) + { + p_sys->p_context->extradata_size = 8; + p_sys->p_context->extradata = malloc( 8 ); + + memcpy( p_sys->p_context->extradata, + p_dec->fmt_in.p_extra, + p_dec->fmt_in.i_extra ); + p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1]; + + msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x", + p_sys->p_context->sub_id ); + } + } + /* FIXME: remove when ffmpeg deals properly with avc1 */ + else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') ) + { + ; + } + /* End FIXME */ + else + { + p_sys->p_context->extradata_size = i_size; + p_sys->p_context->extradata = + malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE ); + memcpy( p_sys->p_context->extradata, + p_dec->fmt_in.p_extra, i_size ); + memset( &((uint8_t*)p_sys->p_context->extradata)[i_size], + 0, FF_INPUT_BUFFER_PADDING_SIZE ); + } + } + + /* ***** misc init ***** */ + p_sys->input_pts = p_sys->input_dts = 0; + p_sys->i_pts = 0; + p_sys->b_has_b_frames = VLC_FALSE; + p_sys->b_first_frame = VLC_TRUE; + p_sys->i_late_frames = 0; + p_sys->i_buffer = 0; + p_sys->i_buffer_orig = 1; + p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig ); + + /* Set output properties */ + p_dec->fmt_out.i_cat = VIDEO_ES; + p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt ); + + /* Setup palette */ +#if LIBAVCODEC_BUILD >= 4688 + if( p_dec->fmt_in.video.p_palette ) + p_sys->p_context->palctrl = + (AVPaletteControl *)p_dec->fmt_in.video.p_palette; + else + p_sys->p_context->palctrl = &palette_control; +#endif + + /* ***** Open the codec ***** */ + vlc_mutex_lock( lockval.p_address ); + if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 ) + { + vlc_mutex_unlock( lockval.p_address ); + msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec ); + free( p_sys ); + return VLC_EGENERIC; + } + vlc_mutex_unlock( lockval.p_address ); + msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec ); + + + return VLC_SUCCESS; +} + +/***************************************************************************** + * DecodeVideo: Called to decode one or more frames + *****************************************************************************/ +picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + int b_drawpicture; + int b_null_size = VLC_FALSE; + block_t *p_block; + + if( !pp_block || !*pp_block ) return NULL; + + p_block = *pp_block; + + if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) ) + { + p_sys->i_buffer = 0; + p_sys->i_pts = 0; /* To make sure we recover properly */ + + p_sys->input_pts = p_sys->input_dts = 0; + p_sys->i_late_frames = 0; + + block_Release( p_block ); + return NULL; + } + + if( p_block->i_flags & BLOCK_FLAG_PREROLL ) + { + /* Do not care about late frames when prerolling + * TODO avoid decoding of non reference frame + * (ie all B except for H264 where it depends only on nal_ref_idc) */ + p_sys->i_late_frames = 0; + } + + if( !p_dec->b_pace_control && p_sys->i_late_frames > 0 && + mdate() - p_sys->i_late_frames_start > I64C(5000000) ) + { + if( p_sys->i_pts ) + { + msg_Err( p_dec, "more than 5 seconds of late video -> " + "dropping frame (computer too slow ?)" ); + p_sys->i_pts = 0; /* To make sure we recover properly */ + } + block_Release( p_block ); + p_sys->i_late_frames--; + return NULL; + } + + if( p_block->i_pts > 0 || p_block->i_dts > 0 ) + { + p_sys->input_pts = p_block->i_pts; + p_sys->input_dts = p_block->i_dts; + + /* Make sure we don't reuse the same timestamps twice */ + p_block->i_pts = p_block->i_dts = 0; + } + + /* TODO implement it in a better way */ + /* A good idea could be to decode all I pictures and see for the other */ + if( !p_dec->b_pace_control && + p_sys->b_hurry_up && p_sys->i_late_frames > 4 ) + { + b_drawpicture = 0; + if( p_sys->i_late_frames < 8 ) + { + p_sys->p_context->hurry_up = 2; + } + else + { + /* picture too late, won't decode + * but break picture until a new I, and for mpeg4 ...*/ + + p_sys->i_late_frames--; /* needed else it will never be decrease */ + block_Release( p_block ); + p_sys->i_buffer = 0; + return NULL; + } + } + else + { + if (!(p_block->i_flags & BLOCK_FLAG_PREROLL)) + { + b_drawpicture = 1; + p_sys->p_context->hurry_up = 0; + } + else + { + b_drawpicture = 0; + p_sys->p_context->hurry_up = 1; + } + } + + + if( p_sys->p_context->width <= 0 || p_sys->p_context->height <= 0 ) + { + p_sys->p_context->hurry_up = 5; + b_null_size = VLC_TRUE; + } + + /* + * Do the actual decoding now + */ + + /* Check if post-processing was enabled */ + p_sys->b_pp = p_sys->b_pp_async; + + /* Don't forget that ffmpeg requires a little more bytes + * that the real frame size */ + if( p_block->i_buffer > 0 ) + { + p_sys->i_buffer = p_block->i_buffer; + if( p_sys->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE > + p_sys->i_buffer_orig ) + { + free( p_sys->p_buffer_orig ); + p_sys->i_buffer_orig = + p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE; + p_sys->p_buffer_orig = malloc( p_sys->i_buffer_orig ); + } + p_sys->p_buffer = p_sys->p_buffer_orig; + p_sys->i_buffer = p_block->i_buffer; + p_dec->p_vlc->pf_memcpy( p_sys->p_buffer, p_block->p_buffer, + p_block->i_buffer ); + memset( p_sys->p_buffer + p_block->i_buffer, 0, + FF_INPUT_BUFFER_PADDING_SIZE ); + + p_block->i_buffer = 0; + } + + while( p_sys->i_buffer > 0 ) + { + int i_used, b_gotpicture; + picture_t *p_pic; + + i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, + &b_gotpicture, + p_sys->p_buffer, p_sys->i_buffer ); + if( b_null_size && p_sys->p_context->width > 0 && + p_sys->p_context->height > 0 ) + { + /* Reparse it to not drop the I frame */ + b_null_size = VLC_FALSE; + p_sys->p_context->hurry_up = 0; + i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic, + &b_gotpicture, + p_sys->p_buffer, p_sys->i_buffer ); + } + + if( i_used < 0 ) + { + msg_Warn( p_dec, "cannot decode one frame (%d bytes)", + p_sys->i_buffer ); + block_Release( p_block ); + return NULL; + } + else if( i_used > p_sys->i_buffer ) + { + i_used = p_sys->i_buffer; + } + + /* Consumed bytes */ + p_sys->i_buffer -= i_used; + p_sys->p_buffer += i_used; + + /* Nothing to display */ + if( !b_gotpicture ) + { + if( i_used == 0 ) break; + continue; + } + + /* Update frame late count (except when doing preroll) */ + if( p_sys->i_pts && p_sys->i_pts <= mdate() && + !(p_block->i_flags & BLOCK_FLAG_PREROLL) ) + { + p_sys->i_late_frames++; + if( p_sys->i_late_frames == 1 ) + p_sys->i_late_frames_start = mdate(); + } + else + { + p_sys->i_late_frames = 0; + } + + if( !b_drawpicture || !p_sys->p_ff_pic->linesize[0] ) + { + /* Do not display the picture */ + continue; + } + + if( !p_sys->p_ff_pic->opaque ) + { + /* Get a new picture */ + p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context ); + if( !p_pic ) + { + block_Release( p_block ); + return NULL; + } + + /* Fill p_picture_t from AVVideoFrame and do chroma conversion + * if needed */ + ffmpeg_CopyPicture( p_dec, p_pic, p_sys->p_ff_pic ); + } + else + { + p_pic = (picture_t *)p_sys->p_ff_pic->opaque; + } + + /* Set the PTS */ + if( p_sys->p_ff_pic->pts ) p_sys->i_pts = p_sys->p_ff_pic->pts; + + /* Sanity check (seems to be needed for some streams ) */ + if( p_sys->p_ff_pic->pict_type == FF_B_TYPE ) + { + p_sys->b_has_b_frames = VLC_TRUE; + } + + /* Send decoded frame to vout */ + if( p_sys->i_pts ) + { + p_pic->date = p_sys->i_pts; + + /* interpolate the next PTS */ + if( p_sys->p_context->frame_rate > 0 ) + { + p_sys->i_pts += I64C(1000000) * + (2 + p_sys->p_ff_pic->repeat_pict) * + p_sys->p_context->frame_rate_base / + (2 * p_sys->p_context->frame_rate); + } + + if( p_sys->b_first_frame ) + { + /* Hack to force display of still pictures */ + p_sys->b_first_frame = VLC_FALSE; + p_pic->b_force = VLC_TRUE; + } + + p_pic->i_nb_fields = 2 + p_sys->p_ff_pic->repeat_pict; +#if LIBAVCODEC_BUILD >= 4685 + p_pic->b_progressive = !p_sys->p_ff_pic->interlaced_frame; + p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first; +#endif + + return p_pic; + } + else + { + p_dec->pf_vout_buffer_del( p_dec, p_pic ); + } + } + + block_Release( p_block ); + return NULL; +} + +/***************************************************************************** + * EndVideo: decoder destruction + ***************************************************************************** + * This function is called when the thread ends after a sucessful + * initialization. + *****************************************************************************/ +void E_(EndVideoDec)( decoder_t *p_dec ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + + if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic ); + +#ifdef LIBAVCODEC_PP + E_(ClosePostproc)( p_dec, p_sys->p_pp ); +#endif + + free( p_sys->p_buffer_orig ); +} + +/***************************************************************************** + * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a + * picture_t structure (when not in direct rendering mode). + *****************************************************************************/ +static void ffmpeg_CopyPicture( decoder_t *p_dec, + picture_t *p_pic, AVFrame *p_ff_pic ) +{ + decoder_sys_t *p_sys = p_dec->p_sys; + + if( ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) ) + { + int i_plane, i_size, i_line; + uint8_t *p_dst, *p_src; + int i_src_stride, i_dst_stride; + +#ifdef LIBAVCODEC_PP + if( p_sys->p_pp && p_sys->b_pp ) + E_(PostprocPict)( p_dec, p_sys->p_pp, p_pic, p_ff_pic ); + else +#endif + for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ ) + { + p_src = p_ff_pic->data[i_plane]; + p_dst = p_pic->p[i_plane].p_pixels; + i_src_stride = p_ff_pic->linesize[i_plane]; + i_dst_stride = p_pic->p[i_plane].i_pitch; + + i_size = __MIN( i_src_stride, i_dst_stride ); + for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines; + i_line++ ) + { + p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_size ); + p_src += i_src_stride; + p_dst += i_dst_stride; + } + } + } + else + { + AVPicture dest_pic; + int i; + + /* we need to convert to I420 */ + switch( p_sys->p_context->pix_fmt ) + { + case PIX_FMT_YUV410P: + case PIX_FMT_YUV411P: + case PIX_FMT_PAL8: + for( i = 0; i < p_pic->i_planes; i++ ) + { + dest_pic.data[i] = p_pic->p[i].p_pixels; + dest_pic.linesize[i] = p_pic->p[i].i_pitch; + } + img_convert( &dest_pic, PIX_FMT_YUV420P, + (AVPicture *)p_ff_pic, + p_sys->p_context->pix_fmt, + p_sys->p_context->width, + p_sys->p_context->height ); + break; + default: + msg_Err( p_dec, "don't know how to convert chroma %i", + p_sys->p_context->pix_fmt ); + p_dec->b_error = 1; + break; + } + } +} + +/***************************************************************************** + * ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer. + ***************************************************************************** + * It is used for direct rendering as well as to get the right PTS for each + * decoded picture (even in indirect rendering mode). + *****************************************************************************/ +static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context, + AVFrame *p_ff_pic ) +{ + decoder_t *p_dec = (decoder_t *)p_context->opaque; + decoder_sys_t *p_sys = p_dec->p_sys; + picture_t *p_pic; + + /* Set picture PTS */ + if( p_sys->input_pts ) + { + p_ff_pic->pts = p_sys->input_pts; + } + else if( p_sys->input_dts ) + { + /* Some demuxers only set the dts so let's try to find a useful + * timestamp from this */ + if( !p_context->has_b_frames || !p_sys->b_has_b_frames || + !p_ff_pic->reference || !p_sys->i_pts ) + { + p_ff_pic->pts = p_sys->input_dts; + } + else p_ff_pic->pts = 0; + } + else p_ff_pic->pts = 0; + + if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */ + { + p_sys->input_pts = p_sys->input_dts = 0; + } + + p_ff_pic->opaque = 0; + + /* Not much to do in indirect rendering mode */ + if( !p_sys->b_direct_rendering || p_sys->b_pp ) + { + return avcodec_default_get_buffer( p_context, p_ff_pic ); + } + + /* Some codecs set pix_fmt only after the 1st frame has been decoded, + * so this check is necessary. */ + if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) || + p_sys->p_context->width % 16 || p_sys->p_context->height % 16 ) + { + msg_Dbg( p_dec, "disabling direct rendering" ); + p_sys->b_direct_rendering = 0; + return avcodec_default_get_buffer( p_context, p_ff_pic ); + } + + /* Get a new picture */ + //p_sys->p_vout->render.b_allow_modify_pics = 0; + p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context ); + if( !p_pic ) + { + p_sys->b_direct_rendering = 0; + return avcodec_default_get_buffer( p_context, p_ff_pic ); + } + p_sys->p_context->draw_horiz_band = NULL; + + p_ff_pic->opaque = (void*)p_pic; + p_ff_pic->type = FF_BUFFER_TYPE_USER; + p_ff_pic->data[0] = p_pic->p[0].p_pixels; + p_ff_pic->data[1] = p_pic->p[1].p_pixels; + p_ff_pic->data[2] = p_pic->p[2].p_pixels; + p_ff_pic->data[3] = NULL; /* alpha channel but I'm not sure */ + + p_ff_pic->linesize[0] = p_pic->p[0].i_pitch; + p_ff_pic->linesize[1] = p_pic->p[1].i_pitch; + p_ff_pic->linesize[2] = p_pic->p[2].i_pitch; + p_ff_pic->linesize[3] = 0; + + if( p_ff_pic->reference != 0 ) + { + p_dec->pf_picture_link( p_dec, p_pic ); + } + + /* FIXME what is that, should give good value */ + p_ff_pic->age = 256*256*256*64; // FIXME FIXME from ffmpeg + + return 0; +} + +static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context, + AVFrame *p_ff_pic ) +{ + decoder_t *p_dec = (decoder_t *)p_context->opaque; + picture_t *p_pic; + + if( !p_ff_pic->opaque ) + { + avcodec_default_release_buffer( p_context, p_ff_pic ); + return; + } + + p_pic = (picture_t*)p_ff_pic->opaque; + + p_ff_pic->data[0] = NULL; + p_ff_pic->data[1] = NULL; + p_ff_pic->data[2] = NULL; + p_ff_pic->data[3] = NULL; + + if( p_ff_pic->reference != 0 ) + { + p_dec->pf_picture_unlink( p_dec, p_pic ); + } +} diff --git a/modules/demux/avi/libavi.c b/modules/demux/avi/libavi.c index 7415c900ee..4fde68f74f 100644 --- a/modules/demux/avi/libavi.c +++ b/modules/demux/avi/libavi.c @@ -2,7 +2,7 @@ * libavi.c : LibAVI ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: libavi.c,v 1.30 2004/01/25 20:05:28 hartman Exp $ + * $Id$ * Authors: Laurent Aimar * * This program is free software; you can redistribute it and/or modify diff --git a/modules/gui/beos/AudioOutput.cpp b/modules/gui/beos/AudioOutput.cpp index d3a9cd9e0f..0a47d2018b 100644 --- a/modules/gui/beos/AudioOutput.cpp +++ b/modules/gui/beos/AudioOutput.cpp @@ -2,7 +2,7 @@ * AudioOutput.cpp: BeOS audio output ***************************************************************************** * Copyright (C) 1999, 2000, 2001 VideoLAN - * $Id: AudioOutput.cpp,v 1.30 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Jean-Marc Dressler * Samuel Hocevar diff --git a/modules/gui/beos/Bitmaps.h b/modules/gui/beos/Bitmaps.h index 57736fe56c..23dca458b5 100644 --- a/modules/gui/beos/Bitmaps.h +++ b/modules/gui/beos/Bitmaps.h @@ -2,7 +2,7 @@ * Bitmaps.h ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: Bitmaps.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Tony Castley * Stephan Aßmus diff --git a/modules/gui/beos/DrawingTidbits.cpp b/modules/gui/beos/DrawingTidbits.cpp index 5ef4ed8ee7..9aa2bb2c3c 100644 --- a/modules/gui/beos/DrawingTidbits.cpp +++ b/modules/gui/beos/DrawingTidbits.cpp @@ -2,7 +2,7 @@ * DrawingTidbits.cpp ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: DrawingTidbits.cpp,v 1.4 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Tony Castley * Stephan Aßmus diff --git a/modules/gui/beos/DrawingTidbits.h b/modules/gui/beos/DrawingTidbits.h index 6f1b16c6e7..71a5c66c54 100644 --- a/modules/gui/beos/DrawingTidbits.h +++ b/modules/gui/beos/DrawingTidbits.h @@ -2,7 +2,7 @@ * DrawingTidbits.h ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: DrawingTidbits.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Tony Castley * Stephan Aßmus diff --git a/modules/gui/beos/PreferencesWindow.cpp b/modules/gui/beos/PreferencesWindow.cpp index ce521dcdf9..2b1b37967b 100644 --- a/modules/gui/beos/PreferencesWindow.cpp +++ b/modules/gui/beos/PreferencesWindow.cpp @@ -2,7 +2,7 @@ * PreferencesWindow.cpp: beos interface ***************************************************************************** * Copyright (C) 1999, 2000, 2001 VideoLAN - * $Id: PreferencesWindow.cpp,v 1.27 2003/12/22 00:06:05 titer Exp $ + * $Id$ * * Authors: Eric Petit * diff --git a/modules/gui/beos/PreferencesWindow.h b/modules/gui/beos/PreferencesWindow.h index 57bb9d0784..361cec7c10 100644 --- a/modules/gui/beos/PreferencesWindow.h +++ b/modules/gui/beos/PreferencesWindow.h @@ -2,7 +2,7 @@ * PreferencesWindow.h ***************************************************************************** * Copyright (C) 1999, 2000, 2001 VideoLAN - * $Id: PreferencesWindow.h,v 1.18 2003/12/21 21:30:43 titer Exp $ + * $Id$ * * Authors: Eric Petit * diff --git a/modules/gui/beos/TransportButton.cpp b/modules/gui/beos/TransportButton.cpp index 27dcd5427b..04767c6d5e 100644 --- a/modules/gui/beos/TransportButton.cpp +++ b/modules/gui/beos/TransportButton.cpp @@ -2,7 +2,7 @@ * TransportButton.cpp ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: TransportButton.cpp,v 1.4 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Tony Castley * Stephan Aßmus diff --git a/modules/gui/beos/TransportButton.h b/modules/gui/beos/TransportButton.h index 1c95b2aa12..1ada57a9bd 100644 --- a/modules/gui/beos/TransportButton.h +++ b/modules/gui/beos/TransportButton.h @@ -2,7 +2,7 @@ * TransportButton.h ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: TransportButton.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $ + * $Id$ * * Authors: Tony Castley * diff --git a/modules/gui/gtk/common.h b/modules/gui/gtk/common.h index ebe339c43d..bcf76cbe79 100644 --- a/modules/gui/gtk/common.h +++ b/modules/gui/gtk/common.h @@ -2,7 +2,7 @@ * gtk_common.h: private Gtk+ interface description ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: common.h,v 1.7 2003/01/26 14:49:09 fenrir Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/gui/gtk/control.h b/modules/gui/gtk/control.h index 719908d9f1..e244ed17cc 100644 --- a/modules/gui/gtk/control.h +++ b/modules/gui/gtk/control.h @@ -2,7 +2,7 @@ * gtk_control.h: prototypes for control functions ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: control.h,v 1.1 2002/08/04 17:23:43 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/display.h b/modules/gui/gtk/display.h index fd90550f1e..b6858ede7e 100644 --- a/modules/gui/gtk/display.h +++ b/modules/gui/gtk/display.h @@ -2,7 +2,7 @@ * display.h: Gtk+ tools for main interface. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: display.h,v 1.3 2003/08/03 23:11:21 gbazin Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/gtk_callbacks.h b/modules/gui/gtk/gtk_callbacks.h index 12a16f880e..e19535af5d 100644 --- a/modules/gui/gtk/gtk_callbacks.h +++ b/modules/gui/gtk/gtk_callbacks.h @@ -2,7 +2,7 @@ * gtk_callbacks.h : Callbacks for the gtk plugin. ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: gtk_callbacks.h,v 1.6 2003/05/05 16:09:39 gbazin Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/menu.h b/modules/gui/gtk/menu.h index 2903459b51..ebd73ac72a 100644 --- a/modules/gui/gtk/menu.h +++ b/modules/gui/gtk/menu.h @@ -2,7 +2,7 @@ * gtk_menu.h: prototypes for menu functions ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: menu.h,v 1.1 2002/08/04 17:23:43 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/modules.c b/modules/gui/gtk/modules.c index 6fa65f904e..940cd31d99 100644 --- a/modules/gui/gtk/modules.c +++ b/modules/gui/gtk/modules.c @@ -2,7 +2,7 @@ * gtk_modules.c : functions to build modules configuration boxes. ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: modules.c,v 1.2 2002/08/08 22:28:22 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/modules.h b/modules/gui/gtk/modules.h index 96eded90d4..5cfb865aae 100644 --- a/modules/gui/gtk/modules.h +++ b/modules/gui/gtk/modules.h @@ -2,7 +2,7 @@ * gtk_modules.h: prototypes for modules functions ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: modules.h,v 1.1 2002/08/04 17:23:43 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/open.h b/modules/gui/gtk/open.h index d52ad1e342..a32788d8e4 100644 --- a/modules/gui/gtk/open.h +++ b/modules/gui/gtk/open.h @@ -2,7 +2,7 @@ * gtk_open.h: prototypes for open functions ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: open.h,v 1.2 2003/12/12 03:01:13 rocky Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/playlist.h b/modules/gui/gtk/playlist.h index 1ec460b4a5..852090d68f 100644 --- a/modules/gui/gtk/playlist.h +++ b/modules/gui/gtk/playlist.h @@ -2,7 +2,7 @@ * gtk_playlist.h : Playlist functions for the Gtk plugin. ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: playlist.h,v 1.1 2002/08/04 17:23:43 sam Exp $ + * $Id$ * * Authors: Pierre Baillet * Stéphane Borel diff --git a/modules/gui/gtk/preferences.c b/modules/gui/gtk/preferences.c index a01bf9bea3..8f44bc3d5a 100644 --- a/modules/gui/gtk/preferences.c +++ b/modules/gui/gtk/preferences.c @@ -2,7 +2,7 @@ * gtk_preferences.c: functions to handle the preferences dialog box. ***************************************************************************** * Copyright (C) 2001-2004 VideoLAN - * $Id: preferences.c,v 1.11 2004/01/25 18:34:55 gbazin Exp $ + * $Id$ * * Authors: Gildas Bazin * Loïc Minier diff --git a/modules/gui/gtk/preferences.h b/modules/gui/gtk/preferences.h index 8a03a3338b..7a58dd2eb3 100644 --- a/modules/gui/gtk/preferences.h +++ b/modules/gui/gtk/preferences.h @@ -2,7 +2,7 @@ * gtk_control.h: prototypes for control functions ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: preferences.h,v 1.1 2002/08/04 17:23:43 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * Stéphane Borel diff --git a/modules/gui/gtk/sout.c b/modules/gui/gtk/sout.c index e0a417abab..44c5ce570e 100644 --- a/modules/gui/gtk/sout.c +++ b/modules/gui/gtk/sout.c @@ -2,7 +2,7 @@ * sout.c : ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: sout.c,v 1.2 2003/05/05 16:09:39 gbazin Exp $ + * $Id$ * * Authors: Laurent Aimar * diff --git a/modules/gui/kde/QConfigItem.cpp b/modules/gui/kde/QConfigItem.cpp index fa8144dfeb..4f33a32cb8 100644 --- a/modules/gui/kde/QConfigItem.cpp +++ b/modules/gui/kde/QConfigItem.cpp @@ -2,7 +2,7 @@ * QConfigItem.cpp: The QConfigItem class ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: QConfigItem.cpp,v 1.3 2002/10/13 14:26:47 sigmunau Exp $ + * $Id$ * * Authors: Sigmund Augdal Mon 12.08.2002 * diff --git a/modules/gui/kde/QConfigItem.h b/modules/gui/kde/QConfigItem.h index 9600556725..f13e092ff8 100644 --- a/modules/gui/kde/QConfigItem.h +++ b/modules/gui/kde/QConfigItem.h @@ -2,7 +2,7 @@ * QConfigItem.h : includes for the QConfigItem class ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: QConfigItem.h,v 1.3 2002/10/13 14:26:47 sigmunau Exp $ + * $Id$ * * Authors: Andres Krapf Sun Mar 25 2001 * diff --git a/modules/gui/kde/info.h b/modules/gui/kde/info.h index 3b19e3021f..b9875324b5 100644 --- a/modules/gui/kde/info.h +++ b/modules/gui/kde/info.h @@ -2,7 +2,7 @@ * info.h: the KInfoWindow class ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: info.h,v 1.2 2003/12/22 14:23:14 sam Exp $ + * $Id$ * * Author: Sigmund Augdal * diff --git a/modules/gui/kde/languagemenu.cpp b/modules/gui/kde/languagemenu.cpp index 93640192ae..5d26c24b2a 100644 --- a/modules/gui/kde/languagemenu.cpp +++ b/modules/gui/kde/languagemenu.cpp @@ -2,7 +2,7 @@ * languagemenu.cpp: the KLanguageMenuAction class ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: languagemenu.cpp,v 1.2 2003/12/22 14:23:14 sam Exp $ + * $Id$ * * Author: Sigmund Augdal * diff --git a/modules/gui/kde/languagemenu.h b/modules/gui/kde/languagemenu.h index 1c539644fd..bb75ea6b5c 100644 --- a/modules/gui/kde/languagemenu.h +++ b/modules/gui/kde/languagemenu.h @@ -2,7 +2,7 @@ * languagemenu.h: the KLanguageMenuAction class ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: languagemenu.h,v 1.2 2003/12/22 14:23:14 sam Exp $ + * $Id$ * * Author: Sigmund Augdal * diff --git a/modules/gui/kde/messages.cpp b/modules/gui/kde/messages.cpp index 38894efd24..df4a4c8011 100644 --- a/modules/gui/kde/messages.cpp +++ b/modules/gui/kde/messages.cpp @@ -2,7 +2,7 @@ * messages.cpp: the KMessagesWindow class ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: messages.cpp,v 1.5 2003/12/22 14:23:14 sam Exp $ + * $Id$ * * Author: Sigmund Augdal * diff --git a/modules/gui/kde/messages.h b/modules/gui/kde/messages.h index 2496952bdb..f88fb28f36 100644 --- a/modules/gui/kde/messages.h +++ b/modules/gui/kde/messages.h @@ -2,7 +2,7 @@ * messages.h: the KMessagesWindow class ***************************************************************************** * Copyright (C) 2001-2003 VideoLAN - * $Id: messages.h,v 1.2 2003/12/22 14:23:14 sam Exp $ + * $Id$ * * Author: Sigmund Augdal * diff --git a/modules/gui/kde/pluginsbox.cpp b/modules/gui/kde/pluginsbox.cpp index 93b24d8191..8997cd8aa7 100644 --- a/modules/gui/kde/pluginsbox.cpp +++ b/modules/gui/kde/pluginsbox.cpp @@ -2,7 +2,7 @@ * pluginbox.cpp: the pluginbox class ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: pluginsbox.cpp,v 1.3 2003/03/29 14:30:55 sigmunau Exp $ + * $Id$ * * Authors: Sigmund Augdal Mon Aug 12 2002 * diff --git a/modules/gui/kde/pluginsbox.h b/modules/gui/kde/pluginsbox.h index f8548bdca3..7ef50a3d72 100644 --- a/modules/gui/kde/pluginsbox.h +++ b/modules/gui/kde/pluginsbox.h @@ -2,7 +2,7 @@ * pluginbox.h: includes for the pluginbox class ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: pluginsbox.h,v 1.3 2003/03/29 14:30:55 sigmunau Exp $ + * $Id$ * * Authors: Sigmund Augdal Mon Aug 12 2002 * diff --git a/modules/gui/kde/preferences.cpp b/modules/gui/kde/preferences.cpp index 372efb75b9..a8e8ce823c 100644 --- a/modules/gui/kde/preferences.cpp +++ b/modules/gui/kde/preferences.cpp @@ -2,7 +2,7 @@ * preferences.cpp: preferences window for the kde gui ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: preferences.cpp,v 1.18 2004/01/25 15:42:57 kuehne Exp $ + * $Id$ * * Authors: Sigmund Augdal Mon Aug 12 2002 * diff --git a/modules/gui/kde/preferences.h b/modules/gui/kde/preferences.h index 34d480f655..788121e3de 100644 --- a/modules/gui/kde/preferences.h +++ b/modules/gui/kde/preferences.h @@ -2,7 +2,7 @@ * preferences.h: includes for the preferences window ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: preferences.h,v 1.2 2002/08/12 17:38:10 sigmunau Exp $ + * $Id$ * * Authors: Sigmund Augdal Mon Aug 12 2002 * diff --git a/modules/gui/pda/pda.h b/modules/gui/pda/pda.h index e779ec272f..2932bcf9e0 100644 --- a/modules/gui/pda/pda.h +++ b/modules/gui/pda/pda.h @@ -2,7 +2,7 @@ * pda.h: private Gtk+ interface description ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: pda.h,v 1.5 2003/11/18 20:36:40 jpsaman Exp $ + * $Id$ * * Authors: Jean-Paul Saman * diff --git a/modules/gui/pda/pda_callbacks.h b/modules/gui/pda/pda_callbacks.h index c80b32dc7b..08c203db95 100644 --- a/modules/gui/pda/pda_callbacks.h +++ b/modules/gui/pda/pda_callbacks.h @@ -2,7 +2,7 @@ * callbacks.h : pda plugin for vlc ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: pda_callbacks.h,v 1.12 2003/12/07 18:58:38 jpsaman Exp $ + * $Id$ * * Authors: Jean-Paul Saman * diff --git a/modules/gui/qt/intf.h b/modules/gui/qt/intf.h index 971dfaad4c..2bdae73f96 100644 --- a/modules/gui/qt/intf.h +++ b/modules/gui/qt/intf.h @@ -2,7 +2,7 @@ * intf.h: Qt interface ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: intf.h,v 1.1 2002/09/30 11:05:39 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/gui/wxwindows/wizard.cpp b/modules/gui/wxwindows/wizard.cpp index bfae413beb..613ec4f5c6 100644 --- a/modules/gui/wxwindows/wizard.cpp +++ b/modules/gui/wxwindows/wizard.cpp @@ -1,1661 +1,1661 @@ -/***************************************************************************** - * wizard.cpp : wxWindows plugin for vlc - ***************************************************************************** - * Copyright (C) 2000-2004 VideoLAN - * $Id$ - * - * Authors: Clément Stenac - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include /* malloc(), free() */ -#include /* ENOMEM */ -#include /* strerror() */ -#include - -#include -#include - -#include "wxwindows.h" - -#include "streamdata.h" - -#include - -class wizHelloPage; -class wizInputPage; - -/***************************************************************************** - * Define events - *****************************************************************************/ -enum -{ - ActionRadio0_Event, ActionRadio1_Event, - MoreInfoStreaming_Event, - MoreInfoTranscode_Event, - - Open_Event , Choose_Event , - ListView_Event, - InputRadio0_Event, InputRadio1_Event, - PartialEnable_Event, - - MethodRadio0_Event, MethodRadio1_Event, - MethodRadio2_Event, MethodRadio3_Event, - - EncapRadio0_Event, EncapRadio1_Event, - EncapRadio2_Event, EncapRadio3_Event, - EncapRadio4_Event, EncapRadio5_Event, - EncapRadio6_Event, EncapRadio7_Event, - EncapRadio8_Event, EncapRadio9_Event, - EncapRadio10_Event, EncapRadio11_Event, - - VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event, - AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event, - - SAP_Event, - -}; - -#define TEXTWIDTH 55 -#define ACTION_STREAM 0 -#define ACTION_TRANSCODE 1 - -BEGIN_EVENT_TABLE(WizardDialog, wxWizard) -END_EVENT_TABLE() - -/***************************************************************************** - * Wizard strings - *****************************************************************************/ - -#define ERROR_MSG _("Error") -#define ITEM_NAME _("Streaming/Transcoding Wizard") - -/* Hello page */ -#define HELLO_TITLE _("Streaming/Transcoding Wizard") -#define HELLO_TEXT _("This wizard helps you to stream, transcode or" \ - " save a stream") -#define HELLO_STREAMING _("Stream to network") -#define HELLO_STREAMING_DESC _("Use this to stream on a network") -#define HELLO_TRANSCODE _("Transcode/Save to file") -#define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file") -#define HELLO_NOTICE _("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them") - -#define MOREINFO_STREAM _("Use this to stream on a network") - -#define MOREINFO_TRANSCODE _("Use this to save a stream to a file. You have the possibility to reencode the stream. You can save whatever VLC can read.\nPlease notice that VLC is not very suited " \ - "for file to file transcoding. You should use its transcoding " \ - "features to save network streams, for example" ) - -/* Input page */ -#define INPUT_TITLE _("Choose input") -#define INPUT_TEXT _("Choose here your input stream") - -#define INPUT_OPEN _("Select a stream" ) -#define INPUT_PL _( "Existing playlist item" ) - -#define CHOOSE_STREAM _("You must choose a stream") -#define NO_PLAYLIST _("Uh Oh! Unable to find playlist !") - -#define PARTIAL _("Use this to read only a part of the stream. " \ - "You must be able to control the incoming stream " \ - "(for example, a file or a disc, but not an UDP " \ - "network stream.)\n" \ - "Enter the starting and ending times (in seconds)") - -#define INPUT_BUTTON _("Choose") - -/* Transcode 1 */ -#define TRANSCODE1_TITLE _("Transcode") -#define TRANSCODE1_TEXT _("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page).") - -#define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \ - "transcode it, enable this") -#define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \ - "information") - -#define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\ - "transcode it, enable this") -#define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \ - "information") - -/* Streaming 1 */ -#define STREAMING1_TITLE _("Streaming") -#define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.") - - -#define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \ - "multicast address" ) -#define NO_ADDRESS _("You need to enter an address" ) - -/* Encap */ -#define ENCAP_TITLE _("Encapsulation format") -#define ENCAP_TEXT _("In this page, you will select how the stream will be "\ - "encapsulated. Depending on the choices you made, all "\ - "formats won't be available." ) - - -/* Transcode 2 */ -#define EXTRATRANSCODE_TITLE _("Additional transcode options") -#define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \ - "additionnal parameters for your transcoding" ) - -#define CHOOSE_OUTFILE _("You must choose a file to save to") - -/* Streaming 2 */ -#define EXTRASTREAMING_TITLE _("Additional streaming options") -#define EXTRASTREAMING_TEXT _("In this page, you will define a few " \ - "additionnal parameters for your stream" ) - -#define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \ - "is the maximum number of routers your stream can go through. " \ - "If you don't know what it means, or if you want to stream on " \ - "your local network only, leave this setting to 1." ) - -#define SAP _("When streaming using UDP, you can announce your streams " \ - "using the SAP/SDP announcing protocol. This way, the clients " \ - "won't have to type in the multicast address, it will appear " \ - "in their playlist if they enable the SAP extra interface.\n" \ - "If you want to give a name to your stream, enter it here, " \ - "else, a default name will be used" ) - -/***************************************************************************** - * All the pages of the wizard, declaration - *****************************************************************************/ - -/* Declare classes */ -class wizHelloPage : public wxWizardPageSimple -{ - public: - wizHelloPage( wxWizard *parent); - void OnActionChange(wxEvent& event); - void OnWizardPageChanging(wxWizardEvent& event); - void OnMoreInfo( wxCommandEvent& event ); - protected: - int i_action; - WizardDialog *p_parent; - wxRadioButton *action_radios[2]; - DECLARE_EVENT_TABLE() -}; - -BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple) - EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange) - EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange) - EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo ) - EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo ) - - EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging) -END_EVENT_TABLE() - - -class wizInputPage : public wxWizardPage -{ - public: - wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *); - wizInputPage::~wizInputPage(); - void OnWizardPageChanging(wxWizardEvent& event); - void OnInputChange(wxEvent& event); - void OnEnablePartial(wxCommandEvent& event); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void SetStreamingPage( wxWizardPage *page); - void SetTranscodePage( wxWizardPage *page); - void SetAction( int i_action ); - void SetPintf( intf_thread_t *p_intf ); - void SetUri( char *psz_uri ); - void SetPartial( int i_from, int i_to ); - - protected: - bool b_chosen; - intf_thread_t *p_intf; - int i_action; - int i_input; - - void OnChoose( wxCommandEvent& event ); - - WizardDialog *p_parent; - wxRadioButton *input_radios[2]; - wxCheckBox *enable_checkbox; - wxBoxSizer *mainSizer; - wxArrayString mrl; - wxTextCtrl *mrl_text; - wxTextCtrl *from_text; - wxTextCtrl *to_text; - OpenDialog *p_open_dialog; - wxListView *listview; - wxPanel *open_panel; - wxWizardPage *p_prev; - wxWizardPage *p_streaming_page; - wxWizardPage *p_transcode_page; - - DECLARE_EVENT_TABLE() -}; - -BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage) - EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange) - EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange) - EVT_BUTTON( Choose_Event, wizInputPage::OnChoose) - EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial) - EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging) -END_EVENT_TABLE() - - -class wizTranscodeCodecPage : public wxWizardPage -{ -public: - wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next); - ~wizTranscodeCodecPage(); - void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void SetPrev( wxWizardPage *page); -protected: - wxCheckBox *video_checkbox; - wxComboBox *video_combo; - wxComboBox *vb_combo; - wxStaticText * video_text; - wxCheckBox *audio_checkbox; - wxComboBox *audio_combo; - wxComboBox *ab_combo; - wxStaticText * audio_text; - - WizardDialog *p_parent; - int i_audio_codec; - int i_video_codec; - - char *vcodec; - char *acodec; - - wxWizardPage *p_prev; - wxWizardPage *p_next; - - void OnVideoCodecChange(wxCommandEvent& event); - void OnAudioCodecChange(wxCommandEvent& event); - void OnEnableVideo(wxCommandEvent& event); - void OnEnableAudio(wxCommandEvent& event); - - DECLARE_EVENT_TABLE() -}; - -BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage) - EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo) - EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio) - EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange) - EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange) - EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging) -END_EVENT_TABLE() - -class wizStreamingMethodPage : public wxWizardPage -{ -public: - wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next); - void OnWizardPageChanging(wxWizardEvent& event); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void SetPrev( wxWizardPage *page); -protected: - DECLARE_EVENT_TABLE() - int i_method; - wxBoxSizer *mainSizer; - wxStaticBoxSizer *address_sizer; - wxStaticText *address_text; - wxTextCtrl *address_txtctrl; - WizardDialog * p_parent; - void OnMethodChange(wxEvent& event); - wxRadioButton *method_radios[4]; - wxWizardPage *p_prev; - wxWizardPage *p_next; -}; - -BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage) - EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange) - EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange) - EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange) - EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange) - EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging) -END_EVENT_TABLE() - - -class wizEncapPage : public wxWizardPage -{ -public: - wizEncapPage( wxWizard *parent); - wizEncapPage::~wizEncapPage(); - void OnWizardPageChanging(wxWizardEvent& event); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void SetStreamingPage( wxWizardPage *page); - void SetTranscodePage( wxWizardPage *page); - void SetPrev( wxWizardPage *page); - void SetAction( int ); - void EnableEncap( int encap ); -protected: - DECLARE_EVENT_TABLE() - int i_encap; - int i_mux; - int i_action; - void OnEncapChange(wxEvent& event); - wxRadioButton *encap_radios[MUXERS_NUMBER]; - WizardDialog *p_parent; - wxWizardPage *p_prev; - wxWizardPage *p_streaming_page; - wxWizardPage *p_transcode_page; -}; - -BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage) - EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging) - EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange) - EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange) -END_EVENT_TABLE() - -/* Additional settings for transcode */ -class wizTranscodeExtraPage : public wxWizardPage -{ -public: - wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev, - wxWizardPage *next); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void OnWizardPageChanging( wxWizardEvent& event ); -protected: - DECLARE_EVENT_TABLE() - void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&); - wxTextCtrl *file_text; - WizardDialog *p_parent; - wxWizardPage *p_prev; - wxWizardPage *p_next; -}; - -BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage) - EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile) - EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging) -END_EVENT_TABLE() - -/* Additional settings for streaming */ -class wizStreamingExtraPage : public wxWizardPage -{ -public: - wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev, - wxWizardPage *next); - virtual wxWizardPage *GetPrev() const; - virtual wxWizardPage *GetNext() const; - void OnWizardPageChanging(wxWizardEvent&); - void OnSAP( wxCommandEvent&); - wxCheckBox *sap_checkbox; - wxTextCtrl *sap_text; -protected: - friend class wizEncapPage; - DECLARE_EVENT_TABLE() - WizardDialog *p_parent; - wxWizardPage *p_prev; - wxWizardPage *p_next; - - wxSpinCtrl *ttl_spin; -}; - -BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage) - EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP ) - EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging) -END_EVENT_TABLE() - - -/* Local functions */ -static int ismult( const char *psz_uri ); - -static void pageHeader( wxWindow *window, wxBoxSizer *sizer, - char *psz_title, char *psz_text); - -static void pageHeader( wxWindow *window, wxBoxSizer *sizer, - char *psz_title, char *psz_text) -{ - wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) ); - wxFont font = wtitle->GetFont(); - font.SetPointSize(14); - wtitle->SetFont(font); - sizer->Add( wtitle, 0, wxALL, 5 ); - sizer->Add( new wxStaticText( window, -1, - wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ), - 0, wxALL, 5 ); -} - -/*************************************************************************** - * Implementation of the pages - ***************************************************************************/ - - -/*************************************************** - * First page: choose between stream and transcode * - ***************************************************/ -wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent) -{ - i_action = 0; - p_parent = (WizardDialog *)parent; - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT ); - - /* Create the radio buttons with their helps */ - action_radios[0] = new wxRadioButton( this, ActionRadio0_Event, - wxU( HELLO_STREAMING ) ); - action_radios[1] = new wxRadioButton( this, ActionRadio1_Event, - wxU( HELLO_TRANSCODE ) ); - i_action = 0; - - mainSizer->Add( 0, 0, 1 ); - - wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL ); - stream_sizer->Add( action_radios[0], 0, wxALL, 5 ); - stream_sizer->Add( 0,0,1 ); - stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event, - wxU( _("More Info")) ), 0, 0, 0 ); - mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 ); - - wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL ); - transcode_sizer->Add( action_radios[1], 0, wxALL, 5 ); - transcode_sizer->Add( 0,0,1); - transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event, - wxU( _("More Info")) ), 0 , 0 , 0 ); - mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 ); - - mainSizer->Add( 0, 0, 1 ); - - mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP| - wxBOTTOM, 5 ); - - mainSizer->Add( new wxStaticText(this, -1, - wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))), - 0, wxALL, 5 ); - - SetSizer(mainSizer); - mainSizer->Fit(this); - } - -void wizHelloPage::OnMoreInfo(wxCommandEvent& event) -{ - wxString msg; - msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ? - MOREINFO_STREAM : - MOREINFO_TRANSCODE ) ) ); - wxMessageBox( msg, wxU(_("More information")), - wxOK | wxICON_INFORMATION, this->p_parent ); -} - -void wizHelloPage::OnActionChange(wxEvent& event) -{ - i_action = event.GetId() - ActionRadio0_Event; - ((wizInputPage *)GetNext())->SetAction( i_action ); - p_parent->SetAction( i_action ); -} - -void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event) -{ - ((wizInputPage *)GetNext())->SetAction( i_action ); - p_parent->SetAction( i_action ); -} - -/************************************ - * Second page: choose input stream * - ************************************/ -wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) : - wxWizardPage(parent) -{ - p_prev = prev; - p_intf = _p_intf; - p_parent = (WizardDialog *)parent; - b_chosen = false; - p_open_dialog = NULL; - listview = NULL; - mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT ); - - mainSizer->Add( 0,20,0 ); - - /* Create the radio buttons */ - input_radios[0] = new wxRadioButton( this, InputRadio0_Event , - wxU( INPUT_OPEN ) ); - mainSizer->Add( input_radios[0], 0, wxALL, 5 ); - input_radios[1] = new wxRadioButton( this, InputRadio1_Event , - wxU( INPUT_PL ) ); - i_input = 0; - mainSizer->Add( input_radios[1], 0, wxALL, 5 ); - - /* Open Panel */ - open_panel = new wxPanel(this, -1); - open_panel->SetAutoLayout( TRUE ); - wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL); - - mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition, - wxSize(200,25) ); - openSizer->Add( mrl_text, 0 , wxALL, 5 ); - openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 ); - open_panel->SetSizer( openSizer ); - openSizer->Layout(); - openSizer->Fit(open_panel); - - mainSizer->Add( open_panel ); - - - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - - if( p_playlist ) - { - if( p_playlist->i_size > 0) - { - listview = new wxListView( this, ListView_Event, - wxDefaultPosition, wxDefaultSize, - wxLC_REPORT | wxSUNKEN_BORDER ); - listview->InsertColumn( 0, wxU(_("Name")) ); - listview->InsertColumn( 1, wxU(_("URI")) ); - listview->SetColumnWidth( 0, 250 ); - listview->SetColumnWidth( 1, 100 ); - for( int i=0 ; i < p_playlist->i_size ; i++ ) - { - wxString filename = wxL2U( p_playlist->pp_items[i]->input. - psz_name ); - listview->InsertItem( i, filename ); - listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]-> - input.psz_uri) ); - } - listview->Select( p_playlist->i_index , TRUE); - mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 ); - - listview->Hide(); - mainSizer->Hide( listview ); - mainSizer->Layout(); - } - else - { - input_radios[1]->Disable(); - } - vlc_object_release( p_playlist ); - } - else - { - input_radios[1]->Disable(); - } - - /* Partial Extract Box */ - mainSizer->Add( 0, 10, 0 ); - wxStaticBox *partial_box = new wxStaticBox( this, -1, - wxU(_("Partial Extract")) ); - - wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box, - wxVERTICAL ); - - enable_checkbox = new wxCheckBox( this, PartialEnable_Event, - wxU(_("Enable") ) ); - enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ; - partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT - - wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 ); - partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ), - 0 , wxLEFT , 5 ); - from_text = new wxTextCtrl( this, -1, wxT(""), - wxDefaultPosition, wxSize( 80,25 ) ); - partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT); - partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ), - 0 , wxLEFT , 5 ); - to_text = new wxTextCtrl( this, -1, wxT(""), - wxDefaultPosition, wxSize( 80 , 25 ) ); - partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT ); - - partial_sizer->Add( partial_sizer2, 0, wxALL, 0 ); - - partial_sizer->Fit( partial_box ); - - mainSizer->Add( partial_sizer, 0, 0, 0 ); - - from_text->Disable(); - to_text->Disable(); - SetSizer(mainSizer); - mainSizer->Fit(this); - mainSizer->Layout(); -} - -wizInputPage::~wizInputPage() -{ -} - -void wizInputPage::OnInputChange(wxEvent& event) -{ - i_input = event.GetId() - InputRadio0_Event; - if( i_input == 0 ) - { - if( listview ) - { - listview->Hide(); - mainSizer->Hide( listview ); - open_panel->Show(); - mainSizer->Show( open_panel ); - mainSizer->Layout(); - } - } - else - { - open_panel->Hide(); - mainSizer->Hide( open_panel ); - listview->Show(); - mainSizer->Show( listview ); - mainSizer->Layout(); - } -} - -void wizInputPage::OnEnablePartial(wxCommandEvent& event) -{ - from_text->Enable( event.IsChecked() ); - to_text->Enable( event.IsChecked() ); -} - - -void wizInputPage::OnChoose(wxCommandEvent& event) -{ - p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM ); - if( p_open_dialog->ShowModal() == wxID_OK && - !p_open_dialog->mrl.IsEmpty() ) - { - mrl_text->SetValue(p_open_dialog->mrl[0] ); - } - delete p_open_dialog; - p_open_dialog = NULL; -} - -void wizInputPage::OnWizardPageChanging(wxWizardEvent& event) -{ - if( i_input == 0) - { - if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) && - event.GetDirection() ) - { - wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ), - wxICON_WARNING | wxOK, this->p_parent ); - event.Veto(); - return; - } - else - { - p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() ); - } - } - else - { - int i = -1; - wxListItem listitem; - i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); - if( i != -1 ) - { - listitem.SetId( i ); - listitem.SetColumn( 1 ); - listview->GetItem( listitem ); - p_parent->SetMrl( (const char*) listitem.GetText().mb_str() ); - } - } - if( enable_checkbox->IsChecked() ) - { - int i_from = atoi( from_text->GetValue().mb_str() ); - int i_to = atoi( to_text->GetValue().mb_str() ); - msg_Dbg( p_intf, "Partial streaming enabled, from %i to %i", - i_from,i_to); - p_parent->SetPartial( i_from, i_to ); - } - return; -} - -wxWizardPage *wizInputPage::GetPrev() const { return p_prev; } -wxWizardPage *wizInputPage::GetNext() const -{ - if( i_action == ACTION_STREAM ) - return p_streaming_page; - else - return p_transcode_page; -} - -void wizInputPage::SetStreamingPage( wxWizardPage *page) -{ - p_streaming_page = page; -} - -void wizInputPage::SetTranscodePage( wxWizardPage *page) -{ - p_transcode_page = page; -} - -void wizInputPage::SetAction( int i_action ) -{ - this->i_action = i_action; -} - -void wizInputPage::SetPintf( intf_thread_t *p_intf ) -{ - this->p_intf = p_intf; -} - -void wizInputPage::SetUri( char *psz_uri ) -{ - mrl_text->SetValue( wxU( psz_uri ) ); -} - -void wizInputPage::SetPartial( int i_from, int i_to ) -{ - wxString msg; - msg.Printf( wxString( wxT( "%i") ), i_from ); - from_text->Enable( TRUE ); - from_text->SetValue( msg ); - msg.Printf( wxString( wxT( "%i") ), i_to ); - to_text->Enable( TRUE ); - to_text->SetValue( msg ); - enable_checkbox->SetValue( TRUE ); -} - -/*************************************************** - * First transcode page: choose codecs * - ***************************************************/ -wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent, - wxWizardPage *next) : wxWizardPage(parent) -{ - p_next = next; - - acodec = NULL; - vcodec = NULL; - p_parent = (WizardDialog *) parent; - - wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); - - /* Header */ - pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT ); - - /* Video Box */ - wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) ); - wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box, - wxVERTICAL ); - /* Line 1 : only the checkbox */ - wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 ); - video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event, - wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 ); - video_sizer1->Add( 0,0,1); - /* Line 2 : codec */ - video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5); - video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""), - wxDefaultPosition, wxSize(200,25), 0, NULL, - wxCB_DROPDOWN| wxCB_READONLY ); - for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ ) - { - video_combo->Append( wxU( vcodecs_array[i].psz_display ) , - (void *)&vcodecs_array[i] ); - } - i_video_codec = 0; - video_combo->SetSelection(0); - - video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 ); - - video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0, - wxLEFT ,5); - vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY ); - video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 ); - - /* Line 3 : text */ - video_text = new wxStaticText( this, -1, - wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) ); - /* Fill the main video sizer */ - video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 ); - video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 ); - - - /* Audio box */ - wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) ); - wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box, - wxVERTICAL ); - /* Line1: enabler */ - wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20); - audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event, - wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); - audio_sizer1->Add( 0, 0, 1 ); - - /* Line 2 : codec */ - audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5); - audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""), - wxDefaultPosition, wxSize(200,25), 0, NULL, - wxCB_DROPDOWN| wxCB_READONLY ); - for( int i= 0; acodecs_array[i].psz_display != NULL; i++ ) - { - audio_combo->Append( wxU( acodecs_array[i].psz_display ) , - (void *)&acodecs_array[i] ); - } - i_audio_codec = 0; - audio_combo->SetSelection(0); - audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 ); - - audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0, - wxLEFT ,5); - ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"), - wxDefaultPosition, wxDefaultSize, - WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY ); - audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 ); - - /* Line 3 : text */ - audio_text = new wxStaticText( this, -1, - wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) ); - - audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5); - audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 ); - - main_sizer->Add( video_sizer, 1, wxGROW, 0 ); - main_sizer->Add( audio_sizer, 1, wxGROW, 0 ); - main_sizer->Layout(); - SetSizerAndFit( main_sizer ); - - /* Default disabled */ - video_combo->Disable(); video_text->Disable();vb_combo->Disable(); - audio_combo->Disable(); audio_text->Disable();ab_combo->Disable(); - -} - -wizTranscodeCodecPage::~wizTranscodeCodecPage() -{ - if( acodec ) free( acodec ); - if( vcodec ) free( vcodec ); -} - -void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event) -{ - video_combo->Enable( event.IsChecked() ); - vb_combo->Enable( event.IsChecked() ); - video_text->Enable( event.IsChecked() ); -} - -void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event) -{ - audio_combo->Enable( event.IsChecked() ); - ab_combo->Enable( event.IsChecked() ); - audio_text->Enable( event.IsChecked() ); -} - -void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event) -{ - struct codec *c = (struct codec*) - (video_combo->GetClientData(video_combo->GetSelection())); - video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) ); - i_video_codec = video_combo->GetSelection(); - vcodec = strdup(c->psz_codec); -} - -void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event) -{ - struct codec *c = (struct codec*) - (audio_combo->GetClientData(audio_combo->GetSelection())); - audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) ); - i_audio_codec = audio_combo->GetSelection(); - acodec = strdup(c->psz_codec); - -} - -void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event) -{ - unsigned int i,j; - - if( !event.GetDirection() ) - { - GetPrev()->Enable(); - return; - } - - /* Set the dummy codec ( accept all muxers ) if needed */ - if( !video_combo->IsEnabled() ) - { - i_video_codec = VCODECS_NUMBER; - } - if( !audio_combo->IsEnabled() ) - { - i_audio_codec = ACODECS_NUMBER; - } - - ((wizEncapPage *)GetNext())->SetPrev(this); - - for( i = 0 ; i< MUXERS_NUMBER ; i++ ) - { - if( vcodecs_array[i_video_codec].muxers[i] != -1 ) - { - for( j = 0 ; j< MUXERS_NUMBER ; j++ ) - { - if( acodecs_array[i_audio_codec].muxers[j] == - vcodecs_array[i_video_codec].muxers[i] ) - { - ((wizEncapPage*)GetNext())->EnableEncap( - vcodecs_array[i_video_codec].muxers[i] ); - } - } - } - } - struct codec *c = (struct codec*) - (video_combo->GetClientData( video_combo->IsEnabled() ? - video_combo->GetSelection(): i_video_codec )); - vcodec = strdup(c->psz_codec); - c = (struct codec*) - (audio_combo->GetClientData( audio_combo->IsEnabled() ? - audio_combo->GetSelection() : i_audio_codec )); - acodec = strdup(c->psz_codec); - - int vb = atoi(vb_combo->GetValue().mb_str() ); - if( vb == 0 ) - { - vb = 1024; - } - int ab = atoi(ab_combo->GetValue().mb_str() ); - if( ab == 0) - { - ab = 192; - } - - p_parent->SetTranscode( vcodec, vb , acodec, ab ); - ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() ); - p_parent->SetAction( p_parent->GetAction() ); - - return; -} - -wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; } -wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; } -void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; } - - -/*************************************************** - * First streaming page: choose method * - ***************************************************/ -wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent, - wxWizardPage *next) : wxWizardPage(parent) -{ - int i; - p_next = next; - p_parent = (WizardDialog *)parent; - - mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT ); - - mainSizer->Add( 0,50,0 ); - - i_method = 0; - - wxStaticBox *method_box = new wxStaticBox( this, -1, - wxU(_("Streaming method")) ); - wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box, - wxHORIZONTAL ); - for( i = 0 ; i< 3 ; i++ ) - { - method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i, - wxU( methods_array[i].psz_method ) ); - method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) ); - method_sizer->Add( method_radios[i], 0, wxALL, 5 ); - } - - method_sizer->Layout(); - - wxStaticBox *address_box = new wxStaticBox( this, -1, - wxU(_("Destination")) ); - - address_sizer = new wxStaticBoxSizer(address_box, - wxVERTICAL ); - - /* Big kludge, we take the longest text to get the size */ - address_text = new wxStaticText(this, -1, - wxU( vlc_wraptext(methods_array[2].psz_address, - TEXTWIDTH, false ) ), - wxDefaultPosition, wxDefaultSize ); - - address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, - wxSize(200,25)); - address_sizer->Add( address_text, 0, wxALL, 5 ); - address_sizer->Add( address_txtctrl, 0, wxALL, 5 ); - address_sizer->Layout(); - - /* Set the minimum size */ - address_sizer->SetMinSize( address_sizer->GetSize() ); - address_text->SetLabel( wxU( - vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false))); - - mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 ); - mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 ); - - mainSizer->Add( 0,0,1 ); - - mainSizer->Layout(); - - SetSizer(mainSizer); - mainSizer->Fit(this); - - return; -} - -void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event) -{ - unsigned int i; - if( !event.GetDirection() ) return; - - /* Check valid address */ - if( i_method == 1 && !ismult( address_txtctrl->GetValue().mb_str()) ) - { - wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ), - wxICON_WARNING | wxOK, this->p_parent ); - event.Veto(); - - } - else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() ) - { - wxMessageBox( wxU( NO_ADDRESS ) , wxU( ERROR_MSG ), - wxICON_WARNING | wxOK, this->p_parent ); - event.Veto(); - - } - - ((wizEncapPage *)GetNext())->SetPrev(this); - for( i = 0 ; i< MUXERS_NUMBER ; i++ ) - { - if( methods_array[i_method].muxers[i] != -1 ) - { - ((wizEncapPage*)GetNext())->EnableEncap( - methods_array[i_method].muxers[i] ); - } - } - p_parent->SetStream( methods_array[i_method].psz_access , - (char *)address_txtctrl->GetValue().c_str() ); - - /* Set the action for the muxer page */ - ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() ); - return; -} - -wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; } -wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; } - -void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; } - - -void wizStreamingMethodPage::OnMethodChange(wxEvent& event) -{ - i_method = event.GetId() - MethodRadio0_Event; - address_text->SetLabel( wxU( - vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false))); - address_sizer->Layout(); - mainSizer->Layout(); -} - -/*************************************************** - * Choose encapsulation format * - ***************************************************/ -wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent) -{ - int i; - i_mux = 0; - p_parent = (WizardDialog *)parent; - p_streaming_page = NULL; - p_transcode_page = NULL; - p_prev = NULL; - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT ); - - mainSizer->Add( 0,0,1 ); - - for( i = 0 ; i< MUXERS_NUMBER ; i++ ) - { - encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i, - wxU( encaps_array[i].psz_encap ) ); - encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) ); - mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 ); - encap_radios[i]->Disable(); - } - - mainSizer->Add( 0,0,1 ); - - SetSizer(mainSizer); - mainSizer->Fit(this); -} - -wizEncapPage::~wizEncapPage() -{ -} - -void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event) -{ - int i; - if( !event.GetDirection() ) - { - for( i = 0 ; i< MUXERS_NUMBER ; i++ ) - { - encap_radios[i]->Disable(); - } - } - p_parent->SetMux( encaps_array[i_mux].psz_mux ); - - if( p_parent->GetAction() == ACTION_STREAM ) - { - if( strstr( p_parent->method, "udp" )) - { - ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable(); - ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false); - } - else - { - ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false ); - ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false ); - } - } - - return; -} - - -void wizEncapPage::OnEncapChange(wxEvent& event) -{ - i_mux = event.GetId() - EncapRadio0_Event; -} - -void wizEncapPage::EnableEncap( int encap ) -{ - int i; - for( i = 0 ; i< MUXERS_NUMBER ; i++) - { - if( encaps_array[i].id == encap ) - { - encap_radios[i]->Enable(); - encap_radios[i]->SetValue(true); - i_mux = i; - } - } -} - -void wizEncapPage::SetStreamingPage( wxWizardPage *page) -{ - p_streaming_page = page; -} - -void wizEncapPage::SetTranscodePage( wxWizardPage *page) -{ - p_transcode_page = page; -} - -wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; } - -wxWizardPage *wizEncapPage::GetNext() const -{ - if( i_action== ACTION_STREAM ) - return p_streaming_page; - else - return p_transcode_page; -} - -void wizEncapPage::SetAction( int i_act ) { i_action = i_act; } - -void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; } - -/*************************************************** - * Extra transcoding page : Select file * - ***************************************************/ -wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent, - wxWizardPage *prev, - wxWizardPage *next) : wxWizardPage(parent) -{ - p_next = next; - p_prev = prev; - p_parent = (WizardDialog *) parent; - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT ); - - mainSizer->Add( 0, 0, 1 ); - - wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 ); - sizer->Add( new wxStaticText( this, -1, - wxU(_("Select the file to save to") ) ), - 0, wxALL, 5 ); - sizer->Add( 0, 0, 1 ); - - file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, - wxSize( 150, -1 ) ); - - sizer->Add( file_text, 0, wxALL, 5 ); - sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) ); - - mainSizer->Add( sizer, 0, 0, 0) ; - - mainSizer->Add( 0, 0, 1 ); - SetSizer(mainSizer); - mainSizer->Fit(this); -} - -void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event) -{ - wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")), - wxT(""), wxT(""), wxT("*"), wxSAVE ); - - if( file_dialog && file_dialog->ShowModal() == wxID_OK ) - { - if( file_dialog->GetFilename().mb_str() ) - { - file_text->SetValue( file_dialog->GetFilename() ); - } - } -} - -void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event ) -{ - if( event.GetDirection() && file_text->GetValue().IsEmpty() ) - { - wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ), - wxICON_WARNING | wxOK, this->p_parent ); - event.Veto(); - } - if( event.GetDirection() ) - { - p_parent->SetTranscodeOut( file_text->GetValue().mb_str()); - } -} - -wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; } -wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; } - -/*********************************************************** - * Extra streaming page - ***********************************************************/ -wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent, - wxWizardPage *prev, - wxWizardPage *next) : wxWizardPage(parent) -{ - p_next = next; - p_prev = prev; - p_parent = (WizardDialog *) parent; - wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); - - /* Create the texts */ - pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT ); - - mainSizer->Add( 0, 0, 1 ); - - wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ; - - /* TTL */ - sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))), - 0, wxALL, 5 ); - ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, - 0, 1, 255, 1 ); - ttl_spin->SetToolTip(wxU(_(TTL) ) ) ; - sizer->Add( ttl_spin, 0, wxALL , 5 ); - - /* SAP announce */ - sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) ); - sap_checkbox->SetToolTip( wxU(_( SAP ) ) ); - sizer->Add( sap_checkbox, 0, 0 , 0 ); - sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, - wxSize(100,25) ); - sap_text->SetToolTip( wxU(_( SAP ) ) ); - sizer->Add( sap_text, 0, wxALL , 5 ); - - mainSizer->Add(sizer, 0, wxALL, 5 ); - - mainSizer->Add( 0, 0, 1 ); - - SetSizer(mainSizer); - mainSizer->Fit(this); -} - -void wizStreamingExtraPage::OnSAP( wxCommandEvent &event ) -{ - sap_text->Enable( event.IsChecked() ); -} - -void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event) -{ - if( sap_checkbox->IsChecked() ) - { - if( sap_text->GetValue().IsEmpty() ) - { - p_parent->SetSAP( true, NULL ); - } - else - { - p_parent->SetSAP( true, - (const char *)sap_text->GetValue().mb_str() ); - } - } - else - { - p_parent->SetSAP( false, NULL ); - } - - p_parent->SetTTL( ttl_spin->GetValue() ); -} - -wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; } -wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; } - - -/*************************************************************************** - * Implementation of the wizard itself - ***************************************************************************/ -wizHelloPage *page1; -wizInputPage *page2 ; -wizTranscodeCodecPage *tr_page1 ; -wizStreamingMethodPage *st_page1; -wizTranscodeExtraPage *tr_page2 ; -wizStreamingExtraPage *st_page2; -wizEncapPage *encap_page; - -WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent, - char *psz_uri, int _i_from, int _i_to ) : -wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition) -{ - /* Initializations */ - p_intf = _p_intf; - SetPageSize(wxSize(400,420)); - - /* Initialize structure */ - i_action = 0; - i_from = _i_from; - i_to = _i_to; - i_ttl = 1; - vb = 0; - ab = 0; - acodec=NULL; - vcodec=NULL; - - page1 = new wizHelloPage(this); - page2 = new wizInputPage(this, page1, p_intf); - - if( psz_uri ) - { - page2->SetUri( psz_uri ); - } - if( i_from != 0 || i_to != 0 ) - { - page2->SetPartial( i_from, i_to ); - } - - encap_page = new wizEncapPage(this ); - tr_page1 = new wizTranscodeCodecPage(this, encap_page ); - st_page1 = new wizStreamingMethodPage(this, encap_page); - - tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL ); - st_page2 = new wizStreamingExtraPage(this, encap_page, NULL ); - - /* Page 1 -> 2 */ - page1->SetNext( page2 ); - /* 2->1 in constructor of 2 */ - - /* Page 2 -> 3 */ - page2->SetTranscodePage(tr_page1); - page2->SetStreamingPage(st_page1); - page2->SetPintf( p_intf ); - tr_page1->SetPrev(page2); - st_page1->SetPrev(page2); - - /* Page 3 -> 4 */ - encap_page->SetTranscodePage( tr_page2 ); - encap_page->SetStreamingPage( st_page2 ); - /* 3->4 in constructor of 3 */ -// encap_page->SetPrev(tr_page1); -} - -WizardDialog::~WizardDialog() -{ - Destroy(); - delete page1; - delete page2; - delete tr_page1; - delete st_page1 ; - delete st_page2; - delete tr_page2; - delete encap_page; -} - -void WizardDialog::SetMrl( const char *mrl ) -{ - this->mrl = strdup( mrl ); -} - -void WizardDialog::SetTTL( int i_ttl ) -{ - this->i_ttl = i_ttl; -} - -void WizardDialog::SetSAP( bool b_enabled, const char *psz_text ) -{ - this->b_sap = b_enabled; - if( b_enabled ) - { - if( psz_text != NULL ) - { - this->psz_sap_name = strdup( psz_text ); - } - else - { - this->psz_sap_name = NULL; - } - } -} - -void WizardDialog::SetPartial( int i_from, int i_to ) -{ - this->i_from = i_from; - this->i_to = i_to; -} - -void WizardDialog::SetTranscode( char *vcodec, int vb, char *acodec,int ab) -{ - if( strcmp( vcodec, "dummy") ) - { - this->vcodec= strdup(vcodec); - } - if( strcmp( acodec, "dummy" ) ) - { - this->acodec = strdup(acodec); - } - this->vb = vb; - this->ab = ab; -} - -void WizardDialog::SetStream( char *method, char *address ) -{ - this->method = strdup( method ); - this->address = strdup( address ); -} - -void WizardDialog::SetTranscodeOut( const char *address ) -{ - this->address = strdup( address ); -} - -void WizardDialog::SetMux( char *mux ) -{ - this->mux = strdup( mux ); -} - -void WizardDialog::SetAction( int i_action ) -{ - this->i_action = i_action; -} - -int WizardDialog::GetAction() -{ - return i_action; -} - -void WizardDialog::Run() -{ - msg_Dbg( p_intf,"starting wizard"); - if( RunWizard(page1) ) - { - int i_size; - char *psz_opt; - msg_Dbg( p_intf,"wizard completed"); - - if( i_action == ACTION_TRANSCODE ) - { - msg_Dbg( p_intf,"Starting transcode of %s to file %s", - mrl, address); - msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s", - vcodec,vb,acodec,ab,mux); - int i_tr_size = 0 ; /* 10 = ab + vb */ - i_tr_size += vcodec ? strlen(vcodec) + strlen("vcodec=") +strlen("vb="): 0; - i_tr_size += acodec ? strlen(acodec) + strlen("acodec=") +strlen("ab=") : 0; - - char *psz_transcode = (char *)malloc( i_tr_size * sizeof(char)); - if( vcodec || acodec ) - { - sprintf( psz_transcode, "transcode{" ); - } - else - { - snprintf( psz_transcode, 1 , "%c", 0 ); - } - if( vcodec ) - { - i_tr_size += 5 + strlen(vcodec); - snprintf( psz_transcode, i_tr_size , "%svcodec=%s,vb=%i", - psz_transcode, vcodec, vb ); - } - if( acodec ) - { - i_tr_size += 6 + strlen(acodec); - /* FIXME */ - sprintf( psz_transcode, "%s%cacodec=%s,ab=%i", - psz_transcode, vcodec ? ',' : ' ', acodec, ab ); - } - if( vcodec || acodec ) - { - i_tr_size +=2; - sprintf( psz_transcode , "%s}:", psz_transcode ); - } - i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode); - psz_opt = (char *)malloc( i_size * sizeof(char) ); - snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s," - "access=file}", - psz_transcode, mux, address ); - } - else - { - msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s", - mrl, address, method, mux); - if( b_sap ) - { - char *psz_sap_option = NULL; - if( psz_sap_name ) - { - psz_sap_option = (char *) malloc( strlen( psz_sap_name ) - + 15 ); - snprintf( psz_sap_option,strlen( psz_sap_name ) + 15, - "sap,name=\"%s\"",psz_sap_name ); - } - else - { - psz_sap_option = (char *) malloc( 5 ); - snprintf( psz_sap_option, 5, "sap" ); - } - i_size = 40 + strlen(mux) + strlen(address) + - strlen( psz_sap_option); - psz_opt = (char *)malloc( i_size * sizeof(char) ); - snprintf( psz_opt, i_size, - ":sout=#standard{mux=%s,url=%s,access=%s,%s}", - mux, address,method, psz_sap_option); - msg_Dbg( p_intf, "Sap enabled: %s", psz_sap_option); - if( psz_sap_option ) free( psz_sap_option ); - } - else - { - i_size = 40 + strlen(mux) + strlen(address); - psz_opt = (char *)malloc( i_size * sizeof(char) ); - snprintf( psz_opt, i_size, - ":sout=#standard{mux=%s,url=%s,access=%s}", - mux, address,method); - } - } - - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); - if( p_playlist ) - { - playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl, - ITEM_NAME ); - playlist_ItemAddOption( p_item, psz_opt); - if( i_from != 0) - { - char psz_from[20]; - msg_Dbg( p_intf, "Setting starttime"); - snprintf( psz_from, 20, "start-time=%i", i_from); - playlist_ItemAddOption( p_item, psz_from); - } - if( i_to != 0) - { - char psz_to[20]; - snprintf( psz_to, 20, "stop-time=%i", i_to); - playlist_ItemAddOption( p_item, psz_to); - } - - char psz_ttl[20]; - snprintf( psz_ttl, 20, "ttl=%i",i_ttl ); - playlist_ItemAddOption( p_item, psz_ttl ); - - playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END ); - vlc_object_release(p_playlist); - } - else - { - wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ), - wxICON_WARNING | wxOK, this ); - } - } - else - { - msg_Dbg( p_intf, "wizard was cancelled"); - } -} -/**************************************************************** - * Local helper functions - ****************************************************************/ -static int ismult( const char *psz_uri ) -{ - char *psz_end; - unsigned long i_value; - - /* IPv6 */ - if( psz_uri[0] == '[') - return strncasecmp( &psz_uri[1], "FF" , 2) ? VLC_FALSE : VLC_TRUE; - - /* IPv4 */ - i_value = strtoul( psz_uri, &psz_end, 10 ); - if( *psz_end != '.' ) { return( VLC_FALSE ); } - - return( ( i_value >= 224 && i_value < 240 ) ? VLC_TRUE : VLC_FALSE ); - -} +/***************************************************************************** + * wizard.cpp : wxWindows plugin for vlc + ***************************************************************************** + * Copyright (C) 2000-2004 VideoLAN + * $Id$ + * + * Authors: Clément Stenac + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* malloc(), free() */ +#include /* ENOMEM */ +#include /* strerror() */ +#include + +#include +#include + +#include "wxwindows.h" + +#include "streamdata.h" + +#include + +class wizHelloPage; +class wizInputPage; + +/***************************************************************************** + * Define events + *****************************************************************************/ +enum +{ + ActionRadio0_Event, ActionRadio1_Event, + MoreInfoStreaming_Event, + MoreInfoTranscode_Event, + + Open_Event , Choose_Event , + ListView_Event, + InputRadio0_Event, InputRadio1_Event, + PartialEnable_Event, + + MethodRadio0_Event, MethodRadio1_Event, + MethodRadio2_Event, MethodRadio3_Event, + + EncapRadio0_Event, EncapRadio1_Event, + EncapRadio2_Event, EncapRadio3_Event, + EncapRadio4_Event, EncapRadio5_Event, + EncapRadio6_Event, EncapRadio7_Event, + EncapRadio8_Event, EncapRadio9_Event, + EncapRadio10_Event, EncapRadio11_Event, + + VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event, + AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event, + + SAP_Event, + +}; + +#define TEXTWIDTH 55 +#define ACTION_STREAM 0 +#define ACTION_TRANSCODE 1 + +BEGIN_EVENT_TABLE(WizardDialog, wxWizard) +END_EVENT_TABLE() + +/***************************************************************************** + * Wizard strings + *****************************************************************************/ + +#define ERROR_MSG _("Error") +#define ITEM_NAME _("Streaming/Transcoding Wizard") + +/* Hello page */ +#define HELLO_TITLE _("Streaming/Transcoding Wizard") +#define HELLO_TEXT _("This wizard helps you to stream, transcode or" \ + " save a stream") +#define HELLO_STREAMING _("Stream to network") +#define HELLO_STREAMING_DESC _("Use this to stream on a network") +#define HELLO_TRANSCODE _("Transcode/Save to file") +#define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file") +#define HELLO_NOTICE _("This wizard only gives access to a small subset of VLC's streaming and transcoding capabilities. Use the Open and Stream Output dialogs to get all of them") + +#define MOREINFO_STREAM _("Use this to stream on a network") + +#define MOREINFO_TRANSCODE _("Use this to save a stream to a file. You have the possibility to reencode the stream. You can save whatever VLC can read.\nPlease notice that VLC is not very suited " \ + "for file to file transcoding. You should use its transcoding " \ + "features to save network streams, for example" ) + +/* Input page */ +#define INPUT_TITLE _("Choose input") +#define INPUT_TEXT _("Choose here your input stream") + +#define INPUT_OPEN _("Select a stream" ) +#define INPUT_PL _( "Existing playlist item" ) + +#define CHOOSE_STREAM _("You must choose a stream") +#define NO_PLAYLIST _("Uh Oh! Unable to find playlist !") + +#define PARTIAL _("Use this to read only a part of the stream. " \ + "You must be able to control the incoming stream " \ + "(for example, a file or a disc, but not an UDP " \ + "network stream.)\n" \ + "Enter the starting and ending times (in seconds)") + +#define INPUT_BUTTON _("Choose") + +/* Transcode 1 */ +#define TRANSCODE1_TITLE _("Transcode") +#define TRANSCODE1_TEXT _("If you want to change the compression format of the audio or video tracks, fill in this page. (If you only want to change the container format, proceed to next page).") + +#define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \ + "transcode it, enable this") +#define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \ + "information") + +#define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\ + "transcode it, enable this") +#define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \ + "information") + +/* Streaming 1 */ +#define STREAMING1_TITLE _("Streaming") +#define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.") + + +#define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \ + "multicast address" ) +#define NO_ADDRESS _("You need to enter an address" ) + +/* Encap */ +#define ENCAP_TITLE _("Encapsulation format") +#define ENCAP_TEXT _("In this page, you will select how the stream will be "\ + "encapsulated. Depending on the choices you made, all "\ + "formats won't be available." ) + + +/* Transcode 2 */ +#define EXTRATRANSCODE_TITLE _("Additional transcode options") +#define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \ + "additionnal parameters for your transcoding" ) + +#define CHOOSE_OUTFILE _("You must choose a file to save to") + +/* Streaming 2 */ +#define EXTRASTREAMING_TITLE _("Additional streaming options") +#define EXTRASTREAMING_TEXT _("In this page, you will define a few " \ + "additionnal parameters for your stream" ) + +#define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \ + "is the maximum number of routers your stream can go through. " \ + "If you don't know what it means, or if you want to stream on " \ + "your local network only, leave this setting to 1." ) + +#define SAP _("When streaming using UDP, you can announce your streams " \ + "using the SAP/SDP announcing protocol. This way, the clients " \ + "won't have to type in the multicast address, it will appear " \ + "in their playlist if they enable the SAP extra interface.\n" \ + "If you want to give a name to your stream, enter it here, " \ + "else, a default name will be used" ) + +/***************************************************************************** + * All the pages of the wizard, declaration + *****************************************************************************/ + +/* Declare classes */ +class wizHelloPage : public wxWizardPageSimple +{ + public: + wizHelloPage( wxWizard *parent); + void OnActionChange(wxEvent& event); + void OnWizardPageChanging(wxWizardEvent& event); + void OnMoreInfo( wxCommandEvent& event ); + protected: + int i_action; + WizardDialog *p_parent; + wxRadioButton *action_radios[2]; + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple) + EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange) + EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange) + EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo ) + EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo ) + + EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging) +END_EVENT_TABLE() + + +class wizInputPage : public wxWizardPage +{ + public: + wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *); + wizInputPage::~wizInputPage(); + void OnWizardPageChanging(wxWizardEvent& event); + void OnInputChange(wxEvent& event); + void OnEnablePartial(wxCommandEvent& event); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void SetStreamingPage( wxWizardPage *page); + void SetTranscodePage( wxWizardPage *page); + void SetAction( int i_action ); + void SetPintf( intf_thread_t *p_intf ); + void SetUri( char *psz_uri ); + void SetPartial( int i_from, int i_to ); + + protected: + bool b_chosen; + intf_thread_t *p_intf; + int i_action; + int i_input; + + void OnChoose( wxCommandEvent& event ); + + WizardDialog *p_parent; + wxRadioButton *input_radios[2]; + wxCheckBox *enable_checkbox; + wxBoxSizer *mainSizer; + wxArrayString mrl; + wxTextCtrl *mrl_text; + wxTextCtrl *from_text; + wxTextCtrl *to_text; + OpenDialog *p_open_dialog; + wxListView *listview; + wxPanel *open_panel; + wxWizardPage *p_prev; + wxWizardPage *p_streaming_page; + wxWizardPage *p_transcode_page; + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage) + EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange) + EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange) + EVT_BUTTON( Choose_Event, wizInputPage::OnChoose) + EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial) + EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging) +END_EVENT_TABLE() + + +class wizTranscodeCodecPage : public wxWizardPage +{ +public: + wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next); + ~wizTranscodeCodecPage(); + void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void SetPrev( wxWizardPage *page); +protected: + wxCheckBox *video_checkbox; + wxComboBox *video_combo; + wxComboBox *vb_combo; + wxStaticText * video_text; + wxCheckBox *audio_checkbox; + wxComboBox *audio_combo; + wxComboBox *ab_combo; + wxStaticText * audio_text; + + WizardDialog *p_parent; + int i_audio_codec; + int i_video_codec; + + char *vcodec; + char *acodec; + + wxWizardPage *p_prev; + wxWizardPage *p_next; + + void OnVideoCodecChange(wxCommandEvent& event); + void OnAudioCodecChange(wxCommandEvent& event); + void OnEnableVideo(wxCommandEvent& event); + void OnEnableAudio(wxCommandEvent& event); + + DECLARE_EVENT_TABLE() +}; + +BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage) + EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo) + EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio) + EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange) + EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange) + EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging) +END_EVENT_TABLE() + +class wizStreamingMethodPage : public wxWizardPage +{ +public: + wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next); + void OnWizardPageChanging(wxWizardEvent& event); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void SetPrev( wxWizardPage *page); +protected: + DECLARE_EVENT_TABLE() + int i_method; + wxBoxSizer *mainSizer; + wxStaticBoxSizer *address_sizer; + wxStaticText *address_text; + wxTextCtrl *address_txtctrl; + WizardDialog * p_parent; + void OnMethodChange(wxEvent& event); + wxRadioButton *method_radios[4]; + wxWizardPage *p_prev; + wxWizardPage *p_next; +}; + +BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage) + EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange) + EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange) + EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange) + EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange) + EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging) +END_EVENT_TABLE() + + +class wizEncapPage : public wxWizardPage +{ +public: + wizEncapPage( wxWizard *parent); + wizEncapPage::~wizEncapPage(); + void OnWizardPageChanging(wxWizardEvent& event); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void SetStreamingPage( wxWizardPage *page); + void SetTranscodePage( wxWizardPage *page); + void SetPrev( wxWizardPage *page); + void SetAction( int ); + void EnableEncap( int encap ); +protected: + DECLARE_EVENT_TABLE() + int i_encap; + int i_mux; + int i_action; + void OnEncapChange(wxEvent& event); + wxRadioButton *encap_radios[MUXERS_NUMBER]; + WizardDialog *p_parent; + wxWizardPage *p_prev; + wxWizardPage *p_streaming_page; + wxWizardPage *p_transcode_page; +}; + +BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage) + EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging) + EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange) + EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange) +END_EVENT_TABLE() + +/* Additional settings for transcode */ +class wizTranscodeExtraPage : public wxWizardPage +{ +public: + wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev, + wxWizardPage *next); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void OnWizardPageChanging( wxWizardEvent& event ); +protected: + DECLARE_EVENT_TABLE() + void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&); + wxTextCtrl *file_text; + WizardDialog *p_parent; + wxWizardPage *p_prev; + wxWizardPage *p_next; +}; + +BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage) + EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile) + EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging) +END_EVENT_TABLE() + +/* Additional settings for streaming */ +class wizStreamingExtraPage : public wxWizardPage +{ +public: + wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev, + wxWizardPage *next); + virtual wxWizardPage *GetPrev() const; + virtual wxWizardPage *GetNext() const; + void OnWizardPageChanging(wxWizardEvent&); + void OnSAP( wxCommandEvent&); + wxCheckBox *sap_checkbox; + wxTextCtrl *sap_text; +protected: + friend class wizEncapPage; + DECLARE_EVENT_TABLE() + WizardDialog *p_parent; + wxWizardPage *p_prev; + wxWizardPage *p_next; + + wxSpinCtrl *ttl_spin; +}; + +BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage) + EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP ) + EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging) +END_EVENT_TABLE() + + +/* Local functions */ +static int ismult( const char *psz_uri ); + +static void pageHeader( wxWindow *window, wxBoxSizer *sizer, + char *psz_title, char *psz_text); + +static void pageHeader( wxWindow *window, wxBoxSizer *sizer, + char *psz_title, char *psz_text) +{ + wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) ); + wxFont font = wtitle->GetFont(); + font.SetPointSize(14); + wtitle->SetFont(font); + sizer->Add( wtitle, 0, wxALL, 5 ); + sizer->Add( new wxStaticText( window, -1, + wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ), + 0, wxALL, 5 ); +} + +/*************************************************************************** + * Implementation of the pages + ***************************************************************************/ + + +/*************************************************** + * First page: choose between stream and transcode * + ***************************************************/ +wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent) +{ + i_action = 0; + p_parent = (WizardDialog *)parent; + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT ); + + /* Create the radio buttons with their helps */ + action_radios[0] = new wxRadioButton( this, ActionRadio0_Event, + wxU( HELLO_STREAMING ) ); + action_radios[1] = new wxRadioButton( this, ActionRadio1_Event, + wxU( HELLO_TRANSCODE ) ); + i_action = 0; + + mainSizer->Add( 0, 0, 1 ); + + wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL ); + stream_sizer->Add( action_radios[0], 0, wxALL, 5 ); + stream_sizer->Add( 0,0,1 ); + stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event, + wxU( _("More Info")) ), 0, 0, 0 ); + mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 ); + + wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL ); + transcode_sizer->Add( action_radios[1], 0, wxALL, 5 ); + transcode_sizer->Add( 0,0,1); + transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event, + wxU( _("More Info")) ), 0 , 0 , 0 ); + mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 ); + + mainSizer->Add( 0, 0, 1 ); + + mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP| + wxBOTTOM, 5 ); + + mainSizer->Add( new wxStaticText(this, -1, + wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))), + 0, wxALL, 5 ); + + SetSizer(mainSizer); + mainSizer->Fit(this); + } + +void wizHelloPage::OnMoreInfo(wxCommandEvent& event) +{ + wxString msg; + msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ? + MOREINFO_STREAM : + MOREINFO_TRANSCODE ) ) ); + wxMessageBox( msg, wxU(_("More information")), + wxOK | wxICON_INFORMATION, this->p_parent ); +} + +void wizHelloPage::OnActionChange(wxEvent& event) +{ + i_action = event.GetId() - ActionRadio0_Event; + ((wizInputPage *)GetNext())->SetAction( i_action ); + p_parent->SetAction( i_action ); +} + +void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event) +{ + ((wizInputPage *)GetNext())->SetAction( i_action ); + p_parent->SetAction( i_action ); +} + +/************************************ + * Second page: choose input stream * + ************************************/ +wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) : + wxWizardPage(parent) +{ + p_prev = prev; + p_intf = _p_intf; + p_parent = (WizardDialog *)parent; + b_chosen = false; + p_open_dialog = NULL; + listview = NULL; + mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT ); + + mainSizer->Add( 0,20,0 ); + + /* Create the radio buttons */ + input_radios[0] = new wxRadioButton( this, InputRadio0_Event , + wxU( INPUT_OPEN ) ); + mainSizer->Add( input_radios[0], 0, wxALL, 5 ); + input_radios[1] = new wxRadioButton( this, InputRadio1_Event , + wxU( INPUT_PL ) ); + i_input = 0; + mainSizer->Add( input_radios[1], 0, wxALL, 5 ); + + /* Open Panel */ + open_panel = new wxPanel(this, -1); + open_panel->SetAutoLayout( TRUE ); + wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL); + + mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition, + wxSize(200,25) ); + openSizer->Add( mrl_text, 0 , wxALL, 5 ); + openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 ); + open_panel->SetSizer( openSizer ); + openSizer->Layout(); + openSizer->Fit(open_panel); + + mainSizer->Add( open_panel ); + + + playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, + VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + + if( p_playlist ) + { + if( p_playlist->i_size > 0) + { + listview = new wxListView( this, ListView_Event, + wxDefaultPosition, wxDefaultSize, + wxLC_REPORT | wxSUNKEN_BORDER ); + listview->InsertColumn( 0, wxU(_("Name")) ); + listview->InsertColumn( 1, wxU(_("URI")) ); + listview->SetColumnWidth( 0, 250 ); + listview->SetColumnWidth( 1, 100 ); + for( int i=0 ; i < p_playlist->i_size ; i++ ) + { + wxString filename = wxL2U( p_playlist->pp_items[i]->input. + psz_name ); + listview->InsertItem( i, filename ); + listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]-> + input.psz_uri) ); + } + listview->Select( p_playlist->i_index , TRUE); + mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 ); + + listview->Hide(); + mainSizer->Hide( listview ); + mainSizer->Layout(); + } + else + { + input_radios[1]->Disable(); + } + vlc_object_release( p_playlist ); + } + else + { + input_radios[1]->Disable(); + } + + /* Partial Extract Box */ + mainSizer->Add( 0, 10, 0 ); + wxStaticBox *partial_box = new wxStaticBox( this, -1, + wxU(_("Partial Extract")) ); + + wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box, + wxVERTICAL ); + + enable_checkbox = new wxCheckBox( this, PartialEnable_Event, + wxU(_("Enable") ) ); + enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ; + partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT + + wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 ); + partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ), + 0 , wxLEFT , 5 ); + from_text = new wxTextCtrl( this, -1, wxT(""), + wxDefaultPosition, wxSize( 80,25 ) ); + partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT); + partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ), + 0 , wxLEFT , 5 ); + to_text = new wxTextCtrl( this, -1, wxT(""), + wxDefaultPosition, wxSize( 80 , 25 ) ); + partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT ); + + partial_sizer->Add( partial_sizer2, 0, wxALL, 0 ); + + partial_sizer->Fit( partial_box ); + + mainSizer->Add( partial_sizer, 0, 0, 0 ); + + from_text->Disable(); + to_text->Disable(); + SetSizer(mainSizer); + mainSizer->Fit(this); + mainSizer->Layout(); +} + +wizInputPage::~wizInputPage() +{ +} + +void wizInputPage::OnInputChange(wxEvent& event) +{ + i_input = event.GetId() - InputRadio0_Event; + if( i_input == 0 ) + { + if( listview ) + { + listview->Hide(); + mainSizer->Hide( listview ); + open_panel->Show(); + mainSizer->Show( open_panel ); + mainSizer->Layout(); + } + } + else + { + open_panel->Hide(); + mainSizer->Hide( open_panel ); + listview->Show(); + mainSizer->Show( listview ); + mainSizer->Layout(); + } +} + +void wizInputPage::OnEnablePartial(wxCommandEvent& event) +{ + from_text->Enable( event.IsChecked() ); + to_text->Enable( event.IsChecked() ); +} + + +void wizInputPage::OnChoose(wxCommandEvent& event) +{ + p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM ); + if( p_open_dialog->ShowModal() == wxID_OK && + !p_open_dialog->mrl.IsEmpty() ) + { + mrl_text->SetValue(p_open_dialog->mrl[0] ); + } + delete p_open_dialog; + p_open_dialog = NULL; +} + +void wizInputPage::OnWizardPageChanging(wxWizardEvent& event) +{ + if( i_input == 0) + { + if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) && + event.GetDirection() ) + { + wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ), + wxICON_WARNING | wxOK, this->p_parent ); + event.Veto(); + return; + } + else + { + p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() ); + } + } + else + { + int i = -1; + wxListItem listitem; + i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + if( i != -1 ) + { + listitem.SetId( i ); + listitem.SetColumn( 1 ); + listview->GetItem( listitem ); + p_parent->SetMrl( (const char*) listitem.GetText().mb_str() ); + } + } + if( enable_checkbox->IsChecked() ) + { + int i_from = atoi( from_text->GetValue().mb_str() ); + int i_to = atoi( to_text->GetValue().mb_str() ); + msg_Dbg( p_intf, "Partial streaming enabled, from %i to %i", + i_from,i_to); + p_parent->SetPartial( i_from, i_to ); + } + return; +} + +wxWizardPage *wizInputPage::GetPrev() const { return p_prev; } +wxWizardPage *wizInputPage::GetNext() const +{ + if( i_action == ACTION_STREAM ) + return p_streaming_page; + else + return p_transcode_page; +} + +void wizInputPage::SetStreamingPage( wxWizardPage *page) +{ + p_streaming_page = page; +} + +void wizInputPage::SetTranscodePage( wxWizardPage *page) +{ + p_transcode_page = page; +} + +void wizInputPage::SetAction( int i_action ) +{ + this->i_action = i_action; +} + +void wizInputPage::SetPintf( intf_thread_t *p_intf ) +{ + this->p_intf = p_intf; +} + +void wizInputPage::SetUri( char *psz_uri ) +{ + mrl_text->SetValue( wxU( psz_uri ) ); +} + +void wizInputPage::SetPartial( int i_from, int i_to ) +{ + wxString msg; + msg.Printf( wxString( wxT( "%i") ), i_from ); + from_text->Enable( TRUE ); + from_text->SetValue( msg ); + msg.Printf( wxString( wxT( "%i") ), i_to ); + to_text->Enable( TRUE ); + to_text->SetValue( msg ); + enable_checkbox->SetValue( TRUE ); +} + +/*************************************************** + * First transcode page: choose codecs * + ***************************************************/ +wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent, + wxWizardPage *next) : wxWizardPage(parent) +{ + p_next = next; + + acodec = NULL; + vcodec = NULL; + p_parent = (WizardDialog *) parent; + + wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL); + + /* Header */ + pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT ); + + /* Video Box */ + wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) ); + wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box, + wxVERTICAL ); + /* Line 1 : only the checkbox */ + wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 ); + video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event, + wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 ); + video_sizer1->Add( 0,0,1); + /* Line 2 : codec */ + video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5); + video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""), + wxDefaultPosition, wxSize(200,25), 0, NULL, + wxCB_DROPDOWN| wxCB_READONLY ); + for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ ) + { + video_combo->Append( wxU( vcodecs_array[i].psz_display ) , + (void *)&vcodecs_array[i] ); + } + i_video_codec = 0; + video_combo->SetSelection(0); + + video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 ); + + video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0, + wxLEFT ,5); + vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY ); + video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 ); + + /* Line 3 : text */ + video_text = new wxStaticText( this, -1, + wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) ); + /* Fill the main video sizer */ + video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 ); + video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 ); + + + /* Audio box */ + wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) ); + wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box, + wxVERTICAL ); + /* Line1: enabler */ + wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20); + audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event, + wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + audio_sizer1->Add( 0, 0, 1 ); + + /* Line 2 : codec */ + audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5); + audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""), + wxDefaultPosition, wxSize(200,25), 0, NULL, + wxCB_DROPDOWN| wxCB_READONLY ); + for( int i= 0; acodecs_array[i].psz_display != NULL; i++ ) + { + audio_combo->Append( wxU( acodecs_array[i].psz_display ) , + (void *)&acodecs_array[i] ); + } + i_audio_codec = 0; + audio_combo->SetSelection(0); + audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 ); + + audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0, + wxLEFT ,5); + ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY ); + audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 ); + + /* Line 3 : text */ + audio_text = new wxStaticText( this, -1, + wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) ); + + audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5); + audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 ); + + main_sizer->Add( video_sizer, 1, wxGROW, 0 ); + main_sizer->Add( audio_sizer, 1, wxGROW, 0 ); + main_sizer->Layout(); + SetSizerAndFit( main_sizer ); + + /* Default disabled */ + video_combo->Disable(); video_text->Disable();vb_combo->Disable(); + audio_combo->Disable(); audio_text->Disable();ab_combo->Disable(); + +} + +wizTranscodeCodecPage::~wizTranscodeCodecPage() +{ + if( acodec ) free( acodec ); + if( vcodec ) free( vcodec ); +} + +void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event) +{ + video_combo->Enable( event.IsChecked() ); + vb_combo->Enable( event.IsChecked() ); + video_text->Enable( event.IsChecked() ); +} + +void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event) +{ + audio_combo->Enable( event.IsChecked() ); + ab_combo->Enable( event.IsChecked() ); + audio_text->Enable( event.IsChecked() ); +} + +void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event) +{ + struct codec *c = (struct codec*) + (video_combo->GetClientData(video_combo->GetSelection())); + video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) ); + i_video_codec = video_combo->GetSelection(); + vcodec = strdup(c->psz_codec); +} + +void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event) +{ + struct codec *c = (struct codec*) + (audio_combo->GetClientData(audio_combo->GetSelection())); + audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) ); + i_audio_codec = audio_combo->GetSelection(); + acodec = strdup(c->psz_codec); + +} + +void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event) +{ + unsigned int i,j; + + if( !event.GetDirection() ) + { + GetPrev()->Enable(); + return; + } + + /* Set the dummy codec ( accept all muxers ) if needed */ + if( !video_combo->IsEnabled() ) + { + i_video_codec = VCODECS_NUMBER; + } + if( !audio_combo->IsEnabled() ) + { + i_audio_codec = ACODECS_NUMBER; + } + + ((wizEncapPage *)GetNext())->SetPrev(this); + + for( i = 0 ; i< MUXERS_NUMBER ; i++ ) + { + if( vcodecs_array[i_video_codec].muxers[i] != -1 ) + { + for( j = 0 ; j< MUXERS_NUMBER ; j++ ) + { + if( acodecs_array[i_audio_codec].muxers[j] == + vcodecs_array[i_video_codec].muxers[i] ) + { + ((wizEncapPage*)GetNext())->EnableEncap( + vcodecs_array[i_video_codec].muxers[i] ); + } + } + } + } + struct codec *c = (struct codec*) + (video_combo->GetClientData( video_combo->IsEnabled() ? + video_combo->GetSelection(): i_video_codec )); + vcodec = strdup(c->psz_codec); + c = (struct codec*) + (audio_combo->GetClientData( audio_combo->IsEnabled() ? + audio_combo->GetSelection() : i_audio_codec )); + acodec = strdup(c->psz_codec); + + int vb = atoi(vb_combo->GetValue().mb_str() ); + if( vb == 0 ) + { + vb = 1024; + } + int ab = atoi(ab_combo->GetValue().mb_str() ); + if( ab == 0) + { + ab = 192; + } + + p_parent->SetTranscode( vcodec, vb , acodec, ab ); + ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() ); + p_parent->SetAction( p_parent->GetAction() ); + + return; +} + +wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; } +wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; } +void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; } + + +/*************************************************** + * First streaming page: choose method * + ***************************************************/ +wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent, + wxWizardPage *next) : wxWizardPage(parent) +{ + int i; + p_next = next; + p_parent = (WizardDialog *)parent; + + mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT ); + + mainSizer->Add( 0,50,0 ); + + i_method = 0; + + wxStaticBox *method_box = new wxStaticBox( this, -1, + wxU(_("Streaming method")) ); + wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box, + wxHORIZONTAL ); + for( i = 0 ; i< 3 ; i++ ) + { + method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i, + wxU( methods_array[i].psz_method ) ); + method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) ); + method_sizer->Add( method_radios[i], 0, wxALL, 5 ); + } + + method_sizer->Layout(); + + wxStaticBox *address_box = new wxStaticBox( this, -1, + wxU(_("Destination")) ); + + address_sizer = new wxStaticBoxSizer(address_box, + wxVERTICAL ); + + /* Big kludge, we take the longest text to get the size */ + address_text = new wxStaticText(this, -1, + wxU( vlc_wraptext(methods_array[2].psz_address, + TEXTWIDTH, false ) ), + wxDefaultPosition, wxDefaultSize ); + + address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, + wxSize(200,25)); + address_sizer->Add( address_text, 0, wxALL, 5 ); + address_sizer->Add( address_txtctrl, 0, wxALL, 5 ); + address_sizer->Layout(); + + /* Set the minimum size */ + address_sizer->SetMinSize( address_sizer->GetSize() ); + address_text->SetLabel( wxU( + vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false))); + + mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 ); + mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 ); + + mainSizer->Add( 0,0,1 ); + + mainSizer->Layout(); + + SetSizer(mainSizer); + mainSizer->Fit(this); + + return; +} + +void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event) +{ + unsigned int i; + if( !event.GetDirection() ) return; + + /* Check valid address */ + if( i_method == 1 && !ismult( address_txtctrl->GetValue().mb_str()) ) + { + wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ), + wxICON_WARNING | wxOK, this->p_parent ); + event.Veto(); + + } + else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() ) + { + wxMessageBox( wxU( NO_ADDRESS ) , wxU( ERROR_MSG ), + wxICON_WARNING | wxOK, this->p_parent ); + event.Veto(); + + } + + ((wizEncapPage *)GetNext())->SetPrev(this); + for( i = 0 ; i< MUXERS_NUMBER ; i++ ) + { + if( methods_array[i_method].muxers[i] != -1 ) + { + ((wizEncapPage*)GetNext())->EnableEncap( + methods_array[i_method].muxers[i] ); + } + } + p_parent->SetStream( methods_array[i_method].psz_access , + (char *)address_txtctrl->GetValue().c_str() ); + + /* Set the action for the muxer page */ + ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() ); + return; +} + +wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; } +wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; } + +void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; } + + +void wizStreamingMethodPage::OnMethodChange(wxEvent& event) +{ + i_method = event.GetId() - MethodRadio0_Event; + address_text->SetLabel( wxU( + vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false))); + address_sizer->Layout(); + mainSizer->Layout(); +} + +/*************************************************** + * Choose encapsulation format * + ***************************************************/ +wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent) +{ + int i; + i_mux = 0; + p_parent = (WizardDialog *)parent; + p_streaming_page = NULL; + p_transcode_page = NULL; + p_prev = NULL; + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT ); + + mainSizer->Add( 0,0,1 ); + + for( i = 0 ; i< MUXERS_NUMBER ; i++ ) + { + encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i, + wxU( encaps_array[i].psz_encap ) ); + encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) ); + mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 ); + encap_radios[i]->Disable(); + } + + mainSizer->Add( 0,0,1 ); + + SetSizer(mainSizer); + mainSizer->Fit(this); +} + +wizEncapPage::~wizEncapPage() +{ +} + +void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event) +{ + int i; + if( !event.GetDirection() ) + { + for( i = 0 ; i< MUXERS_NUMBER ; i++ ) + { + encap_radios[i]->Disable(); + } + } + p_parent->SetMux( encaps_array[i_mux].psz_mux ); + + if( p_parent->GetAction() == ACTION_STREAM ) + { + if( strstr( p_parent->method, "udp" )) + { + ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable(); + ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false); + } + else + { + ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false ); + ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false ); + } + } + + return; +} + + +void wizEncapPage::OnEncapChange(wxEvent& event) +{ + i_mux = event.GetId() - EncapRadio0_Event; +} + +void wizEncapPage::EnableEncap( int encap ) +{ + int i; + for( i = 0 ; i< MUXERS_NUMBER ; i++) + { + if( encaps_array[i].id == encap ) + { + encap_radios[i]->Enable(); + encap_radios[i]->SetValue(true); + i_mux = i; + } + } +} + +void wizEncapPage::SetStreamingPage( wxWizardPage *page) +{ + p_streaming_page = page; +} + +void wizEncapPage::SetTranscodePage( wxWizardPage *page) +{ + p_transcode_page = page; +} + +wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; } + +wxWizardPage *wizEncapPage::GetNext() const +{ + if( i_action== ACTION_STREAM ) + return p_streaming_page; + else + return p_transcode_page; +} + +void wizEncapPage::SetAction( int i_act ) { i_action = i_act; } + +void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; } + +/*************************************************** + * Extra transcoding page : Select file * + ***************************************************/ +wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent, + wxWizardPage *prev, + wxWizardPage *next) : wxWizardPage(parent) +{ + p_next = next; + p_prev = prev; + p_parent = (WizardDialog *) parent; + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT ); + + mainSizer->Add( 0, 0, 1 ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 ); + sizer->Add( new wxStaticText( this, -1, + wxU(_("Select the file to save to") ) ), + 0, wxALL, 5 ); + sizer->Add( 0, 0, 1 ); + + file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, + wxSize( 150, -1 ) ); + + sizer->Add( file_text, 0, wxALL, 5 ); + sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) ); + + mainSizer->Add( sizer, 0, 0, 0) ; + + mainSizer->Add( 0, 0, 1 ); + SetSizer(mainSizer); + mainSizer->Fit(this); +} + +void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event) +{ + wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")), + wxT(""), wxT(""), wxT("*"), wxSAVE ); + + if( file_dialog && file_dialog->ShowModal() == wxID_OK ) + { + if( file_dialog->GetFilename().mb_str() ) + { + file_text->SetValue( file_dialog->GetFilename() ); + } + } +} + +void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event ) +{ + if( event.GetDirection() && file_text->GetValue().IsEmpty() ) + { + wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ), + wxICON_WARNING | wxOK, this->p_parent ); + event.Veto(); + } + if( event.GetDirection() ) + { + p_parent->SetTranscodeOut( file_text->GetValue().mb_str()); + } +} + +wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; } +wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; } + +/*********************************************************** + * Extra streaming page + ***********************************************************/ +wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent, + wxWizardPage *prev, + wxWizardPage *next) : wxWizardPage(parent) +{ + p_next = next; + p_prev = prev; + p_parent = (WizardDialog *) parent; + wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL); + + /* Create the texts */ + pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT ); + + mainSizer->Add( 0, 0, 1 ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ; + + /* TTL */ + sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))), + 0, wxALL, 5 ); + ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, + 0, 1, 255, 1 ); + ttl_spin->SetToolTip(wxU(_(TTL) ) ) ; + sizer->Add( ttl_spin, 0, wxALL , 5 ); + + /* SAP announce */ + sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) ); + sap_checkbox->SetToolTip( wxU(_( SAP ) ) ); + sizer->Add( sap_checkbox, 0, 0 , 0 ); + sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition, + wxSize(100,25) ); + sap_text->SetToolTip( wxU(_( SAP ) ) ); + sizer->Add( sap_text, 0, wxALL , 5 ); + + mainSizer->Add(sizer, 0, wxALL, 5 ); + + mainSizer->Add( 0, 0, 1 ); + + SetSizer(mainSizer); + mainSizer->Fit(this); +} + +void wizStreamingExtraPage::OnSAP( wxCommandEvent &event ) +{ + sap_text->Enable( event.IsChecked() ); +} + +void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event) +{ + if( sap_checkbox->IsChecked() ) + { + if( sap_text->GetValue().IsEmpty() ) + { + p_parent->SetSAP( true, NULL ); + } + else + { + p_parent->SetSAP( true, + (const char *)sap_text->GetValue().mb_str() ); + } + } + else + { + p_parent->SetSAP( false, NULL ); + } + + p_parent->SetTTL( ttl_spin->GetValue() ); +} + +wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; } +wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; } + + +/*************************************************************************** + * Implementation of the wizard itself + ***************************************************************************/ +wizHelloPage *page1; +wizInputPage *page2 ; +wizTranscodeCodecPage *tr_page1 ; +wizStreamingMethodPage *st_page1; +wizTranscodeExtraPage *tr_page2 ; +wizStreamingExtraPage *st_page2; +wizEncapPage *encap_page; + +WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent, + char *psz_uri, int _i_from, int _i_to ) : +wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition) +{ + /* Initializations */ + p_intf = _p_intf; + SetPageSize(wxSize(400,420)); + + /* Initialize structure */ + i_action = 0; + i_from = _i_from; + i_to = _i_to; + i_ttl = 1; + vb = 0; + ab = 0; + acodec=NULL; + vcodec=NULL; + + page1 = new wizHelloPage(this); + page2 = new wizInputPage(this, page1, p_intf); + + if( psz_uri ) + { + page2->SetUri( psz_uri ); + } + if( i_from != 0 || i_to != 0 ) + { + page2->SetPartial( i_from, i_to ); + } + + encap_page = new wizEncapPage(this ); + tr_page1 = new wizTranscodeCodecPage(this, encap_page ); + st_page1 = new wizStreamingMethodPage(this, encap_page); + + tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL ); + st_page2 = new wizStreamingExtraPage(this, encap_page, NULL ); + + /* Page 1 -> 2 */ + page1->SetNext( page2 ); + /* 2->1 in constructor of 2 */ + + /* Page 2 -> 3 */ + page2->SetTranscodePage(tr_page1); + page2->SetStreamingPage(st_page1); + page2->SetPintf( p_intf ); + tr_page1->SetPrev(page2); + st_page1->SetPrev(page2); + + /* Page 3 -> 4 */ + encap_page->SetTranscodePage( tr_page2 ); + encap_page->SetStreamingPage( st_page2 ); + /* 3->4 in constructor of 3 */ +// encap_page->SetPrev(tr_page1); +} + +WizardDialog::~WizardDialog() +{ + Destroy(); + delete page1; + delete page2; + delete tr_page1; + delete st_page1 ; + delete st_page2; + delete tr_page2; + delete encap_page; +} + +void WizardDialog::SetMrl( const char *mrl ) +{ + this->mrl = strdup( mrl ); +} + +void WizardDialog::SetTTL( int i_ttl ) +{ + this->i_ttl = i_ttl; +} + +void WizardDialog::SetSAP( bool b_enabled, const char *psz_text ) +{ + this->b_sap = b_enabled; + if( b_enabled ) + { + if( psz_text != NULL ) + { + this->psz_sap_name = strdup( psz_text ); + } + else + { + this->psz_sap_name = NULL; + } + } +} + +void WizardDialog::SetPartial( int i_from, int i_to ) +{ + this->i_from = i_from; + this->i_to = i_to; +} + +void WizardDialog::SetTranscode( char *vcodec, int vb, char *acodec,int ab) +{ + if( strcmp( vcodec, "dummy") ) + { + this->vcodec= strdup(vcodec); + } + if( strcmp( acodec, "dummy" ) ) + { + this->acodec = strdup(acodec); + } + this->vb = vb; + this->ab = ab; +} + +void WizardDialog::SetStream( char *method, char *address ) +{ + this->method = strdup( method ); + this->address = strdup( address ); +} + +void WizardDialog::SetTranscodeOut( const char *address ) +{ + this->address = strdup( address ); +} + +void WizardDialog::SetMux( char *mux ) +{ + this->mux = strdup( mux ); +} + +void WizardDialog::SetAction( int i_action ) +{ + this->i_action = i_action; +} + +int WizardDialog::GetAction() +{ + return i_action; +} + +void WizardDialog::Run() +{ + msg_Dbg( p_intf,"starting wizard"); + if( RunWizard(page1) ) + { + int i_size; + char *psz_opt; + msg_Dbg( p_intf,"wizard completed"); + + if( i_action == ACTION_TRANSCODE ) + { + msg_Dbg( p_intf,"Starting transcode of %s to file %s", + mrl, address); + msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s", + vcodec,vb,acodec,ab,mux); + int i_tr_size = 0 ; /* 10 = ab + vb */ + i_tr_size += vcodec ? strlen(vcodec) + strlen("vcodec=") +strlen("vb="): 0; + i_tr_size += acodec ? strlen(acodec) + strlen("acodec=") +strlen("ab=") : 0; + + char *psz_transcode = (char *)malloc( i_tr_size * sizeof(char)); + if( vcodec || acodec ) + { + sprintf( psz_transcode, "transcode{" ); + } + else + { + snprintf( psz_transcode, 1 , "%c", 0 ); + } + if( vcodec ) + { + i_tr_size += 5 + strlen(vcodec); + snprintf( psz_transcode, i_tr_size , "%svcodec=%s,vb=%i", + psz_transcode, vcodec, vb ); + } + if( acodec ) + { + i_tr_size += 6 + strlen(acodec); + /* FIXME */ + sprintf( psz_transcode, "%s%cacodec=%s,ab=%i", + psz_transcode, vcodec ? ',' : ' ', acodec, ab ); + } + if( vcodec || acodec ) + { + i_tr_size +=2; + sprintf( psz_transcode , "%s}:", psz_transcode ); + } + i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode); + psz_opt = (char *)malloc( i_size * sizeof(char) ); + snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s," + "access=file}", + psz_transcode, mux, address ); + } + else + { + msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s", + mrl, address, method, mux); + if( b_sap ) + { + char *psz_sap_option = NULL; + if( psz_sap_name ) + { + psz_sap_option = (char *) malloc( strlen( psz_sap_name ) + + 15 ); + snprintf( psz_sap_option,strlen( psz_sap_name ) + 15, + "sap,name=\"%s\"",psz_sap_name ); + } + else + { + psz_sap_option = (char *) malloc( 5 ); + snprintf( psz_sap_option, 5, "sap" ); + } + i_size = 40 + strlen(mux) + strlen(address) + + strlen( psz_sap_option); + psz_opt = (char *)malloc( i_size * sizeof(char) ); + snprintf( psz_opt, i_size, + ":sout=#standard{mux=%s,url=%s,access=%s,%s}", + mux, address,method, psz_sap_option); + msg_Dbg( p_intf, "Sap enabled: %s", psz_sap_option); + if( psz_sap_option ) free( psz_sap_option ); + } + else + { + i_size = 40 + strlen(mux) + strlen(address); + psz_opt = (char *)malloc( i_size * sizeof(char) ); + snprintf( psz_opt, i_size, + ":sout=#standard{mux=%s,url=%s,access=%s}", + mux, address,method); + } + } + + playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, + VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); + if( p_playlist ) + { + playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl, + ITEM_NAME ); + playlist_ItemAddOption( p_item, psz_opt); + if( i_from != 0) + { + char psz_from[20]; + msg_Dbg( p_intf, "Setting starttime"); + snprintf( psz_from, 20, "start-time=%i", i_from); + playlist_ItemAddOption( p_item, psz_from); + } + if( i_to != 0) + { + char psz_to[20]; + snprintf( psz_to, 20, "stop-time=%i", i_to); + playlist_ItemAddOption( p_item, psz_to); + } + + char psz_ttl[20]; + snprintf( psz_ttl, 20, "ttl=%i",i_ttl ); + playlist_ItemAddOption( p_item, psz_ttl ); + + playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END ); + vlc_object_release(p_playlist); + } + else + { + wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ), + wxICON_WARNING | wxOK, this ); + } + } + else + { + msg_Dbg( p_intf, "wizard was cancelled"); + } +} +/**************************************************************** + * Local helper functions + ****************************************************************/ +static int ismult( const char *psz_uri ) +{ + char *psz_end; + unsigned long i_value; + + /* IPv6 */ + if( psz_uri[0] == '[') + return strncasecmp( &psz_uri[1], "FF" , 2) ? VLC_FALSE : VLC_TRUE; + + /* IPv4 */ + i_value = strtoul( psz_uri, &psz_end, 10 ); + if( *psz_end != '.' ) { return( VLC_FALSE ); } + + return( ( i_value >= 224 && i_value < 240 ) ? VLC_TRUE : VLC_FALSE ); + +} diff --git a/modules/misc/dummy/aout.c b/modules/misc/dummy/aout.c index bfd0b2f23f..7db102523e 100644 --- a/modules/misc/dummy/aout.c +++ b/modules/misc/dummy/aout.c @@ -2,7 +2,7 @@ * aout_dummy.c : dummy audio output plugin ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: aout.c,v 1.10 2002/09/30 21:32:33 massiot Exp $ + * $Id$ * * Authors: Christophe Massiot * diff --git a/modules/misc/dummy/dummy.h b/modules/misc/dummy/dummy.h index 82224ebc52..ceff9d2fc6 100644 --- a/modules/misc/dummy/dummy.h +++ b/modules/misc/dummy/dummy.h @@ -2,7 +2,7 @@ * dummy.h : dummy plugin for vlc ***************************************************************************** * Copyright (C) 2000, 2001, 2002 VideoLAN - * $Id: dummy.h,v 1.3 2003/11/16 21:07:31 gbazin Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/misc/dummy/encoder.c b/modules/misc/dummy/encoder.c index 9c900b7d96..90410eda7d 100644 --- a/modules/misc/dummy/encoder.c +++ b/modules/misc/dummy/encoder.c @@ -2,7 +2,7 @@ * encoder.c: dummy encoder plugin for vlc. ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: encoder.c,v 1.1 2003/11/16 21:28:26 gbazin Exp $ + * $Id$ * * Authors: Gildas Bazin * diff --git a/modules/misc/dummy/interface.c b/modules/misc/dummy/interface.c index f0c733ec38..db83e702d3 100644 --- a/modules/misc/dummy/interface.c +++ b/modules/misc/dummy/interface.c @@ -2,7 +2,7 @@ * intf_dummy.c: dummy interface plugin ***************************************************************************** * Copyright (C) 2000, 2001 VideoLAN - * $Id: interface.c,v 1.4 2004/01/25 17:20:19 kuehne Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/misc/gtk_main.c b/modules/misc/gtk_main.c index 962de10bd2..46ec94e601 100644 --- a/modules/misc/gtk_main.c +++ b/modules/misc/gtk_main.c @@ -2,7 +2,7 @@ * gtk_main.c : Gtk+ wrapper for gtk_main ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: gtk_main.c,v 1.15 2003/03/30 18:14:38 gbazin Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/misc/memcpy/fastmemcpy.h b/modules/misc/memcpy/fastmemcpy.h index d65ca2d2db..40c060f6f2 100644 --- a/modules/misc/memcpy/fastmemcpy.h +++ b/modules/misc/memcpy/fastmemcpy.h @@ -1,7 +1,7 @@ /***************************************************************************** * fastmemcpy.h : fast memcpy routines ***************************************************************************** - * $Id: fastmemcpy.h,v 1.2 2002/08/08 00:35:11 sam Exp $ + * $Id$ * * Authors: various Linux kernel hackers * various MPlayer hackers diff --git a/modules/misc/testsuite/test1.c b/modules/misc/testsuite/test1.c index c42177a27d..470d59f3b7 100644 --- a/modules/misc/testsuite/test1.c +++ b/modules/misc/testsuite/test1.c @@ -2,7 +2,7 @@ * test1.c : Empty C module for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: test1.c,v 1.1 2002/10/04 13:13:54 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/misc/testsuite/test2.cpp b/modules/misc/testsuite/test2.cpp index df5e1ac88f..b597b4f424 100644 --- a/modules/misc/testsuite/test2.cpp +++ b/modules/misc/testsuite/test2.cpp @@ -2,7 +2,7 @@ * test2.cpp : Empty C++ module for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: test2.cpp,v 1.2 2002/10/22 21:10:27 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/misc/testsuite/test4.c b/modules/misc/testsuite/test4.c index 85ac61f749..ee68d12bbe 100644 --- a/modules/misc/testsuite/test4.c +++ b/modules/misc/testsuite/test4.c @@ -2,7 +2,7 @@ * test4.c : Miscellaneous stress tests module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: test4.c,v 1.7 2003/05/04 22:42:17 gbazin Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/modules/mux/mpeg/bits.h b/modules/mux/mpeg/bits.h index b1b2cd333b..3219771895 100644 --- a/modules/mux/mpeg/bits.h +++ b/modules/mux/mpeg/bits.h @@ -2,7 +2,7 @@ * bits.h ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: bits.h,v 1.4 2003/05/05 15:52:13 fenrir Exp $ + * $Id$ * * Authors: Laurent Aimar * Eric Petit diff --git a/modules/mux/mpeg/csa.h b/modules/mux/mpeg/csa.h index c79454ada9..3d71e61024 100644 --- a/modules/mux/mpeg/csa.h +++ b/modules/mux/mpeg/csa.h @@ -2,7 +2,7 @@ * csa.h ***************************************************************************** * Copyright (C) 2004 Laurent Aimar - * $Id: csa.h,v 1.1 2004/01/25 02:26:04 fenrir Exp $ + * $Id$ * * Authors: Laurent Aimar * diff --git a/modules/stream_out/transrate/block.c b/modules/stream_out/transrate/block.c index 07c3b433cf..75e51d3f1e 100644 --- a/modules/stream_out/transrate/block.c +++ b/modules/stream_out/transrate/block.c @@ -5,7 +5,7 @@ * Copyright (C) 2003 Antoine Missout * Copyright (C) 2000-2003 Michel Lespinasse * Copyright (C) 1999-2000 Aaron Holtzman - * $Id: frame.c,v 1.2 2004/03/03 11:39:06 massiot Exp $ + * $Id$ * * Authors: Christophe Massiot * Laurent Aimar diff --git a/modules/video_chroma/i420_rgb_c.h b/modules/video_chroma/i420_rgb_c.h index 70aa427991..f84aa3a5e0 100644 --- a/modules/video_chroma/i420_rgb_c.h +++ b/modules/video_chroma/i420_rgb_c.h @@ -5,7 +5,7 @@ * case by optimized functions. ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: i420_rgb_c.h,v 1.2 2003/10/01 03:38:23 sam Exp $ + * $Id$ * * Authors: Vincent Seguin * diff --git a/modules/video_filter/marq.c b/modules/video_filter/marq.c index 0360ef5534..ecca914cee 100644 --- a/modules/video_filter/marq.c +++ b/modules/video_filter/marq.c @@ -1,329 +1,329 @@ -/***************************************************************************** - * marq.c : marquee display video plugin for vlc - ***************************************************************************** - * Copyright (C) 2003-2005 VideoLAN - * $Id: time.c 8751 2004-09-20 21:51:41Z gbazin $ - * - * Authors: Mark Moriarty - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include /* malloc(), free() */ -#include - -#include -#include - -#include "vlc_filter.h" -#include "vlc_block.h" -#include "osd.h" - -/***************************************************************************** - * Local prototypes - *****************************************************************************/ -static int CreateFilter ( vlc_object_t * ); -static void DestroyFilter( vlc_object_t * ); -static subpicture_t *Filter( filter_t *, mtime_t ); - - -static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var, - vlc_value_t oldval, vlc_value_t newval, - void *p_data ); -static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0, - 0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00, - 0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080, - 0x00000080, 0x000000FF, 0x0000FFFF}; -static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"), - N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"), - N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"), - N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"), - N_("Aqua") }; - -/***************************************************************************** - * filter_sys_t: marquee filter descriptor - *****************************************************************************/ -struct filter_sys_t -{ - int i_xoff, i_yoff; /* offsets for the display string in the video window */ - int i_pos; /* permit relative positioning (top, bottom, left, right, center) */ - int i_timeout; - - char *psz_marquee; /* marquee string */ - - int i_font_color, i_font_opacity, i_font_size; /* font control */ - - time_t last_time; - vlc_bool_t b_absolute; /* position control, relative vs. absolute */ - - vlc_bool_t b_need_update; -}; - -#define MSG_TEXT N_("Marquee text") -#define MSG_LONGTEXT N_("Marquee text to display") -#define POSX_TEXT N_("X offset, from left") -#define POSX_LONGTEXT N_("X offset, from the left screen edge" ) -#define POSY_TEXT N_("Y offset, from the top") -#define POSY_LONGTEXT N_("Y offset, down from the top" ) -#define TIMEOUT_TEXT N_("Marquee timeout") -#define TIMEOUT_LONGTEXT N_("Defines the time the marquee must remain " \ - "displayed, in milliseconds. Default value is " \ - "0 (remain forever).") -#define OPACITY_TEXT N_("Opacity, -1..255") -#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of overlay text. " \ - "-1 = use freetype-opacity, 0 = transparent, 255 = totally opaque. " ) -#define SIZE_TEXT N_("Font size, pixels") -#define SIZE_LONGTEXT N_("Specify the font size, in pixels, " \ - "with -1 = use freetype-fontsize" ) - -#define COLOR_TEXT N_("Text Default Color") -#define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal." \ - "-1 = use freetype-color, #000000 = all colors off, " \ - "0xFF0000 = just Red, 0xFFFFFF = all color on [White]" ) - -#define POS_TEXT N_("Marquee position") -#define POS_LONGTEXT N_( \ - "You can enforce the marquee position on the video " \ - "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \ - "also use combinations of these values by adding them).") - -static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 }; -static char *ppsz_pos_descriptions[] = - { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"), - N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") }; - -/***************************************************************************** - * Module descriptor - *****************************************************************************/ -vlc_module_begin(); - set_capability( "sub filter", 0 ); - set_shortname( N_("Marquee" )); - set_callbacks( CreateFilter, DestroyFilter ); - set_category( CAT_VIDEO ); - set_subcategory( SUBCAT_VIDEO_SUBPIC ); - add_string( "marq-marquee", "Marquee", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE ); - add_integer( "marq-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE ); - add_integer( "marq-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE ); - add_integer( "marq-timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT, - VLC_FALSE ); - add_integer( "marq-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE ); - /* 5 sets the default to top [1] left [4] */ - change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); - add_integer_with_range( "marq-opacity", -1, -1, 255, NULL, - OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE ); - add_integer( "marq-color", -1, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE ); - change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); - add_integer( "marq-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE ); - - set_description( _("Marquee display sub filter") ); - add_shortcut( "marq" ); -vlc_module_end(); - -/***************************************************************************** - * CreateFilter: allocates marquee video filter - *****************************************************************************/ -static int CreateFilter( vlc_object_t *p_this ) -{ - filter_t *p_filter = (filter_t *)p_this; - filter_sys_t *p_sys; - vlc_object_t *p_input; - - /* Allocate structure */ - p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); - if( p_sys == NULL ) - { - msg_Err( p_filter, "out of memory" ); - return VLC_ENOMEM; - } - - /* Hook used for callback variables */ - p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); - if( !p_input ) - { - return VLC_ENOOBJ; - } - - p_sys->i_xoff = var_CreateGetInteger( p_input->p_libvlc , "marq-x" ); - p_sys->i_yoff = var_CreateGetInteger( p_input->p_libvlc , "marq-y" ); - p_sys->i_timeout = var_CreateGetInteger( p_input->p_libvlc , "marq-timeout" ); - p_sys->i_pos = var_CreateGetInteger( p_input->p_libvlc , "marq-position" ); - p_sys->psz_marquee = var_CreateGetString( p_input->p_libvlc, "marq-marquee" ); - var_Create( p_input->p_libvlc, "marq-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); - p_sys->i_font_opacity = var_CreateGetInteger( p_input->p_libvlc , "marq-opacity" ); - p_sys->i_font_color = var_CreateGetInteger( p_input->p_libvlc , "marq-color" ); - p_sys->i_font_size = var_CreateGetInteger( p_input->p_libvlc , "marq-size" ); - - var_AddCallback( p_input->p_libvlc, "marq-x", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-y", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-marquee", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-timeout", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-position", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-color", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-opacity", MarqueeCallback, p_sys ); - var_AddCallback( p_input->p_libvlc, "marq-size", MarqueeCallback, p_sys ); - - vlc_object_release( p_input ); - - - /* Misc init */ - p_filter->pf_sub_filter = Filter; - p_sys->last_time = ((time_t)-1); - p_sys->b_need_update = VLC_TRUE; - - return VLC_SUCCESS; -} -/***************************************************************************** - * DestroyFilter: destroy marquee video filter - *****************************************************************************/ -static void DestroyFilter( vlc_object_t *p_this ) -{ - filter_t *p_filter = (filter_t *)p_this; - filter_sys_t *p_sys = p_filter->p_sys; - vlc_object_t *p_input; - - if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); - free( p_sys ); - - /* Delete the marquee variables */ - p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); - if( !p_input ) - { - return; - } - var_Destroy( p_input->p_libvlc , "marq-marquee" ); - var_Destroy( p_input->p_libvlc , "marq-x" ); - var_Destroy( p_input->p_libvlc , "marq-y" ); - var_Destroy( p_input->p_libvlc , "marq-timeout" ); - var_Destroy( p_input->p_libvlc , "marq-position" ); - var_Destroy( p_input->p_libvlc , "marq-color"); - var_Destroy( p_input->p_libvlc , "marq-opacity"); - var_Destroy( p_input->p_libvlc , "marq-size"); - - vlc_object_release( p_input ); -} - -/**************************************************************************** - * Filter: the whole thing - **************************************************************************** - * This function outputs subpictures at regular time intervals. - ****************************************************************************/ -static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) -{ - filter_sys_t *p_sys = p_filter->p_sys; - subpicture_t *p_spu; - video_format_t fmt; - time_t t; - - if( p_sys->last_time == time( NULL ) ) - { - return NULL; - } - - if( p_sys->b_need_update == VLC_FALSE ) - { - return NULL; - } - - p_sys->b_absolute = VLC_TRUE; - if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 ) - { - p_sys->b_absolute = VLC_FALSE; - } - - p_spu = p_filter->pf_sub_buffer_new( p_filter ); - if( !p_spu ) return NULL; - - p_spu->b_absolute = p_sys->b_absolute; - memset( &fmt, 0, sizeof(video_format_t) ); - fmt.i_chroma = VLC_FOURCC('T','E','X','T'); - fmt.i_aspect = 0; - fmt.i_width = fmt.i_height = 0; - fmt.i_x_offset = 0; - fmt.i_y_offset = 0; - p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt ); - if( !p_spu->p_region ) - { - p_filter->pf_sub_buffer_del( p_filter, p_spu ); - return NULL; - } - - t = p_sys->last_time = time( NULL ); - - p_spu->p_region->psz_text = strdup(p_sys->psz_marquee); - p_spu->i_start = date; - p_spu->i_stop = p_sys->i_timeout == 0 ? 0 : date + p_sys->i_timeout * 1000; - p_spu->b_ephemer = VLC_TRUE; - p_spu->i_x = p_sys->i_xoff; - p_spu->i_y = p_sys->i_yoff; - p_spu->p_region->i_font_color = p_sys->i_font_color; - p_spu->p_region->i_font_opacity = p_sys->i_font_opacity; - p_spu->p_region->i_font_size = p_sys->i_font_size; - - p_spu->i_flags = p_sys->i_pos; - - p_sys->b_need_update = VLC_FALSE; - return p_spu; -} - -/********************************************************************** - * Callback to update params on the fly - **********************************************************************/ -static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var, - vlc_value_t oldval, vlc_value_t newval, - void *p_data ) -{ - filter_sys_t *p_sys = (filter_sys_t *) p_data; - - if( !strncmp( psz_var, "marq-marquee", 7 ) ) - { - if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); - p_sys->psz_marquee = strdup( newval.psz_string ); - } - else if ( !strncmp( psz_var, "marq-x", 6 ) ) - { - p_sys->i_xoff = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-y", 6 ) ) - { - p_sys->i_yoff = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-color", 8 ) ) /* "marq-col" */ - { - p_sys->i_font_color = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-opacity", 8 ) ) /* "marq-opa" */ - { - p_sys->i_font_opacity = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-size", 6 ) ) - { - p_sys->i_font_size = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-timeout", 12 ) ) - { - p_sys->i_timeout = newval.i_int; - } - else if ( !strncmp( psz_var, "marq-position", 8 ) ) - /* willing to accept a match against marq-pos */ - { - p_sys->i_pos = newval.i_int; - p_sys->i_xoff = -1; /* force to relative positioning */ - } - p_sys->b_need_update = VLC_TRUE; - return VLC_SUCCESS; -} +/***************************************************************************** + * marq.c : marquee display video plugin for vlc + ***************************************************************************** + * Copyright (C) 2003-2005 VideoLAN + * $Id: time.c 8751 2004-09-20 21:51:41Z gbazin $ + * + * Authors: Mark Moriarty + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* malloc(), free() */ +#include + +#include +#include + +#include "vlc_filter.h" +#include "vlc_block.h" +#include "osd.h" + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +static int CreateFilter ( vlc_object_t * ); +static void DestroyFilter( vlc_object_t * ); +static subpicture_t *Filter( filter_t *, mtime_t ); + + +static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var, + vlc_value_t oldval, vlc_value_t newval, + void *p_data ); +static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0, + 0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00, + 0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080, + 0x00000080, 0x000000FF, 0x0000FFFF}; +static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"), + N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"), + N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"), + N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"), + N_("Aqua") }; + +/***************************************************************************** + * filter_sys_t: marquee filter descriptor + *****************************************************************************/ +struct filter_sys_t +{ + int i_xoff, i_yoff; /* offsets for the display string in the video window */ + int i_pos; /* permit relative positioning (top, bottom, left, right, center) */ + int i_timeout; + + char *psz_marquee; /* marquee string */ + + int i_font_color, i_font_opacity, i_font_size; /* font control */ + + time_t last_time; + vlc_bool_t b_absolute; /* position control, relative vs. absolute */ + + vlc_bool_t b_need_update; +}; + +#define MSG_TEXT N_("Marquee text") +#define MSG_LONGTEXT N_("Marquee text to display") +#define POSX_TEXT N_("X offset, from left") +#define POSX_LONGTEXT N_("X offset, from the left screen edge" ) +#define POSY_TEXT N_("Y offset, from the top") +#define POSY_LONGTEXT N_("Y offset, down from the top" ) +#define TIMEOUT_TEXT N_("Marquee timeout") +#define TIMEOUT_LONGTEXT N_("Defines the time the marquee must remain " \ + "displayed, in milliseconds. Default value is " \ + "0 (remain forever).") +#define OPACITY_TEXT N_("Opacity, -1..255") +#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of overlay text. " \ + "-1 = use freetype-opacity, 0 = transparent, 255 = totally opaque. " ) +#define SIZE_TEXT N_("Font size, pixels") +#define SIZE_LONGTEXT N_("Specify the font size, in pixels, " \ + "with -1 = use freetype-fontsize" ) + +#define COLOR_TEXT N_("Text Default Color") +#define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal." \ + "-1 = use freetype-color, #000000 = all colors off, " \ + "0xFF0000 = just Red, 0xFFFFFF = all color on [White]" ) + +#define POS_TEXT N_("Marquee position") +#define POS_LONGTEXT N_( \ + "You can enforce the marquee position on the video " \ + "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \ + "also use combinations of these values by adding them).") + +static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 }; +static char *ppsz_pos_descriptions[] = + { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"), + N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") }; + +/***************************************************************************** + * Module descriptor + *****************************************************************************/ +vlc_module_begin(); + set_capability( "sub filter", 0 ); + set_shortname( N_("Marquee" )); + set_callbacks( CreateFilter, DestroyFilter ); + set_category( CAT_VIDEO ); + set_subcategory( SUBCAT_VIDEO_SUBPIC ); + add_string( "marq-marquee", "Marquee", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE ); + add_integer( "marq-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE ); + add_integer( "marq-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE ); + add_integer( "marq-timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT, + VLC_FALSE ); + add_integer( "marq-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE ); + /* 5 sets the default to top [1] left [4] */ + change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); + add_integer_with_range( "marq-opacity", -1, -1, 255, NULL, + OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE ); + add_integer( "marq-color", -1, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE ); + change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); + add_integer( "marq-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE ); + + set_description( _("Marquee display sub filter") ); + add_shortcut( "marq" ); +vlc_module_end(); + +/***************************************************************************** + * CreateFilter: allocates marquee video filter + *****************************************************************************/ +static int CreateFilter( vlc_object_t *p_this ) +{ + filter_t *p_filter = (filter_t *)p_this; + filter_sys_t *p_sys; + vlc_object_t *p_input; + + /* Allocate structure */ + p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) ); + if( p_sys == NULL ) + { + msg_Err( p_filter, "out of memory" ); + return VLC_ENOMEM; + } + + /* Hook used for callback variables */ + p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); + if( !p_input ) + { + return VLC_ENOOBJ; + } + + p_sys->i_xoff = var_CreateGetInteger( p_input->p_libvlc , "marq-x" ); + p_sys->i_yoff = var_CreateGetInteger( p_input->p_libvlc , "marq-y" ); + p_sys->i_timeout = var_CreateGetInteger( p_input->p_libvlc , "marq-timeout" ); + p_sys->i_pos = var_CreateGetInteger( p_input->p_libvlc , "marq-position" ); + p_sys->psz_marquee = var_CreateGetString( p_input->p_libvlc, "marq-marquee" ); + var_Create( p_input->p_libvlc, "marq-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); + p_sys->i_font_opacity = var_CreateGetInteger( p_input->p_libvlc , "marq-opacity" ); + p_sys->i_font_color = var_CreateGetInteger( p_input->p_libvlc , "marq-color" ); + p_sys->i_font_size = var_CreateGetInteger( p_input->p_libvlc , "marq-size" ); + + var_AddCallback( p_input->p_libvlc, "marq-x", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-y", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-marquee", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-timeout", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-position", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-color", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-opacity", MarqueeCallback, p_sys ); + var_AddCallback( p_input->p_libvlc, "marq-size", MarqueeCallback, p_sys ); + + vlc_object_release( p_input ); + + + /* Misc init */ + p_filter->pf_sub_filter = Filter; + p_sys->last_time = ((time_t)-1); + p_sys->b_need_update = VLC_TRUE; + + return VLC_SUCCESS; +} +/***************************************************************************** + * DestroyFilter: destroy marquee video filter + *****************************************************************************/ +static void DestroyFilter( vlc_object_t *p_this ) +{ + filter_t *p_filter = (filter_t *)p_this; + filter_sys_t *p_sys = p_filter->p_sys; + vlc_object_t *p_input; + + if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); + free( p_sys ); + + /* Delete the marquee variables */ + p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE ); + if( !p_input ) + { + return; + } + var_Destroy( p_input->p_libvlc , "marq-marquee" ); + var_Destroy( p_input->p_libvlc , "marq-x" ); + var_Destroy( p_input->p_libvlc , "marq-y" ); + var_Destroy( p_input->p_libvlc , "marq-timeout" ); + var_Destroy( p_input->p_libvlc , "marq-position" ); + var_Destroy( p_input->p_libvlc , "marq-color"); + var_Destroy( p_input->p_libvlc , "marq-opacity"); + var_Destroy( p_input->p_libvlc , "marq-size"); + + vlc_object_release( p_input ); +} + +/**************************************************************************** + * Filter: the whole thing + **************************************************************************** + * This function outputs subpictures at regular time intervals. + ****************************************************************************/ +static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) +{ + filter_sys_t *p_sys = p_filter->p_sys; + subpicture_t *p_spu; + video_format_t fmt; + time_t t; + + if( p_sys->last_time == time( NULL ) ) + { + return NULL; + } + + if( p_sys->b_need_update == VLC_FALSE ) + { + return NULL; + } + + p_sys->b_absolute = VLC_TRUE; + if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 ) + { + p_sys->b_absolute = VLC_FALSE; + } + + p_spu = p_filter->pf_sub_buffer_new( p_filter ); + if( !p_spu ) return NULL; + + p_spu->b_absolute = p_sys->b_absolute; + memset( &fmt, 0, sizeof(video_format_t) ); + fmt.i_chroma = VLC_FOURCC('T','E','X','T'); + fmt.i_aspect = 0; + fmt.i_width = fmt.i_height = 0; + fmt.i_x_offset = 0; + fmt.i_y_offset = 0; + p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt ); + if( !p_spu->p_region ) + { + p_filter->pf_sub_buffer_del( p_filter, p_spu ); + return NULL; + } + + t = p_sys->last_time = time( NULL ); + + p_spu->p_region->psz_text = strdup(p_sys->psz_marquee); + p_spu->i_start = date; + p_spu->i_stop = p_sys->i_timeout == 0 ? 0 : date + p_sys->i_timeout * 1000; + p_spu->b_ephemer = VLC_TRUE; + p_spu->i_x = p_sys->i_xoff; + p_spu->i_y = p_sys->i_yoff; + p_spu->p_region->i_font_color = p_sys->i_font_color; + p_spu->p_region->i_font_opacity = p_sys->i_font_opacity; + p_spu->p_region->i_font_size = p_sys->i_font_size; + + p_spu->i_flags = p_sys->i_pos; + + p_sys->b_need_update = VLC_FALSE; + return p_spu; +} + +/********************************************************************** + * Callback to update params on the fly + **********************************************************************/ +static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var, + vlc_value_t oldval, vlc_value_t newval, + void *p_data ) +{ + filter_sys_t *p_sys = (filter_sys_t *) p_data; + + if( !strncmp( psz_var, "marq-marquee", 7 ) ) + { + if( p_sys->psz_marquee ) free( p_sys->psz_marquee ); + p_sys->psz_marquee = strdup( newval.psz_string ); + } + else if ( !strncmp( psz_var, "marq-x", 6 ) ) + { + p_sys->i_xoff = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-y", 6 ) ) + { + p_sys->i_yoff = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-color", 8 ) ) /* "marq-col" */ + { + p_sys->i_font_color = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-opacity", 8 ) ) /* "marq-opa" */ + { + p_sys->i_font_opacity = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-size", 6 ) ) + { + p_sys->i_font_size = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-timeout", 12 ) ) + { + p_sys->i_timeout = newval.i_int; + } + else if ( !strncmp( psz_var, "marq-position", 8 ) ) + /* willing to accept a match against marq-pos */ + { + p_sys->i_pos = newval.i_int; + p_sys->i_xoff = -1; /* force to relative positioning */ + } + p_sys->b_need_update = VLC_TRUE; + return VLC_SUCCESS; +} diff --git a/modules/video_output/directx/glwin32.c b/modules/video_output/directx/glwin32.c index 1950d05bb3..c3b83694c5 100644 --- a/modules/video_output/directx/glwin32.c +++ b/modules/video_output/directx/glwin32.c @@ -1,473 +1,473 @@ -/***************************************************************************** - * glwin32.c: Windows OpenGL provider - ***************************************************************************** - * Copyright (C) 2001-2004 VideoLAN - * $Id$ - * - * Authors: Gildas Bazin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include /* ENOMEM */ -#include /* free() */ -#include /* strerror() */ - -#include -#include -#include - -#include -#include -#include - -#include -#undef GetSystemMetrics - -#ifndef MONITOR_DEFAULTTONEAREST -# define MONITOR_DEFAULTTONEAREST 2 -#endif - -#include - -#include "vout.h" - -/***************************************************************************** - * Local prototypes. - *****************************************************************************/ -static int OpenVideo ( vlc_object_t * ); -static void CloseVideo ( vlc_object_t * ); - -static int Init ( vout_thread_t * ); -static void End ( vout_thread_t * ); -static int Manage ( vout_thread_t * ); -static void GLSwapBuffers( vout_thread_t * ); - -/***************************************************************************** - * Module descriptor - *****************************************************************************/ -vlc_module_begin(); - set_category( CAT_VIDEO ); - set_subcategory( SUBCAT_VIDEO_VOUT ); - set_description( _("Win32 OpenGL provider") ); - set_capability( "opengl provider", 100 ); - add_shortcut( "glwin32" ); - set_callbacks( OpenVideo, CloseVideo ); - - /* FIXME: Hack to avoid unregistering our window class */ - linked_with_a_crap_library_which_uses_atexit( ); -vlc_module_end(); - -#if 0 /* FIXME */ - /* check if we registered a window class because we need to - * unregister it */ - WNDCLASS wndclass; - if( GetClassInfo( GetModuleHandle(NULL), "VLC DirectX", &wndclass ) ) - UnregisterClass( "VLC DirectX", GetModuleHandle(NULL) ); -#endif - -/***************************************************************************** - * OpenVideo: allocate OpenGL provider - ***************************************************************************** - * This function creates and initializes a video window. - *****************************************************************************/ -static int OpenVideo( vlc_object_t *p_this ) -{ - vout_thread_t * p_vout = (vout_thread_t *)p_this; - vlc_value_t val; - - /* Allocate structure */ - p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); - if( p_vout->p_sys == NULL ) - { - msg_Err( p_vout, "out of memory" ); - return VLC_ENOMEM; - } - memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) ); - - /* Initialisations */ - p_vout->pf_init = Init; - p_vout->pf_end = End; - p_vout->pf_manage = Manage; - p_vout->pf_swap = GLSwapBuffers; - - p_vout->p_sys->p_ddobject = NULL; - p_vout->p_sys->p_display = NULL; - p_vout->p_sys->p_current_surface = NULL; - p_vout->p_sys->p_clipper = NULL; - p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL; - p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL; - p_vout->p_sys->i_changes = 0; - p_vout->p_sys->b_wallpaper = 0; - vlc_mutex_init( p_vout, &p_vout->p_sys->lock ); - SetRectEmpty( &p_vout->p_sys->rect_display ); - SetRectEmpty( &p_vout->p_sys->rect_parent ); - - var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); - - p_vout->p_sys->b_cursor_hidden = 0; - p_vout->p_sys->i_lastmoved = mdate(); - - /* Set main window's size */ - p_vout->p_sys->i_window_width = p_vout->i_window_width; - p_vout->p_sys->i_window_height = p_vout->i_window_height; - - /* Create the DirectXEventThread, this thread is created by us to isolate - * the Win32 PeekMessage function calls. We want to do this because - * Windows can stay blocked inside this call for a long time, and when - * this happens it thus blocks vlc's video_output thread. - * DirectXEventThread will take care of the creation of the video - * window (because PeekMessage has to be called from the same thread which - * created the window). */ - msg_Dbg( p_vout, "creating DirectXEventThread" ); - p_vout->p_sys->p_event = - vlc_object_create( p_vout, sizeof(event_thread_t) ); - p_vout->p_sys->p_event->p_vout = p_vout; - if( vlc_thread_create( p_vout->p_sys->p_event, "DirectX Events Thread", - E_(DirectXEventThread), 0, 1 ) ) - { - msg_Err( p_vout, "cannot create DirectXEventThread" ); - vlc_object_destroy( p_vout->p_sys->p_event ); - p_vout->p_sys->p_event = NULL; - goto error; - } - - if( p_vout->p_sys->p_event->b_error ) - { - msg_Err( p_vout, "DirectXEventThread failed" ); - goto error; - } - - vlc_object_attach( p_vout->p_sys->p_event, p_vout ); - - msg_Dbg( p_vout, "DirectXEventThread running" ); - - /* Variable to indicate if the window should be on top of others */ - /* Trigger a callback right now */ - var_Get( p_vout, "video-on-top", &val ); - var_Set( p_vout, "video-on-top", val ); - - return VLC_SUCCESS; - - error: - CloseVideo( VLC_OBJECT(p_vout) ); - return VLC_EGENERIC; -} - -/***************************************************************************** - * Init: initialize video thread output method - *****************************************************************************/ -static int Init( vout_thread_t *p_vout ) -{ - PIXELFORMATDESCRIPTOR pfd; - int iFormat; - - /* Change the window title bar text */ - PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 ); - - p_vout->p_sys->hGLDC = GetDC( p_vout->p_sys->hvideownd ); - - /* Set the pixel format for the DC */ - memset( &pfd, 0, sizeof( pfd ) ); - pfd.nSize = sizeof( pfd ); - pfd.nVersion = 1; - pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; - pfd.iPixelType = PFD_TYPE_RGBA; - pfd.cColorBits = 24; - pfd.cDepthBits = 16; - pfd.iLayerType = PFD_MAIN_PLANE; - iFormat = ChoosePixelFormat( p_vout->p_sys->hGLDC, &pfd ); - SetPixelFormat( p_vout->p_sys->hGLDC, iFormat, &pfd ); - - /* Create and enable the render context */ - p_vout->p_sys->hGLRC = wglCreateContext( p_vout->p_sys->hGLDC ); - wglMakeCurrent( p_vout->p_sys->hGLDC, p_vout->p_sys->hGLRC ); - - return VLC_SUCCESS; -} - -/***************************************************************************** - * End: terminate Sys video thread output method - ***************************************************************************** - * Terminate an output method created by Create. - * It is called at the end of the thread. - *****************************************************************************/ -static void End( vout_thread_t *p_vout ) -{ - wglMakeCurrent( NULL, NULL ); - wglDeleteContext( p_vout->p_sys->hGLRC ); - ReleaseDC( p_vout->p_sys->hvideownd, p_vout->p_sys->hGLDC ); - return; -} - -/***************************************************************************** - * CloseVideo: destroy Sys video thread output method - ***************************************************************************** - * Terminate an output method created by Create - *****************************************************************************/ -static void CloseVideo( vlc_object_t *p_this ) -{ - vout_thread_t * p_vout = (vout_thread_t *)p_this; - - msg_Dbg( p_vout, "CloseVideo" ); - - if( p_vout->p_sys->p_event ) - { - vlc_object_detach( p_vout->p_sys->p_event ); - - /* Kill DirectXEventThread */ - p_vout->p_sys->p_event->b_die = VLC_TRUE; - - /* we need to be sure DirectXEventThread won't stay stuck in - * GetMessage, so we send a fake message */ - if( p_vout->p_sys->hwnd ) - { - PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0); - } - - vlc_thread_join( p_vout->p_sys->p_event ); - vlc_object_destroy( p_vout->p_sys->p_event ); - } - - vlc_mutex_destroy( &p_vout->p_sys->lock ); - - if( p_vout->p_sys ) - { - free( p_vout->p_sys ); - p_vout->p_sys = NULL; - } -} - -/***************************************************************************** - * Manage: handle Sys events - ***************************************************************************** - * This function should be called regularly by the video output thread. - * It returns a non null value if an error occurred. - *****************************************************************************/ -static int Manage( vout_thread_t *p_vout ) -{ - WINDOWPLACEMENT window_placement; - - int i_width = p_vout->p_sys->rect_dest.right - - p_vout->p_sys->rect_dest.left; - int i_height = p_vout->p_sys->rect_dest.bottom - - p_vout->p_sys->rect_dest.top; - glViewport( 0, 0, i_width, i_height ); - - /* If we do not control our window, we check for geometry changes - * ourselves because the parent might not send us its events. */ - vlc_mutex_lock( &p_vout->p_sys->lock ); - if( p_vout->p_sys->hparent && !p_vout->b_fullscreen ) - { - RECT rect_parent; - POINT point; - - vlc_mutex_unlock( &p_vout->p_sys->lock ); - - GetClientRect( p_vout->p_sys->hparent, &rect_parent ); - point.x = point.y = 0; - ClientToScreen( p_vout->p_sys->hparent, &point ); - OffsetRect( &rect_parent, point.x, point.y ); - - if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) ) - { - p_vout->p_sys->rect_parent = rect_parent; - - /* This one is to force the update even if only - * the position has changed */ - SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1, - rect_parent.right - rect_parent.left, - rect_parent.bottom - rect_parent.top, 0 ); - - SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, - rect_parent.right - rect_parent.left, - rect_parent.bottom - rect_parent.top, 0 ); - } - } - else - { - vlc_mutex_unlock( &p_vout->p_sys->lock ); - } - - /* We used to call the Win32 PeekMessage function here to read the window - * messages. But since window can stay blocked into this function for a - * long time (for example when you move your window on the screen), I - * decided to isolate PeekMessage in another thread. */ - - /* - * Fullscreen change - */ - if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE - || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE ) - { - vlc_value_t val; - HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ? - p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd; - - p_vout->b_fullscreen = ! p_vout->b_fullscreen; - - /* We need to switch between Maximized and Normal sized window */ - window_placement.length = sizeof(WINDOWPLACEMENT); - GetWindowPlacement( hwnd, &window_placement ); - if( p_vout->b_fullscreen ) - { - /* Change window style, no borders and no title bar */ - int i_style = WS_CLIPCHILDREN | WS_VISIBLE; - SetWindowLong( hwnd, GWL_STYLE, i_style ); - - if( p_vout->p_sys->hparent ) - { - /* Retrieve current window position so fullscreen will happen - * on the right screen */ - POINT point = {0,0}; - RECT rect; - ClientToScreen( p_vout->p_sys->hwnd, &point ); - GetClientRect( p_vout->p_sys->hwnd, &rect ); - SetWindowPos( hwnd, 0, point.x, point.y, - rect.right, rect.bottom, - SWP_NOZORDER|SWP_FRAMECHANGED ); - GetWindowPlacement( hwnd, &window_placement ); - } - - /* Maximize window */ - window_placement.showCmd = SW_SHOWMAXIMIZED; - SetWindowPlacement( hwnd, &window_placement ); - SetWindowPos( hwnd, 0, 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); - - if( p_vout->p_sys->hparent ) - { - RECT rect; - GetClientRect( hwnd, &rect ); - SetParent( p_vout->p_sys->hwnd, hwnd ); - SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, - rect.right, rect.bottom, - SWP_NOZORDER|SWP_FRAMECHANGED ); - } - - SetForegroundWindow( hwnd ); - } - else - { - /* Change window style, no borders and no title bar */ - SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style ); - - /* Normal window */ - window_placement.showCmd = SW_SHOWNORMAL; - SetWindowPlacement( hwnd, &window_placement ); - SetWindowPos( hwnd, 0, 0, 0, 0, 0, - SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); - - if( p_vout->p_sys->hparent ) - { - RECT rect; - GetClientRect( p_vout->p_sys->hparent, &rect ); - SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent ); - SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, - rect.right, rect.bottom, - SWP_NOZORDER|SWP_FRAMECHANGED ); - - ShowWindow( hwnd, SW_HIDE ); - SetForegroundWindow( p_vout->p_sys->hparent ); - } - - /* Make sure the mouse cursor is displayed */ - PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 ); - } - - /* Update the object variable and trigger callback */ - val.b_bool = p_vout->b_fullscreen; - var_Set( p_vout, "fullscreen", val ); - - p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; - p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE; - } - - /* - * Pointer change - */ - if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden && - (mdate() - p_vout->p_sys->i_lastmoved) > 5000000 ) - { - POINT point; - HWND hwnd; - - /* Hide the cursor only if it is inside our window */ - GetCursorPos( &point ); - hwnd = WindowFromPoint(point); - if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd ) - { - PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 ); - } - else - { - p_vout->p_sys->i_lastmoved = mdate(); - } - } - - /* - * "Always on top" status change - */ - if( p_vout->p_sys->b_on_top_change ) - { - vlc_value_t val; - HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE ); - - var_Get( p_vout, "video-on-top", &val ); - - /* Set the window on top if necessary */ - if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) - & WS_EX_TOPMOST ) ) - { - CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, - MF_BYCOMMAND | MFS_CHECKED ); - SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE ); - } - else - /* The window shouldn't be on top */ - if( !val.b_bool && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) - & WS_EX_TOPMOST ) ) - { - CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, - MF_BYCOMMAND | MFS_UNCHECKED ); - SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, - SWP_NOSIZE | SWP_NOMOVE ); - } - - p_vout->p_sys->b_on_top_change = VLC_FALSE; - } - - /* Check if the event thread is still running */ - if( p_vout->p_sys->p_event->b_die ) - { - return VLC_EGENERIC; /* exit */ - } - - return VLC_SUCCESS; -} - -/***************************************************************************** - * GLSwapBuffers: swap front/back buffers - *****************************************************************************/ -static void GLSwapBuffers( vout_thread_t *p_vout ) -{ - SwapBuffers( p_vout->p_sys->hGLDC ); -} - -int E_(DirectXUpdateOverlay)( vout_thread_t *p_vout ) -{ - return 1; -} +/***************************************************************************** + * glwin32.c: Windows OpenGL provider + ***************************************************************************** + * Copyright (C) 2001-2004 VideoLAN + * $Id$ + * + * Authors: Gildas Bazin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +#include /* ENOMEM */ +#include /* free() */ +#include /* strerror() */ + +#include +#include +#include + +#include +#include +#include + +#include +#undef GetSystemMetrics + +#ifndef MONITOR_DEFAULTTONEAREST +# define MONITOR_DEFAULTTONEAREST 2 +#endif + +#include + +#include "vout.h" + +/***************************************************************************** + * Local prototypes. + *****************************************************************************/ +static int OpenVideo ( vlc_object_t * ); +static void CloseVideo ( vlc_object_t * ); + +static int Init ( vout_thread_t * ); +static void End ( vout_thread_t * ); +static int Manage ( vout_thread_t * ); +static void GLSwapBuffers( vout_thread_t * ); + +/***************************************************************************** + * Module descriptor + *****************************************************************************/ +vlc_module_begin(); + set_category( CAT_VIDEO ); + set_subcategory( SUBCAT_VIDEO_VOUT ); + set_description( _("Win32 OpenGL provider") ); + set_capability( "opengl provider", 100 ); + add_shortcut( "glwin32" ); + set_callbacks( OpenVideo, CloseVideo ); + + /* FIXME: Hack to avoid unregistering our window class */ + linked_with_a_crap_library_which_uses_atexit( ); +vlc_module_end(); + +#if 0 /* FIXME */ + /* check if we registered a window class because we need to + * unregister it */ + WNDCLASS wndclass; + if( GetClassInfo( GetModuleHandle(NULL), "VLC DirectX", &wndclass ) ) + UnregisterClass( "VLC DirectX", GetModuleHandle(NULL) ); +#endif + +/***************************************************************************** + * OpenVideo: allocate OpenGL provider + ***************************************************************************** + * This function creates and initializes a video window. + *****************************************************************************/ +static int OpenVideo( vlc_object_t *p_this ) +{ + vout_thread_t * p_vout = (vout_thread_t *)p_this; + vlc_value_t val; + + /* Allocate structure */ + p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); + if( p_vout->p_sys == NULL ) + { + msg_Err( p_vout, "out of memory" ); + return VLC_ENOMEM; + } + memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) ); + + /* Initialisations */ + p_vout->pf_init = Init; + p_vout->pf_end = End; + p_vout->pf_manage = Manage; + p_vout->pf_swap = GLSwapBuffers; + + p_vout->p_sys->p_ddobject = NULL; + p_vout->p_sys->p_display = NULL; + p_vout->p_sys->p_current_surface = NULL; + p_vout->p_sys->p_clipper = NULL; + p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL; + p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL; + p_vout->p_sys->i_changes = 0; + p_vout->p_sys->b_wallpaper = 0; + vlc_mutex_init( p_vout, &p_vout->p_sys->lock ); + SetRectEmpty( &p_vout->p_sys->rect_display ); + SetRectEmpty( &p_vout->p_sys->rect_parent ); + + var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); + + p_vout->p_sys->b_cursor_hidden = 0; + p_vout->p_sys->i_lastmoved = mdate(); + + /* Set main window's size */ + p_vout->p_sys->i_window_width = p_vout->i_window_width; + p_vout->p_sys->i_window_height = p_vout->i_window_height; + + /* Create the DirectXEventThread, this thread is created by us to isolate + * the Win32 PeekMessage function calls. We want to do this because + * Windows can stay blocked inside this call for a long time, and when + * this happens it thus blocks vlc's video_output thread. + * DirectXEventThread will take care of the creation of the video + * window (because PeekMessage has to be called from the same thread which + * created the window). */ + msg_Dbg( p_vout, "creating DirectXEventThread" ); + p_vout->p_sys->p_event = + vlc_object_create( p_vout, sizeof(event_thread_t) ); + p_vout->p_sys->p_event->p_vout = p_vout; + if( vlc_thread_create( p_vout->p_sys->p_event, "DirectX Events Thread", + E_(DirectXEventThread), 0, 1 ) ) + { + msg_Err( p_vout, "cannot create DirectXEventThread" ); + vlc_object_destroy( p_vout->p_sys->p_event ); + p_vout->p_sys->p_event = NULL; + goto error; + } + + if( p_vout->p_sys->p_event->b_error ) + { + msg_Err( p_vout, "DirectXEventThread failed" ); + goto error; + } + + vlc_object_attach( p_vout->p_sys->p_event, p_vout ); + + msg_Dbg( p_vout, "DirectXEventThread running" ); + + /* Variable to indicate if the window should be on top of others */ + /* Trigger a callback right now */ + var_Get( p_vout, "video-on-top", &val ); + var_Set( p_vout, "video-on-top", val ); + + return VLC_SUCCESS; + + error: + CloseVideo( VLC_OBJECT(p_vout) ); + return VLC_EGENERIC; +} + +/***************************************************************************** + * Init: initialize video thread output method + *****************************************************************************/ +static int Init( vout_thread_t *p_vout ) +{ + PIXELFORMATDESCRIPTOR pfd; + int iFormat; + + /* Change the window title bar text */ + PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 ); + + p_vout->p_sys->hGLDC = GetDC( p_vout->p_sys->hvideownd ); + + /* Set the pixel format for the DC */ + memset( &pfd, 0, sizeof( pfd ) ); + pfd.nSize = sizeof( pfd ); + pfd.nVersion = 1; + pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; + pfd.iPixelType = PFD_TYPE_RGBA; + pfd.cColorBits = 24; + pfd.cDepthBits = 16; + pfd.iLayerType = PFD_MAIN_PLANE; + iFormat = ChoosePixelFormat( p_vout->p_sys->hGLDC, &pfd ); + SetPixelFormat( p_vout->p_sys->hGLDC, iFormat, &pfd ); + + /* Create and enable the render context */ + p_vout->p_sys->hGLRC = wglCreateContext( p_vout->p_sys->hGLDC ); + wglMakeCurrent( p_vout->p_sys->hGLDC, p_vout->p_sys->hGLRC ); + + return VLC_SUCCESS; +} + +/***************************************************************************** + * End: terminate Sys video thread output method + ***************************************************************************** + * Terminate an output method created by Create. + * It is called at the end of the thread. + *****************************************************************************/ +static void End( vout_thread_t *p_vout ) +{ + wglMakeCurrent( NULL, NULL ); + wglDeleteContext( p_vout->p_sys->hGLRC ); + ReleaseDC( p_vout->p_sys->hvideownd, p_vout->p_sys->hGLDC ); + return; +} + +/***************************************************************************** + * CloseVideo: destroy Sys video thread output method + ***************************************************************************** + * Terminate an output method created by Create + *****************************************************************************/ +static void CloseVideo( vlc_object_t *p_this ) +{ + vout_thread_t * p_vout = (vout_thread_t *)p_this; + + msg_Dbg( p_vout, "CloseVideo" ); + + if( p_vout->p_sys->p_event ) + { + vlc_object_detach( p_vout->p_sys->p_event ); + + /* Kill DirectXEventThread */ + p_vout->p_sys->p_event->b_die = VLC_TRUE; + + /* we need to be sure DirectXEventThread won't stay stuck in + * GetMessage, so we send a fake message */ + if( p_vout->p_sys->hwnd ) + { + PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0); + } + + vlc_thread_join( p_vout->p_sys->p_event ); + vlc_object_destroy( p_vout->p_sys->p_event ); + } + + vlc_mutex_destroy( &p_vout->p_sys->lock ); + + if( p_vout->p_sys ) + { + free( p_vout->p_sys ); + p_vout->p_sys = NULL; + } +} + +/***************************************************************************** + * Manage: handle Sys events + ***************************************************************************** + * This function should be called regularly by the video output thread. + * It returns a non null value if an error occurred. + *****************************************************************************/ +static int Manage( vout_thread_t *p_vout ) +{ + WINDOWPLACEMENT window_placement; + + int i_width = p_vout->p_sys->rect_dest.right - + p_vout->p_sys->rect_dest.left; + int i_height = p_vout->p_sys->rect_dest.bottom - + p_vout->p_sys->rect_dest.top; + glViewport( 0, 0, i_width, i_height ); + + /* If we do not control our window, we check for geometry changes + * ourselves because the parent might not send us its events. */ + vlc_mutex_lock( &p_vout->p_sys->lock ); + if( p_vout->p_sys->hparent && !p_vout->b_fullscreen ) + { + RECT rect_parent; + POINT point; + + vlc_mutex_unlock( &p_vout->p_sys->lock ); + + GetClientRect( p_vout->p_sys->hparent, &rect_parent ); + point.x = point.y = 0; + ClientToScreen( p_vout->p_sys->hparent, &point ); + OffsetRect( &rect_parent, point.x, point.y ); + + if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) ) + { + p_vout->p_sys->rect_parent = rect_parent; + + /* This one is to force the update even if only + * the position has changed */ + SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1, + rect_parent.right - rect_parent.left, + rect_parent.bottom - rect_parent.top, 0 ); + + SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, + rect_parent.right - rect_parent.left, + rect_parent.bottom - rect_parent.top, 0 ); + } + } + else + { + vlc_mutex_unlock( &p_vout->p_sys->lock ); + } + + /* We used to call the Win32 PeekMessage function here to read the window + * messages. But since window can stay blocked into this function for a + * long time (for example when you move your window on the screen), I + * decided to isolate PeekMessage in another thread. */ + + /* + * Fullscreen change + */ + if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE + || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE ) + { + vlc_value_t val; + HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ? + p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd; + + p_vout->b_fullscreen = ! p_vout->b_fullscreen; + + /* We need to switch between Maximized and Normal sized window */ + window_placement.length = sizeof(WINDOWPLACEMENT); + GetWindowPlacement( hwnd, &window_placement ); + if( p_vout->b_fullscreen ) + { + /* Change window style, no borders and no title bar */ + int i_style = WS_CLIPCHILDREN | WS_VISIBLE; + SetWindowLong( hwnd, GWL_STYLE, i_style ); + + if( p_vout->p_sys->hparent ) + { + /* Retrieve current window position so fullscreen will happen + * on the right screen */ + POINT point = {0,0}; + RECT rect; + ClientToScreen( p_vout->p_sys->hwnd, &point ); + GetClientRect( p_vout->p_sys->hwnd, &rect ); + SetWindowPos( hwnd, 0, point.x, point.y, + rect.right, rect.bottom, + SWP_NOZORDER|SWP_FRAMECHANGED ); + GetWindowPlacement( hwnd, &window_placement ); + } + + /* Maximize window */ + window_placement.showCmd = SW_SHOWMAXIMIZED; + SetWindowPlacement( hwnd, &window_placement ); + SetWindowPos( hwnd, 0, 0, 0, 0, 0, + SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); + + if( p_vout->p_sys->hparent ) + { + RECT rect; + GetClientRect( hwnd, &rect ); + SetParent( p_vout->p_sys->hwnd, hwnd ); + SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, + rect.right, rect.bottom, + SWP_NOZORDER|SWP_FRAMECHANGED ); + } + + SetForegroundWindow( hwnd ); + } + else + { + /* Change window style, no borders and no title bar */ + SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style ); + + /* Normal window */ + window_placement.showCmd = SW_SHOWNORMAL; + SetWindowPlacement( hwnd, &window_placement ); + SetWindowPos( hwnd, 0, 0, 0, 0, 0, + SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED); + + if( p_vout->p_sys->hparent ) + { + RECT rect; + GetClientRect( p_vout->p_sys->hparent, &rect ); + SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent ); + SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0, + rect.right, rect.bottom, + SWP_NOZORDER|SWP_FRAMECHANGED ); + + ShowWindow( hwnd, SW_HIDE ); + SetForegroundWindow( p_vout->p_sys->hparent ); + } + + /* Make sure the mouse cursor is displayed */ + PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 ); + } + + /* Update the object variable and trigger callback */ + val.b_bool = p_vout->b_fullscreen; + var_Set( p_vout, "fullscreen", val ); + + p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE; + p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE; + } + + /* + * Pointer change + */ + if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden && + (mdate() - p_vout->p_sys->i_lastmoved) > 5000000 ) + { + POINT point; + HWND hwnd; + + /* Hide the cursor only if it is inside our window */ + GetCursorPos( &point ); + hwnd = WindowFromPoint(point); + if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd ) + { + PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 ); + } + else + { + p_vout->p_sys->i_lastmoved = mdate(); + } + } + + /* + * "Always on top" status change + */ + if( p_vout->p_sys->b_on_top_change ) + { + vlc_value_t val; + HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE ); + + var_Get( p_vout, "video-on-top", &val ); + + /* Set the window on top if necessary */ + if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) + & WS_EX_TOPMOST ) ) + { + CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, + MF_BYCOMMAND | MFS_CHECKED ); + SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE ); + } + else + /* The window shouldn't be on top */ + if( !val.b_bool && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE ) + & WS_EX_TOPMOST ) ) + { + CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP, + MF_BYCOMMAND | MFS_UNCHECKED ); + SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE ); + } + + p_vout->p_sys->b_on_top_change = VLC_FALSE; + } + + /* Check if the event thread is still running */ + if( p_vout->p_sys->p_event->b_die ) + { + return VLC_EGENERIC; /* exit */ + } + + return VLC_SUCCESS; +} + +/***************************************************************************** + * GLSwapBuffers: swap front/back buffers + *****************************************************************************/ +static void GLSwapBuffers( vout_thread_t *p_vout ) +{ + SwapBuffers( p_vout->p_sys->hGLDC ); +} + +int E_(DirectXUpdateOverlay)( vout_thread_t *p_vout ) +{ + return 1; +} diff --git a/modules/video_output/qte/qte.h b/modules/video_output/qte/qte.h index e665ca9498..c913c5a2f1 100644 --- a/modules/video_output/qte/qte.h +++ b/modules/video_output/qte/qte.h @@ -2,7 +2,7 @@ * qte.h : QT Embedded plugin for vlc ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: qte.h,v 1.5 2003/02/12 23:09:23 jpsaman Exp $ + * $Id$ * * Authors: Gerald Hansink * Jean-Paul Saman diff --git a/modules/video_output/svgalib.c b/modules/video_output/svgalib.c index c24ddafa38..9a7ff09304 100644 --- a/modules/video_output/svgalib.c +++ b/modules/video_output/svgalib.c @@ -2,7 +2,7 @@ * svgalib.c : SVGAlib plugin for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: svgalib.c,v 1.4 2003/10/25 00:42:31 sam Exp $ + * $Id$ * * Authors: Samuel Hocevar * diff --git a/share/newres.h b/share/newres.h index 89e6e23b88..ac5edb7bc6 100644 --- a/share/newres.h +++ b/share/newres.h @@ -1,39 +1,39 @@ -#ifndef __NEWRES_H__ -#define __NEWRES_H__ - -#if !defined(UNDER_CE) - #define UNDER_CE _WIN32_WCE -#endif - -#if defined(_WIN32_WCE) - #if !defined(WCEOLE_ENABLE_DIALOGEX) - #define DIALOGEX DIALOG DISCARDABLE - #endif - #include - #define SHMENUBAR RCDATA - #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) - #include - #else - #define I_IMAGENONE (-2) - #define NOMENU 0xFFFF - #define IDS_SHNEW 1 - - #define IDM_SHAREDNEW 10 - #define IDM_SHAREDNEWDEFAULT 11 - #endif -#endif // _WIN32_WCE - - -#ifdef RC_INVOKED -#ifndef _INC_WINDOWS -#define _INC_WINDOWS - #include "winuser.h" // extract from windows header -#endif -#endif - -#ifdef IDC_STATIC -#undef IDC_STATIC -#endif -#define IDC_STATIC (-1) - -#endif //__NEWRES_H__ +#ifndef __NEWRES_H__ +#define __NEWRES_H__ + +#if !defined(UNDER_CE) + #define UNDER_CE _WIN32_WCE +#endif + +#if defined(_WIN32_WCE) + #if !defined(WCEOLE_ENABLE_DIALOGEX) + #define DIALOGEX DIALOG DISCARDABLE + #endif + #include + #define SHMENUBAR RCDATA + #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300) + #include + #else + #define I_IMAGENONE (-2) + #define NOMENU 0xFFFF + #define IDS_SHNEW 1 + + #define IDM_SHAREDNEW 10 + #define IDM_SHAREDNEWDEFAULT 11 + #endif +#endif // _WIN32_WCE + + +#ifdef RC_INVOKED +#ifndef _INC_WINDOWS +#define _INC_WINDOWS + #include "winuser.h" // extract from windows header +#endif +#endif + +#ifdef IDC_STATIC +#undef IDC_STATIC +#endif +#define IDC_STATIC (-1) + +#endif //__NEWRES_H__ diff --git a/share/resource.h b/share/resource.h index 8f40863d64..2251e5d7d8 100644 --- a/share/resource.h +++ b/share/resource.h @@ -1,31 +1,31 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Developer Studio generated include file. -// Used by vlc_wince_rc.rc -// -#define IDS_APP_TITLE 1 -#define IDS_HELLO 2 -#define IDC_NIOUP 3 -#define IDI_NIOUP 101 -#define IDM_MENU 102 -#define IDD_ABOUTBOX 103 -#define IDM_FILE_EXIT 40002 -#define IDM_HELP_ABOUT 40003 -#define IDM_PLOP 40004 -#define ID_VIEW_PLAYLIST 40005 -#define ID_VIEW_MESSAGES 40006 -#define ID_SETTINGS_AUDIO 40007 -#define ID_SETTINGS_SUBTITLES 40008 -#define ID_SETTINGS 40011 -#define ID_FILE_OPENFILE 40012 -#define ID_FILE_NETWORKSTREAM 40013 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40014 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by vlc_wince_rc.rc +// +#define IDS_APP_TITLE 1 +#define IDS_HELLO 2 +#define IDC_NIOUP 3 +#define IDI_NIOUP 101 +#define IDM_MENU 102 +#define IDD_ABOUTBOX 103 +#define IDM_FILE_EXIT 40002 +#define IDM_HELP_ABOUT 40003 +#define IDM_PLOP 40004 +#define ID_VIEW_PLAYLIST 40005 +#define ID_VIEW_MESSAGES 40006 +#define ID_SETTINGS_AUDIO 40007 +#define ID_SETTINGS_SUBTITLES 40008 +#define ID_SETTINGS 40011 +#define ID_FILE_OPENFILE 40012 +#define ID_FILE_NETWORKSTREAM 40013 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40014 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/src/input/es_out.c b/src/input/es_out.c index 981c416eb8..f40c4a2904 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -1,1406 +1,1406 @@ -/***************************************************************************** - * es_out.c: Es Out handler for input. - ***************************************************************************** - * Copyright (C) 2003-2004 VideoLAN - * $Id$ - * - * Authors: Laurent Aimar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include - -#include -#include -#include - -#include "input_internal.h" - -#include "vlc_playlist.h" -#include "iso_lang.h" -/* FIXME we should find a better way than including that */ -#include "../misc/iso-639_def.h" - -/***************************************************************************** - * Local prototypes - *****************************************************************************/ -typedef struct -{ - /* Program ID */ - int i_id; - - /* Number of es for this pgrm */ - int i_es; - - vlc_bool_t b_selected; - - /* Clock for this program */ - input_clock_t clock; - -} es_out_pgrm_t; - -struct es_out_id_t -{ - /* ES ID */ - int i_id; - es_out_pgrm_t *p_pgrm; - - /* */ - int64_t i_preroll_end; - - /* Channel in the track type */ - int i_channel; - es_format_t fmt; - char *psz_language; - char *psz_language_code; - decoder_t *p_dec; -}; - -struct es_out_sys_t -{ - input_thread_t *p_input; - - /* all programs */ - int i_pgrm; - es_out_pgrm_t **pgrm; - es_out_pgrm_t **pp_selected_pgrm; /* --programs */ - es_out_pgrm_t *p_pgrm; /* Master program */ - - /* all es */ - int i_id; - int i_es; - es_out_id_t **es; - - /* mode gestion */ - vlc_bool_t b_active; - int i_mode; - - /* es count */ - int i_audio; - int i_video; - int i_sub; - - /* es to select */ - int i_audio_last; - int i_sub_last; - char **ppsz_audio_language; - char **ppsz_sub_language; - - /* current main es */ - es_out_id_t *p_es_audio; - es_out_id_t *p_es_video; - es_out_id_t *p_es_sub; - - /* delay */ - int64_t i_audio_delay; - int64_t i_spu_delay; -}; - -static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * ); -static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * ); -static void EsOutDel ( es_out_t *, es_out_id_t * ); -static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ); -static int EsOutControl( es_out_t *, int i_query, va_list ); - -static void EsOutAddInfo( es_out_t *, es_out_id_t *es ); - -static void EsSelect( es_out_t *out, es_out_id_t *es ); -static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update ); -static char *LanguageGetName( const char *psz_code ); -static char *LanguageGetCode( const char *psz_lang ); -static char **LanguageSplit( const char *psz_langs ); -static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang ); - -/***************************************************************************** - * input_EsOutNew: - *****************************************************************************/ -es_out_t *input_EsOutNew( input_thread_t *p_input ) -{ - es_out_t *out = malloc( sizeof( es_out_t ) ); - es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) ); - vlc_value_t val; - int i; - - out->pf_add = EsOutAdd; - out->pf_send = EsOutSend; - out->pf_del = EsOutDel; - out->pf_control = EsOutControl; - out->p_sys = p_sys; - - p_sys->p_input = p_input; - - p_sys->b_active = VLC_FALSE; - p_sys->i_mode = ES_OUT_MODE_AUTO; - - - p_sys->i_pgrm = 0; - p_sys->pgrm = NULL; - p_sys->p_pgrm = NULL; - - p_sys->i_id = 0; - p_sys->i_es = 0; - p_sys->es = NULL; - - p_sys->i_audio = 0; - p_sys->i_video = 0; - p_sys->i_sub = 0; - - /* */ - var_Get( p_input, "audio-track", &val ); - p_sys->i_audio_last = val.i_int; - - var_Get( p_input, "sub-track", &val ); - p_sys->i_sub_last = val.i_int; - - var_Get( p_input, "audio-language", &val ); - p_sys->ppsz_audio_language = LanguageSplit(val.psz_string); - if( p_sys->ppsz_audio_language ) - { - for( i = 0; p_sys->ppsz_audio_language[i]; i++ ) - msg_Dbg( p_input, "Select audio in language[%d] %s", - i, p_sys->ppsz_audio_language[i] ); - } - - var_Get( p_input, "sub-language", &val ); - p_sys->ppsz_sub_language = LanguageSplit(val.psz_string); - if( p_sys->ppsz_sub_language ) - { - for( i = 0; p_sys->ppsz_sub_language[i]; i++ ) - msg_Dbg( p_input, "Select subtitle in language[%d] %s", - i, p_sys->ppsz_sub_language[i] ); - } - - /* */ - p_sys->p_es_audio = NULL; - p_sys->p_es_video = NULL; - p_sys->p_es_sub = NULL; - - p_sys->i_audio_delay= 0; - p_sys->i_spu_delay = 0; - - return out; -} - -/***************************************************************************** - * input_EsOutDelete: - *****************************************************************************/ -void input_EsOutDelete( es_out_t *out ) -{ - es_out_sys_t *p_sys = out->p_sys; - int i; - - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec ) - { - input_DecoderDelete( p_sys->es[i]->p_dec ); - } - if( p_sys->es[i]->psz_language ) - free( p_sys->es[i]->psz_language ); - if( p_sys->es[i]->psz_language_code ) - free( p_sys->es[i]->psz_language_code ); - es_format_Clean( &p_sys->es[i]->fmt ); - - free( p_sys->es[i] ); - } - if( p_sys->ppsz_audio_language ) - { - for( i = 0; p_sys->ppsz_audio_language[i]; i++ ) - free( p_sys->ppsz_audio_language[i] ); - free( p_sys->ppsz_audio_language ); - } - if( p_sys->ppsz_sub_language ) - { - for( i = 0; p_sys->ppsz_sub_language[i]; i++ ) - free( p_sys->ppsz_sub_language[i] ); - free( p_sys->ppsz_sub_language ); - } - - if( p_sys->es ) - free( p_sys->es ); - - for( i = 0; i < p_sys->i_pgrm; i++ ) - { - free( p_sys->pgrm[i] ); - } - if( p_sys->pgrm ) - free( p_sys->pgrm ); - - free( p_sys ); - free( out ); -} - -es_out_id_t *input_EsOutGetFromID( es_out_t *out, int i_id ) -{ - int i; - if( i_id < 0 ) - { - /* Special HACK, -i_id is tha cat of the stream */ - return (es_out_id_t*)((uint8_t*)NULL-i_id); - } - - for( i = 0; i < out->p_sys->i_es; i++ ) - { - if( out->p_sys->es[i]->i_id == i_id ) - return out->p_sys->es[i]; - } - return NULL; -} - -void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_audio ) -{ - es_out_sys_t *p_sys = out->p_sys; - int i; - - for( i = 0; i < p_sys->i_es; i++ ) - { - es_out_id_t *es = p_sys->es[i]; - - /* Send a dummy block to let decoder know that - * there is a discontinuity */ - if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) ) - { - input_DecoderDiscontinuity( es->p_dec ); - } - } -} - -void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay ) -{ - es_out_sys_t *p_sys = out->p_sys; - - if( i_cat == AUDIO_ES ) - p_sys->i_audio_delay = i_delay; - else if( i_cat == SPU_ES ) - p_sys->i_spu_delay = i_delay; -} - -vlc_bool_t input_EsOutDecodersEmpty( es_out_t *out ) -{ - es_out_sys_t *p_sys = out->p_sys; - int i; - - for( i = 0; i < p_sys->i_es; i++ ) - { - es_out_id_t *es = p_sys->es[i]; - - if( es->p_dec && !input_DecoderEmpty( es->p_dec ) ) - return VLC_FALSE; - } - return VLC_TRUE; -} - -/***************************************************************************** - * - *****************************************************************************/ -static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es, - vlc_bool_t b_delete ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - vlc_value_t val, text; - - char *psz_var; - - if( es->fmt.i_cat == AUDIO_ES ) - psz_var = "audio-es"; - else if( es->fmt.i_cat == VIDEO_ES ) - psz_var = "video-es"; - else if( es->fmt.i_cat == SPU_ES ) - psz_var = "spu-es"; - else - return; - - if( b_delete ) - { - val.i_int = es->i_id; - var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL ); - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); - return; - } - - /* Get the number of ES already added */ - var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); - if( val.i_int == 0 ) - { - vlc_value_t val2; - - /* First one, we need to add the "Disable" choice */ - val2.i_int = -1; text.psz_string = _("Disable"); - var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val2, &text ); - val.i_int++; - } - - /* Take care of the ES description */ - if( es->fmt.psz_description && *es->fmt.psz_description ) - { - if( es->psz_language && *es->psz_language ) - { - text.psz_string = malloc( strlen( es->fmt.psz_description) + strlen( es->psz_language ) + 10 ); - sprintf( text.psz_string, "%s - [%s]", es->fmt.psz_description, es->psz_language ); - } - else text.psz_string = strdup( es->fmt.psz_description ); - } - else - { - if( es->psz_language && *es->psz_language ) - { - char *temp; - text.psz_string = malloc( strlen( _("Track %i") )+ strlen( es->psz_language ) + 30 ); - asprintf( &temp, _("Track %i"), val.i_int ); - sprintf( text.psz_string, "%s - [%s]", temp, es->psz_language ); - free( temp ); - } - else - { - text.psz_string = malloc( strlen( _("Track %i") ) + 20 ); - sprintf( text.psz_string, _("Track %i"), val.i_int ); - } - } - - val.i_int = es->i_id; - var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val, &text ); - - free( text.psz_string ); - - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); -} - -/* EsOutProgramSelect: - * Select a program and update the object variable - */ -static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - vlc_value_t val; - int i; - - if( p_sys->p_pgrm == p_pgrm ) - return; /* Nothing to do */ - - if( p_sys->p_pgrm ) - { - es_out_pgrm_t *old = p_sys->p_pgrm; - msg_Dbg( p_input, "Unselecting program id=%d", old->i_id ); - - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_pgrm == old && p_sys->es[i]->p_dec && - p_sys->i_mode != ES_OUT_MODE_ALL ) - EsUnselect( out, p_sys->es[i], VLC_TRUE ); - } - - p_sys->p_es_audio = NULL; - p_sys->p_es_sub = NULL; - p_sys->p_es_video = NULL; - } - - msg_Dbg( p_input, "Selecting program id=%d", p_pgrm->i_id ); - - /* Mark it selected */ - p_pgrm->b_selected = VLC_TRUE; - - /* Switch master stream */ - if( p_sys->p_pgrm && p_sys->p_pgrm->clock.b_master ) - { - p_sys->p_pgrm->clock.b_master = VLC_FALSE; - } - p_pgrm->clock.b_master = VLC_TRUE; - p_sys->p_pgrm = p_pgrm; - - /* Update "program" */ - val.i_int = p_pgrm->i_id; - var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); - - /* Update "es-*" */ - var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); - var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); - var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_pgrm == p_sys->p_pgrm ) - EsOutESVarUpdate( out, p_sys->es[i], VLC_FALSE ); - EsOutSelect( out, p_sys->es[i], VLC_FALSE ); - } - - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); -} - -/* EsOutAddProgram: - * Add a program - */ -static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - vlc_value_t val; - - es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) ); - - /* Init */ - p_pgrm->i_id = i_group; - p_pgrm->i_es = 0; - p_pgrm->b_selected = VLC_FALSE; - input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->input.i_cr_average ); - - /* Append it */ - TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm ); - - /* Update "program" variable */ - val.i_int = i_group; - var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL ); - - if( i_group == var_GetInteger( p_input, "program" ) ) - { - EsOutProgramSelect( out, p_pgrm ); - } - else - { - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); - } - return p_pgrm; -} - -/* EsOutAdd: - * Add an es_out - */ -static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - - es_out_id_t *es = malloc( sizeof( es_out_id_t ) ); - es_out_pgrm_t *p_pgrm = NULL; - int i; - - if( fmt->i_group < 0 ) - { - msg_Err( p_input, "invalid group number" ); - return NULL; - } - - /* Search the program */ - for( i = 0; i < p_sys->i_pgrm; i++ ) - { - if( fmt->i_group == p_sys->pgrm[i]->i_id ) - { - p_pgrm = p_sys->pgrm[i]; - break; - } - } - if( p_pgrm == NULL ) - { - /* Create a new one */ - p_pgrm = EsOutProgramAdd( out, fmt->i_group ); - } - - /* Increase ref count for program */ - p_pgrm->i_es++; - - /* Set up ES */ - if( fmt->i_id < 0 ) - fmt->i_id = out->p_sys->i_id; - es->i_id = fmt->i_id; - es->p_pgrm = p_pgrm; - es_format_Copy( &es->fmt, fmt ); - es->i_preroll_end = -1; - - switch( fmt->i_cat ) - { - case AUDIO_ES: - es->i_channel = p_sys->i_audio; - break; - - case VIDEO_ES: - es->i_channel = p_sys->i_video; - break; - - case SPU_ES: - es->i_channel = p_sys->i_sub; - break; - - default: - es->i_channel = 0; - break; - } - es->psz_language = LanguageGetName( fmt->psz_language ); /* remember so we only need to do it once */ - es->psz_language_code = LanguageGetCode( fmt->psz_language ); - es->p_dec = NULL; - - if( es->p_pgrm == p_sys->p_pgrm ) - EsOutESVarUpdate( out, es, VLC_FALSE ); - - /* Select it if needed */ - EsOutSelect( out, es, VLC_FALSE ); - - - TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es ); - p_sys->i_id++; /* always incremented */ - switch( fmt->i_cat ) - { - case AUDIO_ES: - p_sys->i_audio++; - break; - case SPU_ES: - p_sys->i_sub++; - break; - case VIDEO_ES: - p_sys->i_video++; - break; - } - - EsOutAddInfo( out, es ); - - return es; -} - -static void EsSelect( es_out_t *out, es_out_id_t *es ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - vlc_value_t val; - char *psz_var; - - if( es->p_dec ) - { - msg_Warn( p_input, "ES 0x%x is already selected", es->i_id ); - return; - } - - if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES ) - { - if( !var_GetBool( p_input, "video" ) || - ( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) ) - { - msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", - es->i_id ); - return; - } - } - else if( es->fmt.i_cat == AUDIO_ES ) - { - var_Get( p_input, "audio", &val ); - if( !var_GetBool( p_input, "audio" ) || - ( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) ) - { - msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", - es->i_id ); - return; - } - } - - es->i_preroll_end = -1; - es->p_dec = input_DecoderNew( p_input, &es->fmt, VLC_FALSE ); - if( es->p_dec == NULL || es->p_pgrm != p_sys->p_pgrm ) - return; - - if( es->fmt.i_cat == VIDEO_ES ) - psz_var = "video-es"; - else if( es->fmt.i_cat == AUDIO_ES ) - psz_var = "audio-es"; - else if( es->fmt.i_cat == SPU_ES ) - psz_var = "spu-es"; - else - return; - - /* Mark it as selected */ - val.i_int = es->i_id; - var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL ); - - - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); -} - -static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - vlc_value_t val; - char *psz_var; - - if( es->p_dec == NULL ) - { - msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id ); - return; - } - - input_DecoderDelete( es->p_dec ); - es->p_dec = NULL; - - if( !b_update ) - return; - - /* Update var */ - if( es->p_dec == NULL ) - return; - if( es->fmt.i_cat == VIDEO_ES ) - psz_var = "video-es"; - else if( es->fmt.i_cat == AUDIO_ES ) - psz_var = "audio-es"; - else if( es->fmt.i_cat == SPU_ES ) - psz_var = "spu-es"; - else - return; - - /* Mark it as selected */ - val.i_int = -1; - var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL ); - - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); -} - -/** - * Select an ES given the current mode - * XXX: you need to take a the lock before (stream.stream_lock) - * - * \param out The es_out structure - * \param es es_out_id structure - * \param b_force ... - * \return nothing - */ -static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ) -{ - es_out_sys_t *p_sys = out->p_sys; - - int i_cat = es->fmt.i_cat; - - if( !p_sys->b_active || - ( !b_force && es->fmt.i_priority < 0 ) ) - { - return; - } - - if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force ) - { - if( !es->p_dec ) - EsSelect( out, es ); - } - else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL ) - { - vlc_value_t val; - int i; - var_Get( p_sys->p_input, "programs", &val ); - for ( i = 0; i < val.p_list->i_count; i++ ) - { - if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force ) - { - if( !es->p_dec ) - EsSelect( out, es ); - break; - } - } - var_Change( p_sys->p_input, "programs", VLC_VAR_FREELIST, &val, NULL ); - } - else if( p_sys->i_mode == ES_OUT_MODE_AUTO ) - { - int i_wanted = -1; - - if( es->p_pgrm != p_sys->p_pgrm ) - return; - - if( i_cat == AUDIO_ES ) - { - int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language, - es->psz_language_code ); - - if( p_sys->p_es_audio && - p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority ) - { - int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language, - p_sys->p_es_audio->psz_language_code ); - - if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) - return; - i_wanted = es->i_channel; - } - else - { - /* Select audio if (no audio selected yet) - * - no audio-language - * - no audio code for the ES - * - audio code in the requested list */ - if( idx1 >= 0 || - !strcmp( es->psz_language_code, "??" ) || - !p_sys->ppsz_audio_language ) - i_wanted = es->i_channel; - } - - if( p_sys->i_audio_last >= 0 ) - i_wanted = p_sys->i_audio_last; - } - else if( i_cat == SPU_ES ) - { - int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language, - es->psz_language_code ); - - if( p_sys->p_es_sub && - p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority ) - { - int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language, - p_sys->p_es_sub->psz_language_code ); - - msg_Dbg( p_sys->p_input, "idx1=%d(%s) idx2=%d(%s)", - idx1, es->psz_language_code, idx2, - p_sys->p_es_sub->psz_language_code ); - - if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) - return; - /* We found a SPU that matches our language request */ - i_wanted = es->i_channel; - } - else if( idx1 >= 0 ) - { - msg_Dbg( p_sys->p_input, "idx1=%d(%s)", - idx1, es->psz_language_code ); - - i_wanted = es->i_channel; - } - if( p_sys->i_sub_last >= 0 ) - i_wanted = p_sys->i_sub_last; - } - else if( i_cat == VIDEO_ES ) - { - i_wanted = es->i_channel; - } - - if( i_wanted == es->i_channel && es->p_dec == NULL ) - EsSelect( out, es ); - } - - /* FIXME TODO handle priority here */ - if( es->p_dec ) - { - if( i_cat == AUDIO_ES ) - { - if( p_sys->i_mode == ES_OUT_MODE_AUTO && - p_sys->p_es_audio && - p_sys->p_es_audio != es && - p_sys->p_es_audio->p_dec ) - { - EsUnselect( out, p_sys->p_es_audio, VLC_FALSE ); - } - p_sys->p_es_audio = es; - } - else if( i_cat == SPU_ES ) - { - if( p_sys->i_mode == ES_OUT_MODE_AUTO && - p_sys->p_es_sub && - p_sys->p_es_sub != es && - p_sys->p_es_sub->p_dec ) - { - EsUnselect( out, p_sys->p_es_sub, VLC_FALSE ); - } - p_sys->p_es_sub = es; - } - else if( i_cat == VIDEO_ES ) - { - p_sys->p_es_video = es; - } - } -} - -/** - * Send a block for the given es_out - * - * \param out the es_out to send from - * \param es the es_out_id - * \param p_block the data block to send - */ -static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - es_out_pgrm_t *p_pgrm = es->p_pgrm; - int64_t i_delay; - - if( es->fmt.i_cat == AUDIO_ES ) - i_delay = p_sys->i_audio_delay; - else if( es->fmt.i_cat == SPU_ES ) - i_delay = p_sys->i_spu_delay; - else - i_delay = 0; - - /* Mark preroll blocks */ - if( es->i_preroll_end >= 0 ) - { - int64_t i_date = p_block->i_pts; - if( i_date <= 0 ) - i_date = p_block->i_dts; - - if( i_date < es->i_preroll_end ) - p_block->i_flags |= BLOCK_FLAG_PREROLL; - else - es->i_preroll_end = -1; - } - - /* +11 -> avoid null value with non null dts/pts */ - if( p_block->i_dts > 0 ) - { - p_block->i_dts = - input_ClockGetTS( p_input, &p_pgrm->clock, - ( p_block->i_dts + 11 ) * 9 / 100 ) + i_delay; - } - if( p_block->i_pts > 0 ) - { - p_block->i_pts = - input_ClockGetTS( p_input, &p_pgrm->clock, - ( p_block->i_pts + 11 ) * 9 / 100 ) + i_delay; - } - if ( es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) ) - { - mtime_t current_date = mdate(); - if( !p_block->i_pts - || p_block->i_pts > current_date + 10000000 - || current_date > p_block->i_pts ) - { - /* ETSI EN 300 472 Annex A : do not take into account the PTS - * for teletext streams. */ - p_block->i_pts = current_date + 400000 - + p_input->i_pts_delay + i_delay; - } - } - - p_block->i_rate = p_input->i_rate; - - /* TODO handle mute */ - if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || - p_input->i_rate == INPUT_RATE_DEFAULT ) ) - { - input_DecoderDecode( es->p_dec, p_block ); - } - else - { - block_Release( p_block ); - } - - return VLC_SUCCESS; -} - -/***************************************************************************** - * EsOutDel: - *****************************************************************************/ -static void EsOutDel( es_out_t *out, es_out_id_t *es ) -{ - es_out_sys_t *p_sys = out->p_sys; - - /* We don't try to reselect */ - if( es->p_dec ) - EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm ); - - if( es->p_pgrm == p_sys->p_pgrm ) - EsOutESVarUpdate( out, es, VLC_TRUE ); - - TAB_REMOVE( p_sys->i_es, p_sys->es, es ); - - es->p_pgrm->i_es--; - if( es->p_pgrm->i_es == 0 ) - { - msg_Warn( p_sys->p_input, "Program doesn't contain anymore ES, " - "TODO cleaning ?" ); - } - - if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL; - if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL; - if( p_sys->p_es_sub == es ) p_sys->p_es_sub = NULL; - - switch( es->fmt.i_cat ) - { - case AUDIO_ES: - p_sys->i_audio--; - break; - case SPU_ES: - p_sys->i_sub--; - break; - case VIDEO_ES: - p_sys->i_video--; - break; - } - - if( es->psz_language ) - free( es->psz_language ); - if( es->psz_language_code ) - free( es->psz_language_code ); - - es_format_Clean( &es->fmt ); - - free( es ); -} - -/** - * Control query handler - * - * \param out the es_out to control - * \param i_query A es_out query as defined in include/ninput.h - * \param args a variable list of arguments for the query - * \return VLC_SUCCESS or an error code - */ -static int EsOutControl( es_out_t *out, int i_query, va_list args ) -{ - es_out_sys_t *p_sys = out->p_sys; - vlc_bool_t b, *pb; - int i, *pi; - - es_out_id_t *es; - - switch( i_query ) - { - case ES_OUT_SET_ES_STATE: - es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - b = (vlc_bool_t) va_arg( args, vlc_bool_t ); - if( b && es->p_dec == NULL ) - { - EsSelect( out, es ); - return es->p_dec ? VLC_SUCCESS : VLC_EGENERIC; - } - else if( !b && es->p_dec ) - { - EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm ); - return VLC_SUCCESS; - } - return VLC_SUCCESS; - - case ES_OUT_GET_ES_STATE: - es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); - - *pb = es->p_dec ? VLC_TRUE : VLC_FALSE; - return VLC_SUCCESS; - - case ES_OUT_SET_ACTIVE: - { - b = (vlc_bool_t) va_arg( args, vlc_bool_t ); - p_sys->b_active = b; - /* Needed ? */ - if( b ) - var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); - return VLC_SUCCESS; - } - - case ES_OUT_GET_ACTIVE: - pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); - *pb = p_sys->b_active; - return VLC_SUCCESS; - - case ES_OUT_SET_MODE: - i = (int) va_arg( args, int ); - if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL || - i == ES_OUT_MODE_AUTO || i == ES_OUT_MODE_PARTIAL ) - { - p_sys->i_mode = i; - - /* Reapply policy mode */ - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec ) - { - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } - for( i = 0; i < p_sys->i_es; i++ ) - { - EsOutSelect( out, p_sys->es[i], VLC_FALSE ); - } - return VLC_SUCCESS; - } - return VLC_EGENERIC; - - case ES_OUT_GET_MODE: - pi = (int*) va_arg( args, int* ); - *pi = p_sys->i_mode; - return VLC_SUCCESS; - - case ES_OUT_SET_ES: - es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - /* Special case NULL, NULL+i_cat */ - if( es == NULL ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } - else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec && - p_sys->es[i]->fmt.i_cat == AUDIO_ES ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } - else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec && - p_sys->es[i]->fmt.i_cat == VIDEO_ES ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } - else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) ) - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( p_sys->es[i]->p_dec && - p_sys->es[i]->fmt.i_cat == SPU_ES ) - EsUnselect( out, p_sys->es[i], - p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); - } - } - else - { - for( i = 0; i < p_sys->i_es; i++ ) - { - if( es == p_sys->es[i] ) - { - EsOutSelect( out, es, VLC_TRUE ); - break; - } - } - } - return VLC_SUCCESS; - - case ES_OUT_SET_PCR: - case ES_OUT_SET_GROUP_PCR: - { - es_out_pgrm_t *p_pgrm = NULL; - int i_group = 0; - int64_t i_pcr; - - if( i_query == ES_OUT_SET_PCR ) - { - p_pgrm = p_sys->p_pgrm; - } - else - { - int i; - i_group = (int)va_arg( args, int ); - for( i = 0; i < p_sys->i_pgrm; i++ ) - { - if( p_sys->pgrm[i]->i_id == i_group ) - { - p_pgrm = p_sys->pgrm[i]; - break; - } - } - } - if( p_pgrm == NULL ) - p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */ - - i_pcr = (int64_t)va_arg( args, int64_t ); - /* search program */ - /* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */ - input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, - (i_pcr + 11 ) * 9 / 100); - return VLC_SUCCESS; - } - - case ES_OUT_RESET_PCR: - for( i = 0; i < p_sys->i_pgrm; i++ ) - { - p_sys->pgrm[i]->clock.i_synchro_state = SYNCHRO_REINIT; - p_sys->pgrm[i]->clock.last_pts = 0; - } - return VLC_SUCCESS; - - case ES_OUT_GET_TS: - if( p_sys->p_pgrm ) - { - int64_t i_ts = (int64_t)va_arg( args, int64_t ); - int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * ); - *pi_ts = input_ClockGetTS( p_sys->p_input, - &p_sys->p_pgrm->clock, - ( i_ts + 11 ) * 9 / 100 ); - return VLC_SUCCESS; - } - return VLC_EGENERIC; - - case ES_OUT_GET_GROUP: - pi = (int*) va_arg( args, int* ); - if( p_sys->p_pgrm ) - *pi = p_sys->p_pgrm->i_id; - else - *pi = -1; /* FIXME */ - return VLC_SUCCESS; - - case ES_OUT_SET_GROUP: - { - int j; - i = (int) va_arg( args, int ); - for( j = 0; j < p_sys->i_pgrm; j++ ) - { - es_out_pgrm_t *p_pgrm = p_sys->pgrm[j]; - if( p_pgrm->i_id == i ) - { - EsOutProgramSelect( out, p_pgrm ); - return VLC_SUCCESS; - } - } - return VLC_EGENERIC; - } - - case ES_OUT_SET_FMT: - { - /* This ain't pretty but is need by some demuxers (eg. Ogg ) - * to update the p_extra data */ - es_format_t *p_fmt; - es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - p_fmt = (es_format_t*) va_arg( args, es_format_t * ); - if( es == NULL ) return VLC_EGENERIC; - - if( p_fmt->i_extra ) - { - es->fmt.i_extra = p_fmt->i_extra; - es->fmt.p_extra = realloc( es->fmt.p_extra, p_fmt->i_extra ); - memcpy( es->fmt.p_extra, p_fmt->p_extra, p_fmt->i_extra ); - - if( !es->p_dec ) return VLC_SUCCESS; - - es->p_dec->fmt_in.i_extra = p_fmt->i_extra; - es->p_dec->fmt_in.p_extra = - realloc( es->p_dec->fmt_in.p_extra, p_fmt->i_extra ); - memcpy( es->p_dec->fmt_in.p_extra, - p_fmt->p_extra, p_fmt->i_extra ); - } - - return VLC_SUCCESS; - } - - case ES_OUT_SET_NEXT_DISPLAY_TIME: - { - int64_t i_date; - - es = (es_out_id_t*) va_arg( args, es_out_id_t * ); - i_date = (int64_t)va_arg( args, int64_t ); - - if( !es || !es->p_dec ) - return VLC_EGENERIC; - - es->i_preroll_end = i_date; - input_DecoderPreroll( es->p_dec, i_date ); - - return VLC_SUCCESS; - } - - default: - msg_Err( p_sys->p_input, "unknown query in es_out_Control" ); - return VLC_EGENERIC; - } -} - -/**************************************************************************** - * LanguageGetName: try to expend iso639 into plain name - ****************************************************************************/ -static char *LanguageGetName( const char *psz_code ) -{ - const iso639_lang_t *pl; - - if( psz_code == NULL ) - { - return strdup( "" ); - } - - if( strlen( psz_code ) == 2 ) - { - pl = GetLang_1( psz_code ); - } - else if( strlen( psz_code ) == 3 ) - { - pl = GetLang_2B( psz_code ); - if( !strcmp( pl->psz_iso639_1, "??" ) ) - { - pl = GetLang_2T( psz_code ); - } - } - else - { - return strdup( psz_code ); - } - - if( !strcmp( pl->psz_iso639_1, "??" ) ) - { - return strdup( psz_code ); - } - else - { - if( *pl->psz_native_name ) - { - return strdup( pl->psz_native_name ); - } - return strdup( pl->psz_eng_name ); - } -} - -/* Get a 2 char code */ -static char *LanguageGetCode( const char *psz_lang ) -{ - const iso639_lang_t *pl; - - if( psz_lang == NULL || *psz_lang == '\0' ) - return strdup("??"); - - for( pl = p_languages; pl->psz_iso639_1 != NULL; pl++ ) - { - if( !strcasecmp( pl->psz_eng_name, psz_lang ) || - !strcasecmp( pl->psz_native_name, psz_lang ) || - !strcasecmp( pl->psz_iso639_1, psz_lang ) || - !strcasecmp( pl->psz_iso639_2T, psz_lang ) || - !strcasecmp( pl->psz_iso639_2B, psz_lang ) ) - break; - } - - if( pl->psz_iso639_1 != NULL ) - return strdup( pl->psz_iso639_1 ); - - return strdup("??"); -} - -static char **LanguageSplit( const char *psz_langs ) -{ - char *psz_dup; - char *psz_parser; - char **ppsz = NULL; - int i_psz = 0; - - if( psz_langs == NULL ) - return NULL; - - psz_parser = psz_dup = strdup(psz_langs); - - while( psz_parser && *psz_parser ) - { - char *psz; - char *psz_code; - - psz = strchr(psz_parser, ',' ); - if( psz ) - { - *psz++ = '\0'; - } - - psz_code = LanguageGetCode( psz_parser ); - if( strcmp( psz_code, "??" ) ) - { - TAB_APPEND( i_psz, ppsz, psz_code ); - } - - psz_parser = psz; - } - - if( i_psz ) - { - TAB_APPEND( i_psz, ppsz, NULL ); - } - - return ppsz; -} - -static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang ) -{ - int i; - - if( !ppsz_langs || !psz_lang ) - return -1; - - for( i = 0; ppsz_langs[i]; i++ ) - if( !strcasecmp( ppsz_langs[i], psz_lang ) ) - return i; - - return -1; -} - -/**************************************************************************** - * EsOutAddInfo: - * - add meta info to the playlist item - ****************************************************************************/ -static void EsOutAddInfo( es_out_t *out, es_out_id_t *es ) -{ - es_out_sys_t *p_sys = out->p_sys; - input_thread_t *p_input = p_sys->p_input; - es_format_t *fmt = &es->fmt; - char *psz_cat; - - /* Add stream info */ - asprintf( &psz_cat, _("Stream %d"), out->p_sys->i_id - 1 ); - - input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"), - "%.4s", (char*)&fmt->i_codec ); - - input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"), - "%s", es->psz_language ); - - /* Add information */ - switch( fmt->i_cat ) - { - case AUDIO_ES: - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Type"), _("Audio") ); - - if( fmt->audio.i_channels > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"), - "%d", fmt->audio.i_channels ); - - if( fmt->audio.i_rate > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"), - _("%d Hz"), fmt->audio.i_rate ); - - if( fmt->audio.i_bitspersample > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Bits per sample"), "%d", - fmt->audio.i_bitspersample ); - - if( fmt->i_bitrate > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"), - _("%d kb/s"), fmt->i_bitrate / 1000 ); - break; - - case VIDEO_ES: - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Type"), _("Video") ); - - if( fmt->video.i_width > 0 && fmt->video.i_height > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Resolution"), "%dx%d", - fmt->video.i_width, fmt->video.i_height ); - - if( fmt->video.i_visible_width > 0 && - fmt->video.i_visible_height > 0 ) - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Display resolution"), "%dx%d", - fmt->video.i_visible_width, - fmt->video.i_visible_height); - break; - - case SPU_ES: - input_Control( p_input, INPUT_ADD_INFO, psz_cat, - _("Type"), _("Subtitle") ); - break; - - default: - break; - } - - free( psz_cat ); -} +/***************************************************************************** + * es_out.c: Es Out handler for input. + ***************************************************************************** + * Copyright (C) 2003-2004 VideoLAN + * $Id$ + * + * Authors: Laurent Aimar + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include + +#include +#include +#include + +#include "input_internal.h" + +#include "vlc_playlist.h" +#include "iso_lang.h" +/* FIXME we should find a better way than including that */ +#include "../misc/iso-639_def.h" + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +typedef struct +{ + /* Program ID */ + int i_id; + + /* Number of es for this pgrm */ + int i_es; + + vlc_bool_t b_selected; + + /* Clock for this program */ + input_clock_t clock; + +} es_out_pgrm_t; + +struct es_out_id_t +{ + /* ES ID */ + int i_id; + es_out_pgrm_t *p_pgrm; + + /* */ + int64_t i_preroll_end; + + /* Channel in the track type */ + int i_channel; + es_format_t fmt; + char *psz_language; + char *psz_language_code; + decoder_t *p_dec; +}; + +struct es_out_sys_t +{ + input_thread_t *p_input; + + /* all programs */ + int i_pgrm; + es_out_pgrm_t **pgrm; + es_out_pgrm_t **pp_selected_pgrm; /* --programs */ + es_out_pgrm_t *p_pgrm; /* Master program */ + + /* all es */ + int i_id; + int i_es; + es_out_id_t **es; + + /* mode gestion */ + vlc_bool_t b_active; + int i_mode; + + /* es count */ + int i_audio; + int i_video; + int i_sub; + + /* es to select */ + int i_audio_last; + int i_sub_last; + char **ppsz_audio_language; + char **ppsz_sub_language; + + /* current main es */ + es_out_id_t *p_es_audio; + es_out_id_t *p_es_video; + es_out_id_t *p_es_sub; + + /* delay */ + int64_t i_audio_delay; + int64_t i_spu_delay; +}; + +static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * ); +static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * ); +static void EsOutDel ( es_out_t *, es_out_id_t * ); +static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ); +static int EsOutControl( es_out_t *, int i_query, va_list ); + +static void EsOutAddInfo( es_out_t *, es_out_id_t *es ); + +static void EsSelect( es_out_t *out, es_out_id_t *es ); +static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update ); +static char *LanguageGetName( const char *psz_code ); +static char *LanguageGetCode( const char *psz_lang ); +static char **LanguageSplit( const char *psz_langs ); +static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang ); + +/***************************************************************************** + * input_EsOutNew: + *****************************************************************************/ +es_out_t *input_EsOutNew( input_thread_t *p_input ) +{ + es_out_t *out = malloc( sizeof( es_out_t ) ); + es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) ); + vlc_value_t val; + int i; + + out->pf_add = EsOutAdd; + out->pf_send = EsOutSend; + out->pf_del = EsOutDel; + out->pf_control = EsOutControl; + out->p_sys = p_sys; + + p_sys->p_input = p_input; + + p_sys->b_active = VLC_FALSE; + p_sys->i_mode = ES_OUT_MODE_AUTO; + + + p_sys->i_pgrm = 0; + p_sys->pgrm = NULL; + p_sys->p_pgrm = NULL; + + p_sys->i_id = 0; + p_sys->i_es = 0; + p_sys->es = NULL; + + p_sys->i_audio = 0; + p_sys->i_video = 0; + p_sys->i_sub = 0; + + /* */ + var_Get( p_input, "audio-track", &val ); + p_sys->i_audio_last = val.i_int; + + var_Get( p_input, "sub-track", &val ); + p_sys->i_sub_last = val.i_int; + + var_Get( p_input, "audio-language", &val ); + p_sys->ppsz_audio_language = LanguageSplit(val.psz_string); + if( p_sys->ppsz_audio_language ) + { + for( i = 0; p_sys->ppsz_audio_language[i]; i++ ) + msg_Dbg( p_input, "Select audio in language[%d] %s", + i, p_sys->ppsz_audio_language[i] ); + } + + var_Get( p_input, "sub-language", &val ); + p_sys->ppsz_sub_language = LanguageSplit(val.psz_string); + if( p_sys->ppsz_sub_language ) + { + for( i = 0; p_sys->ppsz_sub_language[i]; i++ ) + msg_Dbg( p_input, "Select subtitle in language[%d] %s", + i, p_sys->ppsz_sub_language[i] ); + } + + /* */ + p_sys->p_es_audio = NULL; + p_sys->p_es_video = NULL; + p_sys->p_es_sub = NULL; + + p_sys->i_audio_delay= 0; + p_sys->i_spu_delay = 0; + + return out; +} + +/***************************************************************************** + * input_EsOutDelete: + *****************************************************************************/ +void input_EsOutDelete( es_out_t *out ) +{ + es_out_sys_t *p_sys = out->p_sys; + int i; + + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec ) + { + input_DecoderDelete( p_sys->es[i]->p_dec ); + } + if( p_sys->es[i]->psz_language ) + free( p_sys->es[i]->psz_language ); + if( p_sys->es[i]->psz_language_code ) + free( p_sys->es[i]->psz_language_code ); + es_format_Clean( &p_sys->es[i]->fmt ); + + free( p_sys->es[i] ); + } + if( p_sys->ppsz_audio_language ) + { + for( i = 0; p_sys->ppsz_audio_language[i]; i++ ) + free( p_sys->ppsz_audio_language[i] ); + free( p_sys->ppsz_audio_language ); + } + if( p_sys->ppsz_sub_language ) + { + for( i = 0; p_sys->ppsz_sub_language[i]; i++ ) + free( p_sys->ppsz_sub_language[i] ); + free( p_sys->ppsz_sub_language ); + } + + if( p_sys->es ) + free( p_sys->es ); + + for( i = 0; i < p_sys->i_pgrm; i++ ) + { + free( p_sys->pgrm[i] ); + } + if( p_sys->pgrm ) + free( p_sys->pgrm ); + + free( p_sys ); + free( out ); +} + +es_out_id_t *input_EsOutGetFromID( es_out_t *out, int i_id ) +{ + int i; + if( i_id < 0 ) + { + /* Special HACK, -i_id is tha cat of the stream */ + return (es_out_id_t*)((uint8_t*)NULL-i_id); + } + + for( i = 0; i < out->p_sys->i_es; i++ ) + { + if( out->p_sys->es[i]->i_id == i_id ) + return out->p_sys->es[i]; + } + return NULL; +} + +void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_audio ) +{ + es_out_sys_t *p_sys = out->p_sys; + int i; + + for( i = 0; i < p_sys->i_es; i++ ) + { + es_out_id_t *es = p_sys->es[i]; + + /* Send a dummy block to let decoder know that + * there is a discontinuity */ + if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) ) + { + input_DecoderDiscontinuity( es->p_dec ); + } + } +} + +void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay ) +{ + es_out_sys_t *p_sys = out->p_sys; + + if( i_cat == AUDIO_ES ) + p_sys->i_audio_delay = i_delay; + else if( i_cat == SPU_ES ) + p_sys->i_spu_delay = i_delay; +} + +vlc_bool_t input_EsOutDecodersEmpty( es_out_t *out ) +{ + es_out_sys_t *p_sys = out->p_sys; + int i; + + for( i = 0; i < p_sys->i_es; i++ ) + { + es_out_id_t *es = p_sys->es[i]; + + if( es->p_dec && !input_DecoderEmpty( es->p_dec ) ) + return VLC_FALSE; + } + return VLC_TRUE; +} + +/***************************************************************************** + * + *****************************************************************************/ +static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es, + vlc_bool_t b_delete ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + vlc_value_t val, text; + + char *psz_var; + + if( es->fmt.i_cat == AUDIO_ES ) + psz_var = "audio-es"; + else if( es->fmt.i_cat == VIDEO_ES ) + psz_var = "video-es"; + else if( es->fmt.i_cat == SPU_ES ) + psz_var = "spu-es"; + else + return; + + if( b_delete ) + { + val.i_int = es->i_id; + var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL ); + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); + return; + } + + /* Get the number of ES already added */ + var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL ); + if( val.i_int == 0 ) + { + vlc_value_t val2; + + /* First one, we need to add the "Disable" choice */ + val2.i_int = -1; text.psz_string = _("Disable"); + var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val2, &text ); + val.i_int++; + } + + /* Take care of the ES description */ + if( es->fmt.psz_description && *es->fmt.psz_description ) + { + if( es->psz_language && *es->psz_language ) + { + text.psz_string = malloc( strlen( es->fmt.psz_description) + strlen( es->psz_language ) + 10 ); + sprintf( text.psz_string, "%s - [%s]", es->fmt.psz_description, es->psz_language ); + } + else text.psz_string = strdup( es->fmt.psz_description ); + } + else + { + if( es->psz_language && *es->psz_language ) + { + char *temp; + text.psz_string = malloc( strlen( _("Track %i") )+ strlen( es->psz_language ) + 30 ); + asprintf( &temp, _("Track %i"), val.i_int ); + sprintf( text.psz_string, "%s - [%s]", temp, es->psz_language ); + free( temp ); + } + else + { + text.psz_string = malloc( strlen( _("Track %i") ) + 20 ); + sprintf( text.psz_string, _("Track %i"), val.i_int ); + } + } + + val.i_int = es->i_id; + var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val, &text ); + + free( text.psz_string ); + + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); +} + +/* EsOutProgramSelect: + * Select a program and update the object variable + */ +static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + vlc_value_t val; + int i; + + if( p_sys->p_pgrm == p_pgrm ) + return; /* Nothing to do */ + + if( p_sys->p_pgrm ) + { + es_out_pgrm_t *old = p_sys->p_pgrm; + msg_Dbg( p_input, "Unselecting program id=%d", old->i_id ); + + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_pgrm == old && p_sys->es[i]->p_dec && + p_sys->i_mode != ES_OUT_MODE_ALL ) + EsUnselect( out, p_sys->es[i], VLC_TRUE ); + } + + p_sys->p_es_audio = NULL; + p_sys->p_es_sub = NULL; + p_sys->p_es_video = NULL; + } + + msg_Dbg( p_input, "Selecting program id=%d", p_pgrm->i_id ); + + /* Mark it selected */ + p_pgrm->b_selected = VLC_TRUE; + + /* Switch master stream */ + if( p_sys->p_pgrm && p_sys->p_pgrm->clock.b_master ) + { + p_sys->p_pgrm->clock.b_master = VLC_FALSE; + } + p_pgrm->clock.b_master = VLC_TRUE; + p_sys->p_pgrm = p_pgrm; + + /* Update "program" */ + val.i_int = p_pgrm->i_id; + var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL ); + + /* Update "es-*" */ + var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); + var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); + var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL ); + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_pgrm == p_sys->p_pgrm ) + EsOutESVarUpdate( out, p_sys->es[i], VLC_FALSE ); + EsOutSelect( out, p_sys->es[i], VLC_FALSE ); + } + + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); +} + +/* EsOutAddProgram: + * Add a program + */ +static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + vlc_value_t val; + + es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) ); + + /* Init */ + p_pgrm->i_id = i_group; + p_pgrm->i_es = 0; + p_pgrm->b_selected = VLC_FALSE; + input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->input.i_cr_average ); + + /* Append it */ + TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm ); + + /* Update "program" variable */ + val.i_int = i_group; + var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL ); + + if( i_group == var_GetInteger( p_input, "program" ) ) + { + EsOutProgramSelect( out, p_pgrm ); + } + else + { + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); + } + return p_pgrm; +} + +/* EsOutAdd: + * Add an es_out + */ +static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + + es_out_id_t *es = malloc( sizeof( es_out_id_t ) ); + es_out_pgrm_t *p_pgrm = NULL; + int i; + + if( fmt->i_group < 0 ) + { + msg_Err( p_input, "invalid group number" ); + return NULL; + } + + /* Search the program */ + for( i = 0; i < p_sys->i_pgrm; i++ ) + { + if( fmt->i_group == p_sys->pgrm[i]->i_id ) + { + p_pgrm = p_sys->pgrm[i]; + break; + } + } + if( p_pgrm == NULL ) + { + /* Create a new one */ + p_pgrm = EsOutProgramAdd( out, fmt->i_group ); + } + + /* Increase ref count for program */ + p_pgrm->i_es++; + + /* Set up ES */ + if( fmt->i_id < 0 ) + fmt->i_id = out->p_sys->i_id; + es->i_id = fmt->i_id; + es->p_pgrm = p_pgrm; + es_format_Copy( &es->fmt, fmt ); + es->i_preroll_end = -1; + + switch( fmt->i_cat ) + { + case AUDIO_ES: + es->i_channel = p_sys->i_audio; + break; + + case VIDEO_ES: + es->i_channel = p_sys->i_video; + break; + + case SPU_ES: + es->i_channel = p_sys->i_sub; + break; + + default: + es->i_channel = 0; + break; + } + es->psz_language = LanguageGetName( fmt->psz_language ); /* remember so we only need to do it once */ + es->psz_language_code = LanguageGetCode( fmt->psz_language ); + es->p_dec = NULL; + + if( es->p_pgrm == p_sys->p_pgrm ) + EsOutESVarUpdate( out, es, VLC_FALSE ); + + /* Select it if needed */ + EsOutSelect( out, es, VLC_FALSE ); + + + TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es ); + p_sys->i_id++; /* always incremented */ + switch( fmt->i_cat ) + { + case AUDIO_ES: + p_sys->i_audio++; + break; + case SPU_ES: + p_sys->i_sub++; + break; + case VIDEO_ES: + p_sys->i_video++; + break; + } + + EsOutAddInfo( out, es ); + + return es; +} + +static void EsSelect( es_out_t *out, es_out_id_t *es ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + vlc_value_t val; + char *psz_var; + + if( es->p_dec ) + { + msg_Warn( p_input, "ES 0x%x is already selected", es->i_id ); + return; + } + + if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES ) + { + if( !var_GetBool( p_input, "video" ) || + ( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) ) + { + msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x", + es->i_id ); + return; + } + } + else if( es->fmt.i_cat == AUDIO_ES ) + { + var_Get( p_input, "audio", &val ); + if( !var_GetBool( p_input, "audio" ) || + ( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) ) + { + msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x", + es->i_id ); + return; + } + } + + es->i_preroll_end = -1; + es->p_dec = input_DecoderNew( p_input, &es->fmt, VLC_FALSE ); + if( es->p_dec == NULL || es->p_pgrm != p_sys->p_pgrm ) + return; + + if( es->fmt.i_cat == VIDEO_ES ) + psz_var = "video-es"; + else if( es->fmt.i_cat == AUDIO_ES ) + psz_var = "audio-es"; + else if( es->fmt.i_cat == SPU_ES ) + psz_var = "spu-es"; + else + return; + + /* Mark it as selected */ + val.i_int = es->i_id; + var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL ); + + + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); +} + +static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + vlc_value_t val; + char *psz_var; + + if( es->p_dec == NULL ) + { + msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id ); + return; + } + + input_DecoderDelete( es->p_dec ); + es->p_dec = NULL; + + if( !b_update ) + return; + + /* Update var */ + if( es->p_dec == NULL ) + return; + if( es->fmt.i_cat == VIDEO_ES ) + psz_var = "video-es"; + else if( es->fmt.i_cat == AUDIO_ES ) + psz_var = "audio-es"; + else if( es->fmt.i_cat == SPU_ES ) + psz_var = "spu-es"; + else + return; + + /* Mark it as selected */ + val.i_int = -1; + var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL ); + + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); +} + +/** + * Select an ES given the current mode + * XXX: you need to take a the lock before (stream.stream_lock) + * + * \param out The es_out structure + * \param es es_out_id structure + * \param b_force ... + * \return nothing + */ +static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force ) +{ + es_out_sys_t *p_sys = out->p_sys; + + int i_cat = es->fmt.i_cat; + + if( !p_sys->b_active || + ( !b_force && es->fmt.i_priority < 0 ) ) + { + return; + } + + if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force ) + { + if( !es->p_dec ) + EsSelect( out, es ); + } + else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL ) + { + vlc_value_t val; + int i; + var_Get( p_sys->p_input, "programs", &val ); + for ( i = 0; i < val.p_list->i_count; i++ ) + { + if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force ) + { + if( !es->p_dec ) + EsSelect( out, es ); + break; + } + } + var_Change( p_sys->p_input, "programs", VLC_VAR_FREELIST, &val, NULL ); + } + else if( p_sys->i_mode == ES_OUT_MODE_AUTO ) + { + int i_wanted = -1; + + if( es->p_pgrm != p_sys->p_pgrm ) + return; + + if( i_cat == AUDIO_ES ) + { + int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language, + es->psz_language_code ); + + if( p_sys->p_es_audio && + p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority ) + { + int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language, + p_sys->p_es_audio->psz_language_code ); + + if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) + return; + i_wanted = es->i_channel; + } + else + { + /* Select audio if (no audio selected yet) + * - no audio-language + * - no audio code for the ES + * - audio code in the requested list */ + if( idx1 >= 0 || + !strcmp( es->psz_language_code, "??" ) || + !p_sys->ppsz_audio_language ) + i_wanted = es->i_channel; + } + + if( p_sys->i_audio_last >= 0 ) + i_wanted = p_sys->i_audio_last; + } + else if( i_cat == SPU_ES ) + { + int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language, + es->psz_language_code ); + + if( p_sys->p_es_sub && + p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority ) + { + int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language, + p_sys->p_es_sub->psz_language_code ); + + msg_Dbg( p_sys->p_input, "idx1=%d(%s) idx2=%d(%s)", + idx1, es->psz_language_code, idx2, + p_sys->p_es_sub->psz_language_code ); + + if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) ) + return; + /* We found a SPU that matches our language request */ + i_wanted = es->i_channel; + } + else if( idx1 >= 0 ) + { + msg_Dbg( p_sys->p_input, "idx1=%d(%s)", + idx1, es->psz_language_code ); + + i_wanted = es->i_channel; + } + if( p_sys->i_sub_last >= 0 ) + i_wanted = p_sys->i_sub_last; + } + else if( i_cat == VIDEO_ES ) + { + i_wanted = es->i_channel; + } + + if( i_wanted == es->i_channel && es->p_dec == NULL ) + EsSelect( out, es ); + } + + /* FIXME TODO handle priority here */ + if( es->p_dec ) + { + if( i_cat == AUDIO_ES ) + { + if( p_sys->i_mode == ES_OUT_MODE_AUTO && + p_sys->p_es_audio && + p_sys->p_es_audio != es && + p_sys->p_es_audio->p_dec ) + { + EsUnselect( out, p_sys->p_es_audio, VLC_FALSE ); + } + p_sys->p_es_audio = es; + } + else if( i_cat == SPU_ES ) + { + if( p_sys->i_mode == ES_OUT_MODE_AUTO && + p_sys->p_es_sub && + p_sys->p_es_sub != es && + p_sys->p_es_sub->p_dec ) + { + EsUnselect( out, p_sys->p_es_sub, VLC_FALSE ); + } + p_sys->p_es_sub = es; + } + else if( i_cat == VIDEO_ES ) + { + p_sys->p_es_video = es; + } + } +} + +/** + * Send a block for the given es_out + * + * \param out the es_out to send from + * \param es the es_out_id + * \param p_block the data block to send + */ +static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + es_out_pgrm_t *p_pgrm = es->p_pgrm; + int64_t i_delay; + + if( es->fmt.i_cat == AUDIO_ES ) + i_delay = p_sys->i_audio_delay; + else if( es->fmt.i_cat == SPU_ES ) + i_delay = p_sys->i_spu_delay; + else + i_delay = 0; + + /* Mark preroll blocks */ + if( es->i_preroll_end >= 0 ) + { + int64_t i_date = p_block->i_pts; + if( i_date <= 0 ) + i_date = p_block->i_dts; + + if( i_date < es->i_preroll_end ) + p_block->i_flags |= BLOCK_FLAG_PREROLL; + else + es->i_preroll_end = -1; + } + + /* +11 -> avoid null value with non null dts/pts */ + if( p_block->i_dts > 0 ) + { + p_block->i_dts = + input_ClockGetTS( p_input, &p_pgrm->clock, + ( p_block->i_dts + 11 ) * 9 / 100 ) + i_delay; + } + if( p_block->i_pts > 0 ) + { + p_block->i_pts = + input_ClockGetTS( p_input, &p_pgrm->clock, + ( p_block->i_pts + 11 ) * 9 / 100 ) + i_delay; + } + if ( es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) ) + { + mtime_t current_date = mdate(); + if( !p_block->i_pts + || p_block->i_pts > current_date + 10000000 + || current_date > p_block->i_pts ) + { + /* ETSI EN 300 472 Annex A : do not take into account the PTS + * for teletext streams. */ + p_block->i_pts = current_date + 400000 + + p_input->i_pts_delay + i_delay; + } + } + + p_block->i_rate = p_input->i_rate; + + /* TODO handle mute */ + if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES || + p_input->i_rate == INPUT_RATE_DEFAULT ) ) + { + input_DecoderDecode( es->p_dec, p_block ); + } + else + { + block_Release( p_block ); + } + + return VLC_SUCCESS; +} + +/***************************************************************************** + * EsOutDel: + *****************************************************************************/ +static void EsOutDel( es_out_t *out, es_out_id_t *es ) +{ + es_out_sys_t *p_sys = out->p_sys; + + /* We don't try to reselect */ + if( es->p_dec ) + EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm ); + + if( es->p_pgrm == p_sys->p_pgrm ) + EsOutESVarUpdate( out, es, VLC_TRUE ); + + TAB_REMOVE( p_sys->i_es, p_sys->es, es ); + + es->p_pgrm->i_es--; + if( es->p_pgrm->i_es == 0 ) + { + msg_Warn( p_sys->p_input, "Program doesn't contain anymore ES, " + "TODO cleaning ?" ); + } + + if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL; + if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL; + if( p_sys->p_es_sub == es ) p_sys->p_es_sub = NULL; + + switch( es->fmt.i_cat ) + { + case AUDIO_ES: + p_sys->i_audio--; + break; + case SPU_ES: + p_sys->i_sub--; + break; + case VIDEO_ES: + p_sys->i_video--; + break; + } + + if( es->psz_language ) + free( es->psz_language ); + if( es->psz_language_code ) + free( es->psz_language_code ); + + es_format_Clean( &es->fmt ); + + free( es ); +} + +/** + * Control query handler + * + * \param out the es_out to control + * \param i_query A es_out query as defined in include/ninput.h + * \param args a variable list of arguments for the query + * \return VLC_SUCCESS or an error code + */ +static int EsOutControl( es_out_t *out, int i_query, va_list args ) +{ + es_out_sys_t *p_sys = out->p_sys; + vlc_bool_t b, *pb; + int i, *pi; + + es_out_id_t *es; + + switch( i_query ) + { + case ES_OUT_SET_ES_STATE: + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); + b = (vlc_bool_t) va_arg( args, vlc_bool_t ); + if( b && es->p_dec == NULL ) + { + EsSelect( out, es ); + return es->p_dec ? VLC_SUCCESS : VLC_EGENERIC; + } + else if( !b && es->p_dec ) + { + EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm ); + return VLC_SUCCESS; + } + return VLC_SUCCESS; + + case ES_OUT_GET_ES_STATE: + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); + pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); + + *pb = es->p_dec ? VLC_TRUE : VLC_FALSE; + return VLC_SUCCESS; + + case ES_OUT_SET_ACTIVE: + { + b = (vlc_bool_t) va_arg( args, vlc_bool_t ); + p_sys->b_active = b; + /* Needed ? */ + if( b ) + var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE ); + return VLC_SUCCESS; + } + + case ES_OUT_GET_ACTIVE: + pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * ); + *pb = p_sys->b_active; + return VLC_SUCCESS; + + case ES_OUT_SET_MODE: + i = (int) va_arg( args, int ); + if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL || + i == ES_OUT_MODE_AUTO || i == ES_OUT_MODE_PARTIAL ) + { + p_sys->i_mode = i; + + /* Reapply policy mode */ + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec ) + { + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + for( i = 0; i < p_sys->i_es; i++ ) + { + EsOutSelect( out, p_sys->es[i], VLC_FALSE ); + } + return VLC_SUCCESS; + } + return VLC_EGENERIC; + + case ES_OUT_GET_MODE: + pi = (int*) va_arg( args, int* ); + *pi = p_sys->i_mode; + return VLC_SUCCESS; + + case ES_OUT_SET_ES: + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); + /* Special case NULL, NULL+i_cat */ + if( es == NULL ) + { + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec ) + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) ) + { + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec && + p_sys->es[i]->fmt.i_cat == AUDIO_ES ) + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) ) + { + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec && + p_sys->es[i]->fmt.i_cat == VIDEO_ES ) + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) ) + { + for( i = 0; i < p_sys->i_es; i++ ) + { + if( p_sys->es[i]->p_dec && + p_sys->es[i]->fmt.i_cat == SPU_ES ) + EsUnselect( out, p_sys->es[i], + p_sys->es[i]->p_pgrm == p_sys->p_pgrm ); + } + } + else + { + for( i = 0; i < p_sys->i_es; i++ ) + { + if( es == p_sys->es[i] ) + { + EsOutSelect( out, es, VLC_TRUE ); + break; + } + } + } + return VLC_SUCCESS; + + case ES_OUT_SET_PCR: + case ES_OUT_SET_GROUP_PCR: + { + es_out_pgrm_t *p_pgrm = NULL; + int i_group = 0; + int64_t i_pcr; + + if( i_query == ES_OUT_SET_PCR ) + { + p_pgrm = p_sys->p_pgrm; + } + else + { + int i; + i_group = (int)va_arg( args, int ); + for( i = 0; i < p_sys->i_pgrm; i++ ) + { + if( p_sys->pgrm[i]->i_id == i_group ) + { + p_pgrm = p_sys->pgrm[i]; + break; + } + } + } + if( p_pgrm == NULL ) + p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */ + + i_pcr = (int64_t)va_arg( args, int64_t ); + /* search program */ + /* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */ + input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock, + (i_pcr + 11 ) * 9 / 100); + return VLC_SUCCESS; + } + + case ES_OUT_RESET_PCR: + for( i = 0; i < p_sys->i_pgrm; i++ ) + { + p_sys->pgrm[i]->clock.i_synchro_state = SYNCHRO_REINIT; + p_sys->pgrm[i]->clock.last_pts = 0; + } + return VLC_SUCCESS; + + case ES_OUT_GET_TS: + if( p_sys->p_pgrm ) + { + int64_t i_ts = (int64_t)va_arg( args, int64_t ); + int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * ); + *pi_ts = input_ClockGetTS( p_sys->p_input, + &p_sys->p_pgrm->clock, + ( i_ts + 11 ) * 9 / 100 ); + return VLC_SUCCESS; + } + return VLC_EGENERIC; + + case ES_OUT_GET_GROUP: + pi = (int*) va_arg( args, int* ); + if( p_sys->p_pgrm ) + *pi = p_sys->p_pgrm->i_id; + else + *pi = -1; /* FIXME */ + return VLC_SUCCESS; + + case ES_OUT_SET_GROUP: + { + int j; + i = (int) va_arg( args, int ); + for( j = 0; j < p_sys->i_pgrm; j++ ) + { + es_out_pgrm_t *p_pgrm = p_sys->pgrm[j]; + if( p_pgrm->i_id == i ) + { + EsOutProgramSelect( out, p_pgrm ); + return VLC_SUCCESS; + } + } + return VLC_EGENERIC; + } + + case ES_OUT_SET_FMT: + { + /* This ain't pretty but is need by some demuxers (eg. Ogg ) + * to update the p_extra data */ + es_format_t *p_fmt; + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); + p_fmt = (es_format_t*) va_arg( args, es_format_t * ); + if( es == NULL ) return VLC_EGENERIC; + + if( p_fmt->i_extra ) + { + es->fmt.i_extra = p_fmt->i_extra; + es->fmt.p_extra = realloc( es->fmt.p_extra, p_fmt->i_extra ); + memcpy( es->fmt.p_extra, p_fmt->p_extra, p_fmt->i_extra ); + + if( !es->p_dec ) return VLC_SUCCESS; + + es->p_dec->fmt_in.i_extra = p_fmt->i_extra; + es->p_dec->fmt_in.p_extra = + realloc( es->p_dec->fmt_in.p_extra, p_fmt->i_extra ); + memcpy( es->p_dec->fmt_in.p_extra, + p_fmt->p_extra, p_fmt->i_extra ); + } + + return VLC_SUCCESS; + } + + case ES_OUT_SET_NEXT_DISPLAY_TIME: + { + int64_t i_date; + + es = (es_out_id_t*) va_arg( args, es_out_id_t * ); + i_date = (int64_t)va_arg( args, int64_t ); + + if( !es || !es->p_dec ) + return VLC_EGENERIC; + + es->i_preroll_end = i_date; + input_DecoderPreroll( es->p_dec, i_date ); + + return VLC_SUCCESS; + } + + default: + msg_Err( p_sys->p_input, "unknown query in es_out_Control" ); + return VLC_EGENERIC; + } +} + +/**************************************************************************** + * LanguageGetName: try to expend iso639 into plain name + ****************************************************************************/ +static char *LanguageGetName( const char *psz_code ) +{ + const iso639_lang_t *pl; + + if( psz_code == NULL ) + { + return strdup( "" ); + } + + if( strlen( psz_code ) == 2 ) + { + pl = GetLang_1( psz_code ); + } + else if( strlen( psz_code ) == 3 ) + { + pl = GetLang_2B( psz_code ); + if( !strcmp( pl->psz_iso639_1, "??" ) ) + { + pl = GetLang_2T( psz_code ); + } + } + else + { + return strdup( psz_code ); + } + + if( !strcmp( pl->psz_iso639_1, "??" ) ) + { + return strdup( psz_code ); + } + else + { + if( *pl->psz_native_name ) + { + return strdup( pl->psz_native_name ); + } + return strdup( pl->psz_eng_name ); + } +} + +/* Get a 2 char code */ +static char *LanguageGetCode( const char *psz_lang ) +{ + const iso639_lang_t *pl; + + if( psz_lang == NULL || *psz_lang == '\0' ) + return strdup("??"); + + for( pl = p_languages; pl->psz_iso639_1 != NULL; pl++ ) + { + if( !strcasecmp( pl->psz_eng_name, psz_lang ) || + !strcasecmp( pl->psz_native_name, psz_lang ) || + !strcasecmp( pl->psz_iso639_1, psz_lang ) || + !strcasecmp( pl->psz_iso639_2T, psz_lang ) || + !strcasecmp( pl->psz_iso639_2B, psz_lang ) ) + break; + } + + if( pl->psz_iso639_1 != NULL ) + return strdup( pl->psz_iso639_1 ); + + return strdup("??"); +} + +static char **LanguageSplit( const char *psz_langs ) +{ + char *psz_dup; + char *psz_parser; + char **ppsz = NULL; + int i_psz = 0; + + if( psz_langs == NULL ) + return NULL; + + psz_parser = psz_dup = strdup(psz_langs); + + while( psz_parser && *psz_parser ) + { + char *psz; + char *psz_code; + + psz = strchr(psz_parser, ',' ); + if( psz ) + { + *psz++ = '\0'; + } + + psz_code = LanguageGetCode( psz_parser ); + if( strcmp( psz_code, "??" ) ) + { + TAB_APPEND( i_psz, ppsz, psz_code ); + } + + psz_parser = psz; + } + + if( i_psz ) + { + TAB_APPEND( i_psz, ppsz, NULL ); + } + + return ppsz; +} + +static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang ) +{ + int i; + + if( !ppsz_langs || !psz_lang ) + return -1; + + for( i = 0; ppsz_langs[i]; i++ ) + if( !strcasecmp( ppsz_langs[i], psz_lang ) ) + return i; + + return -1; +} + +/**************************************************************************** + * EsOutAddInfo: + * - add meta info to the playlist item + ****************************************************************************/ +static void EsOutAddInfo( es_out_t *out, es_out_id_t *es ) +{ + es_out_sys_t *p_sys = out->p_sys; + input_thread_t *p_input = p_sys->p_input; + es_format_t *fmt = &es->fmt; + char *psz_cat; + + /* Add stream info */ + asprintf( &psz_cat, _("Stream %d"), out->p_sys->i_id - 1 ); + + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"), + "%.4s", (char*)&fmt->i_codec ); + + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"), + "%s", es->psz_language ); + + /* Add information */ + switch( fmt->i_cat ) + { + case AUDIO_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Audio") ); + + if( fmt->audio.i_channels > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"), + "%d", fmt->audio.i_channels ); + + if( fmt->audio.i_rate > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"), + _("%d Hz"), fmt->audio.i_rate ); + + if( fmt->audio.i_bitspersample > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Bits per sample"), "%d", + fmt->audio.i_bitspersample ); + + if( fmt->i_bitrate > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"), + _("%d kb/s"), fmt->i_bitrate / 1000 ); + break; + + case VIDEO_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Video") ); + + if( fmt->video.i_width > 0 && fmt->video.i_height > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Resolution"), "%dx%d", + fmt->video.i_width, fmt->video.i_height ); + + if( fmt->video.i_visible_width > 0 && + fmt->video.i_visible_height > 0 ) + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Display resolution"), "%dx%d", + fmt->video.i_visible_width, + fmt->video.i_visible_height); + break; + + case SPU_ES: + input_Control( p_input, INPUT_ADD_INFO, psz_cat, + _("Type"), _("Subtitle") ); + break; + + default: + break; + } + + free( psz_cat ); +} -- 2.39.2