-/* this file contains the actual definitions of */\r
-/* the IIDs and CLSIDs */\r
-\r
-/* link this file in with the server and any clients */\r
-\r
-\r
-/* File created by MIDL compiler version 5.01.0164 */\r
-/* at Thu Feb 17 09:25:54 2005\r
- */\r
-/* Compiler settings for axvlc.idl:\r
- Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext\r
- error checks: allocation ref bounds_check enum stub_data \r
-*/\r
-//@@MIDL_FILE_HEADING( )\r
-#ifdef __cplusplus\r
-extern "C"{\r
-#endif \r
-\r
-\r
-#ifndef __IID_DEFINED__\r
-#define __IID_DEFINED__\r
-\r
-typedef struct _IID\r
-{\r
- unsigned long x;\r
- unsigned short s1;\r
- unsigned short s2;\r
- unsigned char c[8];\r
-} IID;\r
-\r
-#endif // __IID_DEFINED__\r
-\r
-#ifndef CLSID_DEFINED\r
-#define CLSID_DEFINED\r
-typedef IID CLSID;\r
-#endif // CLSID_DEFINED\r
-\r
-const IID LIBID_AXVLC = {0xDF2BBE39,0x40A8,0x433b,{0xA2,0x79,0x07,0x3F,0x48,0xDA,0x94,0xB6}};\r
-\r
-\r
-const IID IID_IVLCControl = {0xC2FA41D0,0xB113,0x476e,{0xAC,0x8C,0x9B,0xD1,0x49,0x99,0xC1,0xC1}};\r
-\r
-\r
-const IID DIID_DVLCEvents = {0xDF48072F,0x5EF8,0x434e,{0x9B,0x40,0xE2,0xF3,0xAE,0x75,0x9B,0x5F}};\r
-\r
-\r
-const CLSID CLSID_VLCPlugin = {0xE23FE9C6,0x778E,0x49D4,{0xB5,0x37,0x38,0xFC,0xDE,0x48,0x87,0xD8}};\r
-\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
+/* 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 ALWAYS GENERATED file contains the definitions for the interfaces */\r
-\r
-\r
-/* File created by MIDL compiler version 5.01.0164 */\r
-/* at Thu Feb 17 09:25:54 2005\r
- */\r
-/* Compiler settings for axvlc.idl:\r
- Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext\r
- error checks: allocation ref bounds_check enum stub_data \r
-*/\r
-//@@MIDL_FILE_HEADING( )\r
-\r
-\r
-/* verify that the <rpcndr.h> version is high enough to compile this file*/\r
-#ifndef __REQUIRED_RPCNDR_H_VERSION__\r
-#define __REQUIRED_RPCNDR_H_VERSION__ 440\r
-#endif\r
-\r
-#include "rpc.h"\r
-#include "rpcndr.h"\r
-\r
-#ifndef __axvlc_idl_h__\r
-#define __axvlc_idl_h__\r
-\r
-#ifdef __cplusplus\r
-extern "C"{\r
-#endif \r
-\r
-/* Forward Declarations */ \r
-\r
-#ifndef __IVLCControl_FWD_DEFINED__\r
-#define __IVLCControl_FWD_DEFINED__\r
-typedef interface IVLCControl IVLCControl;\r
-#endif /* __IVLCControl_FWD_DEFINED__ */\r
-\r
-\r
-#ifndef __DVLCEvents_FWD_DEFINED__\r
-#define __DVLCEvents_FWD_DEFINED__\r
-typedef interface DVLCEvents DVLCEvents;\r
-#endif /* __DVLCEvents_FWD_DEFINED__ */\r
-\r
-\r
-#ifndef __VLCPlugin_FWD_DEFINED__\r
-#define __VLCPlugin_FWD_DEFINED__\r
-\r
-#ifdef __cplusplus\r
-typedef class VLCPlugin VLCPlugin;\r
-#else\r
-typedef struct VLCPlugin VLCPlugin;\r
-#endif /* __cplusplus */\r
-\r
-#endif /* __VLCPlugin_FWD_DEFINED__ */\r
-\r
-\r
-void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t);\r
-void __RPC_USER MIDL_user_free( void __RPC_FAR * ); \r
-\r
-\r
-#ifndef __AXVLC_LIBRARY_DEFINED__\r
-#define __AXVLC_LIBRARY_DEFINED__\r
-\r
-/* library AXVLC */\r
-/* [helpstring][version][uuid] */ \r
-\r
-\r
-\r
-\r
-enum VLCPlaylistMode\r
- { VLCPlayListInsert = 1,\r
- VLCPlayListReplace = 2,\r
- VLCPlayListAppend = 4,\r
- VLCPlayListGo = 8,\r
- VLCPlayListCheckInsert = 16\r
- };\r
-#define VLCPlayListEnd ( -666 )\r
-\r
-#define DISPID_Visible ( 1 )\r
-\r
-#define DISPID_Playing ( 2 )\r
-\r
-#define DISPID_Position ( 3 )\r
-\r
-#define DISPID_Time ( 4 )\r
-\r
-#define DISPID_Length ( 5 )\r
-\r
-#define DISPID_Volume ( 6 )\r
-\r
-#define DISPID_PlayEvent ( 1 )\r
-\r
-#define DISPID_PauseEvent ( 2 )\r
-\r
-#define DISPID_StopEvent ( 3 )\r
-\r
-\r
-EXTERN_C const IID LIBID_AXVLC;\r
-\r
-#ifndef __IVLCControl_INTERFACE_DEFINED__\r
-#define __IVLCControl_INTERFACE_DEFINED__\r
-\r
-/* interface IVLCControl */\r
-/* [object][oleautomation][hidden][dual][helpstring][uuid] */ \r
-\r
-\r
-EXTERN_C const IID IID_IVLCControl;\r
-\r
-#if defined(__cplusplus) && !defined(CINTERFACE)\r
- \r
- MIDL_INTERFACE("C2FA41D0-B113-476e-AC8C-9BD14999C1C1")\r
- IVLCControl : public IDispatch\r
- {\r
- public:\r
- virtual /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Value( \r
- /* [retval][out] */ VARIANT __RPC_FAR *pvarValue) = 0;\r
- \r
- virtual /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Value( \r
- /* [in] */ VARIANT pvarValue) = 0;\r
- \r
- virtual /* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE get_Visible( \r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible) = 0;\r
- \r
- virtual /* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE put_Visible( \r
- /* [in] */ VARIANT_BOOL visible) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE play( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE pause( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE stop( void) = 0;\r
- \r
- virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Playing( \r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying) = 0;\r
- \r
- virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Playing( \r
- /* [in] */ VARIANT_BOOL isPlaying) = 0;\r
- \r
- virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Position( \r
- /* [retval][out] */ float __RPC_FAR *position) = 0;\r
- \r
- virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position( \r
- /* [in] */ float position) = 0;\r
- \r
- virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Time( \r
- /* [retval][out] */ int __RPC_FAR *seconds) = 0;\r
- \r
- virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Time( \r
- /* [in] */ int seconds) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE shuttle( \r
- /* [in] */ int seconds) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE fullscreen( void) = 0;\r
- \r
- virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Length( \r
- /* [retval][out] */ int __RPC_FAR *seconds) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playFaster( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playSlower( void) = 0;\r
- \r
- virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Volume( \r
- /* [retval][out] */ int __RPC_FAR *volume) = 0;\r
- \r
- virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Volume( \r
- /* [in] */ int volume) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE addTarget( \r
- /* [in] */ BSTR uri,\r
- /* [in] */ VARIANT options,\r
- /* [in] */ enum VLCPlaylistMode mode,\r
- /* [in] */ int position) = 0;\r
- \r
- virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistIndex( \r
- /* [retval][out] */ int __RPC_FAR *index) = 0;\r
- \r
- virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_PlaylistCount( \r
- /* [retval][out] */ int __RPC_FAR *index) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistNext( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistPrev( void) = 0;\r
- \r
- virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistClear( void) = 0;\r
- \r
- virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_VersionInfo( \r
- /* [retval][out] */ BSTR __RPC_FAR *version) = 0;\r
- \r
- };\r
- \r
-#else /* C style interface */\r
-\r
- typedef struct IVLCControlVtbl\r
- {\r
- BEGIN_INTERFACE\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ REFIID riid,\r
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);\r
- \r
- ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [out] */ UINT __RPC_FAR *pctinfo);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ UINT iTInfo,\r
- /* [in] */ LCID lcid,\r
- /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ REFIID riid,\r
- /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,\r
- /* [in] */ UINT cNames,\r
- /* [in] */ LCID lcid,\r
- /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);\r
- \r
- /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ DISPID dispIdMember,\r
- /* [in] */ REFIID riid,\r
- /* [in] */ LCID lcid,\r
- /* [in] */ WORD wFlags,\r
- /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,\r
- /* [out] */ VARIANT __RPC_FAR *pVarResult,\r
- /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,\r
- /* [out] */ UINT __RPC_FAR *puArgErr);\r
- \r
- /* [helpstring][propget][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Value )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT __RPC_FAR *pvarValue);\r
- \r
- /* [helpstring][propput][defaultbind][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Value )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT pvarValue);\r
- \r
- /* [helpstring][bindable][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Visible )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);\r
- \r
- /* [helpstring][bindable][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Visible )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT_BOOL visible);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *play )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *pause )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *stop )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Playing )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying);\r
- \r
- /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Playing )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT_BOOL isPlaying);\r
- \r
- /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Position )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ float __RPC_FAR *position);\r
- \r
- /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Position )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ float position);\r
- \r
- /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Time )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *seconds);\r
- \r
- /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Time )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int seconds);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *shuttle )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int seconds);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *fullscreen )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Length )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *seconds);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playFaster )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playSlower )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Volume )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *volume);\r
- \r
- /* [helpstring][propput][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Volume )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int volume);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *toggleMute )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *addTarget )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ BSTR uri,\r
- /* [in] */ VARIANT options,\r
- /* [in] */ enum VLCPlaylistMode mode,\r
- /* [in] */ int position);\r
- \r
- /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistIndex )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *index);\r
- \r
- /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_PlaylistCount )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *index);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistNext )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistPrev )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistClear )( \r
- IVLCControl __RPC_FAR * This);\r
- \r
- /* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_VersionInfo )( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ BSTR __RPC_FAR *version);\r
- \r
- END_INTERFACE\r
- } IVLCControlVtbl;\r
-\r
- interface IVLCControl\r
- {\r
- CONST_VTBL struct IVLCControlVtbl __RPC_FAR *lpVtbl;\r
- };\r
-\r
- \r
-\r
-#ifdef COBJMACROS\r
-\r
-\r
-#define IVLCControl_QueryInterface(This,riid,ppvObject) \\r
- (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)\r
-\r
-#define IVLCControl_AddRef(This) \\r
- (This)->lpVtbl -> AddRef(This)\r
-\r
-#define IVLCControl_Release(This) \\r
- (This)->lpVtbl -> Release(This)\r
-\r
-\r
-#define IVLCControl_GetTypeInfoCount(This,pctinfo) \\r
- (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)\r
-\r
-#define IVLCControl_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \\r
- (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)\r
-\r
-#define IVLCControl_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \\r
- (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)\r
-\r
-#define IVLCControl_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \\r
- (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)\r
-\r
-\r
-#define IVLCControl_get_Value(This,pvarValue) \\r
- (This)->lpVtbl -> get_Value(This,pvarValue)\r
-\r
-#define IVLCControl_put_Value(This,pvarValue) \\r
- (This)->lpVtbl -> put_Value(This,pvarValue)\r
-\r
-#define IVLCControl_get_Visible(This,visible) \\r
- (This)->lpVtbl -> get_Visible(This,visible)\r
-\r
-#define IVLCControl_put_Visible(This,visible) \\r
- (This)->lpVtbl -> put_Visible(This,visible)\r
-\r
-#define IVLCControl_play(This) \\r
- (This)->lpVtbl -> play(This)\r
-\r
-#define IVLCControl_pause(This) \\r
- (This)->lpVtbl -> pause(This)\r
-\r
-#define IVLCControl_stop(This) \\r
- (This)->lpVtbl -> stop(This)\r
-\r
-#define IVLCControl_get_Playing(This,isPlaying) \\r
- (This)->lpVtbl -> get_Playing(This,isPlaying)\r
-\r
-#define IVLCControl_put_Playing(This,isPlaying) \\r
- (This)->lpVtbl -> put_Playing(This,isPlaying)\r
-\r
-#define IVLCControl_get_Position(This,position) \\r
- (This)->lpVtbl -> get_Position(This,position)\r
-\r
-#define IVLCControl_put_Position(This,position) \\r
- (This)->lpVtbl -> put_Position(This,position)\r
-\r
-#define IVLCControl_get_Time(This,seconds) \\r
- (This)->lpVtbl -> get_Time(This,seconds)\r
-\r
-#define IVLCControl_put_Time(This,seconds) \\r
- (This)->lpVtbl -> put_Time(This,seconds)\r
-\r
-#define IVLCControl_shuttle(This,seconds) \\r
- (This)->lpVtbl -> shuttle(This,seconds)\r
-\r
-#define IVLCControl_fullscreen(This) \\r
- (This)->lpVtbl -> fullscreen(This)\r
-\r
-#define IVLCControl_get_Length(This,seconds) \\r
- (This)->lpVtbl -> get_Length(This,seconds)\r
-\r
-#define IVLCControl_playFaster(This) \\r
- (This)->lpVtbl -> playFaster(This)\r
-\r
-#define IVLCControl_playSlower(This) \\r
- (This)->lpVtbl -> playSlower(This)\r
-\r
-#define IVLCControl_get_Volume(This,volume) \\r
- (This)->lpVtbl -> get_Volume(This,volume)\r
-\r
-#define IVLCControl_put_Volume(This,volume) \\r
- (This)->lpVtbl -> put_Volume(This,volume)\r
-\r
-#define IVLCControl_toggleMute(This) \\r
- (This)->lpVtbl -> toggleMute(This)\r
-\r
-#define IVLCControl_addTarget(This,uri,options,mode,position) \\r
- (This)->lpVtbl -> addTarget(This,uri,options,mode,position)\r
-\r
-#define IVLCControl_get_PlaylistIndex(This,index) \\r
- (This)->lpVtbl -> get_PlaylistIndex(This,index)\r
-\r
-#define IVLCControl_get_PlaylistCount(This,index) \\r
- (This)->lpVtbl -> get_PlaylistCount(This,index)\r
-\r
-#define IVLCControl_playlistNext(This) \\r
- (This)->lpVtbl -> playlistNext(This)\r
-\r
-#define IVLCControl_playlistPrev(This) \\r
- (This)->lpVtbl -> playlistPrev(This)\r
-\r
-#define IVLCControl_playlistClear(This) \\r
- (This)->lpVtbl -> playlistClear(This)\r
-\r
-#define IVLCControl_get_VersionInfo(This,version) \\r
- (This)->lpVtbl -> get_VersionInfo(This,version)\r
-\r
-#endif /* COBJMACROS */\r
-\r
-\r
-#endif /* C style interface */\r
-\r
-\r
-\r
-/* [helpstring][propget][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Value_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT __RPC_FAR *pvarValue);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Value_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propput][defaultbind][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Value_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT pvarValue);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Value_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][bindable][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Visible_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *visible);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Visible_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][bindable][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Visible_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT_BOOL visible);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Visible_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_play_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_play_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_pause_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_pause_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_stop_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_stop_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Playing_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Playing_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Playing_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ VARIANT_BOOL isPlaying);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Playing_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Position_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ float __RPC_FAR *position);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Position_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Position_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ float position);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Position_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Time_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *seconds);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Time_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Time_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int seconds);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Time_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_shuttle_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int seconds);\r
-\r
-\r
-void __RPC_STUB IVLCControl_shuttle_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_fullscreen_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_fullscreen_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Length_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *seconds);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Length_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playFaster_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_playFaster_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playSlower_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_playSlower_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Volume_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *volume);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_Volume_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Volume_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ int volume);\r
-\r
-\r
-void __RPC_STUB IVLCControl_put_Volume_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_toggleMute_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_toggleMute_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_addTarget_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [in] */ BSTR uri,\r
- /* [in] */ VARIANT options,\r
- /* [in] */ enum VLCPlaylistMode mode,\r
- /* [in] */ int position);\r
-\r
-\r
-void __RPC_STUB IVLCControl_addTarget_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistIndex_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *index);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_PlaylistIndex_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_PlaylistCount_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ int __RPC_FAR *index);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_PlaylistCount_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistNext_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_playlistNext_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistPrev_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_playlistPrev_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring] */ HRESULT STDMETHODCALLTYPE IVLCControl_playlistClear_Proxy( \r
- IVLCControl __RPC_FAR * This);\r
-\r
-\r
-void __RPC_STUB IVLCControl_playlistClear_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_VersionInfo_Proxy( \r
- IVLCControl __RPC_FAR * This,\r
- /* [retval][out] */ BSTR __RPC_FAR *version);\r
-\r
-\r
-void __RPC_STUB IVLCControl_get_VersionInfo_Stub(\r
- IRpcStubBuffer *This,\r
- IRpcChannelBuffer *_pRpcChannelBuffer,\r
- PRPC_MESSAGE _pRpcMessage,\r
- DWORD *_pdwStubPhase);\r
-\r
-\r
-\r
-#endif /* __IVLCControl_INTERFACE_DEFINED__ */\r
-\r
-\r
-#ifndef __DVLCEvents_DISPINTERFACE_DEFINED__\r
-#define __DVLCEvents_DISPINTERFACE_DEFINED__\r
-\r
-/* dispinterface DVLCEvents */\r
-/* [hidden][helpstring][uuid] */ \r
-\r
-\r
-EXTERN_C const IID DIID_DVLCEvents;\r
-\r
-#if defined(__cplusplus) && !defined(CINTERFACE)\r
-\r
- MIDL_INTERFACE("DF48072F-5EF8-434e-9B40-E2F3AE759B5F")\r
- DVLCEvents : public IDispatch\r
- {\r
- };\r
- \r
-#else /* C style interface */\r
-\r
- typedef struct DVLCEventsVtbl\r
- {\r
- BEGIN_INTERFACE\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *QueryInterface )( \r
- DVLCEvents __RPC_FAR * This,\r
- /* [in] */ REFIID riid,\r
- /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject);\r
- \r
- ULONG ( STDMETHODCALLTYPE __RPC_FAR *AddRef )( \r
- DVLCEvents __RPC_FAR * This);\r
- \r
- ULONG ( STDMETHODCALLTYPE __RPC_FAR *Release )( \r
- DVLCEvents __RPC_FAR * This);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfoCount )( \r
- DVLCEvents __RPC_FAR * This,\r
- /* [out] */ UINT __RPC_FAR *pctinfo);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetTypeInfo )( \r
- DVLCEvents __RPC_FAR * This,\r
- /* [in] */ UINT iTInfo,\r
- /* [in] */ LCID lcid,\r
- /* [out] */ ITypeInfo __RPC_FAR *__RPC_FAR *ppTInfo);\r
- \r
- HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetIDsOfNames )( \r
- DVLCEvents __RPC_FAR * This,\r
- /* [in] */ REFIID riid,\r
- /* [size_is][in] */ LPOLESTR __RPC_FAR *rgszNames,\r
- /* [in] */ UINT cNames,\r
- /* [in] */ LCID lcid,\r
- /* [size_is][out] */ DISPID __RPC_FAR *rgDispId);\r
- \r
- /* [local] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *Invoke )( \r
- DVLCEvents __RPC_FAR * This,\r
- /* [in] */ DISPID dispIdMember,\r
- /* [in] */ REFIID riid,\r
- /* [in] */ LCID lcid,\r
- /* [in] */ WORD wFlags,\r
- /* [out][in] */ DISPPARAMS __RPC_FAR *pDispParams,\r
- /* [out] */ VARIANT __RPC_FAR *pVarResult,\r
- /* [out] */ EXCEPINFO __RPC_FAR *pExcepInfo,\r
- /* [out] */ UINT __RPC_FAR *puArgErr);\r
- \r
- END_INTERFACE\r
- } DVLCEventsVtbl;\r
-\r
- interface DVLCEvents\r
- {\r
- CONST_VTBL struct DVLCEventsVtbl __RPC_FAR *lpVtbl;\r
- };\r
-\r
- \r
-\r
-#ifdef COBJMACROS\r
-\r
-\r
-#define DVLCEvents_QueryInterface(This,riid,ppvObject) \\r
- (This)->lpVtbl -> QueryInterface(This,riid,ppvObject)\r
-\r
-#define DVLCEvents_AddRef(This) \\r
- (This)->lpVtbl -> AddRef(This)\r
-\r
-#define DVLCEvents_Release(This) \\r
- (This)->lpVtbl -> Release(This)\r
-\r
-\r
-#define DVLCEvents_GetTypeInfoCount(This,pctinfo) \\r
- (This)->lpVtbl -> GetTypeInfoCount(This,pctinfo)\r
-\r
-#define DVLCEvents_GetTypeInfo(This,iTInfo,lcid,ppTInfo) \\r
- (This)->lpVtbl -> GetTypeInfo(This,iTInfo,lcid,ppTInfo)\r
-\r
-#define DVLCEvents_GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId) \\r
- (This)->lpVtbl -> GetIDsOfNames(This,riid,rgszNames,cNames,lcid,rgDispId)\r
-\r
-#define DVLCEvents_Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr) \\r
- (This)->lpVtbl -> Invoke(This,dispIdMember,riid,lcid,wFlags,pDispParams,pVarResult,pExcepInfo,puArgErr)\r
-\r
-#endif /* COBJMACROS */\r
-\r
-\r
-#endif /* C style interface */\r
-\r
-\r
-#endif /* __DVLCEvents_DISPINTERFACE_DEFINED__ */\r
-\r
-\r
-EXTERN_C const CLSID CLSID_VLCPlugin;\r
-\r
-#ifdef __cplusplus\r
-\r
-class DECLSPEC_UUID("E23FE9C6-778E-49D4-B537-38FCDE4887D8")\r
-VLCPlugin;\r
-#endif\r
-#endif /* __AXVLC_LIBRARY_DEFINED__ */\r
-\r
-/* Additional Prototypes for ALL interfaces */\r
-\r
-/* end of Additional Prototypes */\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-#endif\r
+/* 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 <rpcndr.h> 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
-/*****************************************************************************\r
- * connectioncontainer.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "connectioncontainer.h"\r
-\r
-#include "utils.h"\r
-\r
-using namespace std;\r
-\r
-////////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-class VLCEnumConnections : public IEnumConnections\r
-{\r
-public:\r
- VLCEnumConnections(vector<CONNECTDATA> &v) :\r
- e(VLCEnum<CONNECTDATA>(IID_IEnumConnections, v))\r
- { e.setRetainOperation((VLCEnum<CONNECTDATA>::retainer)&retain); };\r
-\r
- VLCEnumConnections(const VLCEnumConnections &vlcEnum) : e(vlcEnum.e) {};\r
-\r
- virtual ~VLCEnumConnections() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- { return e.QueryInterface(riid, ppv); };\r
- STDMETHODIMP_(ULONG) AddRef(void)\r
- { return e.AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void)\r
- {return e.Release(); };\r
-\r
- //IEnumConnectionPoints\r
- STDMETHODIMP Next(ULONG celt, LPCONNECTDATA rgelt, ULONG *pceltFetched)\r
- { return e.Next(celt, rgelt, pceltFetched); };\r
- STDMETHODIMP Skip(ULONG celt)\r
- { return e.Skip(celt);};\r
- STDMETHODIMP Reset(void)\r
- { return e.Reset();};\r
- STDMETHODIMP Clone(LPENUMCONNECTIONS *ppenum)\r
- { if( NULL == ppenum ) return E_POINTER;\r
- *ppenum = dynamic_cast<LPENUMCONNECTIONS>(new VLCEnumConnections(*this));\r
- return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY;\r
- };\r
-\r
-private:\r
-\r
- static void retain(CONNECTDATA cd)\r
- {\r
- cd.pUnk->AddRef();\r
- };\r
-\r
- VLCEnum<CONNECTDATA> e;\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-STDMETHODIMP VLCConnectionPoint::GetConnectionInterface(IID *iid)\r
-{\r
- if( NULL == iid )\r
- return E_POINTER;\r
-\r
- *iid = _iid;\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPoint::GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *ppCPC)\r
-{\r
- if( NULL == ppCPC )\r
- return E_POINTER;\r
-\r
- _p_cpc->AddRef();\r
- *ppCPC = _p_cpc;\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPoint::Advise(IUnknown *pUnk, DWORD *pdwCookie)\r
-{\r
- if( (NULL == pUnk) || (NULL == pdwCookie) )\r
- return E_POINTER;\r
-\r
- CONNECTDATA cd;\r
-\r
- pUnk->AddRef();\r
- cd.pUnk = pUnk;\r
- *pdwCookie = cd.dwCookie = _connections.size();\r
-\r
- _connections.push_back(cd);\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPoint::Unadvise(DWORD pdwCookie)\r
-{\r
- if( pdwCookie < _connections.size() )\r
- {\r
- CONNECTDATA cd = _connections[pdwCookie];\r
- if( NULL != cd.pUnk )\r
- {\r
- cd.pUnk->Release();\r
- cd.pUnk = NULL;\r
- return S_OK;\r
- }\r
- }\r
- return CONNECT_E_NOCONNECTION;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPoint::EnumConnections(IEnumConnections **ppEnum)\r
-{\r
- if( NULL == ppEnum )\r
- return E_POINTER;\r
-\r
- *ppEnum = dynamic_cast<LPENUMCONNECTIONS>(new VLCEnumConnections(_connections));\r
-\r
- return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY;\r
-};\r
-\r
-void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS* pDispParams)\r
-{\r
- vector<CONNECTDATA>::iterator end = _connections.end();\r
- vector<CONNECTDATA>::iterator iter = _connections.begin();\r
-\r
- while( iter != end )\r
- {\r
- CONNECTDATA cd = *iter;\r
- if( NULL != cd.pUnk )\r
- {\r
- IDispatch *pDisp;\r
- if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp)) )\r
- {\r
- pDisp->Invoke(dispId, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, pDispParams, NULL, NULL, NULL);\r
- pDisp->Release();\r
- }\r
- }\r
- ++iter;\r
- }\r
-};\r
-\r
-void VLCConnectionPoint::firePropChangedEvent(DISPID dispId)\r
-{\r
- vector<CONNECTDATA>::iterator end = _connections.end();\r
- vector<CONNECTDATA>::iterator iter = _connections.begin();\r
-\r
- while( iter != end )\r
- {\r
- CONNECTDATA cd = *iter;\r
- if( NULL != cd.pUnk )\r
- {\r
- IPropertyNotifySink *pPropSink;\r
- if( SUCCEEDED(cd.pUnk->QueryInterface(IID_IPropertyNotifySink, (LPVOID *)&pPropSink)) )\r
- {\r
- pPropSink->OnChanged(dispId);\r
- pPropSink->Release();\r
- }\r
- }\r
- ++iter;\r
- }\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-class VLCEnumConnectionPoints : public IEnumConnectionPoints\r
-{\r
-public:\r
- VLCEnumConnectionPoints(vector<LPCONNECTIONPOINT> &v) :\r
- e(VLCEnum<LPCONNECTIONPOINT>(IID_IEnumConnectionPoints, v))\r
- { e.setRetainOperation((VLCEnum<LPCONNECTIONPOINT>::retainer)&retain); };\r
-\r
- VLCEnumConnectionPoints(const VLCEnumConnectionPoints &vlcEnum) : e(vlcEnum.e) {};\r
-\r
- virtual ~VLCEnumConnectionPoints() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- { return e.QueryInterface(riid, ppv); };\r
- STDMETHODIMP_(ULONG) AddRef(void)\r
- { return e.AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void)\r
- {return e.Release(); };\r
-\r
- //IEnumConnectionPoints\r
- STDMETHODIMP Next(ULONG celt, LPCONNECTIONPOINT *rgelt, ULONG *pceltFetched)\r
- { return e.Next(celt, rgelt, pceltFetched); };\r
- STDMETHODIMP Skip(ULONG celt)\r
- { return e.Skip(celt);};\r
- STDMETHODIMP Reset(void)\r
- { return e.Reset();};\r
- STDMETHODIMP Clone(LPENUMCONNECTIONPOINTS *ppenum)\r
- { if( NULL == ppenum ) return E_POINTER;\r
- *ppenum = dynamic_cast<LPENUMCONNECTIONPOINTS>(new VLCEnumConnectionPoints(*this));\r
- return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY;\r
- };\r
-\r
-private:\r
-\r
- static void retain(LPCONNECTIONPOINT cp)\r
- {\r
- cp->AddRef();\r
- };\r
-\r
- VLCEnum<LPCONNECTIONPOINT> e;\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////////////////////////////\r
-\r
-VLCConnectionPointContainer::VLCConnectionPointContainer(VLCPlugin *p_instance) :\r
- _p_instance(p_instance)\r
-{\r
- _p_events = new VLCConnectionPoint(dynamic_cast<LPCONNECTIONPOINTCONTAINER>(this),\r
- _p_instance->getDispEventID());\r
-\r
- _v_cps.push_back(dynamic_cast<LPCONNECTIONPOINT>(_p_events));\r
-\r
- _p_props = new VLCConnectionPoint(dynamic_cast<LPCONNECTIONPOINTCONTAINER>(this),\r
- IID_IPropertyNotifySink);\r
-\r
- _v_cps.push_back(dynamic_cast<LPCONNECTIONPOINT>(_p_props));\r
-};\r
-\r
-VLCConnectionPointContainer::~VLCConnectionPointContainer()\r
-{\r
- _v_cps.clear();\r
- delete _p_props;\r
- delete _p_events;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPointContainer::EnumConnectionPoints(LPENUMCONNECTIONPOINTS *ppEnum)\r
-{\r
- if( NULL == ppEnum )\r
- return E_POINTER;\r
-\r
- *ppEnum = dynamic_cast<LPENUMCONNECTIONPOINTS>(new VLCEnumConnectionPoints(_v_cps));\r
-\r
- return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY;\r
-};\r
-\r
-STDMETHODIMP VLCConnectionPointContainer::FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP)\r
-{\r
- if( NULL == ppCP )\r
- return E_POINTER;\r
-\r
- *ppCP = NULL;\r
-\r
- if( IID_IPropertyNotifySink == riid )\r
- {\r
- _p_props->AddRef();\r
- *ppCP = dynamic_cast<LPCONNECTIONPOINT>(_p_props);\r
- }\r
- else if( _p_instance->getDispEventID() == riid )\r
- {\r
- _p_events->AddRef();\r
- *ppCP = dynamic_cast<LPCONNECTIONPOINT>(_p_events);\r
- }\r
- else\r
- return CONNECT_E_NOCONNECTION;\r
-\r
- return NOERROR;\r
-};\r
-\r
-void VLCConnectionPointContainer::fireEvent(DISPID dispId, DISPPARAMS* pDispParams)\r
-{\r
- _p_events->fireEvent(dispId, pDispParams);\r
-};\r
-\r
-void VLCConnectionPointContainer::firePropChangedEvent(DISPID dispId)\r
-{\r
- _p_props->firePropChangedEvent(dispId);\r
-};\r
-\r
+/*****************************************************************************
+ * connectioncontainer.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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<CONNECTDATA> &v) :
+ e(VLCEnum<CONNECTDATA>(IID_IEnumConnections, v))
+ { e.setRetainOperation((VLCEnum<CONNECTDATA>::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<LPENUMCONNECTIONS>(new VLCEnumConnections(*this));
+ return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY;
+ };
+
+private:
+
+ static void retain(CONNECTDATA cd)
+ {
+ cd.pUnk->AddRef();
+ };
+
+ VLCEnum<CONNECTDATA> 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<LPENUMCONNECTIONS>(new VLCEnumConnections(_connections));
+
+ return (NULL != *ppEnum ) ? S_OK : E_OUTOFMEMORY;
+};
+
+void VLCConnectionPoint::fireEvent(DISPID dispId, DISPPARAMS* pDispParams)
+{
+ vector<CONNECTDATA>::iterator end = _connections.end();
+ vector<CONNECTDATA>::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<CONNECTDATA>::iterator end = _connections.end();
+ vector<CONNECTDATA>::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<LPCONNECTIONPOINT> &v) :
+ e(VLCEnum<LPCONNECTIONPOINT>(IID_IEnumConnectionPoints, v))
+ { e.setRetainOperation((VLCEnum<LPCONNECTIONPOINT>::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<LPENUMCONNECTIONPOINTS>(new VLCEnumConnectionPoints(*this));
+ return (NULL != *ppenum) ? S_OK : E_OUTOFMEMORY;
+ };
+
+private:
+
+ static void retain(LPCONNECTIONPOINT cp)
+ {
+ cp->AddRef();
+ };
+
+ VLCEnum<LPCONNECTIONPOINT> e;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+VLCConnectionPointContainer::VLCConnectionPointContainer(VLCPlugin *p_instance) :
+ _p_instance(p_instance)
+{
+ _p_events = new VLCConnectionPoint(dynamic_cast<LPCONNECTIONPOINTCONTAINER>(this),
+ _p_instance->getDispEventID());
+
+ _v_cps.push_back(dynamic_cast<LPCONNECTIONPOINT>(_p_events));
+
+ _p_props = new VLCConnectionPoint(dynamic_cast<LPCONNECTIONPOINTCONTAINER>(this),
+ IID_IPropertyNotifySink);
+
+ _v_cps.push_back(dynamic_cast<LPCONNECTIONPOINT>(_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<LPENUMCONNECTIONPOINTS>(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<LPCONNECTIONPOINT>(_p_props);
+ }
+ else if( _p_instance->getDispEventID() == riid )
+ {
+ _p_events->AddRef();
+ *ppCP = dynamic_cast<LPCONNECTIONPOINT>(_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);
+};
+
-/*****************************************************************************\r
- * connectioncontainer.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __CONNECTIONCONTAINER_H__\r
-#define __CONNECTIONCONTAINER_H__\r
-\r
-#include <ocidl.h>\r
-#include <vector>\r
-\r
-using namespace std;\r
-\r
-class VLCConnectionPoint : public IConnectionPoint\r
-{\r
-\r
-public:\r
-\r
- VLCConnectionPoint(IConnectionPointContainer *p_cpc, REFIID iid) :\r
- _iid(iid), _p_cpc(p_cpc) {};\r
- virtual ~VLCConnectionPoint() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( NULL == ppv ) return E_POINTER;\r
- if( (IID_IUnknown == riid) \r
- && (IID_IConnectionPoint == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- // must be a standalone object\r
- return E_NOINTERFACE;\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_cpc->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_cpc->Release(); };\r
-\r
- // IConnectionPoint methods\r
- STDMETHODIMP GetConnectionInterface(IID *);\r
- STDMETHODIMP GetConnectionPointContainer(LPCONNECTIONPOINTCONTAINER *);\r
- STDMETHODIMP Advise(IUnknown *, DWORD *);\r
- STDMETHODIMP Unadvise(DWORD);\r
- STDMETHODIMP EnumConnections(LPENUMCONNECTIONS *);\r
-\r
- void fireEvent(DISPID dispIdMember, DISPPARAMS* pDispParams);\r
- void firePropChangedEvent(DISPID dispId);\r
-\r
-private:\r
-\r
- REFIID _iid;\r
- IConnectionPointContainer *_p_cpc;\r
- vector<CONNECTDATA> _connections;\r
-};\r
-\r
-//////////////////////////////////////////////////////////////////////////\r
-\r
-class VLCConnectionPointContainer : public IConnectionPointContainer\r
-{\r
-\r
-public:\r
-\r
- VLCConnectionPointContainer(VLCPlugin *p_instance);\r
- virtual ~VLCConnectionPointContainer();\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IConnectionPointContainer == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IConnectionPointContainer methods\r
- STDMETHODIMP EnumConnectionPoints(LPENUMCONNECTIONPOINTS *);\r
- STDMETHODIMP FindConnectionPoint(REFIID, LPCONNECTIONPOINT *);\r
-\r
- void fireEvent(DISPID, DISPPARAMS*);\r
- void firePropChangedEvent(DISPID dispId);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
- VLCConnectionPoint *_p_events;\r
- VLCConnectionPoint *_p_props;\r
- vector<LPCONNECTIONPOINT> _v_cps;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * connectioncontainer.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ocidl.h>
+#include <vector>
+
+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<LPVOID>(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<CONNECTDATA> _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<LPVOID>(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<LPCONNECTIONPOINT> _v_cps;
+};
+
+#endif
+
-/*****************************************************************************\r
- * main.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-\r
-#include <comcat.h>\r
-#include <windows.h>\r
-#include <shlwapi.h>\r
-\r
-using namespace std;\r
-\r
-#define THREADING_MODEL "Both"\r
-#define COMPANY_STR "VideoLAN"\r
-#define PROGRAM_STR "VLCPlugin"\r
-#define VERSION_MAJOR_STR "1"\r
-#define VERSION_MINOR_STR "0"\r
-#define DESCRIPTION "VideoLAN VLC ActiveX Plugin"\r
-\r
-#define PROGID_STR COMPANY_STR"."PROGRAM_STR\r
-#define VERS_PROGID_STR COMPANY_STR"."PROGRAM_STR"."VERSION_MAJOR_STR\r
-#define VERSION_STR VERSION_MAJOR_STR"."VERSION_MINOR_STR\r
-\r
-#define GUID_STRLEN 39\r
-\r
-/*\r
-** MingW headers do not declare those\r
-*/\r
-extern const CATID CATID_SafeForInitializing;\r
-extern const CATID CATID_SafeForScripting;\r
-\r
-static LONG i_class_ref= 0;\r
-static HINSTANCE h_instance= 0;\r
-\r
-STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)\r
-{\r
- HRESULT hr = CLASS_E_CLASSNOTAVAILABLE;\r
-\r
- *ppv = NULL;\r
-\r
- if( CLSID_VLCPlugin == rclsid )\r
- {\r
- VLCPluginClass *plugin = new VLCPluginClass(&i_class_ref, h_instance);\r
- hr = plugin->QueryInterface(riid, ppv);\r
- plugin->Release();\r
- }\r
- return hr;\r
-};\r
-\r
-STDAPI DllCanUnloadNow(VOID)\r
-{\r
- return (0 == i_class_ref) ? S_OK: S_FALSE;\r
-};\r
-\r
-static LPCTSTR TStrFromGUID(REFGUID clsid) {\r
- LPOLESTR oleStr;\r
-\r
- if( FAILED(StringFromIID(clsid, &oleStr)) )\r
- return NULL;\r
-\r
- //check whether TCHAR and OLECHAR are both either ANSI or UNICODE\r
- if( sizeof(TCHAR) == sizeof(OLECHAR) )\r
- return (LPCTSTR)oleStr;\r
-\r
- LPTSTR pct_CLSID = NULL;\r
-#ifndef OLE2ANSI\r
- size_t len = WideCharToMultiByte(CP_ACP, 0, oleStr, -1, NULL, 0, NULL, NULL);\r
- if( len > 0 )\r
- {\r
- pct_CLSID = (char *)CoTaskMemAlloc(len);\r
- WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len, NULL, NULL);\r
- }\r
-#else\r
- size_t len = MutiByteToWideChar(CP_ACP, 0, oleStr, -1, NULL, 0);\r
- if( len > 0 )\r
- {\r
- clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t));\r
- WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len);\r
- }\r
-#endif\r
- CoTaskMemFree(oleStr);\r
- return pct_CLSID;\r
-};\r
-\r
-static HKEY keyCreate(HKEY parentKey, LPCTSTR keyName)\r
-{\r
- HKEY childKey;\r
- if( ERROR_SUCCESS == RegCreateKeyEx(parentKey, keyName, 0, NULL,\r
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &childKey, NULL) )\r
- {\r
- return childKey;\r
- }\r
- return NULL;\r
-};\r
-\r
-STDAPI DllUnregisterServer(VOID)\r
-{\r
- // unregister type lib from the registry\r
- UnRegisterTypeLib(LIBID_AXVLC, 1, 0, LOCALE_NEUTRAL, SYS_WIN32);\r
-\r
- // remove component categories we supports\r
- ICatRegister *pcr;\r
- if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, \r
- NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) {\r
- CATID implCategories[] = {\r
- CATID_Control,\r
- CATID_PersistsToPropertyBag,\r
- CATID_SafeForInitializing,\r
- CATID_SafeForScripting,\r
- };\r
-\r
- pcr->UnRegisterClassImplCategories(CLSID_VLCPlugin,\r
- sizeof(implCategories)/sizeof(CATID), implCategories);\r
- pcr->Release();\r
- }\r
-\r
- SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR));\r
- SHDeleteKey(HKEY_CLASSES_ROOT, TEXT(PROGID_STR));\r
-\r
- LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin);\r
-\r
- if( NULL == psz_CLSID )\r
- return E_OUTOFMEMORY;\r
-\r
- HKEY hClsIDKey;\r
- if( ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_WRITE, &hClsIDKey) )\r
- {\r
- SHDeleteKey(hClsIDKey, psz_CLSID);\r
- RegCloseKey(hClsIDKey);\r
- }\r
- CoTaskMemFree((void *)psz_CLSID);\r
-\r
- return S_OK;\r
-};\r
-\r
-STDAPI DllRegisterServer(VOID)\r
-{\r
- DllUnregisterServer();\r
-\r
- char DllPath[MAX_PATH];\r
- DWORD DllPathLen= GetModuleFileName(h_instance, DllPath, sizeof(DllPath)) ;\r
- if( 0 == DllPathLen )\r
- return E_FAIL;\r
-\r
- LPCTSTR psz_CLSID = TStrFromGUID(CLSID_VLCPlugin);\r
-\r
- if( NULL == psz_CLSID )\r
- return E_OUTOFMEMORY;\r
-\r
- HKEY hBaseKey;\r
-\r
- if( ERROR_SUCCESS != RegOpenKeyEx(HKEY_CLASSES_ROOT, TEXT("CLSID"), 0, KEY_CREATE_SUB_KEY, &hBaseKey) )\r
- return E_FAIL;\r
-\r
- HKEY hClassKey = keyCreate(hBaseKey, psz_CLSID);\r
- if( NULL != hClassKey )\r
- {\r
- HKEY hSubKey;\r
-\r
- // default key value\r
- RegSetValueEx(hClassKey, NULL, 0, REG_SZ,\r
- (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION));\r
-\r
- // Control key value\r
- hSubKey = keyCreate(hClassKey, TEXT("Control"));\r
- RegCloseKey(hSubKey);\r
-\r
- // InprocServer32 key value\r
- hSubKey = keyCreate(hClassKey, TEXT("InprocServer32"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)DllPath, DllPathLen);\r
- RegSetValueEx(hSubKey, TEXT("ThreadingModel"), 0, REG_SZ,\r
- (const BYTE*)THREADING_MODEL, sizeof(THREADING_MODEL));\r
- RegCloseKey(hSubKey);\r
-\r
- // MiscStatus key value\r
- hSubKey = keyCreate(hClassKey, TEXT("MiscStatus\\1"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ, (const BYTE*)"131473", sizeof("131473"));\r
- RegCloseKey(hSubKey);\r
-\r
- // Programmable key value\r
- hSubKey = keyCreate(hClassKey, TEXT("Programmable"));\r
- RegCloseKey(hSubKey);\r
-\r
- // ProgID key value\r
- hSubKey = keyCreate(hClassKey, TEXT("ProgID"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ, \r
- (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR));\r
- RegCloseKey(hSubKey);\r
-\r
- // VersionIndependentProgID key value\r
- hSubKey = keyCreate(hClassKey, TEXT("VersionIndependentProgID"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ, \r
- (const BYTE*)PROGID_STR, sizeof(PROGID_STR));\r
- RegCloseKey(hSubKey);\r
-\r
- // Version key value\r
- hSubKey = keyCreate(hClassKey, TEXT("Version"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)VERSION_STR, sizeof(VERSION_STR));\r
- RegCloseKey(hSubKey);\r
-\r
- // TypeLib key value\r
- LPCTSTR psz_LIBID = TStrFromGUID(LIBID_AXVLC);\r
- if( NULL != psz_LIBID )\r
- {\r
- hSubKey = keyCreate(hClassKey, TEXT("TypeLib"));\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)psz_LIBID, sizeof(TCHAR)*GUID_STRLEN);\r
- RegCloseKey(hSubKey);\r
- }\r
- RegCloseKey(hClassKey);\r
- }\r
- RegCloseKey(hBaseKey);\r
-\r
- hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(PROGID_STR));\r
- if( NULL != hBaseKey )\r
- {\r
- // default key value\r
- RegSetValueEx(hBaseKey, NULL, 0, REG_SZ,\r
- (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION));\r
-\r
- HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID"));\r
- if( NULL != hSubKey )\r
- {\r
- // default key value\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN);\r
-\r
- RegCloseKey(hSubKey);\r
- }\r
- hSubKey = keyCreate(hBaseKey, TEXT("CurVer"));\r
- if( NULL != hSubKey )\r
- {\r
- // default key value\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)VERS_PROGID_STR, sizeof(VERS_PROGID_STR));\r
-\r
- RegCloseKey(hSubKey);\r
- }\r
- RegCloseKey(hBaseKey);\r
- }\r
-\r
- hBaseKey = keyCreate(HKEY_CLASSES_ROOT, TEXT(VERS_PROGID_STR));\r
- if( NULL != hBaseKey )\r
- {\r
- // default key value\r
- RegSetValueEx(hBaseKey, NULL, 0, REG_SZ,\r
- (const BYTE*)DESCRIPTION, sizeof(DESCRIPTION));\r
-\r
- HKEY hSubKey = keyCreate(hBaseKey, TEXT("CLSID"));\r
- if( NULL != hSubKey )\r
- {\r
- // default key value\r
- RegSetValueEx(hSubKey, NULL, 0, REG_SZ,\r
- (const BYTE*)psz_CLSID, sizeof(TCHAR)*GUID_STRLEN);\r
-\r
- RegCloseKey(hSubKey);\r
- }\r
- RegCloseKey(hBaseKey);\r
- }\r
-\r
- // indicate which component categories we support\r
- ICatRegister *pcr;\r
- if( SUCCEEDED(CoCreateInstance(CLSID_StdComponentCategoriesMgr, \r
- NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr)) ) {\r
- CATID implCategories[] = {\r
- CATID_Control,\r
- CATID_PersistsToPropertyBag,\r
- CATID_SafeForInitializing,\r
- CATID_SafeForScripting,\r
- };\r
-\r
- pcr->RegisterClassImplCategories(CLSID_VLCPlugin,\r
- sizeof(implCategories)/sizeof(CATID), implCategories);\r
- pcr->Release();\r
- }\r
-\r
- // register type lib into the registry\r
- ITypeLib *typeLib;\r
-#ifndef OLE2ANSI\r
- size_t typeLibPathLen = MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, NULL, 0);\r
- if( typeLibPathLen > 0 )\r
- {\r
- LPOLESTR typeLibPath = (LPOLESTR)CoTaskMemAlloc(typeLibPathLen*sizeof(wchar_t));\r
- MultiByteToWideChar(CP_ACP, 0, DllPath, DllPathLen, typeLibPath, typeLibPathLen);\r
- if( SUCCEEDED(LoadTypeLibEx(typeLibPath, REGKIND_REGISTER, &typeLib)) )\r
- typeLib->Release();\r
- CoTaskMemFree((void *)typeLibPath);\r
- }\r
-#else\r
- if( SUCCEEDED(LoadTypeLibEx((LPOLESTR)DllPath, REGKIND_REGISTER, &typeLib)) )\r
- typeLib->Release();\r
-#endif\r
-\r
- CoTaskMemFree((void *)psz_CLSID);\r
-\r
- return S_OK;\r
-};\r
-\r
-#ifdef BUILD_LOCALSERVER\r
-\r
-/*\r
-** easier to debug an application than a DLL on cygwin GDB :)\r
-*/\r
-#include <iostream>\r
-\r
-STDAPI_(int) WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)\r
-{\r
- MSG msg;\r
-\r
- if( FAILED(OleInitialize(NULL)) )\r
- {\r
- cerr << "cannot initialize OLE" << endl;\r
- return 1;\r
- }\r
-\r
- IUnknown *classProc = NULL;\r
-\r
- if( FAILED(DllGetClassObject(CLSID_VLCPlugin, IID_IUnknown, (LPVOID *)&classProc)) )\r
- return 0;\r
- \r
- DWORD dwRegisterClassObject;\r
-\r
- if( FAILED(CoRegisterClassObject(CLSID_VLCPlugin, classProc,\r
- CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE, &dwRegisterClassObject)) )\r
- return 0;\r
-\r
- DWORD dwRegisterActiveObject;\r
-\r
- if( FAILED(RegisterActiveObject(classProc, CLSID_VLCPlugin,\r
- ACTIVEOBJECT_WEAK, &dwRegisterActiveObject)) )\r
- return 0;\r
-\r
- classProc->Release();\r
-\r
- /*\r
- * Polling messages from event queue\r
- */\r
- while( S_FALSE == DllCanUnloadNow() )\r
- {\r
- while( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) )\r
- {\r
- if( msg.message == WM_QUIT )\r
- break; // Leave the PeekMessage while() loop\r
-\r
- /*if(TranslateAccelerator(ghwndApp, ghAccel, &msg))\r
- continue;*/\r
-\r
- TranslateMessage(&msg);\r
- DispatchMessage(&msg);\r
- }\r
-\r
- if(msg.message == WM_QUIT)\r
- break; // Leave the for() loop\r
-\r
- WaitMessage();\r
- }\r
-\r
- if( SUCCEEDED(RevokeActiveObject(dwRegisterActiveObject, NULL)) )\r
- CoRevokeClassObject(dwRegisterClassObject);\r
-\r
- // Reached on WM_QUIT message\r
- CoUninitialize();\r
- return ((int) msg.wParam);\r
-};\r
-\r
-#else\r
-\r
-STDAPI_(BOOL) DllMain(HANDLE hModule, DWORD fdwReason, LPVOID lpReserved )\r
-{\r
- switch( fdwReason )\r
- {\r
- case DLL_PROCESS_ATTACH:\r
- h_instance = (HINSTANCE)hModule;\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- return TRUE;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * main.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <comcat.h>
+#include <windows.h>
+#include <shlwapi.h>
+
+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 <iostream>
+
+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
+
-/*****************************************************************************\r
- * objectsafety.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "objectsafety.h"\r
-\r
-#include "axvlc_idl.h"\r
-\r
-#if 0\r
-const GUID IID_IObjectSafety = \r
- {0xCB5BDC81,0x93C1,0x11cf,{0x8F,0x20,0x00,0x80,0x5F,0x2C,0xD0,0x64}}; \r
-#endif\r
-\r
-STDMETHODIMP VLCObjectSafety::GetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD *pdwSupportedOptions,\r
- DWORD *pdwEnabledOptions\r
-)\r
-{\r
- if( (NULL == pdwSupportedOptions) || (NULL == pdwEnabledOptions) )\r
- return E_POINTER;\r
-\r
- *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA|INTERFACESAFE_FOR_UNTRUSTED_CALLER;\r
-\r
- if( (IID_IDispatch == riid)\r
- || (IID_IVLCControl == riid) )\r
- {\r
- *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER;\r
- return NOERROR;\r
- }\r
- else if( (IID_IPersist == riid)\r
- || (IID_IPersistStreamInit == riid)\r
- || (IID_IPersistStorage == riid)\r
- || (IID_IPersistPropertyBag == riid) )\r
- {\r
- *pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA;\r
- return NOERROR;\r
- }\r
- *pdwEnabledOptions = 0;\r
- return E_NOINTERFACE;\r
-};\r
-\r
-STDMETHODIMP VLCObjectSafety::SetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD dwOptionSetMask,\r
- DWORD dwEnabledOptions\r
-)\r
-{\r
- if( (IID_IDispatch == riid)\r
- || (IID_IVLCControl == riid) )\r
- {\r
- if( (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwOptionSetMask)\r
- && (INTERFACESAFE_FOR_UNTRUSTED_CALLER == dwEnabledOptions) )\r
- {\r
- return NOERROR;\r
- }\r
- return E_FAIL;\r
- }\r
- else if( (IID_IPersist == riid)\r
- || (IID_IPersistStreamInit == riid)\r
- || (IID_IPersistStorage == riid)\r
- || (IID_IPersistPropertyBag == riid) )\r
- {\r
- if( (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwOptionSetMask)\r
- && (INTERFACESAFE_FOR_UNTRUSTED_DATA == dwEnabledOptions) )\r
- {\r
- return NOERROR;\r
- }\r
- return E_FAIL;\r
- }\r
- return E_FAIL;\r
-};\r
-\r
+/*****************************************************************************
+ * objectsafety.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * objectsafety.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __OBJECTSAFETY_H__\r
-#define __OBJECTSAFETY_H__\r
-\r
-#if HAVE_OBJSAFE_HEADER\r
-/*\r
-** at last, a version of mingw that supports this header\r
-*/\r
-#include <objsafe.h>\r
-\r
-#else\r
-\r
-// {CB5BDC81-93C1-11cf-8F20-00805F2CD064}\r
-extern "C" const IID IID_IObjectSafety;\r
-\r
-#define INTERFACESAFE_FOR_UNTRUSTED_CALLER 1L\r
-#define INTERFACESAFE_FOR_UNTRUSTED_DATA 2L\r
-\r
-struct IObjectSafety : public IUnknown\r
-{\r
- virtual STDMETHODIMP GetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD __RPC_FAR *pdwSupportedOptions,\r
- DWORD __RPC_FAR *pdwEnabledOptions\r
- ) = 0;\r
-\r
- virtual STDMETHODIMP SetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD dwSupportedOptions,\r
- DWORD dwOptionSetMask\r
- ) = 0;\r
-};\r
-\r
-#endif\r
-\r
-class VLCObjectSafety : public IObjectSafety\r
-{\r
-public:\r
-\r
- VLCObjectSafety(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCObjectSafety() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid)\r
- && (IID_IObjectSafety == riid) ) \r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IUnknown methods\r
- STDMETHODIMP GetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD *pdwSupportedOptions,\r
- DWORD *pdwEnabledOptions\r
- );\r
-\r
- STDMETHODIMP SetInterfaceSafetyOptions( \r
- REFIID riid,\r
- DWORD dwOptionSetMask,\r
- DWORD dwEnabledOptions\r
- );\r
-\r
-private: \r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
+/*****************************************************************************
+ * objectsafety.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <objsafe.h>
+
+#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<LPVOID>(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
-/*****************************************************************************\r
- * olecontrol.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "olecontrol.h"\r
-\r
-#include "utils.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI)\r
-{\r
- if( NULL == pCI )\r
- return E_POINTER;\r
-\r
- pCI->cb = sizeof(CONTROLINFO);\r
- pCI->hAccel = NULL;\r
- pCI->cAccel = 0;\r
- pCI->dwFlags = 0;\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v)\r
-{\r
- HRESULT hr;\r
- IOleObject *oleObj;\r
-\r
- hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);\r
- if( SUCCEEDED(hr) )\r
- {\r
- IOleClientSite *clientSite;\r
-\r
- hr = oleObj->GetClientSite(&clientSite);\r
- if( SUCCEEDED(hr) && (NULL != clientSite) )\r
- {\r
- hr = GetObjectProperty(clientSite, dispID, v);\r
- clientSite->Release();\r
- }\r
- oleObj->Release();\r
- }\r
- return hr;\r
-};\r
-\r
-STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)\r
-{\r
- switch( dispID )\r
- {\r
- case DISPID_AMBIENT_BACKCOLOR:\r
- break;\r
- case DISPID_AMBIENT_DISPLAYNAME:\r
- break;\r
- case DISPID_AMBIENT_FONT:\r
- break;\r
- case DISPID_AMBIENT_FORECOLOR:\r
- break;\r
- case DISPID_AMBIENT_LOCALEID:\r
- break;\r
- case DISPID_AMBIENT_MESSAGEREFLECT:\r
- break;\r
- case DISPID_AMBIENT_SCALEUNITS:\r
- break;\r
- case DISPID_AMBIENT_TEXTALIGN:\r
- break;\r
- case DISPID_AMBIENT_USERMODE:\r
- break;\r
- case DISPID_AMBIENT_UIDEAD:\r
- break;\r
- case DISPID_AMBIENT_SHOWGRABHANDLES:\r
- break;\r
- case DISPID_AMBIENT_SHOWHATCHING:\r
- break;\r
- case DISPID_AMBIENT_DISPLAYASDEFAULT:\r
- break;\r
- case DISPID_AMBIENT_SUPPORTSMNEMONICS:\r
- break;\r
- case DISPID_AMBIENT_AUTOCLIP:\r
- break;\r
- case DISPID_AMBIENT_APPEARANCE:\r
- break;\r
- case DISPID_AMBIENT_CODEPAGE:\r
- VARIANT v;\r
- VariantInit(&v);\r
- V_VT(&v) = VT_I4;\r
- if( SUCCEEDED(getAmbientProperty(*_p_instance, dispID, v)) )\r
- {\r
- _p_instance->setCodePage(V_I4(&v));\r
- }\r
- break;\r
- case DISPID_AMBIENT_PALETTE:\r
- break;\r
- case DISPID_AMBIENT_CHARSET:\r
- break;\r
- case DISPID_AMBIENT_RIGHTTOLEFT:\r
- break;\r
- case DISPID_AMBIENT_TOPTOBOTTOM:\r
- break;\r
- default:\r
- break;\r
- }\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleControl::FreezeEvents(BOOL bFreeze)\r
-{\r
- _p_instance->setSendEvents(! bFreeze);\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * olecontrol.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * olecontrol.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __OLECONTROL_H__\r
-#define __OLECONTROL_H__\r
-\r
-#include <olectl.h>\r
-\r
-class VLCOleControl : public IOleControl\r
-{\r
-\r
-public:\r
-\r
- VLCOleControl(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCOleControl() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid)\r
- && (IID_IOleControl == riid) ) \r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IOleControl methods\r
- STDMETHODIMP GetControlInfo(CONTROLINFO *pCI);\r
- STDMETHODIMP OnMnemonic(LPMSG pMsg);\r
- STDMETHODIMP OnAmbientPropertyChange(DISPID dispID);\r
- STDMETHODIMP FreezeEvents(BOOL bFreeze);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * olecontrol.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <olectl.h>
+
+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<LPVOID>(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
+
-/*****************************************************************************\r
- * oleinplaceactiveobject.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "oleinplaceactiveobject.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd)\r
-{\r
- if( NULL == pHwnd )\r
- return E_INVALIDARG;\r
-\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )\r
- return S_OK;\r
-\r
- return E_FAIL;\r
- }\r
- *pHwnd = NULL;\r
-\r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::ContextSensitiveHelp(BOOL fEnterMode)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::TranslateAccelerator(LPMSG lpmsg)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::OnFrameWindowActivate(BOOL fActivate)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::OnDocWindowActivate(BOOL fActivate)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceActiveObject::ResizeBorder(LPCRECT prcBorder, LPOLEINPLACEUIWINDOW pUIWindow, BOOL fFrameWindow)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
+/*****************************************************************************
+ * oleinplaceactiveobject.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * oleinplaceactiveobject.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __OLEINPLACEACTIVEOBJECT_H__\r
-#define __OLEINPLACEACTIVEOBJECT_H__\r
-\r
-#include "oleidl.h"\r
-\r
-class VLCOleInPlaceActiveObject : public IOleInPlaceActiveObject\r
-{\r
-\r
-public:\r
-\r
- VLCOleInPlaceActiveObject(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCOleInPlaceActiveObject() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IOleWindow == riid) \r
- && (IID_IOleInPlaceActiveObject == riid) )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IOleWindow methods\r
- STDMETHODIMP GetWindow(HWND *);\r
- STDMETHODIMP ContextSensitiveHelp(BOOL);\r
-\r
- // IOleInPlaceActiveObject methods\r
- STDMETHODIMP EnableModeless(BOOL);\r
- STDMETHODIMP TranslateAccelerator(LPMSG);\r
- STDMETHODIMP OnFrameWindowActivate(BOOL);\r
- STDMETHODIMP OnDocWindowActivate(BOOL);\r
- STDMETHODIMP ResizeBorder(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * oleinplaceactiveobject.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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<LPVOID>(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
+
-/*****************************************************************************\r
- * oleinplaceobject.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "oleinplaceobject.h"\r
-\r
-#include <docobj.h>\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)\r
-{\r
- if( NULL == pHwnd )\r
- return E_INVALIDARG;\r
-\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )\r
- return S_OK;\r
-\r
- return E_FAIL;\r
- }\r
- *pHwnd = NULL;\r
-\r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)\r
-{\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- UIDeactivate();\r
- _p_instance->onInPlaceDeactivate();\r
-\r
- LPOLEOBJECT p_oleObject;\r
- if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) \r
- {\r
- LPOLECLIENTSITE p_clientSite;\r
- if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )\r
- {\r
- LPOLEINPLACESITE p_inPlaceSite;\r
-\r
- if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )\r
- {\r
- p_inPlaceSite->OnInPlaceDeactivate();\r
- p_inPlaceSite->Release();\r
- }\r
- p_clientSite->Release();\r
- }\r
- p_oleObject->Release();\r
- }\r
- return S_OK;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)\r
-{\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- if( _p_instance->hasFocus() )\r
- {\r
- _p_instance->setFocus(FALSE);\r
-\r
- LPOLEOBJECT p_oleObject;\r
- if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) ) \r
- {\r
- LPOLECLIENTSITE p_clientSite;\r
- if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )\r
- {\r
- LPOLEINPLACESITE p_inPlaceSite;\r
-\r
- if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )\r
- {\r
- p_inPlaceSite->OnUIDeactivate(FALSE);\r
- p_inPlaceSite->Release();\r
- }\r
- p_clientSite->Release();\r
- }\r
- p_oleObject->Release();\r
- }\r
- return S_OK;\r
- }\r
- }\r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)\r
-{\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- _p_instance->onPositionChange(lprcPosRect, lprcClipRect);\r
- return S_OK;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleInPlaceObject::ReactivateAndUndo(void)\r
-{\r
- return INPLACE_E_NOTUNDOABLE;\r
-};\r
-\r
+/*****************************************************************************
+ * oleinplaceobject.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <docobj.h>
+
+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;
+};
+
-/*****************************************************************************\r
- * oleinplaceobject.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __OLEINPLACEOBJECT_H__\r
-#define __OLEINPLACEOBJECT_H__\r
-\r
-class VLCOleInPlaceObject : public IOleInPlaceObject\r
-{\r
-\r
-public:\r
-\r
- VLCOleInPlaceObject(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCOleInPlaceObject() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid)\r
- && (IID_IOleWindow == riid)\r
- && (IID_IOleInPlaceObject == riid) ) \r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IOleWindow methods\r
- STDMETHODIMP GetWindow(HWND *);\r
- STDMETHODIMP ContextSensitiveHelp(BOOL);\r
-\r
- // IOleInPlaceObject methods\r
- STDMETHODIMP InPlaceDeactivate(void);\r
- STDMETHODIMP UIDeactivate(void);\r
- STDMETHODIMP SetObjectRects(LPCRECT, LPCRECT);\r
- STDMETHODIMP ReactivateAndUndo(void);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * oleinplaceobject.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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<LPVOID>(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
+
-/*****************************************************************************\r
- * oleobject.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "oleobject.h"\r
-\r
-#include "utils.h"\r
-\r
-#include <docobj.h>\r
-\r
-using namespace std;\r
-\r
-VLCOleObject::VLCOleObject(VLCPlugin *p_instance) :\r
-_p_clientsite(NULL), _p_instance(p_instance) \r
-{\r
- CreateOleAdviseHolder(&_p_advise_holder);\r
-};\r
-\r
-VLCOleObject::~VLCOleObject()\r
-{\r
- _p_advise_holder->Release();\r
- SetClientSite(NULL); \r
-};\r
-\r
-STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)\r
-{\r
- return _p_advise_holder->Advise(pAdvSink, dwConnection);\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)\r
-{\r
- _p_advise_holder->SendOnClose();\r
- OleFlushClipboard();\r
- return _p_instance->onClose(dwSaveOption);\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,\r
- LONG lIndex, HWND hwndParent, LPCRECT lprcPosRect)\r
-{\r
- if( 0 != lIndex )\r
- return DV_E_LINDEX;\r
-\r
- switch( iVerb )\r
- {\r
- case OLEIVERB_PRIMARY:\r
- case OLEIVERB_SHOW:\r
- case OLEIVERB_OPEN:\r
- case OLEIVERB_INPLACEACTIVATE:\r
- if( NULL == hwndParent )\r
- return OLEOBJ_S_INVALIDHWND;\r
-\r
- if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )\r
- return S_OK;\r
-\r
- return OLEOBJ_S_CANNOT_DOVERB_NOW;\r
-\r
- case OLEIVERB_HIDE:\r
- _p_instance->setVisible(FALSE);\r
- return S_OK;\r
-\r
- case OLEIVERB_UIACTIVATE:\r
- return doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect);\r
-\r
- case OLEIVERB_DISCARDUNDOSTATE:\r
- return S_OK;\r
-\r
- default:\r
- if( NULL == hwndParent )\r
- return OLEOBJ_S_INVALIDHWND;\r
-\r
- if( SUCCEEDED(doInPlaceActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect)) )\r
- return OLEOBJ_S_INVALIDVERB;\r
-\r
- return OLEOBJ_S_CANNOT_DOVERB_NOW;\r
- }\r
-};\r
-\r
-HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect)\r
-{\r
- RECT posRect;\r
- RECT clipRect;\r
- LPCRECT lprcClipRect = lprcPosRect;\r
-\r
- if( NULL != pActiveSite )\r
- {\r
- // check if already activated\r
- if( _p_instance->isInPlaceActive() )\r
- {\r
- // just attempt to show object then\r
- pActiveSite->ShowObject();\r
- _p_instance->setVisible(TRUE);\r
- return S_OK;\r
- }\r
-\r
- LPOLEINPLACESITE p_inPlaceSite;\r
-\r
- if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )\r
- {\r
- if( S_OK != p_inPlaceSite->CanInPlaceActivate() )\r
- return E_FAIL;\r
-\r
- LPOLEINPLACEFRAME p_inPlaceFrame;\r
- LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;\r
- OLEINPLACEFRAMEINFO oleFrameInfo;\r
-\r
- if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )\r
- {\r
- lprcPosRect = &posRect;\r
- lprcClipRect = &clipRect;\r
-\r
- if( NULL != p_inPlaceFrame )\r
- p_inPlaceFrame->Release();\r
- if( NULL != p_inPlaceUIWindow )\r
- p_inPlaceUIWindow->Release();\r
- }\r
- }\r
-\r
- if( FAILED(_p_instance->onActivateInPlace(lpMsg, hwndParent, lprcPosRect, lprcClipRect)) )\r
- return E_FAIL;\r
-\r
- if( NULL != p_inPlaceSite )\r
- p_inPlaceSite->OnPosRectChange(lprcPosRect);\r
-\r
- pActiveSite->ShowObject();\r
- _p_instance->setVisible(TRUE);\r
-\r
- if( NULL != p_inPlaceSite )\r
- {\r
- p_inPlaceSite->OnInPlaceActivate();\r
- p_inPlaceSite->Release();\r
- }\r
-\r
- if( NULL != lpMsg )\r
- {\r
- switch( lpMsg->message )\r
- {\r
- case WM_LBUTTONDOWN:\r
- case WM_LBUTTONDBLCLK:\r
- doUIActivate(lpMsg, pActiveSite, hwndParent, lprcPosRect);\r
- break;\r
- default:\r
- break;\r
- }\r
- }\r
- return S_OK;\r
- }\r
- return E_FAIL;\r
-};\r
-\r
-HRESULT VLCOleObject::doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect)\r
-{\r
- if( NULL != pActiveSite )\r
- {\r
- // check if already activated\r
- if( ! _p_instance->isInPlaceActive() )\r
- return OLE_E_NOT_INPLACEACTIVE;\r
-\r
- LPOLEINPLACESITE p_inPlaceSite;\r
-\r
- if( SUCCEEDED(pActiveSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )\r
- {\r
- p_inPlaceSite->OnUIActivate();\r
-\r
- if( NULL != lprcPosRect )\r
- {\r
- p_inPlaceSite->OnPosRectChange(lprcPosRect);\r
- }\r
- p_inPlaceSite->Release();\r
- }\r
-\r
- pActiveSite->ShowObject();\r
- _p_instance->setVisible(TRUE);\r
- _p_instance->setFocus(TRUE);\r
-\r
- return S_OK;\r
- }\r
- return E_FAIL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::EnumAdvise(IEnumSTATDATA **ppEnumAdvise)\r
-{\r
- return _p_advise_holder->EnumAdvise(ppEnumAdvise);\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::EnumVerbs(IEnumOleVerb **ppEnumOleVerb)\r
-{\r
- return OLE_S_USEREG;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetClientSite(LPOLECLIENTSITE *ppClientSite)\r
-{\r
- if( NULL == ppClientSite )\r
- return E_POINTER;\r
- \r
- if( NULL != _p_clientsite )\r
- _p_clientsite->AddRef(); \r
-\r
- *ppClientSite= _p_clientsite;\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetClipboardData(DWORD dwReserved, LPDATAOBJECT *ppDataObject)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetExtent(DWORD dwDrawAspect, SIZEL *pSizel)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetMiscStatus(DWORD dwAspect, DWORD *pdwStatus)\r
-{\r
- if( NULL != pdwStatus )\r
- return E_POINTER;\r
-\r
- switch( dwAspect )\r
- {\r
- case DVASPECT_CONTENT:\r
- *pdwStatus = OLEMISC_RECOMPOSEONRESIZE\r
- | OLEMISC_CANTLINKINSIDE\r
- | OLEMISC_INSIDEOUT\r
- | OLEMISC_ACTIVATEWHENVISIBLE\r
- | OLEMISC_SETCLIENTSITEFIRST;\r
- break;\r
- default:\r
- *pdwStatus = 0;\r
- }\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER *ppMoniker)\r
-{\r
- if( NULL != _p_clientsite )\r
- return _p_clientsite->GetMoniker(dwAssign,dwWhichMoniker, ppMoniker);\r
- \r
- return E_UNEXPECTED;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetUserClassID(LPCLSID pClsid)\r
-{\r
- if( NULL == pClsid )\r
- return E_POINTER;\r
- \r
- pClsid = const_cast<LPCLSID>(&_p_instance->getClassID()); \r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::GetUserType(DWORD dwFormOfType, LPOLESTR *pszUserType)\r
-{\r
- return OLE_S_USEREG;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::InitFromData(LPDATAOBJECT pDataObject, BOOL fCreation, DWORD dwReserved)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::IsUpToDate(void)\r
-{\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)\r
-{\r
- if( NULL != _p_clientsite )\r
- _p_clientsite->Release(); \r
- \r
- if( NULL != pClientSite )\r
- {\r
- pClientSite->AddRef();\r
-\r
- /*\r
- ** retrieve container ambient properties\r
- */\r
- VARIANT v;\r
- VariantInit(&v);\r
- V_VT(&v) = VT_I4;\r
- if( SUCCEEDED(GetObjectProperty(pClientSite, DISPID_AMBIENT_CODEPAGE, v)) )\r
- {\r
- _p_instance->setCodePage(V_I4(&v));\r
- VariantClear(&v);\r
- }\r
- }\r
-\r
- _p_clientsite = pClientSite;\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::SetColorScheme(LOGPALETTE *pLogpal)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel)\r
-{\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::SetHostNames(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj)\r
-{\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::SetMoniker(DWORD dwWhichMoniker, LPMONIKER pMoniker)\r
-{\r
- return _p_advise_holder->SendOnRename(pMoniker);\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::Unadvise(DWORD dwConnection)\r
-{\r
- return _p_advise_holder->Unadvise(dwConnection);\r
-};\r
-\r
-STDMETHODIMP VLCOleObject::Update(void)\r
-{\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * oleobject.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <docobj.h>
+
+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<LPCLSID>(&_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;
+};
+
-/*****************************************************************************\r
- * oleobject.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __OLEOBJECT_H__\r
-#define __OLEOBJECT_H__\r
-\r
-class VLCOleObject : public IOleObject\r
-{\r
-\r
-public:\r
-\r
- VLCOleObject(VLCPlugin *p_instance);\r
- virtual ~VLCOleObject();\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid)\r
- && (IID_IOleObject == riid) ) \r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IOleObject methods\r
- STDMETHODIMP Advise(IAdviseSink *, LPDWORD);\r
- STDMETHODIMP Close(DWORD);\r
- STDMETHODIMP DoVerb(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);\r
- STDMETHODIMP EnumAdvise(IEnumSTATDATA **);\r
- STDMETHODIMP EnumVerbs(IEnumOleVerb **);\r
- STDMETHODIMP GetClientSite(LPOLECLIENTSITE *);\r
- STDMETHODIMP GetClipboardData(DWORD, LPDATAOBJECT *);\r
- STDMETHODIMP GetExtent(DWORD, SIZEL *);\r
- STDMETHODIMP GetMiscStatus(DWORD, DWORD *);\r
- STDMETHODIMP GetMoniker(DWORD, DWORD, LPMONIKER *);\r
- STDMETHODIMP GetUserClassID(CLSID *);\r
- STDMETHODIMP GetUserType(DWORD, LPOLESTR *);\r
- STDMETHODIMP InitFromData(IDataObject *, BOOL, DWORD);\r
- STDMETHODIMP IsUpToDate(void);\r
- STDMETHODIMP SetClientSite(LPOLECLIENTSITE);\r
- STDMETHODIMP SetColorScheme(LOGPALETTE *);\r
- STDMETHODIMP SetExtent(DWORD, SIZEL *);\r
- STDMETHODIMP SetHostNames(LPCOLESTR, LPCOLESTR) ;\r
- STDMETHODIMP SetMoniker(DWORD, LPMONIKER);\r
- STDMETHODIMP Unadvise(DWORD);\r
- STDMETHODIMP Update(void);\r
-\r
-private:\r
-\r
- HRESULT doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect);\r
- HRESULT doUIActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, HWND hwndParent, LPCRECT lprcPosRect);\r
-\r
- IOleAdviseHolder *_p_advise_holder;\r
- IOleClientSite *_p_clientsite;\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * oleobject.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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<LPVOID>(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
+
-/*****************************************************************************\r
- * persistpropbag.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "persistpropbag.h"\r
-\r
-#include "utils.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCPersistPropertyBag::GetClassID(LPCLSID pClsID)\r
-{\r
- if( NULL == pClsID )\r
- return E_POINTER;\r
-\r
- *pClsID = _p_instance->getClassID();\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistPropertyBag::InitNew(void)\r
-{\r
- return _p_instance->onInitNew();\r
-};\r
-\r
-STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)\r
-{\r
- if( NULL == pPropBag )\r
- return E_POINTER;\r
-\r
- HRESULT hr = _p_instance->onInitNew();\r
- if( FAILED(hr) )\r
- return hr;\r
-\r
- VARIANT value;\r
-\r
- V_VT(&value) = VT_BSTR;\r
- if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )\r
- {\r
- char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));\r
- if( NULL != src )\r
- {\r
- _p_instance->setSourceURL(src);\r
- free(src);\r
- }\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BSTR;\r
- if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )\r
- {\r
- char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));\r
- if( NULL != src )\r
- {\r
- _p_instance->setSourceURL(src);\r
- free(src);\r
- }\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BOOL;\r
- if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )\r
- {\r
- _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BOOL;\r
- if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )\r
- {\r
- _p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BOOL;\r
- if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )\r
- {\r
- _p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE);\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BOOL;\r
- if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )\r
- {\r
- _p_instance->setMute(V_BOOL(&value) != VARIANT_FALSE);\r
- VariantClear(&value);\r
- }\r
-\r
- V_VT(&value) = VT_BOOL;\r
- if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )\r
- {\r
- _p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);\r
- VariantClear(&value);\r
- }\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties)\r
-{\r
- if( NULL == pPropBag )\r
- return E_POINTER;\r
-\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * persistpropbag.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * persistpropbag.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __PERSISTPROPBAG_H__\r
-#define __PERSISTPROPBAG_H__\r
-\r
-#include <ocidl.h>\r
-\r
-class VLCPersistPropertyBag : public IPersistPropertyBag\r
-{\r
-\r
-public:\r
-\r
- VLCPersistPropertyBag(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCPersistPropertyBag() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IPersist == riid) \r
- && (IID_IPersistPropertyBag == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IPersist methods\r
- STDMETHODIMP GetClassID(LPCLSID);\r
-\r
- // IPersistPropertyBag methods\r
- STDMETHODIMP InitNew(void);\r
- STDMETHODIMP Load(LPPROPERTYBAG, LPERRORLOG);\r
- STDMETHODIMP Save(LPPROPERTYBAG, BOOL, BOOL);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * persistpropbag.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ocidl.h>
+
+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<LPVOID>(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
+
-/*****************************************************************************\r
- * persiststorage.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "persiststorage.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)\r
-{\r
- if( NULL == pClsID )\r
- return E_POINTER;\r
-\r
- *pClsID = _p_instance->getClassID();\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::IsDirty(void)\r
-{\r
- return S_FALSE;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)\r
-{\r
- if( NULL == pStg )\r
- return E_POINTER;\r
-\r
- return _p_instance->onInitNew();\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)\r
-{\r
- if( NULL == pStg )\r
- return E_POINTER;\r
-\r
- return _p_instance->onInitNew();\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)\r
-{\r
- if( NULL == pStg )\r
- return E_POINTER;\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)\r
-{\r
- if( NULL == pStg )\r
- return E_POINTER;\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStorage::HandsOffStorage(void)\r
-{\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * persiststorage.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * persiststorage.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __PERSISTSTORAGE_H__\r
-#define __PERSISTSTORAGE_H__\r
-\r
-#include <ocidl.h>\r
-\r
-class VLCPersistStorage : public IPersistStorage\r
-{\r
-\r
-public:\r
-\r
- VLCPersistStorage(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCPersistStorage() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IPersist == riid) \r
- && (IID_IPersistStorage == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IPersist methods\r
- STDMETHODIMP GetClassID(LPCLSID);\r
-\r
- // IPersistStorage methods\r
- STDMETHODIMP IsDirty(void);\r
- STDMETHODIMP InitNew(IStorage *);\r
- STDMETHODIMP Load(IStorage *);\r
- STDMETHODIMP Save(IStorage *, BOOL);\r
- STDMETHODIMP SaveCompleted(IStorage *);\r
- STDMETHODIMP HandsOffStorage(void);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * persiststorage.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ocidl.h>
+
+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<LPVOID>(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
+
-/*****************************************************************************\r
- * persiststreaminit.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "persiststreaminit.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)\r
-{\r
- if( NULL == pClsID )\r
- return E_POINTER;\r
-\r
- *pClsID = _p_instance->getClassID();\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStreamInit::InitNew(void)\r
-{\r
- return _p_instance->onInitNew();\r
-};\r
-\r
-STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)\r
-{\r
- if( NULL == pStm )\r
- return E_POINTER;\r
-\r
- return _p_instance->onInitNew();\r
-};\r
-\r
-STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)\r
-{\r
- if( NULL == pStm )\r
- return E_POINTER;\r
-\r
- return S_OK;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStreamInit::IsDirty(void)\r
-{\r
- return S_FALSE;\r
-};\r
-\r
-STDMETHODIMP VLCPersistStreamInit::GetSizeMax(ULARGE_INTEGER *pcbSize)\r
-{\r
- pcbSize->QuadPart = 0ULL;\r
-\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * persiststreaminit.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * persiststreaminit.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __PERSISTSTREAMINIT_H__\r
-#define __PERSISTSTREAMINIT_H__\r
-\r
-#include <ocidl.h>\r
-\r
-class VLCPersistStreamInit : public IPersistStreamInit\r
-{\r
-\r
-public:\r
-\r
- VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCPersistStreamInit() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IPersist == riid) \r
- && (IID_IPersistStreamInit == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IPersist methods\r
- STDMETHODIMP GetClassID(LPCLSID);\r
-\r
- // IPersistStreamInit methods\r
- STDMETHODIMP IsDirty(void);\r
- STDMETHODIMP InitNew(void);\r
- STDMETHODIMP Load(LPSTREAM);\r
- STDMETHODIMP Save(LPSTREAM, BOOL);\r
- STDMETHODIMP GetSizeMax(ULARGE_INTEGER *);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * persiststreaminit.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ocidl.h>
+
+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<LPVOID>(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
+
-/*****************************************************************************\r
- * plugin.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-\r
-#include "oleobject.h"\r
-#include "olecontrol.h"\r
-#include "oleinplaceobject.h"\r
-#include "oleinplaceactiveobject.h"\r
-#include "persistpropbag.h"\r
-#include "persiststreaminit.h"\r
-#include "persiststorage.h"\r
-#include "provideclassinfo.h"\r
-#include "connectioncontainer.h"\r
-#include "objectsafety.h"\r
-#include "vlccontrol.h"\r
-\r
-#include "utils.h"\r
-\r
-#include <string.h>\r
-#include <winreg.h>\r
-\r
-using namespace std;\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-//class factory\r
-\r
-// {E23FE9C6-778E-49d4-B537-38FCDE4887D8}\r
-//const GUID CLSID_VLCPlugin = \r
-// { 0xe23fe9c6, 0x778e, 0x49d4, { 0xb5, 0x37, 0x38, 0xfc, 0xde, 0x48, 0x87, 0xd8 } };\r
-\r
-static LRESULT CALLBACK VLCInPlaceClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {\r
- switch( uMsg )\r
- {\r
- case WM_ERASEBKGND:\r
- return 1L;\r
-\r
- case WM_PAINT:\r
- PAINTSTRUCT ps;\r
- if( GetUpdateRect(hWnd, NULL, FALSE) )\r
- {\r
- BeginPaint(hWnd, &ps);\r
- EndPaint(hWnd, &ps);\r
- }\r
- return 0L;\r
-\r
- default:\r
- return DefWindowProc(hWnd, uMsg, wParam, lParam);\r
- }\r
-};\r
-\r
-static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {\r
- VLCPlugin *p_instance = reinterpret_cast<VLCPlugin *>(GetWindowLongPtr(hWnd, GWLP_USERDATA));\r
-\r
- switch( uMsg )\r
- {\r
- case WM_ERASEBKGND:\r
- return 1L;\r
-\r
- case WM_PAINT:\r
- PAINTSTRUCT ps;\r
- RECT pr;\r
- if( GetUpdateRect(hWnd, &pr, FALSE) )\r
- {\r
- BeginPaint(hWnd, &ps);\r
- p_instance->onPaint(ps, pr);\r
- EndPaint(hWnd, &ps);\r
- }\r
- return 0L;\r
-\r
- default:\r
- return DefWindowProc(hWnd, uMsg, wParam, lParam);\r
- }\r
-};\r
-\r
-VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :\r
- _p_class_ref(p_class_ref),\r
- _hinstance(hInstance)\r
-{\r
- WNDCLASS wClass;\r
-\r
- if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )\r
- {\r
- wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;\r
- wClass.lpfnWndProc = VLCInPlaceClassWndProc;\r
- wClass.cbClsExtra = 0;\r
- wClass.cbWndExtra = 0;\r
- wClass.hInstance = hInstance;\r
- wClass.hIcon = NULL;\r
- wClass.hCursor = LoadCursor(NULL, IDC_ARROW);\r
- wClass.hbrBackground = NULL;\r
- wClass.lpszMenuName = NULL;\r
- wClass.lpszClassName = getInPlaceWndClassName();\r
- \r
- _inplace_wndclass_atom = RegisterClass(&wClass);\r
- }\r
- else\r
- {\r
- _inplace_wndclass_atom = 0;\r
- }\r
-\r
- if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )\r
- {\r
- wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW;\r
- wClass.lpfnWndProc = VLCVideoClassWndProc;\r
- wClass.cbClsExtra = 0;\r
- wClass.cbWndExtra = 0;\r
- wClass.hInstance = hInstance;\r
- wClass.hIcon = NULL;\r
- wClass.hCursor = LoadCursor(NULL, IDC_ARROW);\r
- wClass.hbrBackground = NULL;\r
- wClass.lpszMenuName = NULL;\r
- wClass.lpszClassName = getVideoWndClassName();\r
- \r
- _video_wndclass_atom = RegisterClass(&wClass);\r
- }\r
- else\r
- {\r
- _video_wndclass_atom = 0;\r
- }\r
-\r
- _inplace_hbitmap = (HBITMAP)LoadImage(getHInstance(), TEXT("INPLACE-PICT"), IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR);\r
-\r
- AddRef();\r
-};\r
-\r
-VLCPluginClass::~VLCPluginClass()\r
-{\r
- if( 0 != _inplace_wndclass_atom )\r
- UnregisterClass(MAKEINTATOM(_inplace_wndclass_atom), _hinstance);\r
-\r
- if( 0 != _video_wndclass_atom )\r
- UnregisterClass(MAKEINTATOM(_video_wndclass_atom), _hinstance);\r
-\r
- if( NULL != _inplace_hbitmap )\r
- DeleteObject(_inplace_hbitmap);\r
-};\r
-\r
-STDMETHODIMP VLCPluginClass::QueryInterface(REFIID riid, void **ppv)\r
-{\r
- if( NULL == ppv )\r
- return E_INVALIDARG;\r
-\r
- if( (IID_IUnknown == riid) || (IID_IClassFactory == riid) )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
-\r
- return NOERROR;\r
- }\r
-\r
- *ppv = NULL;\r
-\r
- return E_NOINTERFACE;\r
-};\r
-\r
-STDMETHODIMP_(ULONG) VLCPluginClass::AddRef(void)\r
-{\r
- return InterlockedIncrement(_p_class_ref);\r
-};\r
-\r
-STDMETHODIMP_(ULONG) VLCPluginClass::Release(void)\r
-{\r
- ULONG refcount = InterlockedDecrement(_p_class_ref);\r
- if( 0 == refcount )\r
- {\r
- delete this;\r
- return 0;\r
- }\r
- return refcount;\r
-};\r
-\r
-STDMETHODIMP VLCPluginClass::CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv)\r
-{\r
- if( NULL == ppv )\r
- return E_POINTER;\r
-\r
- *ppv = NULL;\r
-\r
- if( NULL != pUnkOuter )\r
- return CLASS_E_NOAGGREGATION;\r
-\r
- VLCPlugin *plugin = new VLCPlugin(this);\r
- if( NULL != plugin )\r
- {\r
- HRESULT hr = plugin->QueryInterface(riid, ppv);\r
- plugin->Release();\r
- return hr;\r
- }\r
- return E_OUTOFMEMORY;\r
-};\r
-\r
-STDMETHODIMP VLCPluginClass::LockServer(BOOL fLock)\r
-{\r
- if( fLock )\r
- AddRef();\r
- else \r
- Release();\r
-\r
- return S_OK;\r
-};\r
-\r
-////////////////////////////////////////////////////////////////////////\r
-\r
-VLCPlugin::VLCPlugin(VLCPluginClass *p_class) :\r
- _inplacewnd(NULL),\r
- _p_class(p_class),\r
- _i_ref(1UL),\r
- _codepage(CP_ACP),\r
- _psz_src(NULL),\r
- _b_autostart(TRUE),\r
- _b_loopmode(FALSE),\r
- _b_visible(TRUE),\r
- _b_sendevents(TRUE),\r
- _i_vlc(0)\r
-{\r
- p_class->AddRef();\r
-\r
- vlcOleObject = new VLCOleObject(this);\r
- vlcOleControl = new VLCOleControl(this);\r
- vlcOleInPlaceObject = new VLCOleInPlaceObject(this);\r
- vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);\r
- vlcPersistStorage = new VLCPersistStorage(this);\r
- vlcPersistStreamInit = new VLCPersistStreamInit(this);\r
- vlcPersistPropertyBag = new VLCPersistPropertyBag(this);\r
- vlcProvideClassInfo = new VLCProvideClassInfo(this);\r
- vlcConnectionPointContainer = new VLCConnectionPointContainer(this);\r
- vlcObjectSafety = new VLCObjectSafety(this);\r
- vlcControl = new VLCControl(this);\r
-};\r
-\r
-VLCPlugin::~VLCPlugin()\r
-{\r
- vlcOleInPlaceObject->UIDeactivate();\r
- vlcOleInPlaceObject->InPlaceDeactivate();\r
-\r
- delete vlcControl;\r
- delete vlcObjectSafety;\r
- delete vlcConnectionPointContainer;\r
- delete vlcProvideClassInfo;\r
- delete vlcPersistPropertyBag;\r
- delete vlcPersistStreamInit;\r
- delete vlcPersistStorage;\r
- delete vlcOleInPlaceActiveObject;\r
- delete vlcOleInPlaceObject;\r
- delete vlcOleControl;\r
- delete vlcOleObject;\r
-\r
- if( _psz_src )\r
- free(_psz_src);\r
-\r
- _p_class->Release();\r
-};\r
-\r
-STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)\r
-{\r
- if( NULL == ppv )\r
- return E_INVALIDARG;\r
-\r
- if( IID_IUnknown == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- else if( IID_IOleObject == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcOleObject);\r
- return NOERROR;\r
- }\r
- else if( IID_IOleControl == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcOleControl);\r
- return NOERROR;\r
- }\r
- else if( IID_IOleWindow == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);\r
- return NOERROR;\r
- }\r
- else if( IID_IOleInPlaceObject == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);\r
- return NOERROR;\r
- }\r
- else if( IID_IOleInPlaceActiveObject == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);\r
- return NOERROR;\r
- }\r
- else if( IID_IPersist == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);\r
- return NOERROR;\r
- }\r
- else if( IID_IPersistStreamInit == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);\r
- return NOERROR;\r
- }\r
- else if( IID_IPersistStorage == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);\r
- return NOERROR;\r
- }\r
- else if( IID_IPersistPropertyBag == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);\r
- return NOERROR;\r
- }\r
- else if( IID_IProvideClassInfo == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);\r
- return NOERROR;\r
- }\r
- else if( IID_IProvideClassInfo2 == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);\r
- return NOERROR;\r
- }\r
- else if( IID_IConnectionPointContainer == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);\r
- return NOERROR;\r
- }\r
- else if( IID_IObjectSafety == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);\r
- return NOERROR;\r
- }\r
- else if( IID_IDispatch == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcControl);\r
- return NOERROR;\r
- }\r
- else if( IID_IVLCControl == riid )\r
- {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(vlcControl);\r
- return NOERROR;\r
- }\r
-\r
- *ppv = NULL;\r
-\r
- return E_NOINTERFACE;\r
-};\r
-\r
-STDMETHODIMP_(ULONG) VLCPlugin::AddRef(void)\r
-{\r
- return InterlockedIncrement((LONG *)&_i_ref);\r
-};\r
-\r
-STDMETHODIMP_(ULONG) VLCPlugin::Release(void)\r
-{\r
- if( ! InterlockedDecrement((LONG *)&_i_ref) )\r
- {\r
- delete this;\r
- return 0;\r
- }\r
- return _i_ref;\r
-};\r
-\r
-//////////////////////////////////////\r
-\r
-/*\r
-** we use an in-place child window to represent plugin viewport,\r
-** whose size is limited by the clipping rectangle\r
-** all drawing within this window must follow \r
-** cartesian coordinate system represented by _bounds.\r
-*/\r
-\r
-void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect)\r
-{\r
- _bounds.right = lprPosRect->right-lprPosRect->left;\r
-\r
- if( lprcClipRect->left <= lprPosRect->left )\r
- {\r
- // left side is not clipped out\r
- _bounds.left = 0;\r
-\r
- if( lprcClipRect->right >= lprPosRect->right )\r
- {\r
- // right side is not clipped out, no change\r
- }\r
- else if( lprcClipRect->right >= lprPosRect->left )\r
- {\r
- // right side is clipped out\r
- lprPosRect->right = lprcClipRect->right;\r
- }\r
- else\r
- {\r
- // outside of clipping rectange, not visible\r
- lprPosRect->right = lprPosRect->left;\r
- }\r
- }\r
- else\r
- {\r
- // left side is clipped out\r
- _bounds.left = lprPosRect->left-lprcClipRect->left;\r
- _bounds.right += _bounds.left;\r
-\r
- lprPosRect->left = lprcClipRect->left;\r
- if( lprcClipRect->right >= lprPosRect->right )\r
- {\r
- // right side is not clipped out\r
- }\r
- else\r
- {\r
- // right side is clipped out\r
- lprPosRect->right = lprcClipRect->right;\r
- }\r
- }\r
-\r
- _bounds.bottom = lprPosRect->bottom-lprPosRect->top;\r
-\r
- if( lprcClipRect->top <= lprPosRect->top )\r
- {\r
- // top side is not clipped out\r
- _bounds.top = 0;\r
-\r
- if( lprcClipRect->bottom >= lprPosRect->bottom )\r
- {\r
- // bottom side is not clipped out, no change\r
- }\r
- else if( lprcClipRect->bottom >= lprPosRect->top )\r
- {\r
- // bottom side is clipped out\r
- lprPosRect->bottom = lprcClipRect->bottom;\r
- }\r
- else\r
- {\r
- // outside of clipping rectange, not visible\r
- lprPosRect->right = lprPosRect->left;\r
- }\r
- }\r
- else\r
- {\r
- _bounds.top = lprPosRect->top-lprcClipRect->top;\r
- _bounds.bottom += _bounds.top;\r
-\r
- lprPosRect->top = lprcClipRect->top;\r
- if( lprcClipRect->bottom >= lprPosRect->bottom )\r
- {\r
- // bottom side is not clipped out\r
- }\r
- else\r
- {\r
- // bottom side is clipped out\r
- lprPosRect->bottom = lprcClipRect->bottom;\r
- }\r
- }\r
-};\r
-\r
-HRESULT VLCPlugin::onInitNew(void)\r
-{\r
- if( 0 == _i_vlc )\r
- {\r
- char *ppsz_argv[] = { "vlc", "-vv" };\r
- HKEY h_key;\r
- DWORD i_type, i_data = MAX_PATH + 1;\r
- char p_data[MAX_PATH + 1];\r
- if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, "Software\\VideoLAN\\VLC",\r
- 0, KEY_READ, &h_key ) == ERROR_SUCCESS )\r
- {\r
- if( RegQueryValueEx( h_key, "InstallDir", 0, &i_type,\r
- (LPBYTE)p_data, &i_data ) == ERROR_SUCCESS )\r
- {\r
- if( i_type == REG_SZ )\r
- {\r
- strcat( p_data, "\\vlc" );\r
- ppsz_argv[0] = p_data;\r
- }\r
- }\r
- RegCloseKey( h_key );\r
- }\r
-\r
-#if 0\r
- ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";\r
-#endif\r
-\r
- _i_vlc = VLC_Create();\r
- \r
- if( VLC_Init(_i_vlc, sizeof(ppsz_argv)/sizeof(char*), ppsz_argv) )\r
- {\r
- VLC_Destroy(_i_vlc);\r
- _i_vlc = 0;\r
- return E_FAIL;\r
- }\r
- return S_OK;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-HRESULT VLCPlugin::onClose(DWORD dwSaveOption)\r
-{\r
- if( _i_vlc )\r
- {\r
- if( isInPlaceActive() )\r
- {\r
- onInPlaceDeactivate();\r
- }\r
-\r
- VLC_CleanUp(_i_vlc);\r
- VLC_Destroy(_i_vlc);\r
- _i_vlc = 0;\r
- }\r
- return S_OK;\r
-};\r
-\r
-BOOL VLCPlugin::isInPlaceActive(void)\r
-{\r
- return (NULL != _inplacewnd);\r
-};\r
-\r
-HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)\r
-{\r
- RECT posRect = *lprcPosRect;\r
-\r
- calcPositionChange(&posRect, lprcClipRect);\r
-\r
- _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),\r
- "VLC Plugin In-Place Window",\r
- WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP,\r
- posRect.left,\r
- posRect.top,\r
- posRect.right-posRect.left,\r
- posRect.bottom-posRect.top,\r
- hwndParent,\r
- 0,\r
- _p_class->getHInstance(),\r
- NULL\r
- );\r
-\r
- if( NULL == _inplacewnd )\r
- return E_FAIL;\r
-\r
- SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));\r
-\r
- _videownd = CreateWindow(_p_class->getVideoWndClassName(),\r
- "VLC Plugin Video Window",\r
- WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE,\r
- _bounds.left,\r
- _bounds.top,\r
- _bounds.right-_bounds.left,\r
- _bounds.bottom-_bounds.top,\r
- _inplacewnd,\r
- 0,\r
- _p_class->getHInstance(),\r
- NULL\r
- );\r
-\r
- if( NULL == _videownd )\r
- {\r
- DestroyWindow(_inplacewnd);\r
- return E_FAIL;\r
- }\r
-\r
- SetWindowLongPtr(_videownd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));\r
-\r
- if( getVisible() )\r
- ShowWindow(_inplacewnd, SW_SHOWNORMAL);\r
-\r
- /* horrible cast there */\r
- vlc_value_t val;\r
- val.i_int = reinterpret_cast<int>(_videownd);\r
- VLC_VariableSet(_i_vlc, "drawable", val);\r
-\r
- if( NULL != _psz_src )\r
- {\r
- // add target to playlist\r
- char *cOptions[1];\r
- int cOptionsCount = 0;\r
-\r
- if( _b_loopmode )\r
- {\r
- cOptions[cOptionsCount++] = "loop";\r
- }\r
- VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);\r
-\r
- if( _b_autostart )\r
- {\r
- VLC_Play(_i_vlc);\r
- fireOnPlayEvent();\r
- }\r
- }\r
- return S_OK;\r
-};\r
-\r
-HRESULT VLCPlugin::onInPlaceDeactivate(void)\r
-{\r
- VLC_Stop(_i_vlc);\r
- fireOnStopEvent();\r
-\r
- DestroyWindow(_videownd);\r
- _videownd = NULL;\r
- DestroyWindow(_inplacewnd);\r
- _inplacewnd = NULL;\r
- \r
- return S_OK;\r
-};\r
-\r
-void VLCPlugin::setVisible(BOOL fVisible)\r
-{\r
- _b_visible = fVisible;\r
- if( isInPlaceActive() )\r
- ShowWindow(_inplacewnd, fVisible ? SW_SHOWNORMAL : SW_HIDE);\r
- firePropChangedEvent(DISPID_Visible);\r
-};\r
-\r
-void VLCPlugin::setFocus(BOOL fFocus)\r
-{\r
- if( fFocus )\r
- SetActiveWindow(_inplacewnd);\r
-};\r
-\r
-BOOL VLCPlugin::hasFocus(void)\r
-{\r
- return GetActiveWindow() == _inplacewnd;\r
-};\r
-\r
-void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr)\r
-{\r
- /*\r
- ** if VLC is playing, it may not display any VIDEO content \r
- ** hence, draw control logo\r
- */ \r
- int width = _bounds.right-_bounds.left;\r
- int height = _bounds.bottom-_bounds.top;\r
-\r
- HBITMAP pict = _p_class->getInPlacePict();\r
- if( NULL != pict )\r
- {\r
- HDC hdcPict = CreateCompatibleDC(ps.hdc);\r
- if( NULL != hdcPict )\r
- {\r
- BITMAP bm;\r
- if( GetObject(pict, sizeof(BITMAPINFO), &bm) )\r
- {\r
- int dstWidth = bm.bmWidth;\r
- if( dstWidth > width-4 )\r
- dstWidth = width-4;\r
-\r
- int dstHeight = bm.bmHeight;\r
- if( dstHeight > height-4 )\r
- dstHeight = height-4;\r
-\r
- int dstX = (width-dstWidth)/2;\r
- int dstY = (height-dstHeight)/2;\r
-\r
- SelectObject(hdcPict, pict);\r
- StretchBlt(ps.hdc, dstX, dstY, dstWidth, dstHeight,\r
- hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);\r
- DeleteDC(hdcPict);\r
- ExcludeClipRect(ps.hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY);\r
- }\r
- }\r
- }\r
-\r
- FillRect(ps.hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH));\r
- SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH));\r
-\r
- MoveToEx(ps.hdc, 0, 0, NULL);\r
- LineTo(ps.hdc, width-1, 0);\r
- LineTo(ps.hdc, width-1, height-1);\r
- LineTo(ps.hdc, 0, height-1);\r
- LineTo(ps.hdc, 0, 0);\r
-};\r
-\r
-void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)\r
-{\r
- RECT posRect = *lprcPosRect;\r
-\r
- calcPositionChange(&posRect, lprcClipRect);\r
-\r
- /*\r
- ** change in-place window geometry to match clipping region\r
- */\r
- MoveWindow(_inplacewnd,\r
- posRect.left,\r
- posRect.top,\r
- posRect.right-posRect.left,\r
- posRect.bottom-posRect.top,\r
- FALSE);\r
-\r
- /*\r
- ** change video window geometry to match object bounds within clipping region\r
- */\r
- MoveWindow(_videownd,\r
- _bounds.left,\r
- _bounds.top,\r
- _bounds.right-_bounds.left,\r
- _bounds.bottom-_bounds.top,\r
- FALSE);\r
-\r
- RECT updateRect;\r
-\r
- updateRect.left = -_bounds.left;\r
- updateRect.top = -_bounds.top;\r
- updateRect.right = _bounds.right-_bounds.left;\r
- updateRect.bottom = _bounds.bottom-_bounds.top;\r
-\r
- ValidateRect(_videownd, NULL);\r
- InvalidateRect(_videownd, &updateRect, FALSE);\r
- UpdateWindow(_videownd);\r
-};\r
-\r
-void VLCPlugin::firePropChangedEvent(DISPID dispid)\r
-{\r
- if( _b_sendevents )\r
- {\r
- vlcConnectionPointContainer->firePropChangedEvent(dispid); \r
- }\r
-};\r
-\r
-void VLCPlugin::fireOnPlayEvent(void)\r
-{\r
- if( _b_sendevents )\r
- {\r
- DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};\r
- vlcConnectionPointContainer->fireEvent(DISPID_PlayEvent, &dispparamsNoArgs); \r
- }\r
-};\r
-\r
-void VLCPlugin::fireOnPauseEvent(void)\r
-{\r
- if( _b_sendevents )\r
- {\r
- DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};\r
- vlcConnectionPointContainer->fireEvent(DISPID_PauseEvent, &dispparamsNoArgs); \r
- }\r
-};\r
-\r
-void VLCPlugin::fireOnStopEvent(void)\r
-{\r
- if( _b_sendevents )\r
- {\r
- DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};\r
- vlcConnectionPointContainer->fireEvent(DISPID_StopEvent, &dispparamsNoArgs); \r
- }\r
-};\r
-\r
+/*****************************************************************************
+ * plugin.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <string.h>
+#include <winreg.h>
+
+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<VLCPlugin *>(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<LPVOID>(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<LPVOID>(this);
+ return NOERROR;
+ }
+ else if( IID_IOleObject == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcOleObject);
+ return NOERROR;
+ }
+ else if( IID_IOleControl == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcOleControl);
+ return NOERROR;
+ }
+ else if( IID_IOleWindow == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
+ return NOERROR;
+ }
+ else if( IID_IOleInPlaceObject == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceObject);
+ return NOERROR;
+ }
+ else if( IID_IOleInPlaceActiveObject == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
+ return NOERROR;
+ }
+ else if( IID_IPersist == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
+ return NOERROR;
+ }
+ else if( IID_IPersistStreamInit == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
+ return NOERROR;
+ }
+ else if( IID_IPersistStorage == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcPersistStorage);
+ return NOERROR;
+ }
+ else if( IID_IPersistPropertyBag == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
+ return NOERROR;
+ }
+ else if( IID_IProvideClassInfo == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
+ return NOERROR;
+ }
+ else if( IID_IProvideClassInfo2 == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcProvideClassInfo);
+ return NOERROR;
+ }
+ else if( IID_IConnectionPointContainer == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcConnectionPointContainer);
+ return NOERROR;
+ }
+ else if( IID_IObjectSafety == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcObjectSafety);
+ return NOERROR;
+ }
+ else if( IID_IDispatch == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(vlcControl);
+ return NOERROR;
+ }
+ else if( IID_IVLCControl == riid )
+ {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(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<LONG_PTR>(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<LONG_PTR>(this));
+
+ if( getVisible() )
+ ShowWindow(_inplacewnd, SW_SHOWNORMAL);
+
+ /* horrible cast there */
+ vlc_value_t val;
+ val.i_int = reinterpret_cast<int>(_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);
+ }
+};
+
-/*****************************************************************************\r
- * plugin.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __PLUGIN_H__\r
-#define __PLUGIN_H__\r
-\r
-#include <ole2.h>\r
-#include <olectl.h>\r
-\r
-#include <vlc/vlc.h>\r
-\r
-extern const GUID CLSID_VLCPlugin; \r
-extern const GUID LIBID_AXVLC; \r
-extern const GUID DIID_DVLCEvents; \r
-\r
-class VLCPluginClass : public IClassFactory\r
-{\r
-\r
-public:\r
-\r
- VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance);\r
-\r
- /* IUnknown methods */\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv);\r
- STDMETHODIMP_(ULONG) AddRef(void);\r
- STDMETHODIMP_(ULONG) Release(void);\r
-\r
- /* IClassFactory methods */\r
- STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);\r
- STDMETHODIMP LockServer(BOOL fLock);\r
-\r
- LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };\r
- LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };\r
- HINSTANCE getHInstance(void) const { return _hinstance; };\r
- HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; };\r
-\r
-protected:\r
-\r
- virtual ~VLCPluginClass();\r
-\r
-private:\r
-\r
- LPLONG _p_class_ref;\r
- HINSTANCE _hinstance;\r
- ATOM _inplace_wndclass_atom;\r
- ATOM _video_wndclass_atom;\r
- HBITMAP _inplace_hbitmap;\r
-};\r
-\r
-class VLCPlugin : public IUnknown\r
-{\r
-\r
-public:\r
-\r
- VLCPlugin(VLCPluginClass *p_class);\r
-\r
- /* IUnknown methods */\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv);\r
- STDMETHODIMP_(ULONG) AddRef(void);\r
- STDMETHODIMP_(ULONG) Release(void);\r
-\r
- /* custom methods */\r
- HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)\r
- { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };\r
- REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };\r
- REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };\r
-\r
- HRESULT onInitNew(void);\r
- HRESULT onClose(DWORD dwSaveOption);\r
-\r
- BOOL isInPlaceActive(void);\r
- HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);\r
- HRESULT onInPlaceDeactivate(void);\r
- HWND getInPlaceWindow(void) const { return _inplacewnd; };\r
-\r
- BOOL hasFocus(void);\r
- void setFocus(BOOL fFocus);\r
-\r
- UINT getCodePage(void) { return _codepage; };\r
- void setCodePage(UINT cp) { _codepage = cp; };\r
-\r
- int getVLCObject(void) { return _i_vlc; };\r
-\r
- // control properties\r
- void setSourceURL(const char *url) { _psz_src = strdup(url); };\r
- void setAutoStart(BOOL autostart) { _b_autostart = autostart; };\r
- void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };\r
- void setMute(BOOL mute) {\r
- if( mute && _i_vlc )\r
- {\r
- VLC_VolumeMute(_i_vlc);\r
- }\r
- };\r
- void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };\r
- void setVisible(BOOL fVisible);\r
- BOOL getVisible(void) { return _b_visible; };\r
-\r
- // container events\r
- void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);\r
- void onPaint(PAINTSTRUCT &ps, RECT &pr);\r
-\r
- // control events\r
- void firePropChangedEvent(DISPID dispid);\r
- void fireOnPlayEvent(void);\r
- void fireOnPauseEvent(void);\r
- void fireOnStopEvent(void);\r
-\r
-protected:\r
-\r
- virtual ~VLCPlugin();\r
-\r
-private:\r
-\r
- void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect);\r
-\r
- //implemented interfaces\r
- class VLCOleObject *vlcOleObject;\r
- class VLCOleControl *vlcOleControl;\r
- class VLCOleInPlaceObject *vlcOleInPlaceObject;\r
- class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;\r
- class VLCPersistStreamInit *vlcPersistStreamInit;\r
- class VLCPersistStorage *vlcPersistStorage;\r
- class VLCPersistPropertyBag *vlcPersistPropertyBag;\r
- class VLCProvideClassInfo *vlcProvideClassInfo;\r
- class VLCConnectionPointContainer *vlcConnectionPointContainer;\r
- class VLCObjectSafety *vlcObjectSafety;\r
- class VLCControl *vlcControl;\r
-\r
- // in place activated window (Clipping window)\r
- HWND _inplacewnd;\r
- // video window (Drawing window)\r
- HWND _videownd;\r
- RECT _bounds;\r
-\r
- VLCPluginClass *_p_class;\r
- ULONG _i_ref;\r
-\r
- UINT _codepage;\r
- char *_psz_src;\r
- BOOL _b_autostart;\r
- BOOL _b_loopmode;\r
- BOOL _b_visible;\r
- BOOL _b_sendevents;\r
- int _i_vlc;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * plugin.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ole2.h>
+#include <olectl.h>
+
+#include <vlc/vlc.h>
+
+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
+
-/*****************************************************************************\r
- * provideclassinfo.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "provideclassinfo.h"\r
-\r
-using namespace std;\r
-\r
-STDMETHODIMP VLCProvideClassInfo::GetClassInfo(ITypeInfo **ppTI)\r
-{\r
- ITypeLib *p_typelib;\r
-\r
- if( NULL == ppTI )\r
- return E_POINTER;\r
-\r
- HRESULT hr = _p_instance->getTypeLib(LOCALE_NEUTRAL, &p_typelib);\r
- if( SUCCEEDED(hr) )\r
- {\r
- hr = p_typelib->GetTypeInfoOfGuid(_p_instance->getClassID(), ppTI);\r
- if( FAILED(hr) )\r
- {\r
- *ppTI = NULL;\r
- }\r
- p_typelib->Release();\r
- }\r
- return hr;\r
-};\r
-\r
-STDMETHODIMP VLCProvideClassInfo::GetGUID(DWORD dwGuidKind, GUID *pGUID)\r
-{\r
- if( GUIDKIND_DEFAULT_SOURCE_DISP_IID != dwGuidKind )\r
- return E_INVALIDARG;\r
-\r
- if( NULL == pGUID )\r
- return E_POINTER;\r
-\r
- *pGUID = _p_instance->getDispEventID();\r
-\r
- return S_OK;\r
-};\r
-\r
+/*****************************************************************************
+ * provideclassinfo.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
-/*****************************************************************************\r
- * provideclassinfo.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __PROVIDECLASSINFO_H__\r
-#define __PROVIDECLASSINFO_H__\r
-\r
-#include <ocidl.h>\r
-\r
-class VLCProvideClassInfo : public IProvideClassInfo2\r
-{\r
-\r
-public:\r
-\r
- VLCProvideClassInfo(VLCPlugin *p_instance) : _p_instance(p_instance) {};\r
- virtual ~VLCProvideClassInfo() {};\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid) \r
- && (IID_IProvideClassInfo == riid) \r
- && (IID_IProvideClassInfo2 == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IProvideClassInfo methods\r
- STDMETHODIMP GetClassInfo(ITypeInfo **);\r
-\r
- // IProvideClassInfo2 methods\r
- STDMETHODIMP GetGUID(DWORD, GUID *);\r
-\r
-private:\r
-\r
- VLCPlugin *_p_instance;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * provideclassinfo.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ocidl.h>
+
+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<LPVOID>(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
+
-/*****************************************************************************\r
- * utils.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "utils.h"\r
-\r
-/*\r
-** conversion facilities\r
-*/\r
-\r
-using namespace std;\r
-\r
-char *CStrFromBSTR(int codePage, BSTR bstr)\r
-{\r
- UINT len = SysStringLen(bstr);\r
- if( len > 0 )\r
- {\r
- size_t mblen = WideCharToMultiByte(codePage,\r
- 0, bstr, len, NULL, 0, NULL, NULL);\r
- if( mblen > 0 )\r
- {\r
- char *buffer = (char *)malloc(mblen+1);\r
- ZeroMemory(buffer, mblen+1);\r
- if( WideCharToMultiByte(codePage, 0, bstr, len, buffer, mblen, NULL, NULL) )\r
- return buffer;\r
- }\r
- }\r
- return NULL;\r
-};\r
-\r
-BSTR BSTRFromCStr(int codePage, const char *s)\r
-{\r
- int wideLen = MultiByteToWideChar(codePage, 0, s, -1, NULL, 0);\r
- if( wideLen )\r
- {\r
- WCHAR* wideStr = (WCHAR*)malloc(wideLen*sizeof(WCHAR));\r
- if( NULL != wideStr )\r
- {\r
- BSTR bstr;\r
-\r
- ZeroMemory(wideStr, wideLen*sizeof(WCHAR));\r
- MultiByteToWideChar(codePage, 0, s, -1, wideStr, wideLen);\r
- bstr = SysAllocString(wideStr);\r
- free(wideStr);\r
-\r
- return bstr;\r
- }\r
- }\r
- return NULL;\r
-};\r
-\r
-/*\r
-** properties\r
-*/\r
-\r
-HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v)\r
-{\r
- IDispatch *pDisp;\r
- HRESULT hr = object->QueryInterface(IID_IDispatch, (LPVOID *)&pDisp);\r
- if( SUCCEEDED(hr) )\r
- {\r
- DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};\r
- VARIANT vres;\r
- hr = pDisp->Invoke(dispID, IID_NULL, LOCALE_USER_DEFAULT,\r
- DISPATCH_PROPERTYGET, &dispparamsNoArgs, &vres, NULL, NULL);\r
- if( SUCCEEDED(hr) )\r
- {\r
- if( V_VT(&v) != V_VT(&vres) )\r
- {\r
- hr = VariantChangeType(&v, &vres, 0, V_VT(&v));\r
- VariantClear(&vres);\r
- }\r
- else\r
- {\r
- v = vres;\r
- }\r
- }\r
- pDisp->Release();\r
- }\r
- return hr;\r
-};\r
-\r
-\r
+/*****************************************************************************
+ * utils.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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;
+};
+
+
-/*****************************************************************************\r
- * utils.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef __UTILS_H__\r
-#define __UTILS_H__\r
-\r
-#include <ole2.h>\r
-\r
-#include <vector>\r
-\r
-// utilities\r
-extern char *CStrFromBSTR(int codePage, BSTR bstr);\r
-extern BSTR BSTRFromCStr(int codePage, const char *s);\r
-\r
-// properties\r
-extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v);\r
-\r
-// enumeration\r
-template<class T> class VLCEnum : IUnknown\r
-{\r
-\r
-public:\r
-\r
- VLCEnum(REFIID riid, std::vector<T> &);\r
- VLCEnum(const VLCEnum<T> &);\r
- virtual ~VLCEnum() {};\r
-\r
- VLCEnum<T>& operator=(const VLCEnum<T> &t);\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **);\r
- STDMETHODIMP_(ULONG) AddRef(void);\r
- STDMETHODIMP_(ULONG) Release(void);\r
-\r
- // IEnumXXXX methods\r
- STDMETHODIMP Next(ULONG, T *, ULONG *);\r
- STDMETHODIMP Skip(ULONG);\r
- STDMETHODIMP Reset(void);\r
- // cloning is implemented by subclasses and must use copy constructor\r
- //STDMETHODIMP Clone(VLCEnum<T> **);\r
- // cloning is implemented by subclasses and must use copy constructor\r
-\r
- typedef void (*retainer)(T);\r
-\r
- void setRetainOperation(retainer retain) { _retain = retain; };\r
-\r
-private:\r
-\r
- LONG _refcount;\r
- std::vector<T> _v;\r
- typename std::vector<T>::iterator _i;\r
- REFIID _riid;\r
- retainer _retain;\r
-};\r
-\r
-template<class T>\r
-VLCEnum<T>::VLCEnum(REFIID riid, std::vector<T> &v) :\r
- _refcount(1),\r
- _v(v),\r
- _riid(riid),\r
- _retain(NULL)\r
-{\r
- _i= v.begin();\r
-};\r
-\r
-template<class T>\r
-VLCEnum<T>::VLCEnum(const VLCEnum<T> &e) :\r
- _refcount(1),\r
- _v(e._v),\r
- _riid(e._riid)\r
-{\r
-};\r
-\r
-template<class T>\r
-VLCEnum<T>& VLCEnum<T>::operator=(const VLCEnum<T> &e)\r
-{\r
- this->_refcount = 1;\r
- this->_riid = e._riid;\r
- this->_v = e._v;\r
- this->_i = e._i;\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP VLCEnum<T>::QueryInterface(REFIID riid, void **ppv)\r
-{\r
- if( NULL == ppv ) return E_POINTER;\r
- if( (IID_IUnknown == riid) \r
- && ( _riid == riid) ) {\r
- AddRef();\r
- *ppv = reinterpret_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return E_NOINTERFACE;\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP_(ULONG) VLCEnum<T>::AddRef(void)\r
-{\r
- return InterlockedIncrement(&_refcount);\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP_(ULONG) VLCEnum<T>::Release(void)\r
-{\r
- ULONG refcount = InterlockedDecrement(&_refcount);\r
- if( 0 == refcount )\r
- {\r
- delete this;\r
- return 0;\r
- }\r
- return refcount;\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP VLCEnum<T>::Next(ULONG celt, T *rgelt, ULONG *pceltFetched)\r
-{\r
- if( NULL == rgelt )\r
- return E_POINTER;\r
-\r
- if( (celt > 1) && (NULL == pceltFetched) )\r
- return E_INVALIDARG;\r
-\r
- ULONG c = 0;\r
- typename std::vector<T>::iterator end = _v.end();\r
-\r
- while( (c < celt) && (_i != end) )\r
- {\r
- rgelt[c] = *_i;\r
- if( NULL != _retain ) _retain(rgelt[c]);\r
- ++_i;\r
- ++c;\r
- }\r
-\r
- if( NULL != pceltFetched )\r
- *pceltFetched = c;\r
-\r
- return (c == celt) ? S_OK : S_FALSE;\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP VLCEnum<T>::Skip(ULONG celt)\r
-{\r
- ULONG c = 0;\r
- typename std::vector<T>::iterator end = _v.end();\r
-\r
- while( (c < celt) && (_i != end) )\r
- {\r
- ++_i;\r
- ++c;\r
- }\r
- return (c == celt) ? S_OK : S_FALSE;\r
-};\r
-\r
-template<class T>\r
-STDMETHODIMP VLCEnum<T>::Reset(void)\r
-{\r
- _i= _v.begin();\r
- return S_OK;\r
-};\r
-\r
-#endif\r
-\r
+/*****************************************************************************
+ * utils.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <ole2.h>
+
+#include <vector>
+
+// 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 T> class VLCEnum : IUnknown
+{
+
+public:
+
+ VLCEnum(REFIID riid, std::vector<T> &);
+ VLCEnum(const VLCEnum<T> &);
+ virtual ~VLCEnum() {};
+
+ VLCEnum<T>& operator=(const VLCEnum<T> &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<T> **);
+ // 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<T> _v;
+ typename std::vector<T>::iterator _i;
+ REFIID _riid;
+ retainer _retain;
+};
+
+template<class T>
+VLCEnum<T>::VLCEnum(REFIID riid, std::vector<T> &v) :
+ _refcount(1),
+ _v(v),
+ _riid(riid),
+ _retain(NULL)
+{
+ _i= v.begin();
+};
+
+template<class T>
+VLCEnum<T>::VLCEnum(const VLCEnum<T> &e) :
+ _refcount(1),
+ _v(e._v),
+ _riid(e._riid)
+{
+};
+
+template<class T>
+VLCEnum<T>& VLCEnum<T>::operator=(const VLCEnum<T> &e)
+{
+ this->_refcount = 1;
+ this->_riid = e._riid;
+ this->_v = e._v;
+ this->_i = e._i;
+};
+
+template<class T>
+STDMETHODIMP VLCEnum<T>::QueryInterface(REFIID riid, void **ppv)
+{
+ if( NULL == ppv ) return E_POINTER;
+ if( (IID_IUnknown == riid)
+ && ( _riid == riid) ) {
+ AddRef();
+ *ppv = reinterpret_cast<LPVOID>(this);
+ return NOERROR;
+ }
+ return E_NOINTERFACE;
+};
+
+template<class T>
+STDMETHODIMP_(ULONG) VLCEnum<T>::AddRef(void)
+{
+ return InterlockedIncrement(&_refcount);
+};
+
+template<class T>
+STDMETHODIMP_(ULONG) VLCEnum<T>::Release(void)
+{
+ ULONG refcount = InterlockedDecrement(&_refcount);
+ if( 0 == refcount )
+ {
+ delete this;
+ return 0;
+ }
+ return refcount;
+};
+
+template<class T>
+STDMETHODIMP VLCEnum<T>::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<T>::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<class T>
+STDMETHODIMP VLCEnum<T>::Skip(ULONG celt)
+{
+ ULONG c = 0;
+ typename std::vector<T>::iterator end = _v.end();
+
+ while( (c < celt) && (_i != end) )
+ {
+ ++_i;
+ ++c;
+ }
+ return (c == celt) ? S_OK : S_FALSE;
+};
+
+template<class T>
+STDMETHODIMP VLCEnum<T>::Reset(void)
+{
+ _i= _v.begin();
+ return S_OK;
+};
+
+#endif
+
-/*****************************************************************************\r
- * vlccontrol.cpp: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include "plugin.h"\r
-#include "vlccontrol.h"\r
-\r
-#include "utils.h"\r
-\r
-VLCControl::~VLCControl()\r
-{\r
- if( _p_typeinfo )\r
- _p_typeinfo->Release();\r
-};\r
-\r
-HRESULT VLCControl::getTypeInfo(void)\r
-{\r
- HRESULT hr = NOERROR;\r
- if( NULL == _p_typeinfo )\r
- {\r
- ITypeLib *p_typelib;\r
-\r
- HRESULT hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);\r
- if( SUCCEEDED(hr) )\r
- {\r
- hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCControl, &_p_typeinfo);\r
- if( FAILED(hr) )\r
- {\r
- _p_typeinfo = NULL;\r
- }\r
- p_typelib->Release();\r
- }\r
- }\r
- return hr;\r
-};\r
-\r
-STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo)\r
-{\r
- if( SUCCEEDED(getTypeInfo()) )\r
- *pctInfo = 1;\r
- else\r
- *pctInfo = 0;\r
-\r
- return NOERROR;\r
-};\r
-\r
-STDMETHODIMP VLCControl::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)\r
-{\r
- if( NULL == ppTInfo )\r
- return E_INVALIDARG;\r
-\r
- if( SUCCEEDED(getTypeInfo()) )\r
- {\r
- _p_typeinfo->AddRef();\r
- *ppTInfo = _p_typeinfo;\r
- return NO_ERROR;\r
- }\r
- *ppTInfo = NULL;\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCControl::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, \r
- UINT cNames, LCID lcid, DISPID* rgDispID)\r
-{\r
- if( SUCCEEDED(getTypeInfo()) )\r
- {\r
- return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);\r
- }\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCControl::Invoke(DISPID dispIdMember, REFIID riid,\r
- LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,\r
- VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)\r
-{\r
- if( SUCCEEDED(getTypeInfo()) )\r
- {\r
- return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,\r
- pVarResult, pExcepInfo, puArgErr);\r
- }\r
- return E_NOTIMPL;\r
-};\r
-\r
-STDMETHODIMP VLCControl::get_Value(VARIANT *pvarValue)\r
-{\r
- if( NULL == pvarValue )\r
- return E_INVALIDARG;\r
-\r
- V_VT(pvarValue) = VT_BOOL;\r
- return get_Playing(&V_BOOL(pvarValue));\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Value(VARIANT pvarValue)\r
-{\r
- if( VT_BOOL != V_VT(&pvarValue) )\r
- {\r
- VARIANT boolValue;\r
- HRESULT hr = VariantChangeType(&boolValue, &pvarValue, 0, VT_BOOL);\r
- if( SUCCEEDED(hr) )\r
- {\r
- hr = get_Playing(&V_BOOL(&pvarValue));\r
- //VariantClear(&boolValue);\r
- }\r
- return hr;\r
- }\r
- return get_Playing(&V_BOOL(&pvarValue));\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_Visible(VARIANT_BOOL *isVisible)\r
-{\r
- if( NULL == isVisible )\r
- return E_INVALIDARG;\r
-\r
- *isVisible = _p_instance->getVisible();\r
-\r
- return NOERROR;\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Visible(VARIANT_BOOL isVisible)\r
-{\r
- _p_instance->setVisible(isVisible != VARIANT_FALSE);\r
-\r
- return NOERROR;\r
-};\r
-\r
-STDMETHODIMP VLCControl::play(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_Play(i_vlc);\r
- _p_instance->fireOnPlayEvent();\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::pause(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_Pause(i_vlc);\r
- _p_instance->fireOnPauseEvent();\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::stop(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_Stop(i_vlc);\r
- _p_instance->fireOnStopEvent();\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-}\r
- \r
-STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)\r
-{\r
- if( NULL == isPlaying )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *isPlaying = VLC_IsPlaying(i_vlc) ? VARIANT_TRUE : VARIANT_FALSE;\r
- return NOERROR;\r
- }\r
- *isPlaying = VARIANT_FALSE;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Playing(VARIANT_BOOL isPlaying)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- if( VARIANT_FALSE == isPlaying )\r
- {\r
- if( VLC_IsPlaying(i_vlc) )\r
- VLC_Stop(i_vlc);\r
- }\r
- else\r
- {\r
- if( ! VLC_IsPlaying(i_vlc) )\r
- VLC_Play(i_vlc);\r
- }\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_Position(float *position)\r
-{\r
- if( NULL == position )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *position = VLC_PositionGet(i_vlc);\r
- return NOERROR;\r
- }\r
- *position = 0.0f;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Position(float position)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_PositionSet(i_vlc, position);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_Time(int *seconds)\r
-{\r
- if( NULL == seconds )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *seconds = VLC_TimeGet(i_vlc);\r
- return NOERROR;\r
- }\r
- *seconds = 0;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Time(int seconds)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_TimeSet(i_vlc, seconds, VLC_FALSE);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::shuttle(int seconds)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_TimeSet(i_vlc, seconds, VLC_TRUE);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::fullscreen(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_FullScreen(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_Length(int *seconds)\r
-{\r
- if( NULL == seconds )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *seconds = VLC_LengthGet(i_vlc);\r
- return NOERROR;\r
- }\r
- *seconds = 0;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::playFaster(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_SpeedFaster(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::playSlower(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_SpeedSlower(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_Volume(int *volume)\r
-{\r
- if( NULL == volume )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *volume = VLC_VolumeGet(i_vlc);\r
- return NOERROR;\r
- }\r
- *volume = 0;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::put_Volume(int volume)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_VolumeSet(i_vlc, volume);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::toggleMute(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_VolumeMute(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
-\r
-static void freeTargetOptions(char **cOptions, int cOptionCount)\r
-{\r
- // clean up \r
- for( long pos=0; pos<cOptionCount; ++pos )\r
- {\r
- char *cOption = cOptions[pos];\r
- if( NULL != cOption )\r
- free(cOption);\r
- else\r
- break;\r
- }\r
- if( NULL != cOptions )\r
- free(cOptions);\r
-};\r
-\r
-static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount)\r
-{\r
- HRESULT hr = E_INVALIDARG;\r
- if( VT_ERROR == V_VT(options) )\r
- {\r
- if( DISP_E_PARAMNOTFOUND == V_ERROR(options) )\r
- {\r
- // optional parameter not set\r
- *cOptions = NULL;\r
- *cOptionCount = 0;\r
- return NOERROR;\r
- }\r
- }\r
- else if( (VT_EMPTY == V_VT(options)) || (VT_NULL == V_VT(options)) )\r
- {\r
- // null parameter\r
- *cOptions = NULL;\r
- *cOptionCount = 0;\r
- return NOERROR;\r
- }\r
- else if( VT_DISPATCH == V_VT(options) )\r
- {\r
- // collection parameter\r
- VARIANT colEnum;\r
- V_VT(&colEnum) = VT_UNKNOWN;\r
- hr = GetObjectProperty(V_DISPATCH(options), DISPID_NEWENUM, colEnum);\r
- if( SUCCEEDED(hr) )\r
- {\r
- IEnumVARIANT *enumVar;\r
- hr = V_UNKNOWN(&colEnum)->QueryInterface(IID_IEnumVARIANT, (LPVOID *)&enumVar);\r
- if( SUCCEEDED(hr) )\r
- {\r
- long pos = 0;\r
- long capacity = 16;\r
- VARIANT option;\r
-\r
- *cOptions = (char **)malloc(capacity*sizeof(char *));\r
- if( NULL != *cOptions )\r
- {\r
- ZeroMemory(*cOptions, sizeof(char *)*capacity);\r
- while( SUCCEEDED(hr) && (S_OK == enumVar->Next(1, &option, NULL)) )\r
- {\r
- if( VT_BSTR == V_VT(&option) )\r
- {\r
- char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));\r
- (*cOptions)[pos] = cOption;\r
- if( NULL != cOption )\r
- {\r
- ++pos;\r
- if( pos == capacity )\r
- {\r
- char **moreOptions = (char **)realloc(*cOptions, (capacity+16)*sizeof(char *));\r
- if( NULL != moreOptions )\r
- {\r
- ZeroMemory(moreOptions+capacity, sizeof(char *)*16);\r
- capacity += 16;\r
- *cOptions = moreOptions;\r
- }\r
- else\r
- hr = E_OUTOFMEMORY;\r
- }\r
- }\r
- else\r
- hr = E_OUTOFMEMORY;\r
- }\r
- else\r
- hr = E_INVALIDARG;\r
-\r
- VariantClear(&option);\r
- }\r
- *cOptionCount = pos;\r
- if( FAILED(hr) )\r
- {\r
- // free already processed elements\r
- freeTargetOptions(*cOptions, *cOptionCount);\r
- }\r
- }\r
- else\r
- hr = E_OUTOFMEMORY;\r
- enumVar->Release();\r
- }\r
- }\r
- }\r
- else if( V_ISARRAY(options) )\r
- {\r
- // array parameter\r
- SAFEARRAY *array = V_ISBYREF(options) ? *V_ARRAYREF(options) : V_ARRAY(options);\r
-\r
- if( SafeArrayGetDim(array) != 1 )\r
- return E_INVALIDARG;\r
-\r
- long lBound = 0;\r
- long uBound = 0;\r
- SafeArrayGetLBound(array, 1, &lBound);\r
- SafeArrayGetUBound(array, 1, &uBound);\r
-\r
- // have we got any options\r
- if( uBound > lBound )\r
- {\r
- VARTYPE vType;\r
- HRESULT hr = SafeArrayGetVartype(array, &vType);\r
- if( FAILED(hr) )\r
- return hr;\r
-\r
- long pos;\r
-\r
- // marshall options into an array of C strings\r
- if( VT_VARIANT == vType )\r
- {\r
- *cOptions = (char **)malloc(sizeof(char *)*(uBound-lBound));\r
- if( NULL != options )\r
- return E_OUTOFMEMORY;\r
-\r
- for(pos=lBound; SUCCEEDED(hr) && (pos<uBound); ++pos )\r
- {\r
- VARIANT option;\r
- hr = SafeArrayGetElement(array, &pos, &option);\r
- if( SUCCEEDED(hr) )\r
- {\r
- if( VT_BSTR == V_VT(&option) ) \r
- {\r
- char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));\r
- (*cOptions)[pos-lBound] = cOption;\r
- if( NULL == cOption )\r
- hr = E_OUTOFMEMORY;\r
- }\r
- else\r
- hr = E_INVALIDARG;\r
- VariantClear(&option);\r
- }\r
- }\r
- }\r
- else if( VT_BSTR == vType )\r
- {\r
- *cOptions = (char **)malloc(sizeof(char *)*(uBound-lBound));\r
- if( NULL != options )\r
- return E_OUTOFMEMORY;\r
-\r
- ZeroMemory(cOptions, sizeof(char *)*(uBound-lBound));\r
- for(pos=lBound; SUCCEEDED(hr) && (pos<uBound); ++pos )\r
- {\r
- BSTR option;\r
- hr = SafeArrayGetElement(array, &pos, &option);\r
- if( SUCCEEDED(hr) )\r
- {\r
- char *cOption = CStrFromBSTR(codePage, option);\r
- (*cOptions)[pos-lBound] = cOption;\r
- if( NULL == cOption )\r
- hr = E_OUTOFMEMORY;\r
- SysFreeString(option);\r
- }\r
- }\r
- }\r
- else\r
- // unsupported type\r
- return E_INVALIDARG;\r
-\r
- *cOptionCount = pos-lBound;\r
- if( FAILED(hr) )\r
- {\r
- // free already processed elements\r
- freeTargetOptions(*cOptions, *cOptionCount);\r
- }\r
- }\r
- else\r
- {\r
- // empty array\r
- *cOptions = NULL;\r
- *cOptionCount = 0;\r
- return NOERROR;\r
- }\r
- }\r
- return hr;\r
-};\r
-\r
-/*\r
-** use VARIANT rather than a SAFEARRAY as argument type\r
-** for compatibility with some scripting language (JScript)\r
-*/\r
-\r
-STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)\r
-{\r
- if( NULL == uri )\r
- return E_INVALIDARG;\r
-\r
- HRESULT hr = E_UNEXPECTED;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- int codePage = _p_instance->getCodePage();\r
- char *cUri = CStrFromBSTR(codePage, uri);\r
- if( NULL == cUri )\r
- return E_OUTOFMEMORY;\r
-\r
- int cOptionsCount;\r
- char **cOptions;\r
-\r
- if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) )\r
- return E_INVALIDARG;\r
-\r
- VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position);\r
- hr = NOERROR;\r
-\r
- freeTargetOptions(cOptions, cOptionsCount);\r
- free(cUri);\r
- }\r
- return hr;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_PlaylistIndex(int *index)\r
-{\r
- if( NULL == index )\r
- return E_INVALIDARG;\r
-\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *index = VLC_PlaylistIndex(i_vlc);\r
- return NOERROR;\r
- }\r
- *index = 0;\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_PlaylistCount(int *count)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- *count = VLC_PlaylistNumberOfItems(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::playlistNext(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_PlaylistNext(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::playlistPrev(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_PlaylistPrev(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::playlistClear(void)\r
-{\r
- int i_vlc = _p_instance->getVLCObject();\r
- if( i_vlc )\r
- {\r
- VLC_PlaylistClear(i_vlc);\r
- return NOERROR;\r
- }\r
- return E_UNEXPECTED;\r
-};\r
- \r
-STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)\r
-{\r
- if( NULL == version )\r
- return E_INVALIDARG;\r
-\r
- const char *versionStr = VLC_Version();\r
- if( NULL != versionStr )\r
- {\r
- *version = BSTRFromCStr(_p_instance->getCodePage(), versionStr);\r
- \r
- return NULL == *version ? E_OUTOFMEMORY : NOERROR;\r
- }\r
- *version = NULL;\r
- return E_FAIL;\r
-};\r
- \r
+/*****************************************************************************
+ * vlccontrol.cpp: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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; pos<cOptionCount; ++pos )
+ {
+ char *cOption = cOptions[pos];
+ if( NULL != cOption )
+ free(cOption);
+ else
+ break;
+ }
+ if( NULL != cOptions )
+ free(cOptions);
+};
+
+static HRESULT createTargetOptions(int codePage, VARIANT *options, char ***cOptions, int *cOptionCount)
+{
+ HRESULT hr = E_INVALIDARG;
+ if( VT_ERROR == V_VT(options) )
+ {
+ if( DISP_E_PARAMNOTFOUND == V_ERROR(options) )
+ {
+ // optional parameter not set
+ *cOptions = NULL;
+ *cOptionCount = 0;
+ return NOERROR;
+ }
+ }
+ else if( (VT_EMPTY == V_VT(options)) || (VT_NULL == V_VT(options)) )
+ {
+ // null parameter
+ *cOptions = NULL;
+ *cOptionCount = 0;
+ return NOERROR;
+ }
+ else if( VT_DISPATCH == V_VT(options) )
+ {
+ // collection parameter
+ VARIANT colEnum;
+ V_VT(&colEnum) = VT_UNKNOWN;
+ hr = GetObjectProperty(V_DISPATCH(options), DISPID_NEWENUM, colEnum);
+ if( SUCCEEDED(hr) )
+ {
+ IEnumVARIANT *enumVar;
+ hr = V_UNKNOWN(&colEnum)->QueryInterface(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) && (pos<uBound); ++pos )
+ {
+ VARIANT option;
+ hr = SafeArrayGetElement(array, &pos, &option);
+ if( SUCCEEDED(hr) )
+ {
+ if( VT_BSTR == V_VT(&option) )
+ {
+ char *cOption = CStrFromBSTR(codePage, V_BSTR(&option));
+ (*cOptions)[pos-lBound] = cOption;
+ if( NULL == cOption )
+ hr = E_OUTOFMEMORY;
+ }
+ else
+ hr = E_INVALIDARG;
+ VariantClear(&option);
+ }
+ }
+ }
+ else if( VT_BSTR == vType )
+ {
+ *cOptions = (char **)malloc(sizeof(char *)*(uBound-lBound));
+ if( NULL != options )
+ return E_OUTOFMEMORY;
+
+ ZeroMemory(cOptions, sizeof(char *)*(uBound-lBound));
+ for(pos=lBound; SUCCEEDED(hr) && (pos<uBound); ++pos )
+ {
+ BSTR option;
+ hr = SafeArrayGetElement(array, &pos, &option);
+ if( SUCCEEDED(hr) )
+ {
+ char *cOption = CStrFromBSTR(codePage, option);
+ (*cOptions)[pos-lBound] = cOption;
+ if( NULL == cOption )
+ hr = E_OUTOFMEMORY;
+ SysFreeString(option);
+ }
+ }
+ }
+ else
+ // unsupported type
+ return E_INVALIDARG;
+
+ *cOptionCount = pos-lBound;
+ if( FAILED(hr) )
+ {
+ // free already processed elements
+ freeTargetOptions(*cOptions, *cOptionCount);
+ }
+ }
+ else
+ {
+ // empty array
+ *cOptions = NULL;
+ *cOptionCount = 0;
+ return NOERROR;
+ }
+ }
+ return hr;
+};
+
+/*
+** use VARIANT rather than a SAFEARRAY as argument type
+** for compatibility with some scripting language (JScript)
+*/
+
+STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position)
+{
+ if( NULL == uri )
+ return E_INVALIDARG;
+
+ HRESULT hr = E_UNEXPECTED;
+
+ int i_vlc = _p_instance->getVLCObject();
+ 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;
+};
+
-/*****************************************************************************\r
- * vlccontrol.h: ActiveX control for VLC\r
- *****************************************************************************\r
- * Copyright (C) 2005 VideoLAN\r
- *\r
- * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#ifndef _VLCCONTROL_H_\r
-#define _VLCCONTROL_H_\r
-\r
-#include <oaidl.h>\r
-#include "axvlc_idl.h"\r
-\r
-class VLCControl : public IVLCControl\r
-{\r
- \r
-public:\r
-\r
- VLCControl(VLCPlugin *p_instance) : _p_instance(p_instance), _p_typeinfo(NULL) {};\r
- virtual ~VLCControl();\r
-\r
- // IUnknown methods\r
- STDMETHODIMP QueryInterface(REFIID riid, void **ppv)\r
- {\r
- if( (NULL != ppv)\r
- && (IID_IUnknown == riid)\r
- && (IID_IDispatch == riid)\r
- && (IID_IVLCControl == riid) ) {\r
- AddRef();\r
- *ppv = dynamic_cast<LPVOID>(this);\r
- return NOERROR;\r
- }\r
- return _p_instance->QueryInterface(riid, ppv);\r
- };\r
-\r
- STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };\r
- STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };\r
-\r
- // IDispatch methods\r
- STDMETHODIMP GetTypeInfoCount(UINT*);\r
- STDMETHODIMP GetTypeInfo(UINT, LCID, LPTYPEINFO*);\r
- STDMETHODIMP GetIDsOfNames(REFIID,LPOLESTR*,UINT,LCID,DISPID*);\r
- STDMETHODIMP Invoke(DISPID,REFIID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,UINT*);\r
-\r
- // IVLCControl methods\r
- STDMETHODIMP get_Value(VARIANT *pvarValue);\r
- STDMETHODIMP put_Value(VARIANT pvarValue);\r
- STDMETHODIMP play(void);\r
- STDMETHODIMP get_Visible(VARIANT_BOOL *visible);\r
- STDMETHODIMP put_Visible(VARIANT_BOOL visible);\r
- STDMETHODIMP pause(void);\r
- STDMETHODIMP stop(void);\r
- STDMETHODIMP get_Playing(VARIANT_BOOL *isPlaying);\r
- STDMETHODIMP put_Playing(VARIANT_BOOL isPlaying);\r
- STDMETHODIMP get_Position(float *position);\r
- STDMETHODIMP put_Position(float position);\r
- STDMETHODIMP get_Time(int *seconds);\r
- STDMETHODIMP put_Time(int seconds);\r
- STDMETHODIMP shuttle(int seconds);\r
- STDMETHODIMP fullscreen();\r
- STDMETHODIMP get_Length(int *seconds);\r
- STDMETHODIMP playFaster(void);\r
- STDMETHODIMP playSlower(void);\r
- STDMETHODIMP get_Volume(int *volume);\r
- STDMETHODIMP put_Volume(int volume);\r
- STDMETHODIMP toggleMute(void);\r
- STDMETHODIMP addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position);\r
- STDMETHODIMP get_PlaylistIndex(int *index);\r
- STDMETHODIMP get_PlaylistCount(int *count);\r
- STDMETHODIMP playlistNext(void);\r
- STDMETHODIMP playlistPrev(void);\r
- STDMETHODIMP playlistClear(void);\r
- STDMETHODIMP get_VersionInfo(BSTR *version);\r
- \r
-private:\r
-\r
- HRESULT getTypeInfo();\r
-\r
- VLCPlugin *_p_instance;\r
- ITypeInfo *_p_typeinfo;\r
-\r
-};\r
- \r
-#endif\r
-\r
+/*****************************************************************************
+ * vlccontrol.h: ActiveX control for VLC
+ *****************************************************************************
+ * Copyright (C) 2005 VideoLAN
+ *
+ * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *
+ * 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 <oaidl.h>
+#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<LPVOID>(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
+
* 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 <polux@via.ecp.fr>
*
* 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 <thedj at users.sourceforge.net>
*
* 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 <jb@technologeek.org>
*
* 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 <stef@via.ecp.fr>
* Arnaud de Bossoreille de Ribou <bozo@via.ecp.fr>
* 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 <sam@zoy.org>
* Gildas Bazin <gbazin@netcourrier.com>
* 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
* 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
* 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 <fenrir@via.ecp.fr>
*
* 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 <sam@zoy.org>
*
* 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 <sam@zoy.org>
*
* 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 <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* 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 <sam@zoy.org>
* Gildas Bazin <gbazin@netcourrier.com>
* beos.cpp: Screen capture module.
*****************************************************************************
* Copyright (C) 2004 VideoLAN
- * $Id: screen.c 8284 2004-07-26 10:27:55Z gbazin $
+ * $Id$
*
* Authors: Eric Petit <titer@m0k.org>
*
* 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
* 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 <jobi@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* 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 <jobi@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* 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 <jobi@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* equalizer_presets.h:
*****************************************************************************
* Copyright (C) 2004 VideoLAN
- * $Id:$
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* 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 <gbazin@netcourrier.com>
*
-/*****************************************************************************\r
- * video.c: video decoder using the ffmpeg library\r
- *****************************************************************************\r
- * Copyright (C) 1999-2001 VideoLAN\r
- * $Id$\r
- *\r
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>\r
- * Gildas Bazin <gbazin@videolan.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-/*****************************************************************************\r
- * Preamble\r
- *****************************************************************************/\r
-#include <vlc/vlc.h>\r
-#include <vlc/decoder.h>\r
-\r
-/* ffmpeg header */\r
-#ifdef HAVE_FFMPEG_AVCODEC_H\r
-# include <ffmpeg/avcodec.h>\r
-#else\r
-# include <avcodec.h>\r
-#endif\r
-\r
-#include "ffmpeg.h"\r
-\r
-/*****************************************************************************\r
- * decoder_sys_t : decoder descriptor\r
- *****************************************************************************/\r
-struct decoder_sys_t\r
-{\r
- /* Common part between video and audio decoder */\r
- int i_cat;\r
- int i_codec_id;\r
- char *psz_namecodec;\r
-\r
- AVCodecContext *p_context;\r
- AVCodec *p_codec;\r
-\r
- /* Video decoder specific part */\r
- mtime_t input_pts;\r
- mtime_t input_dts;\r
- mtime_t i_pts;\r
-\r
- AVFrame *p_ff_pic;\r
- BITMAPINFOHEADER *p_format;\r
-\r
- /* for frame skipping algo */\r
- int b_hurry_up;\r
- int i_frame_skip;\r
-\r
- /* how many decoded frames are late */\r
- int i_late_frames;\r
- mtime_t i_late_frames_start;\r
-\r
- /* for direct rendering */\r
- int b_direct_rendering;\r
-\r
- vlc_bool_t b_has_b_frames;\r
-\r
- /* Hack to force display of still pictures */\r
- vlc_bool_t b_first_frame;\r
-\r
- int i_buffer_orig, i_buffer;\r
- char *p_buffer_orig, *p_buffer;\r
-\r
- /* Postprocessing handle */\r
- void *p_pp;\r
- vlc_bool_t b_pp;\r
- vlc_bool_t b_pp_async;\r
- vlc_bool_t b_pp_init;\r
-};\r
-\r
-/* FIXME (dummy palette for now) */\r
-static AVPaletteControl palette_control;\r
-\r
-/*****************************************************************************\r
- * Local prototypes\r
- *****************************************************************************/\r
-static void ffmpeg_CopyPicture ( decoder_t *, picture_t *, AVFrame * );\r
-static int ffmpeg_GetFrameBuf ( struct AVCodecContext *, AVFrame * );\r
-static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *, AVFrame * );\r
-\r
-static uint32_t ffmpeg_CodecTag( vlc_fourcc_t fcc )\r
-{\r
- uint8_t *p = (uint8_t*)&fcc;\r
- return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);\r
-}\r
-\r
-/*****************************************************************************\r
- * Local Functions\r
- *****************************************************************************/\r
-static uint32_t ffmpeg_PixFmtToChroma( int i_ff_chroma )\r
-{\r
- switch( i_ff_chroma )\r
- {\r
- case PIX_FMT_YUV420P:\r
- return VLC_FOURCC('I','4','2','0');\r
- case PIX_FMT_YUV422P:\r
- return VLC_FOURCC('I','4','2','2');\r
- case PIX_FMT_YUV444P:\r
- return VLC_FOURCC('I','4','4','4');\r
-\r
- case PIX_FMT_YUV422:\r
- return VLC_FOURCC('Y','U','Y','2');\r
-\r
- case PIX_FMT_RGB555:\r
- return VLC_FOURCC('R','V','1','5');\r
- case PIX_FMT_RGB565:\r
- return VLC_FOURCC('R','V','1','6');\r
- case PIX_FMT_RGB24:\r
- return VLC_FOURCC('R','V','2','4');\r
- case PIX_FMT_RGBA32:\r
- return VLC_FOURCC('R','V','3','2');\r
- case PIX_FMT_GRAY8:\r
- return VLC_FOURCC('G','R','E','Y');\r
-\r
- case PIX_FMT_YUV410P:\r
- case PIX_FMT_YUV411P:\r
- case PIX_FMT_BGR24:\r
- default:\r
- return 0;\r
- }\r
-}\r
-\r
-/* Returns a new picture buffer */\r
-static inline picture_t *ffmpeg_NewPictBuf( decoder_t *p_dec,\r
- AVCodecContext *p_context )\r
-{\r
- decoder_sys_t *p_sys = p_dec->p_sys;\r
- picture_t *p_pic;\r
-\r
- p_dec->fmt_out.video.i_width = p_context->width;\r
- p_dec->fmt_out.video.i_height = p_context->height;\r
- p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );\r
-\r
- if( !p_context->width || !p_context->height )\r
- {\r
- return NULL; /* invalid display size */\r
- }\r
-\r
- if( !p_dec->fmt_out.i_codec )\r
- {\r
- /* we make conversion if possible*/\r
- p_dec->fmt_out.i_codec = VLC_FOURCC('I','4','2','0');\r
- }\r
-\r
- /* If an aspect-ratio was specified in the input format then force it */\r
- if( p_dec->fmt_in.video.i_aspect )\r
- {\r
- p_dec->fmt_out.video.i_aspect = p_dec->fmt_in.video.i_aspect;\r
- }\r
- else\r
- {\r
-#if LIBAVCODEC_BUILD >= 4687\r
- p_dec->fmt_out.video.i_aspect =\r
- VOUT_ASPECT_FACTOR * ( av_q2d(p_context->sample_aspect_ratio) *\r
- p_context->width / p_context->height );\r
-#else\r
- p_dec->fmt_out.video.i_aspect =\r
- VOUT_ASPECT_FACTOR * p_context->aspect_ratio;\r
-#endif\r
- if( p_dec->fmt_out.video.i_aspect == 0 )\r
- {\r
- p_dec->fmt_out.video.i_aspect =\r
- VOUT_ASPECT_FACTOR * p_context->width / p_context->height;\r
- }\r
- }\r
-\r
- if( p_context->frame_rate > 0 && p_context->frame_rate_base > 0 )\r
- {\r
- p_dec->fmt_out.video.i_frame_rate = p_context->frame_rate;\r
- p_dec->fmt_out.video.i_frame_rate_base = p_context->frame_rate_base;\r
- }\r
-\r
- p_pic = p_dec->pf_vout_buffer_new( p_dec );\r
-\r
-#ifdef LIBAVCODEC_PP\r
- if( p_sys->p_pp && p_sys->b_pp && !p_sys->b_pp_init )\r
- {\r
- E_(InitPostproc)( p_dec, p_sys->p_pp, p_context->width,\r
- p_context->height, p_context->pix_fmt );\r
- p_sys->b_pp_init = VLC_TRUE;\r
- }\r
-#endif\r
-\r
- return p_pic;\r
-}\r
-\r
-/*****************************************************************************\r
- * InitVideo: initialize the video decoder\r
- *****************************************************************************\r
- * the ffmpeg codec will be opened, some memory allocated. The vout is not yet\r
- * opened (done after the first decoded frame).\r
- *****************************************************************************/\r
-int E_(InitVideoDec)( decoder_t *p_dec, AVCodecContext *p_context,\r
- AVCodec *p_codec, int i_codec_id, char *psz_namecodec )\r
-{\r
- decoder_sys_t *p_sys;\r
- vlc_value_t lockval;\r
- vlc_value_t val;\r
-\r
- var_Get( p_dec->p_libvlc, "avcodec", &lockval );\r
-\r
- /* Allocate the memory needed to store the decoder's structure */\r
- if( ( p_dec->p_sys = p_sys =\r
- (decoder_sys_t *)malloc(sizeof(decoder_sys_t)) ) == NULL )\r
- {\r
- msg_Err( p_dec, "out of memory" );\r
- return VLC_EGENERIC;\r
- }\r
-\r
- p_dec->p_sys->p_context = p_context;\r
- p_dec->p_sys->p_codec = p_codec;\r
- p_dec->p_sys->i_codec_id = i_codec_id;\r
- p_dec->p_sys->psz_namecodec = psz_namecodec;\r
- p_sys->p_ff_pic = avcodec_alloc_frame();\r
-\r
- /* ***** Fill p_context with init values ***** */\r
- /* FIXME: remove when ffmpeg deals properly with avc1 */\r
- if( p_dec->fmt_in.i_codec != VLC_FOURCC('a','v','c','1') )\r
- /* End FIXME */\r
- p_sys->p_context->codec_tag = ffmpeg_CodecTag( p_dec->fmt_in.i_codec );\r
- p_sys->p_context->width = p_dec->fmt_in.video.i_width;\r
- p_sys->p_context->height = p_dec->fmt_in.video.i_height;\r
- p_sys->p_context->bits_per_sample = p_dec->fmt_in.video.i_bits_per_pixel;\r
-\r
- /* ***** Get configuration of ffmpeg plugin ***** */\r
- p_sys->p_context->workaround_bugs =\r
- config_GetInt( p_dec, "ffmpeg-workaround-bugs" );\r
- p_sys->p_context->error_resilience =\r
- config_GetInt( p_dec, "ffmpeg-error-resilience" );\r
-\r
- var_Create( p_dec, "grayscale", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );\r
- var_Get( p_dec, "grayscale", &val );\r
- if( val.b_bool ) p_sys->p_context->flags |= CODEC_FLAG_GRAY;\r
-\r
- var_Create( p_dec, "ffmpeg-vismv", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );\r
- var_Get( p_dec, "ffmpeg-vismv", &val );\r
-#if LIBAVCODEC_BUILD >= 4698\r
- if( val.i_int ) p_sys->p_context->debug_mv = val.i_int;\r
-#endif\r
-\r
- var_Create( p_dec, "ffmpeg-lowres", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );\r
- var_Get( p_dec, "ffmpeg-lowres", &val );\r
-#if LIBAVCODEC_BUILD >= 4723\r
- if( val.i_int > 0 && val.i_int <= 2 ) p_sys->p_context->lowres = val.i_int;\r
-#endif\r
-\r
- /* ***** ffmpeg frame skipping ***** */\r
- var_Create( p_dec, "ffmpeg-hurry-up", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );\r
- var_Get( p_dec, "ffmpeg-hurry-up", &val );\r
- p_sys->b_hurry_up = val.b_bool;\r
-\r
- /* ***** ffmpeg direct rendering ***** */\r
- p_sys->b_direct_rendering = 0;\r
- var_Create( p_dec, "ffmpeg-dr", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );\r
- var_Get( p_dec, "ffmpeg-dr", &val );\r
- if( val.b_bool && (p_sys->p_codec->capabilities & CODEC_CAP_DR1) &&\r
- ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) &&\r
- /* Apparently direct rendering doesn't work with YUV422P */\r
- p_sys->p_context->pix_fmt != PIX_FMT_YUV422P &&\r
- /* H264 uses too many reference frames */\r
- p_sys->i_codec_id != CODEC_ID_H264 &&\r
- !(p_sys->p_context->width % 16) && !(p_sys->p_context->height % 16) &&\r
-#if LIBAVCODEC_BUILD >= 4698\r
- !p_sys->p_context->debug_mv )\r
-#else\r
- 1 )\r
-#endif\r
- {\r
- /* Some codecs set pix_fmt only after the 1st frame has been decoded,\r
- * so we need to do another check in ffmpeg_GetFrameBuf() */\r
- p_sys->b_direct_rendering = 1;\r
- }\r
-\r
-#ifdef LIBAVCODEC_PP\r
- p_sys->p_pp = NULL;\r
- p_sys->b_pp = p_sys->b_pp_async = p_sys->b_pp_init = VLC_FALSE;\r
- p_sys->p_pp = E_(OpenPostproc)( p_dec, &p_sys->b_pp_async );\r
-#endif\r
-\r
- /* ffmpeg doesn't properly release old pictures when frames are skipped */\r
- //if( p_sys->b_hurry_up ) p_sys->b_direct_rendering = 0;\r
- if( p_sys->b_direct_rendering )\r
- {\r
- msg_Dbg( p_dec, "using direct rendering" );\r
- p_sys->p_context->flags |= CODEC_FLAG_EMU_EDGE;\r
- }\r
-\r
- /* Always use our get_buffer wrapper so we can calculate the\r
- * PTS correctly */\r
- p_sys->p_context->get_buffer = ffmpeg_GetFrameBuf;\r
- p_sys->p_context->release_buffer = ffmpeg_ReleaseFrameBuf;\r
- p_sys->p_context->opaque = p_dec;\r
-\r
- /* ***** init this codec with special data ***** */\r
- if( p_dec->fmt_in.i_extra )\r
- {\r
- int i_size = p_dec->fmt_in.i_extra;\r
-\r
- if( p_sys->i_codec_id == CODEC_ID_SVQ3 )\r
- {\r
- uint8_t *p;\r
-\r
- p_sys->p_context->extradata_size = i_size + 12;\r
- p = p_sys->p_context->extradata =\r
- malloc( p_sys->p_context->extradata_size );\r
-\r
- memcpy( &p[0], "SVQ3", 4 );\r
- memset( &p[4], 0, 8 );\r
- memcpy( &p[12], p_dec->fmt_in.p_extra, i_size );\r
-\r
- /* Now remove all atoms before the SMI one */\r
- if( p_sys->p_context->extradata_size > 0x5a &&\r
- strncmp( &p[0x56], "SMI ", 4 ) )\r
- {\r
- uint8_t *psz = &p[0x52];\r
-\r
- while( psz < &p[p_sys->p_context->extradata_size - 8] )\r
- {\r
- int i_size = GetDWBE( psz );\r
- if( i_size <= 1 )\r
- {\r
- /* FIXME handle 1 as long size */\r
- break;\r
- }\r
- if( !strncmp( &psz[4], "SMI ", 4 ) )\r
- {\r
- memmove( &p[0x52], psz,\r
- &p[p_sys->p_context->extradata_size] - psz );\r
- break;\r
- }\r
-\r
- psz += i_size;\r
- }\r
- }\r
- }\r
- else if( p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '0' ) ||\r
- p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '1', '3' ) ||\r
- p_dec->fmt_in.i_codec == VLC_FOURCC( 'R', 'V', '2', '0' ) )\r
- {\r
- if( p_dec->fmt_in.i_extra == 8 )\r
- {\r
- p_sys->p_context->extradata_size = 8;\r
- p_sys->p_context->extradata = malloc( 8 );\r
-\r
- memcpy( p_sys->p_context->extradata,\r
- p_dec->fmt_in.p_extra,\r
- p_dec->fmt_in.i_extra );\r
- p_sys->p_context->sub_id= ((uint32_t*)p_dec->fmt_in.p_extra)[1];\r
-\r
- msg_Warn( p_dec, "using extra data for RV codec sub_id=%08x",\r
- p_sys->p_context->sub_id );\r
- }\r
- }\r
- /* FIXME: remove when ffmpeg deals properly with avc1 */\r
- else if( p_dec->fmt_in.i_codec == VLC_FOURCC('a','v','c','1') )\r
- {\r
- ;\r
- }\r
- /* End FIXME */\r
- else\r
- {\r
- p_sys->p_context->extradata_size = i_size;\r
- p_sys->p_context->extradata =\r
- malloc( i_size + FF_INPUT_BUFFER_PADDING_SIZE );\r
- memcpy( p_sys->p_context->extradata,\r
- p_dec->fmt_in.p_extra, i_size );\r
- memset( &((uint8_t*)p_sys->p_context->extradata)[i_size],\r
- 0, FF_INPUT_BUFFER_PADDING_SIZE );\r
- }\r
- }\r
-\r
- /* ***** misc init ***** */\r
- p_sys->input_pts = p_sys->input_dts = 0;\r
- p_sys->i_pts = 0;\r
- p_sys->b_has_b_frames = VLC_FALSE;\r
- p_sys->b_first_frame = VLC_TRUE;\r
- p_sys->i_late_frames = 0;\r
- p_sys->i_buffer = 0;\r
- p_sys->i_buffer_orig = 1;\r
- p_sys->p_buffer_orig = p_sys->p_buffer = malloc( p_sys->i_buffer_orig );\r
-\r
- /* Set output properties */\r
- p_dec->fmt_out.i_cat = VIDEO_ES;\r
- p_dec->fmt_out.i_codec = ffmpeg_PixFmtToChroma( p_context->pix_fmt );\r
-\r
- /* Setup palette */\r
-#if LIBAVCODEC_BUILD >= 4688\r
- if( p_dec->fmt_in.video.p_palette )\r
- p_sys->p_context->palctrl =\r
- (AVPaletteControl *)p_dec->fmt_in.video.p_palette;\r
- else\r
- p_sys->p_context->palctrl = &palette_control;\r
-#endif\r
-\r
- /* ***** Open the codec ***** */\r
- vlc_mutex_lock( lockval.p_address );\r
- if( avcodec_open( p_sys->p_context, p_sys->p_codec ) < 0 )\r
- {\r
- vlc_mutex_unlock( lockval.p_address );\r
- msg_Err( p_dec, "cannot open codec (%s)", p_sys->psz_namecodec );\r
- free( p_sys );\r
- return VLC_EGENERIC;\r
- }\r
- vlc_mutex_unlock( lockval.p_address );\r
- msg_Dbg( p_dec, "ffmpeg codec (%s) started", p_sys->psz_namecodec );\r
-\r
-\r
- return VLC_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************\r
- * DecodeVideo: Called to decode one or more frames\r
- *****************************************************************************/\r
-picture_t *E_(DecodeVideo)( decoder_t *p_dec, block_t **pp_block )\r
-{\r
- decoder_sys_t *p_sys = p_dec->p_sys;\r
- int b_drawpicture;\r
- int b_null_size = VLC_FALSE;\r
- block_t *p_block;\r
-\r
- if( !pp_block || !*pp_block ) return NULL;\r
-\r
- p_block = *pp_block;\r
-\r
- if( p_block->i_flags & (BLOCK_FLAG_DISCONTINUITY|BLOCK_FLAG_CORRUPTED) )\r
- {\r
- p_sys->i_buffer = 0;\r
- p_sys->i_pts = 0; /* To make sure we recover properly */\r
-\r
- p_sys->input_pts = p_sys->input_dts = 0;\r
- p_sys->i_late_frames = 0;\r
-\r
- block_Release( p_block );\r
- return NULL;\r
- }\r
-\r
- if( p_block->i_flags & BLOCK_FLAG_PREROLL )\r
- {\r
- /* Do not care about late frames when prerolling\r
- * TODO avoid decoding of non reference frame\r
- * (ie all B except for H264 where it depends only on nal_ref_idc) */\r
- p_sys->i_late_frames = 0;\r
- }\r
-\r
- if( !p_dec->b_pace_control && p_sys->i_late_frames > 0 &&\r
- mdate() - p_sys->i_late_frames_start > I64C(5000000) )\r
- {\r
- if( p_sys->i_pts )\r
- {\r
- msg_Err( p_dec, "more than 5 seconds of late video -> "\r
- "dropping frame (computer too slow ?)" );\r
- p_sys->i_pts = 0; /* To make sure we recover properly */\r
- }\r
- block_Release( p_block );\r
- p_sys->i_late_frames--;\r
- return NULL;\r
- }\r
-\r
- if( p_block->i_pts > 0 || p_block->i_dts > 0 )\r
- {\r
- p_sys->input_pts = p_block->i_pts;\r
- p_sys->input_dts = p_block->i_dts;\r
-\r
- /* Make sure we don't reuse the same timestamps twice */\r
- p_block->i_pts = p_block->i_dts = 0;\r
- }\r
-\r
- /* TODO implement it in a better way */\r
- /* A good idea could be to decode all I pictures and see for the other */\r
- if( !p_dec->b_pace_control &&\r
- p_sys->b_hurry_up && p_sys->i_late_frames > 4 )\r
- {\r
- b_drawpicture = 0;\r
- if( p_sys->i_late_frames < 8 )\r
- {\r
- p_sys->p_context->hurry_up = 2;\r
- }\r
- else\r
- {\r
- /* picture too late, won't decode\r
- * but break picture until a new I, and for mpeg4 ...*/\r
-\r
- p_sys->i_late_frames--; /* needed else it will never be decrease */\r
- block_Release( p_block );\r
- p_sys->i_buffer = 0;\r
- return NULL;\r
- }\r
- }\r
- else\r
- {\r
- if (!(p_block->i_flags & BLOCK_FLAG_PREROLL))\r
- {\r
- b_drawpicture = 1;\r
- p_sys->p_context->hurry_up = 0;\r
- }\r
- else\r
- {\r
- b_drawpicture = 0;\r
- p_sys->p_context->hurry_up = 1;\r
- }\r
- }\r
-\r
-\r
- if( p_sys->p_context->width <= 0 || p_sys->p_context->height <= 0 )\r
- {\r
- p_sys->p_context->hurry_up = 5;\r
- b_null_size = VLC_TRUE;\r
- }\r
-\r
- /*\r
- * Do the actual decoding now\r
- */\r
-\r
- /* Check if post-processing was enabled */\r
- p_sys->b_pp = p_sys->b_pp_async;\r
-\r
- /* Don't forget that ffmpeg requires a little more bytes\r
- * that the real frame size */\r
- if( p_block->i_buffer > 0 )\r
- {\r
- p_sys->i_buffer = p_block->i_buffer;\r
- if( p_sys->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE >\r
- p_sys->i_buffer_orig )\r
- {\r
- free( p_sys->p_buffer_orig );\r
- p_sys->i_buffer_orig =\r
- p_block->i_buffer + FF_INPUT_BUFFER_PADDING_SIZE;\r
- p_sys->p_buffer_orig = malloc( p_sys->i_buffer_orig );\r
- }\r
- p_sys->p_buffer = p_sys->p_buffer_orig;\r
- p_sys->i_buffer = p_block->i_buffer;\r
- p_dec->p_vlc->pf_memcpy( p_sys->p_buffer, p_block->p_buffer,\r
- p_block->i_buffer );\r
- memset( p_sys->p_buffer + p_block->i_buffer, 0,\r
- FF_INPUT_BUFFER_PADDING_SIZE );\r
-\r
- p_block->i_buffer = 0;\r
- }\r
-\r
- while( p_sys->i_buffer > 0 )\r
- {\r
- int i_used, b_gotpicture;\r
- picture_t *p_pic;\r
-\r
- i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic,\r
- &b_gotpicture,\r
- p_sys->p_buffer, p_sys->i_buffer );\r
- if( b_null_size && p_sys->p_context->width > 0 &&\r
- p_sys->p_context->height > 0 )\r
- {\r
- /* Reparse it to not drop the I frame */\r
- b_null_size = VLC_FALSE;\r
- p_sys->p_context->hurry_up = 0;\r
- i_used = avcodec_decode_video( p_sys->p_context, p_sys->p_ff_pic,\r
- &b_gotpicture,\r
- p_sys->p_buffer, p_sys->i_buffer );\r
- }\r
-\r
- if( i_used < 0 )\r
- {\r
- msg_Warn( p_dec, "cannot decode one frame (%d bytes)",\r
- p_sys->i_buffer );\r
- block_Release( p_block );\r
- return NULL;\r
- }\r
- else if( i_used > p_sys->i_buffer )\r
- {\r
- i_used = p_sys->i_buffer;\r
- }\r
-\r
- /* Consumed bytes */\r
- p_sys->i_buffer -= i_used;\r
- p_sys->p_buffer += i_used;\r
-\r
- /* Nothing to display */\r
- if( !b_gotpicture )\r
- {\r
- if( i_used == 0 ) break;\r
- continue;\r
- }\r
-\r
- /* Update frame late count (except when doing preroll) */\r
- if( p_sys->i_pts && p_sys->i_pts <= mdate() &&\r
- !(p_block->i_flags & BLOCK_FLAG_PREROLL) )\r
- {\r
- p_sys->i_late_frames++;\r
- if( p_sys->i_late_frames == 1 )\r
- p_sys->i_late_frames_start = mdate();\r
- }\r
- else\r
- {\r
- p_sys->i_late_frames = 0;\r
- }\r
-\r
- if( !b_drawpicture || !p_sys->p_ff_pic->linesize[0] )\r
- {\r
- /* Do not display the picture */\r
- continue;\r
- }\r
-\r
- if( !p_sys->p_ff_pic->opaque )\r
- {\r
- /* Get a new picture */\r
- p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context );\r
- if( !p_pic )\r
- {\r
- block_Release( p_block );\r
- return NULL;\r
- }\r
-\r
- /* Fill p_picture_t from AVVideoFrame and do chroma conversion\r
- * if needed */\r
- ffmpeg_CopyPicture( p_dec, p_pic, p_sys->p_ff_pic );\r
- }\r
- else\r
- {\r
- p_pic = (picture_t *)p_sys->p_ff_pic->opaque;\r
- }\r
-\r
- /* Set the PTS */\r
- if( p_sys->p_ff_pic->pts ) p_sys->i_pts = p_sys->p_ff_pic->pts;\r
-\r
- /* Sanity check (seems to be needed for some streams ) */\r
- if( p_sys->p_ff_pic->pict_type == FF_B_TYPE )\r
- {\r
- p_sys->b_has_b_frames = VLC_TRUE;\r
- }\r
-\r
- /* Send decoded frame to vout */\r
- if( p_sys->i_pts )\r
- {\r
- p_pic->date = p_sys->i_pts;\r
-\r
- /* interpolate the next PTS */\r
- if( p_sys->p_context->frame_rate > 0 )\r
- {\r
- p_sys->i_pts += I64C(1000000) *\r
- (2 + p_sys->p_ff_pic->repeat_pict) *\r
- p_sys->p_context->frame_rate_base /\r
- (2 * p_sys->p_context->frame_rate);\r
- }\r
-\r
- if( p_sys->b_first_frame )\r
- {\r
- /* Hack to force display of still pictures */\r
- p_sys->b_first_frame = VLC_FALSE;\r
- p_pic->b_force = VLC_TRUE;\r
- }\r
-\r
- p_pic->i_nb_fields = 2 + p_sys->p_ff_pic->repeat_pict;\r
-#if LIBAVCODEC_BUILD >= 4685\r
- p_pic->b_progressive = !p_sys->p_ff_pic->interlaced_frame;\r
- p_pic->b_top_field_first = p_sys->p_ff_pic->top_field_first;\r
-#endif\r
-\r
- return p_pic;\r
- }\r
- else\r
- {\r
- p_dec->pf_vout_buffer_del( p_dec, p_pic );\r
- }\r
- }\r
-\r
- block_Release( p_block );\r
- return NULL;\r
-}\r
-\r
-/*****************************************************************************\r
- * EndVideo: decoder destruction\r
- *****************************************************************************\r
- * This function is called when the thread ends after a sucessful\r
- * initialization.\r
- *****************************************************************************/\r
-void E_(EndVideoDec)( decoder_t *p_dec )\r
-{\r
- decoder_sys_t *p_sys = p_dec->p_sys;\r
-\r
- if( p_sys->p_ff_pic ) av_free( p_sys->p_ff_pic );\r
-\r
-#ifdef LIBAVCODEC_PP\r
- E_(ClosePostproc)( p_dec, p_sys->p_pp );\r
-#endif\r
-\r
- free( p_sys->p_buffer_orig );\r
-}\r
-\r
-/*****************************************************************************\r
- * ffmpeg_CopyPicture: copy a picture from ffmpeg internal buffers to a\r
- * picture_t structure (when not in direct rendering mode).\r
- *****************************************************************************/\r
-static void ffmpeg_CopyPicture( decoder_t *p_dec,\r
- picture_t *p_pic, AVFrame *p_ff_pic )\r
-{\r
- decoder_sys_t *p_sys = p_dec->p_sys;\r
-\r
- if( ffmpeg_PixFmtToChroma( p_sys->p_context->pix_fmt ) )\r
- {\r
- int i_plane, i_size, i_line;\r
- uint8_t *p_dst, *p_src;\r
- int i_src_stride, i_dst_stride;\r
-\r
-#ifdef LIBAVCODEC_PP\r
- if( p_sys->p_pp && p_sys->b_pp )\r
- E_(PostprocPict)( p_dec, p_sys->p_pp, p_pic, p_ff_pic );\r
- else\r
-#endif\r
- for( i_plane = 0; i_plane < p_pic->i_planes; i_plane++ )\r
- {\r
- p_src = p_ff_pic->data[i_plane];\r
- p_dst = p_pic->p[i_plane].p_pixels;\r
- i_src_stride = p_ff_pic->linesize[i_plane];\r
- i_dst_stride = p_pic->p[i_plane].i_pitch;\r
-\r
- i_size = __MIN( i_src_stride, i_dst_stride );\r
- for( i_line = 0; i_line < p_pic->p[i_plane].i_visible_lines;\r
- i_line++ )\r
- {\r
- p_dec->p_vlc->pf_memcpy( p_dst, p_src, i_size );\r
- p_src += i_src_stride;\r
- p_dst += i_dst_stride;\r
- }\r
- }\r
- }\r
- else\r
- {\r
- AVPicture dest_pic;\r
- int i;\r
-\r
- /* we need to convert to I420 */\r
- switch( p_sys->p_context->pix_fmt )\r
- {\r
- case PIX_FMT_YUV410P:\r
- case PIX_FMT_YUV411P:\r
- case PIX_FMT_PAL8:\r
- for( i = 0; i < p_pic->i_planes; i++ )\r
- {\r
- dest_pic.data[i] = p_pic->p[i].p_pixels;\r
- dest_pic.linesize[i] = p_pic->p[i].i_pitch;\r
- }\r
- img_convert( &dest_pic, PIX_FMT_YUV420P,\r
- (AVPicture *)p_ff_pic,\r
- p_sys->p_context->pix_fmt,\r
- p_sys->p_context->width,\r
- p_sys->p_context->height );\r
- break;\r
- default:\r
- msg_Err( p_dec, "don't know how to convert chroma %i",\r
- p_sys->p_context->pix_fmt );\r
- p_dec->b_error = 1;\r
- break;\r
- }\r
- }\r
-}\r
-\r
-/*****************************************************************************\r
- * ffmpeg_GetFrameBuf: callback used by ffmpeg to get a frame buffer.\r
- *****************************************************************************\r
- * It is used for direct rendering as well as to get the right PTS for each\r
- * decoded picture (even in indirect rendering mode).\r
- *****************************************************************************/\r
-static int ffmpeg_GetFrameBuf( struct AVCodecContext *p_context,\r
- AVFrame *p_ff_pic )\r
-{\r
- decoder_t *p_dec = (decoder_t *)p_context->opaque;\r
- decoder_sys_t *p_sys = p_dec->p_sys;\r
- picture_t *p_pic;\r
-\r
- /* Set picture PTS */\r
- if( p_sys->input_pts )\r
- {\r
- p_ff_pic->pts = p_sys->input_pts;\r
- }\r
- else if( p_sys->input_dts )\r
- {\r
- /* Some demuxers only set the dts so let's try to find a useful\r
- * timestamp from this */\r
- if( !p_context->has_b_frames || !p_sys->b_has_b_frames ||\r
- !p_ff_pic->reference || !p_sys->i_pts )\r
- {\r
- p_ff_pic->pts = p_sys->input_dts;\r
- }\r
- else p_ff_pic->pts = 0;\r
- }\r
- else p_ff_pic->pts = 0;\r
-\r
- if( p_sys->i_pts ) /* make sure 1st frame has a pts > 0 */\r
- {\r
- p_sys->input_pts = p_sys->input_dts = 0;\r
- }\r
-\r
- p_ff_pic->opaque = 0;\r
-\r
- /* Not much to do in indirect rendering mode */\r
- if( !p_sys->b_direct_rendering || p_sys->b_pp )\r
- {\r
- return avcodec_default_get_buffer( p_context, p_ff_pic );\r
- }\r
-\r
- /* Some codecs set pix_fmt only after the 1st frame has been decoded,\r
- * so this check is necessary. */\r
- if( !ffmpeg_PixFmtToChroma( p_context->pix_fmt ) ||\r
- p_sys->p_context->width % 16 || p_sys->p_context->height % 16 )\r
- {\r
- msg_Dbg( p_dec, "disabling direct rendering" );\r
- p_sys->b_direct_rendering = 0;\r
- return avcodec_default_get_buffer( p_context, p_ff_pic );\r
- }\r
-\r
- /* Get a new picture */\r
- //p_sys->p_vout->render.b_allow_modify_pics = 0;\r
- p_pic = ffmpeg_NewPictBuf( p_dec, p_sys->p_context );\r
- if( !p_pic )\r
- {\r
- p_sys->b_direct_rendering = 0;\r
- return avcodec_default_get_buffer( p_context, p_ff_pic );\r
- }\r
- p_sys->p_context->draw_horiz_band = NULL;\r
-\r
- p_ff_pic->opaque = (void*)p_pic;\r
- p_ff_pic->type = FF_BUFFER_TYPE_USER;\r
- p_ff_pic->data[0] = p_pic->p[0].p_pixels;\r
- p_ff_pic->data[1] = p_pic->p[1].p_pixels;\r
- p_ff_pic->data[2] = p_pic->p[2].p_pixels;\r
- p_ff_pic->data[3] = NULL; /* alpha channel but I'm not sure */\r
-\r
- p_ff_pic->linesize[0] = p_pic->p[0].i_pitch;\r
- p_ff_pic->linesize[1] = p_pic->p[1].i_pitch;\r
- p_ff_pic->linesize[2] = p_pic->p[2].i_pitch;\r
- p_ff_pic->linesize[3] = 0;\r
-\r
- if( p_ff_pic->reference != 0 )\r
- {\r
- p_dec->pf_picture_link( p_dec, p_pic );\r
- }\r
-\r
- /* FIXME what is that, should give good value */\r
- p_ff_pic->age = 256*256*256*64; // FIXME FIXME from ffmpeg\r
-\r
- return 0;\r
-}\r
-\r
-static void ffmpeg_ReleaseFrameBuf( struct AVCodecContext *p_context,\r
- AVFrame *p_ff_pic )\r
-{\r
- decoder_t *p_dec = (decoder_t *)p_context->opaque;\r
- picture_t *p_pic;\r
-\r
- if( !p_ff_pic->opaque )\r
- {\r
- avcodec_default_release_buffer( p_context, p_ff_pic );\r
- return;\r
- }\r
-\r
- p_pic = (picture_t*)p_ff_pic->opaque;\r
-\r
- p_ff_pic->data[0] = NULL;\r
- p_ff_pic->data[1] = NULL;\r
- p_ff_pic->data[2] = NULL;\r
- p_ff_pic->data[3] = NULL;\r
-\r
- if( p_ff_pic->reference != 0 )\r
- {\r
- p_dec->pf_picture_unlink( p_dec, p_pic );\r
- }\r
-}\r
+/*****************************************************************************
+ * video.c: video decoder using the ffmpeg library
+ *****************************************************************************
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id$
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ * Gildas Bazin <gbazin@videolan.org>
+ *
+ * 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 <vlc/vlc.h>
+#include <vlc/decoder.h>
+
+/* ffmpeg header */
+#ifdef HAVE_FFMPEG_AVCODEC_H
+# include <ffmpeg/avcodec.h>
+#else
+# include <avcodec.h>
+#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 );
+ }
+}
* 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 <fenrir@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* 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 <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Bitmaps.h
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: Bitmaps.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $
+ * $Id$
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com>
* DrawingTidbits.cpp
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: DrawingTidbits.cpp,v 1.4 2004/01/26 16:52:31 zorglub Exp $
+ * $Id$
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com>
* DrawingTidbits.h
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: DrawingTidbits.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $
+ * $Id$
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com>
* 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 <titer@videolan.org>
*
* 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 <titer@videolan.org>
*
* TransportButton.cpp
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: TransportButton.cpp,v 1.4 2004/01/26 16:52:31 zorglub Exp $
+ * $Id$
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
* Stephan Aßmus <stippi@yellowbites.com>
* TransportButton.h
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: TransportButton.h,v 1.3 2004/01/26 16:52:31 zorglub Exp $
+ * $Id$
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
*
* 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 <sam@zoy.org>
*
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <oct@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <gbazin@netcourrier.com>
* Loïc Minier <lool@via.ecp.fr>
* 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 <sam@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
* 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 <fenrir@via.ecp.fr>
*
* 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 <sigmunau@idi.ntnu.no> Mon 12.08.2002
*
* 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 <dae@chez.com> Sun Mar 25 2001
*
* 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 <sigmunau@idi.ntnu.no>
*
* 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 <sigmunau@idi.ntnu.no>
*
* 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 <sigmunau@idi.ntnu.no>
*
* 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 <sigmunau@idi.ntnu.no>
*
* 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 <sigmunau@idi.ntnu.no>
*
* 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 <sigmunau@idi.ntnu.no> Mon Aug 12 2002
*
* 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 <sigmunau@idi.ntnu.no> Mon Aug 12 2002
*
* 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 <sigmunau@idi.ntnu.no> Mon Aug 12 2002
*
* 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 <sigmunau@idi.ntnu.no> Mon Aug 12 2002
*
* 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 <jpsaman@wxs.nl>
*
* 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 <jpsaman@wxs.nl>
*
* 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 <sam@zoy.org>
*
-/*****************************************************************************\r
- * wizard.cpp : wxWindows plugin for vlc\r
- *****************************************************************************\r
- * Copyright (C) 2000-2004 VideoLAN\r
- * $Id$\r
- *\r
- * Authors: Clément Stenac <zorglub@videolan.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-/*****************************************************************************\r
- * Preamble\r
- *****************************************************************************/\r
-#include <stdlib.h> /* malloc(), free() */\r
-#include <errno.h> /* ENOMEM */\r
-#include <string.h> /* strerror() */\r
-#include <stdio.h>\r
-\r
-#include <vlc/vlc.h>\r
-#include <vlc/intf.h>\r
-\r
-#include "wxwindows.h"\r
-\r
-#include "streamdata.h"\r
-\r
-#include <wx/statline.h>\r
-\r
-class wizHelloPage;\r
-class wizInputPage;\r
-\r
-/*****************************************************************************\r
- * Define events\r
- *****************************************************************************/\r
-enum\r
-{\r
- ActionRadio0_Event, ActionRadio1_Event,\r
- MoreInfoStreaming_Event,\r
- MoreInfoTranscode_Event,\r
-\r
- Open_Event , Choose_Event ,\r
- ListView_Event,\r
- InputRadio0_Event, InputRadio1_Event,\r
- PartialEnable_Event,\r
-\r
- MethodRadio0_Event, MethodRadio1_Event,\r
- MethodRadio2_Event, MethodRadio3_Event,\r
-\r
- EncapRadio0_Event, EncapRadio1_Event,\r
- EncapRadio2_Event, EncapRadio3_Event,\r
- EncapRadio4_Event, EncapRadio5_Event,\r
- EncapRadio6_Event, EncapRadio7_Event,\r
- EncapRadio8_Event, EncapRadio9_Event,\r
- EncapRadio10_Event, EncapRadio11_Event,\r
-\r
- VideoEnable_Event, VideoCodec_Event,VideoBitrate_Event,\r
- AudioEnable_Event, AudioCodec_Event,AudioBitrate_Event,\r
-\r
- SAP_Event,\r
-\r
-};\r
-\r
-#define TEXTWIDTH 55\r
-#define ACTION_STREAM 0\r
-#define ACTION_TRANSCODE 1\r
-\r
-BEGIN_EVENT_TABLE(WizardDialog, wxWizard)\r
-END_EVENT_TABLE()\r
-\r
-/*****************************************************************************\r
- * Wizard strings\r
- *****************************************************************************/\r
-\r
-#define ERROR_MSG _("Error")\r
-#define ITEM_NAME _("Streaming/Transcoding Wizard")\r
-\r
-/* Hello page */\r
-#define HELLO_TITLE _("Streaming/Transcoding Wizard")\r
-#define HELLO_TEXT _("This wizard helps you to stream, transcode or" \\r
- " save a stream")\r
-#define HELLO_STREAMING _("Stream to network")\r
-#define HELLO_STREAMING_DESC _("Use this to stream on a network")\r
-#define HELLO_TRANSCODE _("Transcode/Save to file")\r
-#define HELLO_TRANSCODE_DESC _("Use this to re-encode a stream and save it to a file")\r
-#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")\r
-\r
-#define MOREINFO_STREAM _("Use this to stream on a network")\r
-\r
-#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 " \\r
- "for file to file transcoding. You should use its transcoding " \\r
- "features to save network streams, for example" )\r
-\r
-/* Input page */\r
-#define INPUT_TITLE _("Choose input")\r
-#define INPUT_TEXT _("Choose here your input stream")\r
-\r
-#define INPUT_OPEN _("Select a stream" )\r
-#define INPUT_PL _( "Existing playlist item" )\r
-\r
-#define CHOOSE_STREAM _("You must choose a stream")\r
-#define NO_PLAYLIST _("Uh Oh! Unable to find playlist !")\r
-\r
-#define PARTIAL _("Use this to read only a part of the stream. " \\r
- "You must be able to control the incoming stream " \\r
- "(for example, a file or a disc, but not an UDP " \\r
- "network stream.)\n" \\r
- "Enter the starting and ending times (in seconds)")\r
-\r
-#define INPUT_BUTTON _("Choose")\r
-\r
-/* Transcode 1 */\r
-#define TRANSCODE1_TITLE _("Transcode")\r
-#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).")\r
-\r
-#define TR_VIDEO_TEXT0 _("If your stream has video and you want to " \\r
- "transcode it, enable this")\r
-#define TR_VIDEO_TEXT _("Select your video codec. Click one to get more " \\r
- "information")\r
-\r
-#define TR_AUDIO_TEXT0 _("If your stream has audio and you want to "\\r
- "transcode it, enable this")\r
-#define TR_AUDIO_TEXT _("Select your audio codec. Click one to get more " \\r
- "information")\r
-\r
-/* Streaming 1 */\r
-#define STREAMING1_TITLE _("Streaming")\r
-#define STREAMING1_TEXT _("In this page, you will select how your input stream will be sent.")\r
-\r
-\r
-#define INVALID_MCAST_ADDRESS _("This does not appear to be a valid " \\r
- "multicast address" )\r
-#define NO_ADDRESS _("You need to enter an address" )\r
-\r
-/* Encap */\r
-#define ENCAP_TITLE _("Encapsulation format")\r
-#define ENCAP_TEXT _("In this page, you will select how the stream will be "\\r
- "encapsulated. Depending on the choices you made, all "\\r
- "formats won't be available." )\r
-\r
-\r
-/* Transcode 2 */\r
-#define EXTRATRANSCODE_TITLE _("Additional transcode options")\r
-#define EXTRATRANSCODE_TEXT _("In this page, you will define a few " \\r
- "additionnal parameters for your transcoding" )\r
-\r
-#define CHOOSE_OUTFILE _("You must choose a file to save to")\r
-\r
-/* Streaming 2 */\r
-#define EXTRASTREAMING_TITLE _("Additional streaming options")\r
-#define EXTRASTREAMING_TEXT _("In this page, you will define a few " \\r
- "additionnal parameters for your stream" )\r
-\r
-#define TTL _("Define the TTL (Time-To-Live) of the stream. This parameter " \\r
- "is the maximum number of routers your stream can go through. " \\r
- "If you don't know what it means, or if you want to stream on " \\r
- "your local network only, leave this setting to 1." )\r
-\r
-#define SAP _("When streaming using UDP, you can announce your streams " \\r
- "using the SAP/SDP announcing protocol. This way, the clients " \\r
- "won't have to type in the multicast address, it will appear " \\r
- "in their playlist if they enable the SAP extra interface.\n" \\r
- "If you want to give a name to your stream, enter it here, " \\r
- "else, a default name will be used" )\r
-\r
-/*****************************************************************************\r
- * All the pages of the wizard, declaration\r
- *****************************************************************************/\r
-\r
-/* Declare classes */\r
-class wizHelloPage : public wxWizardPageSimple\r
-{\r
- public:\r
- wizHelloPage( wxWizard *parent);\r
- void OnActionChange(wxEvent& event);\r
- void OnWizardPageChanging(wxWizardEvent& event);\r
- void OnMoreInfo( wxCommandEvent& event );\r
- protected:\r
- int i_action;\r
- WizardDialog *p_parent;\r
- wxRadioButton *action_radios[2];\r
- DECLARE_EVENT_TABLE()\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizHelloPage, wxWizardPageSimple)\r
- EVT_RADIOBUTTON( ActionRadio0_Event, wizHelloPage::OnActionChange)\r
- EVT_RADIOBUTTON( ActionRadio1_Event, wizHelloPage::OnActionChange)\r
- EVT_BUTTON( MoreInfoStreaming_Event, wizHelloPage::OnMoreInfo )\r
- EVT_BUTTON( MoreInfoTranscode_Event, wizHelloPage::OnMoreInfo )\r
-\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizHelloPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-\r
-class wizInputPage : public wxWizardPage\r
-{\r
- public:\r
- wizInputPage( wxWizard *, wxWizardPage *, intf_thread_t *);\r
- wizInputPage::~wizInputPage();\r
- void OnWizardPageChanging(wxWizardEvent& event);\r
- void OnInputChange(wxEvent& event);\r
- void OnEnablePartial(wxCommandEvent& event);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void SetStreamingPage( wxWizardPage *page);\r
- void SetTranscodePage( wxWizardPage *page);\r
- void SetAction( int i_action );\r
- void SetPintf( intf_thread_t *p_intf );\r
- void SetUri( char *psz_uri );\r
- void SetPartial( int i_from, int i_to );\r
-\r
- protected:\r
- bool b_chosen;\r
- intf_thread_t *p_intf;\r
- int i_action;\r
- int i_input;\r
-\r
- void OnChoose( wxCommandEvent& event );\r
-\r
- WizardDialog *p_parent;\r
- wxRadioButton *input_radios[2];\r
- wxCheckBox *enable_checkbox;\r
- wxBoxSizer *mainSizer;\r
- wxArrayString mrl;\r
- wxTextCtrl *mrl_text;\r
- wxTextCtrl *from_text;\r
- wxTextCtrl *to_text;\r
- OpenDialog *p_open_dialog;\r
- wxListView *listview;\r
- wxPanel *open_panel;\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_streaming_page;\r
- wxWizardPage *p_transcode_page;\r
-\r
- DECLARE_EVENT_TABLE()\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizInputPage, wxWizardPage)\r
- EVT_RADIOBUTTON( InputRadio0_Event, wizInputPage::OnInputChange)\r
- EVT_RADIOBUTTON( InputRadio1_Event, wizInputPage::OnInputChange)\r
- EVT_BUTTON( Choose_Event, wizInputPage::OnChoose)\r
- EVT_CHECKBOX( PartialEnable_Event, wizInputPage::OnEnablePartial)\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizInputPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-\r
-class wizTranscodeCodecPage : public wxWizardPage\r
-{\r
-public:\r
- wizTranscodeCodecPage( wxWizard *parent, wxWizardPage *next);\r
- ~wizTranscodeCodecPage();\r
- void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void SetPrev( wxWizardPage *page);\r
-protected:\r
- wxCheckBox *video_checkbox;\r
- wxComboBox *video_combo;\r
- wxComboBox *vb_combo;\r
- wxStaticText * video_text;\r
- wxCheckBox *audio_checkbox;\r
- wxComboBox *audio_combo;\r
- wxComboBox *ab_combo;\r
- wxStaticText * audio_text;\r
-\r
- WizardDialog *p_parent;\r
- int i_audio_codec;\r
- int i_video_codec;\r
-\r
- char *vcodec;\r
- char *acodec;\r
-\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_next;\r
-\r
- void OnVideoCodecChange(wxCommandEvent& event);\r
- void OnAudioCodecChange(wxCommandEvent& event);\r
- void OnEnableVideo(wxCommandEvent& event);\r
- void OnEnableAudio(wxCommandEvent& event);\r
-\r
- DECLARE_EVENT_TABLE()\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizTranscodeCodecPage, wxWizardPage)\r
- EVT_CHECKBOX( VideoEnable_Event, wizTranscodeCodecPage::OnEnableVideo)\r
- EVT_CHECKBOX( AudioEnable_Event, wizTranscodeCodecPage::OnEnableAudio)\r
- EVT_COMBOBOX( VideoCodec_Event, wizTranscodeCodecPage::OnVideoCodecChange)\r
- EVT_COMBOBOX( AudioCodec_Event, wizTranscodeCodecPage::OnAudioCodecChange)\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeCodecPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-class wizStreamingMethodPage : public wxWizardPage\r
-{\r
-public:\r
- wizStreamingMethodPage( wxWizard *parent, wxWizardPage *next);\r
- void OnWizardPageChanging(wxWizardEvent& event);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void SetPrev( wxWizardPage *page);\r
-protected:\r
- DECLARE_EVENT_TABLE()\r
- int i_method;\r
- wxBoxSizer *mainSizer;\r
- wxStaticBoxSizer *address_sizer;\r
- wxStaticText *address_text;\r
- wxTextCtrl *address_txtctrl;\r
- WizardDialog * p_parent;\r
- void OnMethodChange(wxEvent& event);\r
- wxRadioButton *method_radios[4];\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_next;\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizStreamingMethodPage, wxWizardPage)\r
- EVT_RADIOBUTTON( MethodRadio0_Event, wizStreamingMethodPage::OnMethodChange)\r
- EVT_RADIOBUTTON( MethodRadio1_Event, wizStreamingMethodPage::OnMethodChange)\r
- EVT_RADIOBUTTON( MethodRadio2_Event, wizStreamingMethodPage::OnMethodChange)\r
- EVT_RADIOBUTTON( MethodRadio3_Event, wizStreamingMethodPage::OnMethodChange)\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingMethodPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-\r
-class wizEncapPage : public wxWizardPage\r
-{\r
-public:\r
- wizEncapPage( wxWizard *parent);\r
- wizEncapPage::~wizEncapPage();\r
- void OnWizardPageChanging(wxWizardEvent& event);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void SetStreamingPage( wxWizardPage *page);\r
- void SetTranscodePage( wxWizardPage *page);\r
- void SetPrev( wxWizardPage *page);\r
- void SetAction( int );\r
- void EnableEncap( int encap );\r
-protected:\r
- DECLARE_EVENT_TABLE()\r
- int i_encap;\r
- int i_mux;\r
- int i_action;\r
- void OnEncapChange(wxEvent& event);\r
- wxRadioButton *encap_radios[MUXERS_NUMBER];\r
- WizardDialog *p_parent;\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_streaming_page;\r
- wxWizardPage *p_transcode_page;\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizEncapPage, wxWizardPage)\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizEncapPage::OnWizardPageChanging)\r
- EVT_RADIOBUTTON( EncapRadio0_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio1_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio2_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio3_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio4_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio5_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio6_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio7_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio8_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio9_Event, wizEncapPage::OnEncapChange)\r
- EVT_RADIOBUTTON( EncapRadio10_Event, wizEncapPage::OnEncapChange)\r
-END_EVENT_TABLE()\r
-\r
-/* Additional settings for transcode */\r
-class wizTranscodeExtraPage : public wxWizardPage\r
-{\r
-public:\r
- wizTranscodeExtraPage( wxWizard *parent, wxWizardPage *prev,\r
- wxWizardPage *next);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void OnWizardPageChanging( wxWizardEvent& event );\r
-protected:\r
- DECLARE_EVENT_TABLE()\r
- void wizTranscodeExtraPage::OnSelectFile(wxCommandEvent&);\r
- wxTextCtrl *file_text;\r
- WizardDialog *p_parent;\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_next;\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizTranscodeExtraPage, wxWizardPage)\r
- EVT_BUTTON( Open_Event, wizTranscodeExtraPage::OnSelectFile)\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizTranscodeExtraPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-/* Additional settings for streaming */\r
-class wizStreamingExtraPage : public wxWizardPage\r
-{\r
-public:\r
- wizStreamingExtraPage( wxWizard *parent, wxWizardPage *prev,\r
- wxWizardPage *next);\r
- virtual wxWizardPage *GetPrev() const;\r
- virtual wxWizardPage *GetNext() const;\r
- void OnWizardPageChanging(wxWizardEvent&);\r
- void OnSAP( wxCommandEvent&);\r
- wxCheckBox *sap_checkbox;\r
- wxTextCtrl *sap_text;\r
-protected:\r
- friend class wizEncapPage;\r
- DECLARE_EVENT_TABLE()\r
- WizardDialog *p_parent;\r
- wxWizardPage *p_prev;\r
- wxWizardPage *p_next;\r
-\r
- wxSpinCtrl *ttl_spin;\r
-};\r
-\r
-BEGIN_EVENT_TABLE(wizStreamingExtraPage, wxWizardPage)\r
- EVT_CHECKBOX( SAP_Event, wizStreamingExtraPage::OnSAP )\r
- EVT_WIZARD_PAGE_CHANGING(-1, wizStreamingExtraPage::OnWizardPageChanging)\r
-END_EVENT_TABLE()\r
-\r
-\r
-/* Local functions */\r
-static int ismult( const char *psz_uri );\r
-\r
-static void pageHeader( wxWindow *window, wxBoxSizer *sizer,\r
- char *psz_title, char *psz_text);\r
-\r
-static void pageHeader( wxWindow *window, wxBoxSizer *sizer,\r
- char *psz_title, char *psz_text)\r
-{\r
- wxStaticText *wtitle = new wxStaticText( window, -1, wxU( psz_title ) );\r
- wxFont font = wtitle->GetFont();\r
- font.SetPointSize(14);\r
- wtitle->SetFont(font);\r
- sizer->Add( wtitle, 0, wxALL, 5 );\r
- sizer->Add( new wxStaticText( window, -1,\r
- wxU( vlc_wraptext( psz_text , TEXTWIDTH, false ) ) ),\r
- 0, wxALL, 5 );\r
-}\r
-\r
-/***************************************************************************\r
- * Implementation of the pages\r
- ***************************************************************************/\r
-\r
-\r
-/***************************************************\r
- * First page: choose between stream and transcode *\r
- ***************************************************/\r
-wizHelloPage::wizHelloPage( wxWizard *parent) : wxWizardPageSimple(parent)\r
-{\r
- i_action = 0;\r
- p_parent = (WizardDialog *)parent;\r
- wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, HELLO_TITLE, HELLO_TEXT );\r
-\r
- /* Create the radio buttons with their helps */\r
- action_radios[0] = new wxRadioButton( this, ActionRadio0_Event,\r
- wxU( HELLO_STREAMING ) );\r
- action_radios[1] = new wxRadioButton( this, ActionRadio1_Event,\r
- wxU( HELLO_TRANSCODE ) );\r
- i_action = 0;\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
-\r
- wxBoxSizer *stream_sizer = new wxBoxSizer( wxHORIZONTAL );\r
- stream_sizer->Add( action_radios[0], 0, wxALL, 5 );\r
- stream_sizer->Add( 0,0,1 );\r
- stream_sizer->Add( new wxButton( this, MoreInfoStreaming_Event,\r
- wxU( _("More Info")) ), 0, 0, 0 );\r
- mainSizer->Add( stream_sizer, 0, wxALL | wxEXPAND , 5 );\r
-\r
- wxBoxSizer *transcode_sizer = new wxBoxSizer( wxHORIZONTAL );\r
- transcode_sizer->Add( action_radios[1], 0, wxALL, 5 );\r
- transcode_sizer->Add( 0,0,1);\r
- transcode_sizer->Add( new wxButton( this, MoreInfoTranscode_Event,\r
- wxU( _("More Info")) ), 0 , 0 , 0 );\r
- mainSizer->Add( transcode_sizer, 0, wxALL | wxEXPAND, 5 );\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
-\r
- mainSizer->Add( new wxStaticLine(this, -1 ), 0, wxEXPAND| wxTOP|\r
- wxBOTTOM, 5 );\r
-\r
- mainSizer->Add( new wxStaticText(this, -1,\r
- wxU( vlc_wraptext(HELLO_NOTICE , TEXTWIDTH , false ))),\r
- 0, wxALL, 5 );\r
-\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
- }\r
-\r
-void wizHelloPage::OnMoreInfo(wxCommandEvent& event)\r
-{\r
- wxString msg;\r
- msg.Printf( wxString( wxU( event.GetId() == MoreInfoStreaming_Event ?\r
- MOREINFO_STREAM :\r
- MOREINFO_TRANSCODE ) ) );\r
- wxMessageBox( msg, wxU(_("More information")),\r
- wxOK | wxICON_INFORMATION, this->p_parent );\r
-}\r
-\r
-void wizHelloPage::OnActionChange(wxEvent& event)\r
-{\r
- i_action = event.GetId() - ActionRadio0_Event;\r
- ((wizInputPage *)GetNext())->SetAction( i_action );\r
- p_parent->SetAction( i_action );\r
-}\r
-\r
-void wizHelloPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- ((wizInputPage *)GetNext())->SetAction( i_action );\r
- p_parent->SetAction( i_action );\r
-}\r
-\r
-/************************************\r
- * Second page: choose input stream *\r
- ************************************/\r
-wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t *_p_intf) :\r
- wxWizardPage(parent)\r
-{\r
- p_prev = prev;\r
- p_intf = _p_intf;\r
- p_parent = (WizardDialog *)parent;\r
- b_chosen = false;\r
- p_open_dialog = NULL;\r
- listview = NULL; \r
- mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, INPUT_TITLE, INPUT_TEXT );\r
-\r
- mainSizer->Add( 0,20,0 );\r
-\r
- /* Create the radio buttons */\r
- input_radios[0] = new wxRadioButton( this, InputRadio0_Event ,\r
- wxU( INPUT_OPEN ) );\r
- mainSizer->Add( input_radios[0], 0, wxALL, 5 );\r
- input_radios[1] = new wxRadioButton( this, InputRadio1_Event ,\r
- wxU( INPUT_PL ) );\r
- i_input = 0;\r
- mainSizer->Add( input_radios[1], 0, wxALL, 5 );\r
-\r
- /* Open Panel */\r
- open_panel = new wxPanel(this, -1);\r
- open_panel->SetAutoLayout( TRUE );\r
- wxBoxSizer *openSizer = new wxBoxSizer(wxHORIZONTAL);\r
-\r
- mrl_text = new wxTextCtrl( open_panel, -1, wxU( "" ), wxDefaultPosition,\r
- wxSize(200,25) );\r
- openSizer->Add( mrl_text, 0 , wxALL, 5 );\r
- openSizer->Add( new wxButton( open_panel, Choose_Event, wxU(_("Choose...")) ), 0, wxALL, 5 );\r
- open_panel->SetSizer( openSizer );\r
- openSizer->Layout();\r
- openSizer->Fit(open_panel);\r
-\r
- mainSizer->Add( open_panel );\r
-\r
-\r
- playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,\r
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );\r
-\r
- if( p_playlist )\r
- {\r
- if( p_playlist->i_size > 0)\r
- {\r
- listview = new wxListView( this, ListView_Event,\r
- wxDefaultPosition, wxDefaultSize,\r
- wxLC_REPORT | wxSUNKEN_BORDER );\r
- listview->InsertColumn( 0, wxU(_("Name")) );\r
- listview->InsertColumn( 1, wxU(_("URI")) );\r
- listview->SetColumnWidth( 0, 250 );\r
- listview->SetColumnWidth( 1, 100 );\r
- for( int i=0 ; i < p_playlist->i_size ; i++ )\r
- {\r
- wxString filename = wxL2U( p_playlist->pp_items[i]->input.\r
- psz_name );\r
- listview->InsertItem( i, filename );\r
- listview->SetItem( i, 1, wxL2U( p_playlist->pp_items[i]->\r
- input.psz_uri) );\r
- }\r
- listview->Select( p_playlist->i_index , TRUE);\r
- mainSizer->Add( listview, 1, wxALL|wxEXPAND, 5 );\r
-\r
- listview->Hide();\r
- mainSizer->Hide( listview );\r
- mainSizer->Layout();\r
- }\r
- else\r
- {\r
- input_radios[1]->Disable();\r
- }\r
- vlc_object_release( p_playlist );\r
- }\r
- else\r
- {\r
- input_radios[1]->Disable();\r
- }\r
-\r
- /* Partial Extract Box */\r
- mainSizer->Add( 0, 10, 0 );\r
- wxStaticBox *partial_box = new wxStaticBox( this, -1,\r
- wxU(_("Partial Extract")) );\r
-\r
- wxStaticBoxSizer *partial_sizer = new wxStaticBoxSizer( partial_box,\r
- wxVERTICAL );\r
-\r
- enable_checkbox = new wxCheckBox( this, PartialEnable_Event,\r
- wxU(_("Enable") ) );\r
- enable_checkbox->SetToolTip(wxU(_(PARTIAL) ) ) ;\r
- partial_sizer->Add( enable_checkbox, 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 ); //wxLEFT\r
-\r
- wxFlexGridSizer *partial_sizer2 = new wxFlexGridSizer( 4 , 1 , 20 );\r
- partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "From" ) ) ),\r
- 0 , wxLEFT , 5 );\r
- from_text = new wxTextCtrl( this, -1, wxT(""),\r
- wxDefaultPosition, wxSize( 80,25 ) );\r
- partial_sizer2->Add( from_text, 0 , wxALIGN_RIGHT);\r
- partial_sizer2->Add( new wxStaticText(this, -1, wxU(_( "To" ) ) ),\r
- 0 , wxLEFT , 5 );\r
- to_text = new wxTextCtrl( this, -1, wxT(""),\r
- wxDefaultPosition, wxSize( 80 , 25 ) );\r
- partial_sizer2->Add( to_text, 0 , wxALIGN_RIGHT );\r
-\r
- partial_sizer->Add( partial_sizer2, 0, wxALL, 0 );\r
-\r
- partial_sizer->Fit( partial_box );\r
-\r
- mainSizer->Add( partial_sizer, 0, 0, 0 );\r
-\r
- from_text->Disable();\r
- to_text->Disable();\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
- mainSizer->Layout();\r
-}\r
-\r
-wizInputPage::~wizInputPage()\r
-{\r
-}\r
-\r
-void wizInputPage::OnInputChange(wxEvent& event)\r
-{\r
- i_input = event.GetId() - InputRadio0_Event;\r
- if( i_input == 0 )\r
- {\r
- if( listview )\r
- {\r
- listview->Hide();\r
- mainSizer->Hide( listview );\r
- open_panel->Show();\r
- mainSizer->Show( open_panel );\r
- mainSizer->Layout();\r
- }\r
- }\r
- else\r
- {\r
- open_panel->Hide();\r
- mainSizer->Hide( open_panel );\r
- listview->Show();\r
- mainSizer->Show( listview );\r
- mainSizer->Layout();\r
- }\r
-}\r
-\r
-void wizInputPage::OnEnablePartial(wxCommandEvent& event)\r
-{\r
- from_text->Enable( event.IsChecked() );\r
- to_text->Enable( event.IsChecked() );\r
-}\r
-\r
-\r
-void wizInputPage::OnChoose(wxCommandEvent& event)\r
-{\r
- p_open_dialog = new OpenDialog( p_intf, this, -1, -1, OPEN_STREAM );\r
- if( p_open_dialog->ShowModal() == wxID_OK &&\r
- !p_open_dialog->mrl.IsEmpty() )\r
- {\r
- mrl_text->SetValue(p_open_dialog->mrl[0] );\r
- }\r
- delete p_open_dialog;\r
- p_open_dialog = NULL;\r
-}\r
-\r
-void wizInputPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- if( i_input == 0)\r
- {\r
- if( mrl_text->GetValue().IsSameAs( wxT(""), TRUE ) &&\r
- event.GetDirection() )\r
- {\r
- wxMessageBox( wxU( CHOOSE_STREAM ), wxU( ERROR_MSG ),\r
- wxICON_WARNING | wxOK, this->p_parent );\r
- event.Veto();\r
- return;\r
- }\r
- else\r
- {\r
- p_parent->SetMrl( (const char *)mrl_text->GetValue().mb_str() );\r
- }\r
- }\r
- else\r
- {\r
- int i = -1;\r
- wxListItem listitem;\r
- i = listview->GetNextItem( i , wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);\r
- if( i != -1 )\r
- {\r
- listitem.SetId( i );\r
- listitem.SetColumn( 1 );\r
- listview->GetItem( listitem );\r
- p_parent->SetMrl( (const char*) listitem.GetText().mb_str() );\r
- }\r
- }\r
- if( enable_checkbox->IsChecked() )\r
- {\r
- int i_from = atoi( from_text->GetValue().mb_str() );\r
- int i_to = atoi( to_text->GetValue().mb_str() );\r
- msg_Dbg( p_intf, "Partial streaming enabled, from %i to %i",\r
- i_from,i_to);\r
- p_parent->SetPartial( i_from, i_to );\r
- }\r
- return;\r
-}\r
-\r
-wxWizardPage *wizInputPage::GetPrev() const { return p_prev; }\r
-wxWizardPage *wizInputPage::GetNext() const\r
-{\r
- if( i_action == ACTION_STREAM )\r
- return p_streaming_page;\r
- else\r
- return p_transcode_page;\r
-}\r
-\r
-void wizInputPage::SetStreamingPage( wxWizardPage *page)\r
-{\r
- p_streaming_page = page;\r
-}\r
-\r
-void wizInputPage::SetTranscodePage( wxWizardPage *page)\r
-{\r
- p_transcode_page = page;\r
-}\r
-\r
-void wizInputPage::SetAction( int i_action )\r
-{\r
- this->i_action = i_action;\r
-}\r
-\r
-void wizInputPage::SetPintf( intf_thread_t *p_intf )\r
-{\r
- this->p_intf = p_intf;\r
-}\r
-\r
-void wizInputPage::SetUri( char *psz_uri )\r
-{\r
- mrl_text->SetValue( wxU( psz_uri ) );\r
-}\r
-\r
-void wizInputPage::SetPartial( int i_from, int i_to )\r
-{\r
- wxString msg;\r
- msg.Printf( wxString( wxT( "%i") ), i_from );\r
- from_text->Enable( TRUE );\r
- from_text->SetValue( msg );\r
- msg.Printf( wxString( wxT( "%i") ), i_to );\r
- to_text->Enable( TRUE );\r
- to_text->SetValue( msg );\r
- enable_checkbox->SetValue( TRUE );\r
-}\r
-\r
-/***************************************************\r
- * First transcode page: choose codecs *\r
- ***************************************************/\r
-wizTranscodeCodecPage::wizTranscodeCodecPage( wxWizard *parent,\r
- wxWizardPage *next) : wxWizardPage(parent)\r
-{\r
- p_next = next;\r
-\r
- acodec = NULL;\r
- vcodec = NULL;\r
- p_parent = (WizardDialog *) parent;\r
-\r
- wxBoxSizer *main_sizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Header */\r
- pageHeader( this, main_sizer, TRANSCODE1_TITLE, TRANSCODE1_TEXT );\r
-\r
- /* Video Box */\r
- wxStaticBox *video_box = new wxStaticBox( this, -1, wxU(_("Video")) );\r
- wxStaticBoxSizer *video_sizer = new wxStaticBoxSizer( video_box,\r
- wxVERTICAL );\r
- /* Line 1 : only the checkbox */\r
- wxFlexGridSizer *video_sizer1 = new wxFlexGridSizer( 2,3,20 );\r
- video_sizer1->Add( new wxCheckBox( this, VideoEnable_Event,\r
- wxU(_("Transcode video") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL , 5 );\r
- video_sizer1->Add( 0,0,1);\r
- /* Line 2 : codec */\r
- video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT ,5);\r
- video_combo = new wxComboBox( this, VideoCodec_Event, wxT(""),\r
- wxDefaultPosition, wxSize(200,25), 0, NULL, \r
- wxCB_DROPDOWN| wxCB_READONLY );\r
- for( int i= 0; vcodecs_array[i].psz_display != NULL; i++ )\r
- {\r
- video_combo->Append( wxU( vcodecs_array[i].psz_display ) ,\r
- (void *)&vcodecs_array[i] );\r
- }\r
- i_video_codec = 0;\r
- video_combo->SetSelection(0);\r
-\r
- video_sizer1->Add( video_combo, 0 , wxALIGN_LEFT , 0 );\r
-\r
- video_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,\r
- wxLEFT ,5);\r
- vb_combo = new wxComboBox( this, VideoBitrate_Event, wxT("1024"),\r
- wxDefaultPosition, wxDefaultSize,\r
- WXSIZEOF(vbitrates_array), vbitrates_array, wxCB_READONLY );\r
- video_sizer1->Add( vb_combo, 0, wxALIGN_LEFT , 0 );\r
-\r
- /* Line 3 : text */\r
- video_text = new wxStaticText( this, -1,\r
- wxU( vlc_wraptext( TR_VIDEO_TEXT, TEXTWIDTH, false) ) );\r
- /* Fill the main video sizer */\r
- video_sizer->Add( video_sizer1 , 0, wxEXPAND , 5 );\r
- video_sizer->Add( video_text, 0, wxLEFT|wxTOP , 5 );\r
-\r
-\r
- /* Audio box */\r
- wxStaticBox *audio_box = new wxStaticBox( this, -1, wxU(_("Audio")) );\r
- wxStaticBoxSizer *audio_sizer = new wxStaticBoxSizer( audio_box,\r
- wxVERTICAL );\r
- /* Line1: enabler */\r
- wxFlexGridSizer *audio_sizer1 = new wxFlexGridSizer( 2,3,20);\r
- audio_sizer1->Add( new wxCheckBox( this, AudioEnable_Event,\r
- wxU(_("Transcode audio") ) ), 0 , wxALIGN_CENTER_VERTICAL|wxALL, 5 );\r
- audio_sizer1->Add( 0, 0, 1 );\r
-\r
- /* Line 2 : codec */\r
- audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Codec"))),0,wxLEFT,5);\r
- audio_combo = new wxComboBox( this, AudioCodec_Event, wxT(""),\r
- wxDefaultPosition, wxSize(200,25), 0, NULL, \r
- wxCB_DROPDOWN| wxCB_READONLY );\r
- for( int i= 0; acodecs_array[i].psz_display != NULL; i++ )\r
- {\r
- audio_combo->Append( wxU( acodecs_array[i].psz_display ) ,\r
- (void *)&acodecs_array[i] );\r
- }\r
- i_audio_codec = 0;\r
- audio_combo->SetSelection(0);\r
- audio_sizer1->Add( audio_combo, 0 , wxALIGN_LEFT, 0 );\r
-\r
- audio_sizer1->Add( new wxStaticText(this, -1, wxU(_("Bitrate (kb/s)"))),0,\r
- wxLEFT ,5);\r
- ab_combo = new wxComboBox( this, AudioBitrate_Event, wxT("192"),\r
- wxDefaultPosition, wxDefaultSize,\r
- WXSIZEOF(abitrates_array), abitrates_array, wxCB_READONLY );\r
- audio_sizer1->Add( ab_combo, 0, wxALIGN_LEFT, 0 );\r
-\r
- /* Line 3 : text */\r
- audio_text = new wxStaticText( this, -1,\r
- wxU( vlc_wraptext( TR_AUDIO_TEXT, TEXTWIDTH, false) ) );\r
-\r
- audio_sizer->Add(audio_sizer1, 0, wxEXPAND, 5);\r
- audio_sizer->Add( audio_text, 0, wxLEFT | wxTOP, 5 );\r
-\r
- main_sizer->Add( video_sizer, 1, wxGROW, 0 );\r
- main_sizer->Add( audio_sizer, 1, wxGROW, 0 );\r
- main_sizer->Layout();\r
- SetSizerAndFit( main_sizer );\r
-\r
- /* Default disabled */\r
- video_combo->Disable(); video_text->Disable();vb_combo->Disable();\r
- audio_combo->Disable(); audio_text->Disable();ab_combo->Disable();\r
-\r
-}\r
-\r
-wizTranscodeCodecPage::~wizTranscodeCodecPage()\r
-{\r
- if( acodec ) free( acodec );\r
- if( vcodec ) free( vcodec );\r
-}\r
-\r
-void wizTranscodeCodecPage::OnEnableVideo(wxCommandEvent& event)\r
-{\r
- video_combo->Enable( event.IsChecked() );\r
- vb_combo->Enable( event.IsChecked() );\r
- video_text->Enable( event.IsChecked() );\r
-}\r
-\r
-void wizTranscodeCodecPage::OnEnableAudio(wxCommandEvent& event)\r
-{\r
- audio_combo->Enable( event.IsChecked() );\r
- ab_combo->Enable( event.IsChecked() );\r
- audio_text->Enable( event.IsChecked() );\r
-}\r
-\r
-void wizTranscodeCodecPage::OnVideoCodecChange(wxCommandEvent& event)\r
-{\r
- struct codec *c = (struct codec*)\r
- (video_combo->GetClientData(video_combo->GetSelection()));\r
- video_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );\r
- i_video_codec = video_combo->GetSelection();\r
- vcodec = strdup(c->psz_codec);\r
-}\r
-\r
-void wizTranscodeCodecPage::OnAudioCodecChange(wxCommandEvent& event)\r
-{\r
- struct codec *c = (struct codec*)\r
- (audio_combo->GetClientData(audio_combo->GetSelection()));\r
- audio_text->SetLabel( wxU( vlc_wraptext(c->psz_descr, TEXTWIDTH, false) ) );\r
- i_audio_codec = audio_combo->GetSelection();\r
- acodec = strdup(c->psz_codec);\r
-\r
-}\r
-\r
-void wizTranscodeCodecPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- unsigned int i,j;\r
-\r
- if( !event.GetDirection() )\r
- {\r
- GetPrev()->Enable();\r
- return;\r
- }\r
-\r
- /* Set the dummy codec ( accept all muxers ) if needed */\r
- if( !video_combo->IsEnabled() )\r
- {\r
- i_video_codec = VCODECS_NUMBER;\r
- }\r
- if( !audio_combo->IsEnabled() )\r
- {\r
- i_audio_codec = ACODECS_NUMBER;\r
- }\r
-\r
- ((wizEncapPage *)GetNext())->SetPrev(this);\r
-\r
- for( i = 0 ; i< MUXERS_NUMBER ; i++ )\r
- {\r
- if( vcodecs_array[i_video_codec].muxers[i] != -1 )\r
- {\r
- for( j = 0 ; j< MUXERS_NUMBER ; j++ )\r
- {\r
- if( acodecs_array[i_audio_codec].muxers[j] ==\r
- vcodecs_array[i_video_codec].muxers[i] )\r
- {\r
- ((wizEncapPage*)GetNext())->EnableEncap(\r
- vcodecs_array[i_video_codec].muxers[i] );\r
- }\r
- }\r
- }\r
- }\r
- struct codec *c = (struct codec*)\r
- (video_combo->GetClientData( video_combo->IsEnabled() ?\r
- video_combo->GetSelection(): i_video_codec ));\r
- vcodec = strdup(c->psz_codec);\r
- c = (struct codec*)\r
- (audio_combo->GetClientData( audio_combo->IsEnabled() ?\r
- audio_combo->GetSelection() : i_audio_codec ));\r
- acodec = strdup(c->psz_codec);\r
-\r
- int vb = atoi(vb_combo->GetValue().mb_str() );\r
- if( vb == 0 )\r
- {\r
- vb = 1024;\r
- }\r
- int ab = atoi(ab_combo->GetValue().mb_str() );\r
- if( ab == 0)\r
- {\r
- ab = 192;\r
- }\r
-\r
- p_parent->SetTranscode( vcodec, vb , acodec, ab );\r
- ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );\r
- p_parent->SetAction( p_parent->GetAction() );\r
-\r
- return;\r
-}\r
-\r
-wxWizardPage *wizTranscodeCodecPage::GetPrev() const { return p_prev; }\r
-wxWizardPage *wizTranscodeCodecPage::GetNext() const { return p_next; }\r
-void wizTranscodeCodecPage::SetPrev( wxWizardPage *page) {p_prev = page; }\r
-\r
-\r
-/***************************************************\r
- * First streaming page: choose method *\r
- ***************************************************/\r
-wizStreamingMethodPage::wizStreamingMethodPage( wxWizard *parent,\r
- wxWizardPage *next) : wxWizardPage(parent)\r
-{\r
- int i;\r
- p_next = next;\r
- p_parent = (WizardDialog *)parent;\r
-\r
- mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, STREAMING1_TITLE, STREAMING1_TEXT );\r
-\r
- mainSizer->Add( 0,50,0 );\r
-\r
- i_method = 0;\r
-\r
- wxStaticBox *method_box = new wxStaticBox( this, -1,\r
- wxU(_("Streaming method")) );\r
- wxStaticBoxSizer *method_sizer = new wxStaticBoxSizer(method_box,\r
- wxHORIZONTAL );\r
- for( i = 0 ; i< 3 ; i++ )\r
- {\r
- method_radios[i] = new wxRadioButton( this, MethodRadio0_Event + i,\r
- wxU( methods_array[i].psz_method ) );\r
- method_radios[i]->SetToolTip( wxU(_( methods_array[i].psz_descr ) ) );\r
- method_sizer->Add( method_radios[i], 0, wxALL, 5 );\r
- }\r
-\r
- method_sizer->Layout();\r
-\r
- wxStaticBox *address_box = new wxStaticBox( this, -1,\r
- wxU(_("Destination")) );\r
-\r
- address_sizer = new wxStaticBoxSizer(address_box,\r
- wxVERTICAL );\r
-\r
- /* Big kludge, we take the longest text to get the size */\r
- address_text = new wxStaticText(this, -1,\r
- wxU( vlc_wraptext(methods_array[2].psz_address,\r
- TEXTWIDTH, false ) ),\r
- wxDefaultPosition, wxDefaultSize );\r
-\r
- address_txtctrl = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,\r
- wxSize(200,25));\r
- address_sizer->Add( address_text, 0, wxALL, 5 );\r
- address_sizer->Add( address_txtctrl, 0, wxALL, 5 );\r
- address_sizer->Layout();\r
-\r
- /* Set the minimum size */\r
- address_sizer->SetMinSize( address_sizer->GetSize() );\r
- address_text->SetLabel( wxU(\r
- vlc_wraptext( _(methods_array[0].psz_address), TEXTWIDTH, false)));\r
-\r
- mainSizer->Add( method_sizer, 0, wxALL | wxEXPAND, 5 );\r
- mainSizer->Add( address_sizer, 0, wxALL | wxEXPAND, 5 );\r
-\r
- mainSizer->Add( 0,0,1 );\r
-\r
- mainSizer->Layout();\r
-\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
-\r
- return;\r
-}\r
-\r
-void wizStreamingMethodPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- unsigned int i;\r
- if( !event.GetDirection() ) return;\r
-\r
- /* Check valid address */\r
- if( i_method == 1 && !ismult( address_txtctrl->GetValue().mb_str()) )\r
- {\r
- wxMessageBox( wxU( INVALID_MCAST_ADDRESS ) , wxU( ERROR_MSG ),\r
- wxICON_WARNING | wxOK, this->p_parent );\r
- event.Veto();\r
-\r
- }\r
- else if( i_method == 0 && address_txtctrl->GetValue().IsEmpty() )\r
- {\r
- wxMessageBox( wxU( NO_ADDRESS ) , wxU( ERROR_MSG ),\r
- wxICON_WARNING | wxOK, this->p_parent );\r
- event.Veto();\r
-\r
- }\r
-\r
- ((wizEncapPage *)GetNext())->SetPrev(this);\r
- for( i = 0 ; i< MUXERS_NUMBER ; i++ )\r
- {\r
- if( methods_array[i_method].muxers[i] != -1 )\r
- {\r
- ((wizEncapPage*)GetNext())->EnableEncap(\r
- methods_array[i_method].muxers[i] );\r
- }\r
- }\r
- p_parent->SetStream( methods_array[i_method].psz_access ,\r
- (char *)address_txtctrl->GetValue().c_str() );\r
-\r
- /* Set the action for the muxer page */\r
- ((wizEncapPage*)GetNext())->SetAction( p_parent->GetAction() );\r
- return;\r
-}\r
-\r
-wxWizardPage *wizStreamingMethodPage::GetPrev() const { return p_prev; }\r
-wxWizardPage *wizStreamingMethodPage::GetNext() const { return p_next; }\r
-\r
-void wizStreamingMethodPage::SetPrev( wxWizardPage *page) {p_prev = page; }\r
-\r
-\r
-void wizStreamingMethodPage::OnMethodChange(wxEvent& event)\r
-{\r
- i_method = event.GetId() - MethodRadio0_Event;\r
- address_text->SetLabel( wxU(\r
- vlc_wraptext( _(methods_array[i_method].psz_address), TEXTWIDTH, false)));\r
- address_sizer->Layout();\r
- mainSizer->Layout();\r
-}\r
-\r
-/***************************************************\r
- * Choose encapsulation format *\r
- ***************************************************/\r
-wizEncapPage::wizEncapPage( wxWizard *parent ) : wxWizardPage(parent)\r
-{\r
- int i;\r
- i_mux = 0;\r
- p_parent = (WizardDialog *)parent;\r
- p_streaming_page = NULL;\r
- p_transcode_page = NULL;\r
- p_prev = NULL;\r
- wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, ENCAP_TITLE, ENCAP_TEXT );\r
-\r
- mainSizer->Add( 0,0,1 );\r
-\r
- for( i = 0 ; i< MUXERS_NUMBER ; i++ )\r
- {\r
- encap_radios[i] = new wxRadioButton( this, EncapRadio0_Event + i,\r
- wxU( encaps_array[i].psz_encap ) );\r
- encap_radios[i]->SetToolTip( wxU(_( encaps_array[i].psz_descr ) ) );\r
- mainSizer->Add( encap_radios[i], 0, wxLEFT, 5 );\r
- encap_radios[i]->Disable();\r
- }\r
-\r
- mainSizer->Add( 0,0,1 );\r
-\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
-}\r
-\r
-wizEncapPage::~wizEncapPage()\r
-{\r
-}\r
-\r
-void wizEncapPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- int i;\r
- if( !event.GetDirection() )\r
- {\r
- for( i = 0 ; i< MUXERS_NUMBER ; i++ )\r
- {\r
- encap_radios[i]->Disable();\r
- }\r
- }\r
- p_parent->SetMux( encaps_array[i_mux].psz_mux );\r
-\r
- if( p_parent->GetAction() == ACTION_STREAM )\r
- {\r
- if( strstr( p_parent->method, "udp" ))\r
- {\r
- ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable();\r
- ((wizStreamingExtraPage *)GetNext())->sap_text->Enable(false);\r
- }\r
- else\r
- {\r
- ((wizStreamingExtraPage *)GetNext())->sap_checkbox->Enable( false );\r
- ((wizStreamingExtraPage *)GetNext())->sap_text->Enable( false );\r
- }\r
- }\r
-\r
- return;\r
-}\r
-\r
-\r
-void wizEncapPage::OnEncapChange(wxEvent& event)\r
-{\r
- i_mux = event.GetId() - EncapRadio0_Event;\r
-}\r
-\r
-void wizEncapPage::EnableEncap( int encap )\r
-{\r
- int i;\r
- for( i = 0 ; i< MUXERS_NUMBER ; i++)\r
- {\r
- if( encaps_array[i].id == encap )\r
- {\r
- encap_radios[i]->Enable();\r
- encap_radios[i]->SetValue(true);\r
- i_mux = i;\r
- }\r
- }\r
-}\r
-\r
-void wizEncapPage::SetStreamingPage( wxWizardPage *page)\r
-{\r
- p_streaming_page = page;\r
-}\r
-\r
-void wizEncapPage::SetTranscodePage( wxWizardPage *page)\r
-{\r
- p_transcode_page = page;\r
-}\r
-\r
-wxWizardPage *wizEncapPage::GetPrev() const { return p_prev; }\r
-\r
-wxWizardPage *wizEncapPage::GetNext() const\r
-{\r
- if( i_action== ACTION_STREAM )\r
- return p_streaming_page;\r
- else\r
- return p_transcode_page;\r
-}\r
-\r
-void wizEncapPage::SetAction( int i_act ) { i_action = i_act; }\r
-\r
-void wizEncapPage::SetPrev( wxWizardPage *page) { p_prev = page; }\r
-\r
-/***************************************************\r
- * Extra transcoding page : Select file *\r
- ***************************************************/\r
-wizTranscodeExtraPage::wizTranscodeExtraPage( wxWizard *parent,\r
- wxWizardPage *prev,\r
- wxWizardPage *next) : wxWizardPage(parent)\r
-{\r
- p_next = next;\r
- p_prev = prev;\r
- p_parent = (WizardDialog *) parent;\r
- wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, EXTRATRANSCODE_TITLE, EXTRATRANSCODE_TEXT );\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
-\r
- wxFlexGridSizer *sizer = new wxFlexGridSizer( 2, 2, 1 );\r
- sizer->Add( new wxStaticText( this, -1,\r
- wxU(_("Select the file to save to") ) ),\r
- 0, wxALL, 5 );\r
- sizer->Add( 0, 0, 1 );\r
-\r
- file_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,\r
- wxSize( 150, -1 ) );\r
-\r
- sizer->Add( file_text, 0, wxALL, 5 );\r
- sizer->Add( new wxButton( this, Open_Event, wxU("Choose") ) );\r
-\r
- mainSizer->Add( sizer, 0, 0, 0) ;\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
-}\r
-\r
-void wizTranscodeExtraPage::OnSelectFile( wxCommandEvent &event)\r
-{\r
- wxFileDialog *file_dialog = new wxFileDialog( this, wxU(_("Open File")),\r
- wxT(""), wxT(""), wxT("*"), wxSAVE );\r
-\r
- if( file_dialog && file_dialog->ShowModal() == wxID_OK )\r
- {\r
- if( file_dialog->GetFilename().mb_str() )\r
- {\r
- file_text->SetValue( file_dialog->GetFilename() );\r
- }\r
- }\r
-}\r
-\r
-void wizTranscodeExtraPage::OnWizardPageChanging( wxWizardEvent& event )\r
-{\r
- if( event.GetDirection() && file_text->GetValue().IsEmpty() )\r
- {\r
- wxMessageBox( wxU( CHOOSE_OUTFILE ), wxU( ERROR_MSG ),\r
- wxICON_WARNING | wxOK, this->p_parent );\r
- event.Veto();\r
- }\r
- if( event.GetDirection() )\r
- {\r
- p_parent->SetTranscodeOut( file_text->GetValue().mb_str());\r
- }\r
-}\r
-\r
-wxWizardPage *wizTranscodeExtraPage::GetPrev() const { return p_prev; }\r
-wxWizardPage *wizTranscodeExtraPage::GetNext() const {return p_next; }\r
-\r
-/***********************************************************\r
- * Extra streaming page\r
- ***********************************************************/\r
-wizStreamingExtraPage::wizStreamingExtraPage( wxWizard *parent,\r
- wxWizardPage *prev,\r
- wxWizardPage *next) : wxWizardPage(parent)\r
-{\r
- p_next = next;\r
- p_prev = prev;\r
- p_parent = (WizardDialog *) parent;\r
- wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);\r
-\r
- /* Create the texts */\r
- pageHeader( this, mainSizer, EXTRASTREAMING_TITLE, EXTRASTREAMING_TEXT );\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
-\r
- wxFlexGridSizer *sizer = new wxFlexGridSizer( 2,2,1) ;\r
-\r
- /* TTL */\r
- sizer->Add( new wxStaticText( this, -1, wxU(_("Time-To-Live (TTL)"))),\r
- 0, wxALL, 5 );\r
- ttl_spin = new wxSpinCtrl( this, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize,\r
- 0, 1, 255, 1 );\r
- ttl_spin->SetToolTip(wxU(_(TTL) ) ) ;\r
- sizer->Add( ttl_spin, 0, wxALL , 5 );\r
-\r
- /* SAP announce */\r
- sap_checkbox = new wxCheckBox( this, SAP_Event, wxU(_("SAP Announce")) );\r
- sap_checkbox->SetToolTip( wxU(_( SAP ) ) );\r
- sizer->Add( sap_checkbox, 0, 0 , 0 );\r
- sap_text = new wxTextCtrl( this, -1, wxU(""), wxDefaultPosition,\r
- wxSize(100,25) );\r
- sap_text->SetToolTip( wxU(_( SAP ) ) );\r
- sizer->Add( sap_text, 0, wxALL , 5 );\r
-\r
- mainSizer->Add(sizer, 0, wxALL, 5 );\r
-\r
- mainSizer->Add( 0, 0, 1 );\r
-\r
- SetSizer(mainSizer);\r
- mainSizer->Fit(this);\r
-}\r
-\r
-void wizStreamingExtraPage::OnSAP( wxCommandEvent &event )\r
-{\r
- sap_text->Enable( event.IsChecked() );\r
-}\r
-\r
-void wizStreamingExtraPage::OnWizardPageChanging(wxWizardEvent& event)\r
-{\r
- if( sap_checkbox->IsChecked() )\r
- {\r
- if( sap_text->GetValue().IsEmpty() )\r
- {\r
- p_parent->SetSAP( true, NULL );\r
- }\r
- else\r
- {\r
- p_parent->SetSAP( true,\r
- (const char *)sap_text->GetValue().mb_str() );\r
- }\r
- }\r
- else\r
- {\r
- p_parent->SetSAP( false, NULL );\r
- }\r
-\r
- p_parent->SetTTL( ttl_spin->GetValue() );\r
-}\r
-\r
-wxWizardPage *wizStreamingExtraPage::GetPrev() const { return p_prev; }\r
-wxWizardPage *wizStreamingExtraPage::GetNext() const {return p_next; }\r
-\r
-\r
-/***************************************************************************\r
- * Implementation of the wizard itself\r
- ***************************************************************************/\r
-wizHelloPage *page1;\r
-wizInputPage *page2 ;\r
-wizTranscodeCodecPage *tr_page1 ;\r
-wizStreamingMethodPage *st_page1;\r
-wizTranscodeExtraPage *tr_page2 ;\r
-wizStreamingExtraPage *st_page2;\r
-wizEncapPage *encap_page;\r
-\r
-WizardDialog::WizardDialog(intf_thread_t *_p_intf, wxWindow *_p_parent,\r
- char *psz_uri, int _i_from, int _i_to ) :\r
-wxWizard( _p_parent, -1, wxU(_("Streaming/Transcoding Wizard")), wxNullBitmap, wxDefaultPosition)\r
-{\r
- /* Initializations */\r
- p_intf = _p_intf;\r
- SetPageSize(wxSize(400,420));\r
-\r
- /* Initialize structure */\r
- i_action = 0;\r
- i_from = _i_from;\r
- i_to = _i_to;\r
- i_ttl = 1;\r
- vb = 0;\r
- ab = 0;\r
- acodec=NULL;\r
- vcodec=NULL;\r
-\r
- page1 = new wizHelloPage(this);\r
- page2 = new wizInputPage(this, page1, p_intf);\r
-\r
- if( psz_uri )\r
- {\r
- page2->SetUri( psz_uri );\r
- }\r
- if( i_from != 0 || i_to != 0 )\r
- {\r
- page2->SetPartial( i_from, i_to );\r
- }\r
-\r
- encap_page = new wizEncapPage(this );\r
- tr_page1 = new wizTranscodeCodecPage(this, encap_page );\r
- st_page1 = new wizStreamingMethodPage(this, encap_page);\r
-\r
- tr_page2 = new wizTranscodeExtraPage(this, encap_page, NULL );\r
- st_page2 = new wizStreamingExtraPage(this, encap_page, NULL );\r
-\r
- /* Page 1 -> 2 */\r
- page1->SetNext( page2 );\r
- /* 2->1 in constructor of 2 */\r
-\r
- /* Page 2 -> 3 */\r
- page2->SetTranscodePage(tr_page1);\r
- page2->SetStreamingPage(st_page1);\r
- page2->SetPintf( p_intf );\r
- tr_page1->SetPrev(page2);\r
- st_page1->SetPrev(page2);\r
-\r
- /* Page 3 -> 4 */\r
- encap_page->SetTranscodePage( tr_page2 );\r
- encap_page->SetStreamingPage( st_page2 );\r
- /* 3->4 in constructor of 3 */\r
-// encap_page->SetPrev(tr_page1);\r
-}\r
-\r
-WizardDialog::~WizardDialog()\r
-{\r
- Destroy();\r
- delete page1;\r
- delete page2;\r
- delete tr_page1;\r
- delete st_page1 ;\r
- delete st_page2;\r
- delete tr_page2;\r
- delete encap_page;\r
-}\r
-\r
-void WizardDialog::SetMrl( const char *mrl )\r
-{\r
- this->mrl = strdup( mrl );\r
-}\r
-\r
-void WizardDialog::SetTTL( int i_ttl )\r
-{\r
- this->i_ttl = i_ttl;\r
-}\r
-\r
-void WizardDialog::SetSAP( bool b_enabled, const char *psz_text )\r
-{\r
- this->b_sap = b_enabled;\r
- if( b_enabled )\r
- {\r
- if( psz_text != NULL )\r
- {\r
- this->psz_sap_name = strdup( psz_text );\r
- }\r
- else\r
- {\r
- this->psz_sap_name = NULL;\r
- }\r
- }\r
-}\r
-\r
-void WizardDialog::SetPartial( int i_from, int i_to )\r
-{\r
- this->i_from = i_from;\r
- this->i_to = i_to;\r
-}\r
-\r
-void WizardDialog::SetTranscode( char *vcodec, int vb, char *acodec,int ab)\r
-{\r
- if( strcmp( vcodec, "dummy") )\r
- {\r
- this->vcodec= strdup(vcodec);\r
- }\r
- if( strcmp( acodec, "dummy" ) )\r
- {\r
- this->acodec = strdup(acodec);\r
- }\r
- this->vb = vb;\r
- this->ab = ab;\r
-}\r
-\r
-void WizardDialog::SetStream( char *method, char *address )\r
-{\r
- this->method = strdup( method );\r
- this->address = strdup( address );\r
-}\r
-\r
-void WizardDialog::SetTranscodeOut( const char *address )\r
-{\r
- this->address = strdup( address );\r
-}\r
-\r
-void WizardDialog::SetMux( char *mux )\r
-{\r
- this->mux = strdup( mux );\r
-}\r
-\r
-void WizardDialog::SetAction( int i_action )\r
-{\r
- this->i_action = i_action;\r
-}\r
-\r
-int WizardDialog::GetAction()\r
-{\r
- return i_action;\r
-}\r
-\r
-void WizardDialog::Run()\r
-{\r
- msg_Dbg( p_intf,"starting wizard");\r
- if( RunWizard(page1) )\r
- {\r
- int i_size;\r
- char *psz_opt;\r
- msg_Dbg( p_intf,"wizard completed");\r
-\r
- if( i_action == ACTION_TRANSCODE )\r
- {\r
- msg_Dbg( p_intf,"Starting transcode of %s to file %s",\r
- mrl, address);\r
- msg_Dbg( p_intf,"Using %s (%i kbps) / %s (%i kbps),encap %s",\r
- vcodec,vb,acodec,ab,mux);\r
- int i_tr_size = 0 ; /* 10 = ab + vb */\r
- i_tr_size += vcodec ? strlen(vcodec) + strlen("vcodec=") +strlen("vb="): 0;\r
- i_tr_size += acodec ? strlen(acodec) + strlen("acodec=") +strlen("ab=") : 0;\r
-\r
- char *psz_transcode = (char *)malloc( i_tr_size * sizeof(char));\r
- if( vcodec || acodec )\r
- {\r
- sprintf( psz_transcode, "transcode{" );\r
- }\r
- else\r
- {\r
- snprintf( psz_transcode, 1 , "%c", 0 );\r
- }\r
- if( vcodec )\r
- {\r
- i_tr_size += 5 + strlen(vcodec);\r
- snprintf( psz_transcode, i_tr_size , "%svcodec=%s,vb=%i",\r
- psz_transcode, vcodec, vb );\r
- }\r
- if( acodec )\r
- {\r
- i_tr_size += 6 + strlen(acodec);\r
- /* FIXME */\r
- sprintf( psz_transcode, "%s%cacodec=%s,ab=%i",\r
- psz_transcode, vcodec ? ',' : ' ', acodec, ab );\r
- }\r
- if( vcodec || acodec )\r
- {\r
- i_tr_size +=2;\r
- sprintf( psz_transcode , "%s}:", psz_transcode );\r
- }\r
- i_size = 73 + strlen(mux) + strlen(address) + strlen(psz_transcode);\r
- psz_opt = (char *)malloc( i_size * sizeof(char) );\r
- snprintf( psz_opt, i_size, ":sout=#%sstandard{mux=%s,url=%s,"\r
- "access=file}",\r
- psz_transcode, mux, address );\r
- }\r
- else\r
- {\r
- msg_Dbg( p_intf, "Starting stream of %s to %s using %s, encap %s",\r
- mrl, address, method, mux);\r
- if( b_sap )\r
- {\r
- char *psz_sap_option = NULL;\r
- if( psz_sap_name )\r
- {\r
- psz_sap_option = (char *) malloc( strlen( psz_sap_name )\r
- + 15 );\r
- snprintf( psz_sap_option,strlen( psz_sap_name ) + 15,\r
- "sap,name=\"%s\"",psz_sap_name );\r
- }\r
- else\r
- {\r
- psz_sap_option = (char *) malloc( 5 );\r
- snprintf( psz_sap_option, 5, "sap" );\r
- }\r
- i_size = 40 + strlen(mux) + strlen(address) +\r
- strlen( psz_sap_option);\r
- psz_opt = (char *)malloc( i_size * sizeof(char) );\r
- snprintf( psz_opt, i_size,\r
- ":sout=#standard{mux=%s,url=%s,access=%s,%s}",\r
- mux, address,method, psz_sap_option);\r
- msg_Dbg( p_intf, "Sap enabled: %s", psz_sap_option);\r
- if( psz_sap_option ) free( psz_sap_option );\r
- }\r
- else\r
- {\r
- i_size = 40 + strlen(mux) + strlen(address);\r
- psz_opt = (char *)malloc( i_size * sizeof(char) );\r
- snprintf( psz_opt, i_size,\r
- ":sout=#standard{mux=%s,url=%s,access=%s}",\r
- mux, address,method);\r
- }\r
- }\r
-\r
- playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,\r
- VLC_OBJECT_PLAYLIST, FIND_ANYWHERE);\r
- if( p_playlist )\r
- {\r
- playlist_item_t *p_item = playlist_ItemNew( p_playlist, mrl,\r
- ITEM_NAME );\r
- playlist_ItemAddOption( p_item, psz_opt);\r
- if( i_from != 0)\r
- {\r
- char psz_from[20];\r
- msg_Dbg( p_intf, "Setting starttime");\r
- snprintf( psz_from, 20, "start-time=%i", i_from);\r
- playlist_ItemAddOption( p_item, psz_from);\r
- }\r
- if( i_to != 0)\r
- {\r
- char psz_to[20];\r
- snprintf( psz_to, 20, "stop-time=%i", i_to);\r
- playlist_ItemAddOption( p_item, psz_to);\r
- }\r
-\r
- char psz_ttl[20];\r
- snprintf( psz_ttl, 20, "ttl=%i",i_ttl );\r
- playlist_ItemAddOption( p_item, psz_ttl );\r
-\r
- playlist_AddItem( p_playlist, p_item, PLAYLIST_GO, PLAYLIST_END );\r
- vlc_object_release(p_playlist);\r
- }\r
- else\r
- {\r
- wxMessageBox( wxU( NO_PLAYLIST ), wxU( ERROR_MSG ),\r
- wxICON_WARNING | wxOK, this );\r
- }\r
- }\r
- else\r
- {\r
- msg_Dbg( p_intf, "wizard was cancelled");\r
- }\r
-}\r
-/****************************************************************\r
- * Local helper functions\r
- ****************************************************************/\r
-static int ismult( const char *psz_uri )\r
-{\r
- char *psz_end;\r
- unsigned long i_value;\r
-\r
- /* IPv6 */\r
- if( psz_uri[0] == '[')\r
- return strncasecmp( &psz_uri[1], "FF" , 2) ? VLC_FALSE : VLC_TRUE;\r
-\r
- /* IPv4 */\r
- i_value = strtoul( psz_uri, &psz_end, 10 );\r
- if( *psz_end != '.' ) { return( VLC_FALSE ); }\r
-\r
- return( ( i_value >= 224 && i_value < 240 ) ? VLC_TRUE : VLC_FALSE );\r
-\r
-}\r
+/*****************************************************************************
+ * wizard.cpp : wxWindows plugin for vlc
+ *****************************************************************************
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *
+ * 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 <stdlib.h> /* malloc(), free() */
+#include <errno.h> /* ENOMEM */
+#include <string.h> /* strerror() */
+#include <stdio.h>
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+
+#include "wxwindows.h"
+
+#include "streamdata.h"
+
+#include <wx/statline.h>
+
+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 );
+
+}
* 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 <massiot@via.ecp.fr>
*
* 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 <sam@zoy.org>
*
* 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 <gbazin@netcourrier.com>
*
* 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 <sam@zoy.org>
*
* 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 <sam@zoy.org>
*
/*****************************************************************************
* 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
* 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 <sam@zoy.org>
*
* 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 <sam@zoy.org>
*
* 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 <sam@zoy.org>
*
* 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 <fenrir@via.ecp.fr>
* Eric Petit <titer@videolan.org>
* 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 <fenrir@via.ecp.fr>
*
* Copyright (C) 2003 Antoine Missout
* Copyright (C) 2000-2003 Michel Lespinasse <walken@zoy.org>
* Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
- * $Id: frame.c,v 1.2 2004/03/03 11:39:06 massiot Exp $
+ * $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
* 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 <seguin@via.ecp.fr>
*
-/*****************************************************************************\r
- * marq.c : marquee display video plugin for vlc\r
- *****************************************************************************\r
- * Copyright (C) 2003-2005 VideoLAN\r
- * $Id: time.c 8751 2004-09-20 21:51:41Z gbazin $\r
- *\r
- * Authors: Mark Moriarty\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-/*****************************************************************************\r
- * Preamble\r
- *****************************************************************************/\r
-#include <stdlib.h> /* malloc(), free() */\r
-#include <string.h>\r
-\r
-#include <vlc/vlc.h>\r
-#include <vlc/vout.h>\r
-\r
-#include "vlc_filter.h"\r
-#include "vlc_block.h"\r
-#include "osd.h"\r
-\r
-/*****************************************************************************\r
- * Local prototypes\r
- *****************************************************************************/\r
-static int CreateFilter ( vlc_object_t * );\r
-static void DestroyFilter( vlc_object_t * );\r
-static subpicture_t *Filter( filter_t *, mtime_t );\r
-\r
-\r
-static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,\r
- vlc_value_t oldval, vlc_value_t newval,\r
- void *p_data );\r
-static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0, \r
- 0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00, \r
- 0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080, \r
- 0x00000080, 0x000000FF, 0x0000FFFF}; \r
-static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"), \r
- N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),\r
- N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"), \r
- N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"), \r
- N_("Aqua") };\r
-\r
-/*****************************************************************************\r
- * filter_sys_t: marquee filter descriptor\r
- *****************************************************************************/\r
-struct filter_sys_t\r
-{\r
- int i_xoff, i_yoff; /* offsets for the display string in the video window */\r
- int i_pos; /* permit relative positioning (top, bottom, left, right, center) */\r
- int i_timeout;\r
-\r
- char *psz_marquee; /* marquee string */\r
-\r
- int i_font_color, i_font_opacity, i_font_size; /* font control */\r
- \r
- time_t last_time;\r
- vlc_bool_t b_absolute; /* position control, relative vs. absolute */\r
-\r
- vlc_bool_t b_need_update;\r
-};\r
-\r
-#define MSG_TEXT N_("Marquee text")\r
-#define MSG_LONGTEXT N_("Marquee text to display")\r
-#define POSX_TEXT N_("X offset, from left")\r
-#define POSX_LONGTEXT N_("X offset, from the left screen edge" )\r
-#define POSY_TEXT N_("Y offset, from the top")\r
-#define POSY_LONGTEXT N_("Y offset, down from the top" )\r
-#define TIMEOUT_TEXT N_("Marquee timeout")\r
-#define TIMEOUT_LONGTEXT N_("Defines the time the marquee must remain " \\r
- "displayed, in milliseconds. Default value is " \\r
- "0 (remain forever).")\r
-#define OPACITY_TEXT N_("Opacity, -1..255")\r
-#define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of overlay text. " \\r
- "-1 = use freetype-opacity, 0 = transparent, 255 = totally opaque. " )\r
-#define SIZE_TEXT N_("Font size, pixels")\r
-#define SIZE_LONGTEXT N_("Specify the font size, in pixels, " \\r
- "with -1 = use freetype-fontsize" )\r
-\r
-#define COLOR_TEXT N_("Text Default Color")\r
-#define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal." \\r
- "-1 = use freetype-color, #000000 = all colors off, " \\r
- "0xFF0000 = just Red, 0xFFFFFF = all color on [White]" )\r
-\r
-#define POS_TEXT N_("Marquee position")\r
-#define POS_LONGTEXT N_( \\r
- "You can enforce the marquee position on the video " \\r
- "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \\r
- "also use combinations of these values by adding them).")\r
-\r
-static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };\r
-static char *ppsz_pos_descriptions[] =\r
- { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),\r
- N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };\r
-\r
-/*****************************************************************************\r
- * Module descriptor\r
- *****************************************************************************/\r
-vlc_module_begin();\r
- set_capability( "sub filter", 0 );\r
- set_shortname( N_("Marquee" ));\r
- set_callbacks( CreateFilter, DestroyFilter );\r
- set_category( CAT_VIDEO );\r
- set_subcategory( SUBCAT_VIDEO_SUBPIC );\r
- add_string( "marq-marquee", "Marquee", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );\r
- add_integer( "marq-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_FALSE );\r
- add_integer( "marq-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_FALSE );\r
- add_integer( "marq-timeout", 0, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT,\r
- VLC_FALSE );\r
- add_integer( "marq-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_TRUE );\r
- /* 5 sets the default to top [1] left [4] */\r
- change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );\r
- add_integer_with_range( "marq-opacity", -1, -1, 255, NULL,\r
- OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );\r
- add_integer( "marq-color", -1, NULL, COLOR_TEXT, COLOR_LONGTEXT, VLC_TRUE );\r
- change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );\r
- add_integer( "marq-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE );\r
-\r
- set_description( _("Marquee display sub filter") );\r
- add_shortcut( "marq" );\r
-vlc_module_end();\r
-\r
-/*****************************************************************************\r
- * CreateFilter: allocates marquee video filter\r
- *****************************************************************************/\r
-static int CreateFilter( vlc_object_t *p_this )\r
-{\r
- filter_t *p_filter = (filter_t *)p_this;\r
- filter_sys_t *p_sys;\r
- vlc_object_t *p_input;\r
-\r
- /* Allocate structure */\r
- p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );\r
- if( p_sys == NULL )\r
- {\r
- msg_Err( p_filter, "out of memory" );\r
- return VLC_ENOMEM;\r
- }\r
-\r
- /* Hook used for callback variables */\r
- p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );\r
- if( !p_input )\r
- {\r
- return VLC_ENOOBJ;\r
- }\r
-\r
- p_sys->i_xoff = var_CreateGetInteger( p_input->p_libvlc , "marq-x" );\r
- p_sys->i_yoff = var_CreateGetInteger( p_input->p_libvlc , "marq-y" );\r
- p_sys->i_timeout = var_CreateGetInteger( p_input->p_libvlc , "marq-timeout" );\r
- p_sys->i_pos = var_CreateGetInteger( p_input->p_libvlc , "marq-position" );\r
- p_sys->psz_marquee = var_CreateGetString( p_input->p_libvlc, "marq-marquee" );\r
- var_Create( p_input->p_libvlc, "marq-opacity", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );\r
- p_sys->i_font_opacity = var_CreateGetInteger( p_input->p_libvlc , "marq-opacity" );\r
- p_sys->i_font_color = var_CreateGetInteger( p_input->p_libvlc , "marq-color" );\r
- p_sys->i_font_size = var_CreateGetInteger( p_input->p_libvlc , "marq-size" );\r
-\r
- var_AddCallback( p_input->p_libvlc, "marq-x", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-y", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-marquee", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-timeout", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-position", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-color", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-opacity", MarqueeCallback, p_sys );\r
- var_AddCallback( p_input->p_libvlc, "marq-size", MarqueeCallback, p_sys );\r
-\r
- vlc_object_release( p_input );\r
-\r
-\r
- /* Misc init */\r
- p_filter->pf_sub_filter = Filter;\r
- p_sys->last_time = ((time_t)-1);\r
- p_sys->b_need_update = VLC_TRUE;\r
-\r
- return VLC_SUCCESS;\r
-}\r
-/*****************************************************************************\r
- * DestroyFilter: destroy marquee video filter\r
- *****************************************************************************/\r
-static void DestroyFilter( vlc_object_t *p_this )\r
-{\r
- filter_t *p_filter = (filter_t *)p_this;\r
- filter_sys_t *p_sys = p_filter->p_sys;\r
- vlc_object_t *p_input;\r
-\r
- if( p_sys->psz_marquee ) free( p_sys->psz_marquee );\r
- free( p_sys );\r
-\r
- /* Delete the marquee variables */\r
- p_input = vlc_object_find( p_this, VLC_OBJECT_INPUT, FIND_ANYWHERE );\r
- if( !p_input )\r
- {\r
- return;\r
- }\r
- var_Destroy( p_input->p_libvlc , "marq-marquee" );\r
- var_Destroy( p_input->p_libvlc , "marq-x" );\r
- var_Destroy( p_input->p_libvlc , "marq-y" );\r
- var_Destroy( p_input->p_libvlc , "marq-timeout" );\r
- var_Destroy( p_input->p_libvlc , "marq-position" );\r
- var_Destroy( p_input->p_libvlc , "marq-color");\r
- var_Destroy( p_input->p_libvlc , "marq-opacity");\r
- var_Destroy( p_input->p_libvlc , "marq-size");\r
-\r
- vlc_object_release( p_input );\r
-}\r
-\r
-/****************************************************************************\r
- * Filter: the whole thing\r
- ****************************************************************************\r
- * This function outputs subpictures at regular time intervals.\r
- ****************************************************************************/\r
-static subpicture_t *Filter( filter_t *p_filter, mtime_t date )\r
-{\r
- filter_sys_t *p_sys = p_filter->p_sys;\r
- subpicture_t *p_spu;\r
- video_format_t fmt;\r
- time_t t;\r
-\r
- if( p_sys->last_time == time( NULL ) )\r
- {\r
- return NULL;\r
- }\r
-\r
- if( p_sys->b_need_update == VLC_FALSE )\r
- {\r
- return NULL;\r
- }\r
- \r
- p_sys->b_absolute = VLC_TRUE;\r
- if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )\r
- {\r
- p_sys->b_absolute = VLC_FALSE;\r
- }\r
-\r
- p_spu = p_filter->pf_sub_buffer_new( p_filter );\r
- if( !p_spu ) return NULL;\r
-\r
- p_spu->b_absolute = p_sys->b_absolute;\r
- memset( &fmt, 0, sizeof(video_format_t) );\r
- fmt.i_chroma = VLC_FOURCC('T','E','X','T');\r
- fmt.i_aspect = 0;\r
- fmt.i_width = fmt.i_height = 0;\r
- fmt.i_x_offset = 0;\r
- fmt.i_y_offset = 0;\r
- p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );\r
- if( !p_spu->p_region )\r
- {\r
- p_filter->pf_sub_buffer_del( p_filter, p_spu );\r
- return NULL;\r
- }\r
-\r
- t = p_sys->last_time = time( NULL );\r
-\r
- p_spu->p_region->psz_text = strdup(p_sys->psz_marquee);\r
- p_spu->i_start = date;\r
- p_spu->i_stop = p_sys->i_timeout == 0 ? 0 : date + p_sys->i_timeout * 1000;\r
- p_spu->b_ephemer = VLC_TRUE;\r
- p_spu->i_x = p_sys->i_xoff;\r
- p_spu->i_y = p_sys->i_yoff;\r
- p_spu->p_region->i_font_color = p_sys->i_font_color;\r
- p_spu->p_region->i_font_opacity = p_sys->i_font_opacity;\r
- p_spu->p_region->i_font_size = p_sys->i_font_size;\r
- \r
- p_spu->i_flags = p_sys->i_pos;\r
-\r
- p_sys->b_need_update = VLC_FALSE;\r
- return p_spu;\r
-}\r
-\r
-/**********************************************************************\r
- * Callback to update params on the fly\r
- **********************************************************************/\r
-static int MarqueeCallback( vlc_object_t *p_this, char const *psz_var,\r
- vlc_value_t oldval, vlc_value_t newval,\r
- void *p_data )\r
-{\r
- filter_sys_t *p_sys = (filter_sys_t *) p_data;\r
-\r
- if( !strncmp( psz_var, "marq-marquee", 7 ) )\r
- {\r
- if( p_sys->psz_marquee ) free( p_sys->psz_marquee );\r
- p_sys->psz_marquee = strdup( newval.psz_string );\r
- }\r
- else if ( !strncmp( psz_var, "marq-x", 6 ) )\r
- {\r
- p_sys->i_xoff = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-y", 6 ) )\r
- {\r
- p_sys->i_yoff = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-color", 8 ) ) /* "marq-col" */ \r
- {\r
- p_sys->i_font_color = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-opacity", 8 ) ) /* "marq-opa" */ \r
- {\r
- p_sys->i_font_opacity = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-size", 6 ) )\r
- {\r
- p_sys->i_font_size = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-timeout", 12 ) )\r
- {\r
- p_sys->i_timeout = newval.i_int;\r
- }\r
- else if ( !strncmp( psz_var, "marq-position", 8 ) )\r
- /* willing to accept a match against marq-pos */\r
- {\r
- p_sys->i_pos = newval.i_int;\r
- p_sys->i_xoff = -1; /* force to relative positioning */\r
- }\r
- p_sys->b_need_update = VLC_TRUE;\r
- return VLC_SUCCESS;\r
-}\r
+/*****************************************************************************
+ * 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 <stdlib.h> /* malloc(), free() */
+#include <string.h>
+
+#include <vlc/vlc.h>
+#include <vlc/vout.h>
+
+#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;
+}
-/*****************************************************************************\r
- * glwin32.c: Windows OpenGL provider\r
- *****************************************************************************\r
- * Copyright (C) 2001-2004 VideoLAN\r
- * $Id$\r
- *\r
- * Authors: Gildas Bazin <gbazin@videolan.org>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-#include <errno.h> /* ENOMEM */\r
-#include <stdlib.h> /* free() */\r
-#include <string.h> /* strerror() */\r
-\r
-#include <vlc/vlc.h>\r
-#include <vlc/intf.h>\r
-#include <vlc/vout.h>\r
-\r
-#include <windows.h>\r
-#include <ddraw.h>\r
-#include <commctrl.h>\r
-\r
-#include <multimon.h>\r
-#undef GetSystemMetrics\r
-\r
-#ifndef MONITOR_DEFAULTTONEAREST\r
-# define MONITOR_DEFAULTTONEAREST 2\r
-#endif\r
-\r
-#include <GL/gl.h>\r
-\r
-#include "vout.h"\r
-\r
-/*****************************************************************************\r
- * Local prototypes.\r
- *****************************************************************************/\r
-static int OpenVideo ( vlc_object_t * );\r
-static void CloseVideo ( vlc_object_t * );\r
-\r
-static int Init ( vout_thread_t * );\r
-static void End ( vout_thread_t * );\r
-static int Manage ( vout_thread_t * );\r
-static void GLSwapBuffers( vout_thread_t * );\r
-\r
-/*****************************************************************************\r
- * Module descriptor\r
- *****************************************************************************/\r
-vlc_module_begin();\r
- set_category( CAT_VIDEO );\r
- set_subcategory( SUBCAT_VIDEO_VOUT );\r
- set_description( _("Win32 OpenGL provider") );\r
- set_capability( "opengl provider", 100 );\r
- add_shortcut( "glwin32" );\r
- set_callbacks( OpenVideo, CloseVideo );\r
-\r
- /* FIXME: Hack to avoid unregistering our window class */\r
- linked_with_a_crap_library_which_uses_atexit( );\r
-vlc_module_end();\r
-\r
-#if 0 /* FIXME */\r
- /* check if we registered a window class because we need to\r
- * unregister it */\r
- WNDCLASS wndclass;\r
- if( GetClassInfo( GetModuleHandle(NULL), "VLC DirectX", &wndclass ) )\r
- UnregisterClass( "VLC DirectX", GetModuleHandle(NULL) );\r
-#endif\r
-\r
-/*****************************************************************************\r
- * OpenVideo: allocate OpenGL provider\r
- *****************************************************************************\r
- * This function creates and initializes a video window.\r
- *****************************************************************************/\r
-static int OpenVideo( vlc_object_t *p_this )\r
-{\r
- vout_thread_t * p_vout = (vout_thread_t *)p_this;\r
- vlc_value_t val;\r
-\r
- /* Allocate structure */\r
- p_vout->p_sys = malloc( sizeof( vout_sys_t ) );\r
- if( p_vout->p_sys == NULL )\r
- {\r
- msg_Err( p_vout, "out of memory" );\r
- return VLC_ENOMEM;\r
- }\r
- memset( p_vout->p_sys, 0, sizeof( vout_sys_t ) );\r
-\r
- /* Initialisations */\r
- p_vout->pf_init = Init;\r
- p_vout->pf_end = End;\r
- p_vout->pf_manage = Manage;\r
- p_vout->pf_swap = GLSwapBuffers;\r
-\r
- p_vout->p_sys->p_ddobject = NULL;\r
- p_vout->p_sys->p_display = NULL;\r
- p_vout->p_sys->p_current_surface = NULL;\r
- p_vout->p_sys->p_clipper = NULL;\r
- p_vout->p_sys->hwnd = p_vout->p_sys->hvideownd = NULL;\r
- p_vout->p_sys->hparent = p_vout->p_sys->hfswnd = NULL;\r
- p_vout->p_sys->i_changes = 0;\r
- p_vout->p_sys->b_wallpaper = 0;\r
- vlc_mutex_init( p_vout, &p_vout->p_sys->lock );\r
- SetRectEmpty( &p_vout->p_sys->rect_display );\r
- SetRectEmpty( &p_vout->p_sys->rect_parent );\r
-\r
- var_Create( p_vout, "video-title", VLC_VAR_STRING | VLC_VAR_DOINHERIT );\r
-\r
- p_vout->p_sys->b_cursor_hidden = 0;\r
- p_vout->p_sys->i_lastmoved = mdate();\r
-\r
- /* Set main window's size */\r
- p_vout->p_sys->i_window_width = p_vout->i_window_width;\r
- p_vout->p_sys->i_window_height = p_vout->i_window_height;\r
-\r
- /* Create the DirectXEventThread, this thread is created by us to isolate\r
- * the Win32 PeekMessage function calls. We want to do this because\r
- * Windows can stay blocked inside this call for a long time, and when\r
- * this happens it thus blocks vlc's video_output thread.\r
- * DirectXEventThread will take care of the creation of the video\r
- * window (because PeekMessage has to be called from the same thread which\r
- * created the window). */\r
- msg_Dbg( p_vout, "creating DirectXEventThread" );\r
- p_vout->p_sys->p_event =\r
- vlc_object_create( p_vout, sizeof(event_thread_t) );\r
- p_vout->p_sys->p_event->p_vout = p_vout;\r
- if( vlc_thread_create( p_vout->p_sys->p_event, "DirectX Events Thread",\r
- E_(DirectXEventThread), 0, 1 ) )\r
- {\r
- msg_Err( p_vout, "cannot create DirectXEventThread" );\r
- vlc_object_destroy( p_vout->p_sys->p_event );\r
- p_vout->p_sys->p_event = NULL;\r
- goto error;\r
- }\r
-\r
- if( p_vout->p_sys->p_event->b_error )\r
- {\r
- msg_Err( p_vout, "DirectXEventThread failed" );\r
- goto error;\r
- }\r
-\r
- vlc_object_attach( p_vout->p_sys->p_event, p_vout );\r
-\r
- msg_Dbg( p_vout, "DirectXEventThread running" );\r
-\r
- /* Variable to indicate if the window should be on top of others */\r
- /* Trigger a callback right now */\r
- var_Get( p_vout, "video-on-top", &val );\r
- var_Set( p_vout, "video-on-top", val );\r
-\r
- return VLC_SUCCESS;\r
-\r
- error:\r
- CloseVideo( VLC_OBJECT(p_vout) );\r
- return VLC_EGENERIC;\r
-}\r
-\r
-/*****************************************************************************\r
- * Init: initialize video thread output method\r
- *****************************************************************************/\r
-static int Init( vout_thread_t *p_vout )\r
-{\r
- PIXELFORMATDESCRIPTOR pfd;\r
- int iFormat;\r
-\r
- /* Change the window title bar text */\r
- PostMessage( p_vout->p_sys->hwnd, WM_VLC_CHANGE_TEXT, 0, 0 );\r
-\r
- p_vout->p_sys->hGLDC = GetDC( p_vout->p_sys->hvideownd );\r
-\r
- /* Set the pixel format for the DC */\r
- memset( &pfd, 0, sizeof( pfd ) );\r
- pfd.nSize = sizeof( pfd );\r
- pfd.nVersion = 1;\r
- pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;\r
- pfd.iPixelType = PFD_TYPE_RGBA;\r
- pfd.cColorBits = 24;\r
- pfd.cDepthBits = 16;\r
- pfd.iLayerType = PFD_MAIN_PLANE;\r
- iFormat = ChoosePixelFormat( p_vout->p_sys->hGLDC, &pfd );\r
- SetPixelFormat( p_vout->p_sys->hGLDC, iFormat, &pfd );\r
-\r
- /* Create and enable the render context */\r
- p_vout->p_sys->hGLRC = wglCreateContext( p_vout->p_sys->hGLDC );\r
- wglMakeCurrent( p_vout->p_sys->hGLDC, p_vout->p_sys->hGLRC );\r
-\r
- return VLC_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************\r
- * End: terminate Sys video thread output method\r
- *****************************************************************************\r
- * Terminate an output method created by Create.\r
- * It is called at the end of the thread.\r
- *****************************************************************************/\r
-static void End( vout_thread_t *p_vout )\r
-{\r
- wglMakeCurrent( NULL, NULL );\r
- wglDeleteContext( p_vout->p_sys->hGLRC );\r
- ReleaseDC( p_vout->p_sys->hvideownd, p_vout->p_sys->hGLDC );\r
- return;\r
-}\r
-\r
-/*****************************************************************************\r
- * CloseVideo: destroy Sys video thread output method\r
- *****************************************************************************\r
- * Terminate an output method created by Create\r
- *****************************************************************************/\r
-static void CloseVideo( vlc_object_t *p_this )\r
-{\r
- vout_thread_t * p_vout = (vout_thread_t *)p_this;\r
-\r
- msg_Dbg( p_vout, "CloseVideo" );\r
-\r
- if( p_vout->p_sys->p_event )\r
- {\r
- vlc_object_detach( p_vout->p_sys->p_event );\r
-\r
- /* Kill DirectXEventThread */\r
- p_vout->p_sys->p_event->b_die = VLC_TRUE;\r
-\r
- /* we need to be sure DirectXEventThread won't stay stuck in\r
- * GetMessage, so we send a fake message */\r
- if( p_vout->p_sys->hwnd )\r
- {\r
- PostMessage( p_vout->p_sys->hwnd, WM_NULL, 0, 0);\r
- }\r
-\r
- vlc_thread_join( p_vout->p_sys->p_event );\r
- vlc_object_destroy( p_vout->p_sys->p_event );\r
- }\r
-\r
- vlc_mutex_destroy( &p_vout->p_sys->lock );\r
-\r
- if( p_vout->p_sys )\r
- {\r
- free( p_vout->p_sys );\r
- p_vout->p_sys = NULL;\r
- }\r
-}\r
-\r
-/*****************************************************************************\r
- * Manage: handle Sys events\r
- *****************************************************************************\r
- * This function should be called regularly by the video output thread.\r
- * It returns a non null value if an error occurred.\r
- *****************************************************************************/\r
-static int Manage( vout_thread_t *p_vout )\r
-{\r
- WINDOWPLACEMENT window_placement;\r
-\r
- int i_width = p_vout->p_sys->rect_dest.right -\r
- p_vout->p_sys->rect_dest.left;\r
- int i_height = p_vout->p_sys->rect_dest.bottom -\r
- p_vout->p_sys->rect_dest.top;\r
- glViewport( 0, 0, i_width, i_height );\r
-\r
- /* If we do not control our window, we check for geometry changes\r
- * ourselves because the parent might not send us its events. */\r
- vlc_mutex_lock( &p_vout->p_sys->lock );\r
- if( p_vout->p_sys->hparent && !p_vout->b_fullscreen )\r
- {\r
- RECT rect_parent;\r
- POINT point;\r
-\r
- vlc_mutex_unlock( &p_vout->p_sys->lock );\r
-\r
- GetClientRect( p_vout->p_sys->hparent, &rect_parent );\r
- point.x = point.y = 0;\r
- ClientToScreen( p_vout->p_sys->hparent, &point );\r
- OffsetRect( &rect_parent, point.x, point.y );\r
-\r
- if( !EqualRect( &rect_parent, &p_vout->p_sys->rect_parent ) )\r
- {\r
- p_vout->p_sys->rect_parent = rect_parent;\r
-\r
- /* This one is to force the update even if only\r
- * the position has changed */\r
- SetWindowPos( p_vout->p_sys->hwnd, 0, 1, 1,\r
- rect_parent.right - rect_parent.left,\r
- rect_parent.bottom - rect_parent.top, 0 );\r
-\r
- SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,\r
- rect_parent.right - rect_parent.left,\r
- rect_parent.bottom - rect_parent.top, 0 );\r
- }\r
- }\r
- else\r
- {\r
- vlc_mutex_unlock( &p_vout->p_sys->lock );\r
- }\r
-\r
- /* We used to call the Win32 PeekMessage function here to read the window\r
- * messages. But since window can stay blocked into this function for a\r
- * long time (for example when you move your window on the screen), I\r
- * decided to isolate PeekMessage in another thread. */\r
-\r
- /*\r
- * Fullscreen change\r
- */\r
- if( p_vout->i_changes & VOUT_FULLSCREEN_CHANGE\r
- || p_vout->p_sys->i_changes & VOUT_FULLSCREEN_CHANGE )\r
- {\r
- vlc_value_t val;\r
- HWND hwnd = (p_vout->p_sys->hparent && p_vout->p_sys->hfswnd) ?\r
- p_vout->p_sys->hfswnd : p_vout->p_sys->hwnd;\r
-\r
- p_vout->b_fullscreen = ! p_vout->b_fullscreen;\r
-\r
- /* We need to switch between Maximized and Normal sized window */\r
- window_placement.length = sizeof(WINDOWPLACEMENT);\r
- GetWindowPlacement( hwnd, &window_placement );\r
- if( p_vout->b_fullscreen )\r
- {\r
- /* Change window style, no borders and no title bar */\r
- int i_style = WS_CLIPCHILDREN | WS_VISIBLE;\r
- SetWindowLong( hwnd, GWL_STYLE, i_style );\r
-\r
- if( p_vout->p_sys->hparent )\r
- {\r
- /* Retrieve current window position so fullscreen will happen\r
- * on the right screen */\r
- POINT point = {0,0};\r
- RECT rect;\r
- ClientToScreen( p_vout->p_sys->hwnd, &point );\r
- GetClientRect( p_vout->p_sys->hwnd, &rect );\r
- SetWindowPos( hwnd, 0, point.x, point.y,\r
- rect.right, rect.bottom,\r
- SWP_NOZORDER|SWP_FRAMECHANGED );\r
- GetWindowPlacement( hwnd, &window_placement );\r
- }\r
-\r
- /* Maximize window */\r
- window_placement.showCmd = SW_SHOWMAXIMIZED;\r
- SetWindowPlacement( hwnd, &window_placement );\r
- SetWindowPos( hwnd, 0, 0, 0, 0, 0,\r
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);\r
-\r
- if( p_vout->p_sys->hparent )\r
- {\r
- RECT rect;\r
- GetClientRect( hwnd, &rect );\r
- SetParent( p_vout->p_sys->hwnd, hwnd );\r
- SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,\r
- rect.right, rect.bottom,\r
- SWP_NOZORDER|SWP_FRAMECHANGED );\r
- }\r
-\r
- SetForegroundWindow( hwnd );\r
- }\r
- else\r
- {\r
- /* Change window style, no borders and no title bar */\r
- SetWindowLong( hwnd, GWL_STYLE, p_vout->p_sys->i_window_style );\r
-\r
- /* Normal window */\r
- window_placement.showCmd = SW_SHOWNORMAL;\r
- SetWindowPlacement( hwnd, &window_placement );\r
- SetWindowPos( hwnd, 0, 0, 0, 0, 0,\r
- SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);\r
-\r
- if( p_vout->p_sys->hparent )\r
- {\r
- RECT rect;\r
- GetClientRect( p_vout->p_sys->hparent, &rect );\r
- SetParent( p_vout->p_sys->hwnd, p_vout->p_sys->hparent );\r
- SetWindowPos( p_vout->p_sys->hwnd, 0, 0, 0,\r
- rect.right, rect.bottom,\r
- SWP_NOZORDER|SWP_FRAMECHANGED );\r
-\r
- ShowWindow( hwnd, SW_HIDE );\r
- SetForegroundWindow( p_vout->p_sys->hparent );\r
- }\r
-\r
- /* Make sure the mouse cursor is displayed */\r
- PostMessage( p_vout->p_sys->hwnd, WM_VLC_SHOW_MOUSE, 0, 0 );\r
- }\r
-\r
- /* Update the object variable and trigger callback */\r
- val.b_bool = p_vout->b_fullscreen;\r
- var_Set( p_vout, "fullscreen", val );\r
-\r
- p_vout->i_changes &= ~VOUT_FULLSCREEN_CHANGE;\r
- p_vout->p_sys->i_changes &= ~VOUT_FULLSCREEN_CHANGE;\r
- }\r
-\r
- /*\r
- * Pointer change\r
- */\r
- if( p_vout->b_fullscreen && !p_vout->p_sys->b_cursor_hidden &&\r
- (mdate() - p_vout->p_sys->i_lastmoved) > 5000000 )\r
- {\r
- POINT point;\r
- HWND hwnd;\r
-\r
- /* Hide the cursor only if it is inside our window */\r
- GetCursorPos( &point );\r
- hwnd = WindowFromPoint(point);\r
- if( hwnd == p_vout->p_sys->hwnd || hwnd == p_vout->p_sys->hvideownd )\r
- {\r
- PostMessage( p_vout->p_sys->hwnd, WM_VLC_HIDE_MOUSE, 0, 0 );\r
- }\r
- else\r
- {\r
- p_vout->p_sys->i_lastmoved = mdate();\r
- }\r
- }\r
-\r
- /*\r
- * "Always on top" status change\r
- */\r
- if( p_vout->p_sys->b_on_top_change )\r
- {\r
- vlc_value_t val;\r
- HMENU hMenu = GetSystemMenu( p_vout->p_sys->hwnd, FALSE );\r
-\r
- var_Get( p_vout, "video-on-top", &val );\r
-\r
- /* Set the window on top if necessary */\r
- if( val.b_bool && !( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )\r
- & WS_EX_TOPMOST ) )\r
- {\r
- CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,\r
- MF_BYCOMMAND | MFS_CHECKED );\r
- SetWindowPos( p_vout->p_sys->hwnd, HWND_TOPMOST, 0, 0, 0, 0,\r
- SWP_NOSIZE | SWP_NOMOVE );\r
- }\r
- else\r
- /* The window shouldn't be on top */\r
- if( !val.b_bool && ( GetWindowLong( p_vout->p_sys->hwnd, GWL_EXSTYLE )\r
- & WS_EX_TOPMOST ) )\r
- {\r
- CheckMenuItem( hMenu, IDM_TOGGLE_ON_TOP,\r
- MF_BYCOMMAND | MFS_UNCHECKED );\r
- SetWindowPos( p_vout->p_sys->hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,\r
- SWP_NOSIZE | SWP_NOMOVE );\r
- }\r
-\r
- p_vout->p_sys->b_on_top_change = VLC_FALSE;\r
- }\r
-\r
- /* Check if the event thread is still running */\r
- if( p_vout->p_sys->p_event->b_die )\r
- {\r
- return VLC_EGENERIC; /* exit */\r
- }\r
-\r
- return VLC_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************\r
- * GLSwapBuffers: swap front/back buffers\r
- *****************************************************************************/\r
-static void GLSwapBuffers( vout_thread_t *p_vout )\r
-{\r
- SwapBuffers( p_vout->p_sys->hGLDC );\r
-}\r
-\r
-int E_(DirectXUpdateOverlay)( vout_thread_t *p_vout )\r
-{\r
- return 1;\r
-}\r
+/*****************************************************************************
+ * glwin32.c: Windows OpenGL provider
+ *****************************************************************************
+ * Copyright (C) 2001-2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin@videolan.org>
+ *
+ * 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 <errno.h> /* ENOMEM */
+#include <stdlib.h> /* free() */
+#include <string.h> /* strerror() */
+
+#include <vlc/vlc.h>
+#include <vlc/intf.h>
+#include <vlc/vout.h>
+
+#include <windows.h>
+#include <ddraw.h>
+#include <commctrl.h>
+
+#include <multimon.h>
+#undef GetSystemMetrics
+
+#ifndef MONITOR_DEFAULTTONEAREST
+# define MONITOR_DEFAULTTONEAREST 2
+#endif
+
+#include <GL/gl.h>
+
+#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;
+}
* 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 <gerald.hansink@ordain.nl>
* Jean-Paul Saman <jpsaman@wxs.nl>
* 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 <sam@zoy.org>
*
-#ifndef __NEWRES_H__\r
-#define __NEWRES_H__\r
-\r
-#if !defined(UNDER_CE)\r
- #define UNDER_CE _WIN32_WCE\r
-#endif\r
-\r
-#if defined(_WIN32_WCE)\r
- #if !defined(WCEOLE_ENABLE_DIALOGEX)\r
- #define DIALOGEX DIALOG DISCARDABLE\r
- #endif\r
- #include <commctrl.h>\r
- #define SHMENUBAR RCDATA\r
- #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300)\r
- #include <aygshell.h> \r
- #else\r
- #define I_IMAGENONE (-2)\r
- #define NOMENU 0xFFFF\r
- #define IDS_SHNEW 1\r
-\r
- #define IDM_SHAREDNEW 10\r
- #define IDM_SHAREDNEWDEFAULT 11\r
- #endif\r
-#endif // _WIN32_WCE\r
-\r
-\r
-#ifdef RC_INVOKED\r
-#ifndef _INC_WINDOWS\r
-#define _INC_WINDOWS\r
- #include "winuser.h" // extract from windows header\r
-#endif\r
-#endif\r
-\r
-#ifdef IDC_STATIC\r
-#undef IDC_STATIC\r
-#endif\r
-#define IDC_STATIC (-1)\r
-\r
-#endif //__NEWRES_H__\r
+#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 <commctrl.h>
+ #define SHMENUBAR RCDATA
+ #if defined(WIN32_PLATFORM_PSPC) && (_WIN32_WCE >= 300)
+ #include <aygshell.h>
+ #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__
-//{{NO_DEPENDENCIES}}\r
-// Microsoft Developer Studio generated include file.\r
-// Used by vlc_wince_rc.rc\r
-//\r
-#define IDS_APP_TITLE 1\r
-#define IDS_HELLO 2\r
-#define IDC_NIOUP 3\r
-#define IDI_NIOUP 101\r
-#define IDM_MENU 102\r
-#define IDD_ABOUTBOX 103\r
-#define IDM_FILE_EXIT 40002\r
-#define IDM_HELP_ABOUT 40003\r
-#define IDM_PLOP 40004\r
-#define ID_VIEW_PLAYLIST 40005\r
-#define ID_VIEW_MESSAGES 40006\r
-#define ID_SETTINGS_AUDIO 40007\r
-#define ID_SETTINGS_SUBTITLES 40008\r
-#define ID_SETTINGS 40011\r
-#define ID_FILE_OPENFILE 40012\r
-#define ID_FILE_NETWORKSTREAM 40013\r
-\r
-// Next default values for new objects\r
-// \r
-#ifdef APSTUDIO_INVOKED\r
-#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE 104\r
-#define _APS_NEXT_COMMAND_VALUE 40014\r
-#define _APS_NEXT_CONTROL_VALUE 1001\r
-#define _APS_NEXT_SYMED_VALUE 101\r
-#endif\r
-#endif\r
+//{{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
-/*****************************************************************************\r
- * es_out.c: Es Out handler for input.\r
- *****************************************************************************\r
- * Copyright (C) 2003-2004 VideoLAN\r
- * $Id$\r
- *\r
- * Authors: Laurent Aimar <fenrir@via.ecp.fr>\r
- *\r
- * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 2 of the License, or\r
- * (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.\r
- *****************************************************************************/\r
-\r
-/*****************************************************************************\r
- * Preamble\r
- *****************************************************************************/\r
-#include <stdlib.h>\r
-\r
-#include <vlc/vlc.h>\r
-#include <vlc/input.h>\r
-#include <vlc/decoder.h>\r
-\r
-#include "input_internal.h"\r
-\r
-#include "vlc_playlist.h"\r
-#include "iso_lang.h"\r
-/* FIXME we should find a better way than including that */\r
-#include "../misc/iso-639_def.h"\r
-\r
-/*****************************************************************************\r
- * Local prototypes\r
- *****************************************************************************/\r
-typedef struct\r
-{\r
- /* Program ID */\r
- int i_id;\r
-\r
- /* Number of es for this pgrm */\r
- int i_es;\r
-\r
- vlc_bool_t b_selected;\r
-\r
- /* Clock for this program */\r
- input_clock_t clock;\r
-\r
-} es_out_pgrm_t;\r
-\r
-struct es_out_id_t\r
-{\r
- /* ES ID */\r
- int i_id;\r
- es_out_pgrm_t *p_pgrm;\r
-\r
- /* */\r
- int64_t i_preroll_end;\r
-\r
- /* Channel in the track type */\r
- int i_channel;\r
- es_format_t fmt;\r
- char *psz_language;\r
- char *psz_language_code;\r
- decoder_t *p_dec;\r
-};\r
-\r
-struct es_out_sys_t\r
-{\r
- input_thread_t *p_input;\r
-\r
- /* all programs */\r
- int i_pgrm;\r
- es_out_pgrm_t **pgrm;\r
- es_out_pgrm_t **pp_selected_pgrm; /* --programs */\r
- es_out_pgrm_t *p_pgrm; /* Master program */\r
-\r
- /* all es */\r
- int i_id;\r
- int i_es;\r
- es_out_id_t **es;\r
-\r
- /* mode gestion */\r
- vlc_bool_t b_active;\r
- int i_mode;\r
-\r
- /* es count */\r
- int i_audio;\r
- int i_video;\r
- int i_sub;\r
-\r
- /* es to select */\r
- int i_audio_last;\r
- int i_sub_last;\r
- char **ppsz_audio_language;\r
- char **ppsz_sub_language;\r
-\r
- /* current main es */\r
- es_out_id_t *p_es_audio;\r
- es_out_id_t *p_es_video;\r
- es_out_id_t *p_es_sub;\r
-\r
- /* delay */\r
- int64_t i_audio_delay;\r
- int64_t i_spu_delay;\r
-};\r
-\r
-static es_out_id_t *EsOutAdd ( es_out_t *, es_format_t * );\r
-static int EsOutSend ( es_out_t *, es_out_id_t *, block_t * );\r
-static void EsOutDel ( es_out_t *, es_out_id_t * );\r
-static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force );\r
-static int EsOutControl( es_out_t *, int i_query, va_list );\r
-\r
-static void EsOutAddInfo( es_out_t *, es_out_id_t *es );\r
-\r
-static void EsSelect( es_out_t *out, es_out_id_t *es );\r
-static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update );\r
-static char *LanguageGetName( const char *psz_code );\r
-static char *LanguageGetCode( const char *psz_lang );\r
-static char **LanguageSplit( const char *psz_langs );\r
-static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang );\r
-\r
-/*****************************************************************************\r
- * input_EsOutNew:\r
- *****************************************************************************/\r
-es_out_t *input_EsOutNew( input_thread_t *p_input )\r
-{\r
- es_out_t *out = malloc( sizeof( es_out_t ) );\r
- es_out_sys_t *p_sys = malloc( sizeof( es_out_sys_t ) );\r
- vlc_value_t val;\r
- int i;\r
-\r
- out->pf_add = EsOutAdd;\r
- out->pf_send = EsOutSend;\r
- out->pf_del = EsOutDel;\r
- out->pf_control = EsOutControl;\r
- out->p_sys = p_sys;\r
-\r
- p_sys->p_input = p_input;\r
-\r
- p_sys->b_active = VLC_FALSE;\r
- p_sys->i_mode = ES_OUT_MODE_AUTO;\r
-\r
-\r
- p_sys->i_pgrm = 0;\r
- p_sys->pgrm = NULL;\r
- p_sys->p_pgrm = NULL;\r
-\r
- p_sys->i_id = 0;\r
- p_sys->i_es = 0;\r
- p_sys->es = NULL;\r
-\r
- p_sys->i_audio = 0;\r
- p_sys->i_video = 0;\r
- p_sys->i_sub = 0;\r
-\r
- /* */\r
- var_Get( p_input, "audio-track", &val );\r
- p_sys->i_audio_last = val.i_int;\r
-\r
- var_Get( p_input, "sub-track", &val );\r
- p_sys->i_sub_last = val.i_int;\r
-\r
- var_Get( p_input, "audio-language", &val );\r
- p_sys->ppsz_audio_language = LanguageSplit(val.psz_string);\r
- if( p_sys->ppsz_audio_language )\r
- {\r
- for( i = 0; p_sys->ppsz_audio_language[i]; i++ )\r
- msg_Dbg( p_input, "Select audio in language[%d] %s",\r
- i, p_sys->ppsz_audio_language[i] );\r
- }\r
-\r
- var_Get( p_input, "sub-language", &val );\r
- p_sys->ppsz_sub_language = LanguageSplit(val.psz_string);\r
- if( p_sys->ppsz_sub_language )\r
- {\r
- for( i = 0; p_sys->ppsz_sub_language[i]; i++ )\r
- msg_Dbg( p_input, "Select subtitle in language[%d] %s",\r
- i, p_sys->ppsz_sub_language[i] );\r
- }\r
-\r
- /* */\r
- p_sys->p_es_audio = NULL;\r
- p_sys->p_es_video = NULL;\r
- p_sys->p_es_sub = NULL;\r
-\r
- p_sys->i_audio_delay= 0;\r
- p_sys->i_spu_delay = 0;\r
-\r
- return out;\r
-}\r
-\r
-/*****************************************************************************\r
- * input_EsOutDelete:\r
- *****************************************************************************/\r
-void input_EsOutDelete( es_out_t *out )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- int i;\r
-\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec )\r
- {\r
- input_DecoderDelete( p_sys->es[i]->p_dec );\r
- }\r
- if( p_sys->es[i]->psz_language )\r
- free( p_sys->es[i]->psz_language );\r
- if( p_sys->es[i]->psz_language_code )\r
- free( p_sys->es[i]->psz_language_code );\r
- es_format_Clean( &p_sys->es[i]->fmt );\r
-\r
- free( p_sys->es[i] );\r
- }\r
- if( p_sys->ppsz_audio_language )\r
- {\r
- for( i = 0; p_sys->ppsz_audio_language[i]; i++ )\r
- free( p_sys->ppsz_audio_language[i] );\r
- free( p_sys->ppsz_audio_language );\r
- }\r
- if( p_sys->ppsz_sub_language )\r
- {\r
- for( i = 0; p_sys->ppsz_sub_language[i]; i++ )\r
- free( p_sys->ppsz_sub_language[i] );\r
- free( p_sys->ppsz_sub_language );\r
- }\r
-\r
- if( p_sys->es )\r
- free( p_sys->es );\r
-\r
- for( i = 0; i < p_sys->i_pgrm; i++ )\r
- {\r
- free( p_sys->pgrm[i] );\r
- }\r
- if( p_sys->pgrm )\r
- free( p_sys->pgrm );\r
-\r
- free( p_sys );\r
- free( out );\r
-}\r
-\r
-es_out_id_t *input_EsOutGetFromID( es_out_t *out, int i_id )\r
-{\r
- int i;\r
- if( i_id < 0 )\r
- {\r
- /* Special HACK, -i_id is tha cat of the stream */\r
- return (es_out_id_t*)((uint8_t*)NULL-i_id);\r
- }\r
-\r
- for( i = 0; i < out->p_sys->i_es; i++ )\r
- {\r
- if( out->p_sys->es[i]->i_id == i_id )\r
- return out->p_sys->es[i];\r
- }\r
- return NULL;\r
-}\r
-\r
-void input_EsOutDiscontinuity( es_out_t *out, vlc_bool_t b_audio )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- int i;\r
-\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- es_out_id_t *es = p_sys->es[i];\r
-\r
- /* Send a dummy block to let decoder know that\r
- * there is a discontinuity */\r
- if( es->p_dec && ( !b_audio || es->fmt.i_cat == AUDIO_ES ) )\r
- {\r
- input_DecoderDiscontinuity( es->p_dec );\r
- }\r
- }\r
-}\r
-\r
-void input_EsOutSetDelay( es_out_t *out, int i_cat, int64_t i_delay )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
-\r
- if( i_cat == AUDIO_ES )\r
- p_sys->i_audio_delay = i_delay;\r
- else if( i_cat == SPU_ES )\r
- p_sys->i_spu_delay = i_delay;\r
-}\r
-\r
-vlc_bool_t input_EsOutDecodersEmpty( es_out_t *out )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- int i;\r
-\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- es_out_id_t *es = p_sys->es[i];\r
-\r
- if( es->p_dec && !input_DecoderEmpty( es->p_dec ) )\r
- return VLC_FALSE;\r
- }\r
- return VLC_TRUE;\r
-}\r
-\r
-/*****************************************************************************\r
- *\r
- *****************************************************************************/\r
-static void EsOutESVarUpdate( es_out_t *out, es_out_id_t *es,\r
- vlc_bool_t b_delete )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- vlc_value_t val, text;\r
-\r
- char *psz_var;\r
-\r
- if( es->fmt.i_cat == AUDIO_ES )\r
- psz_var = "audio-es";\r
- else if( es->fmt.i_cat == VIDEO_ES )\r
- psz_var = "video-es";\r
- else if( es->fmt.i_cat == SPU_ES )\r
- psz_var = "spu-es";\r
- else\r
- return;\r
-\r
- if( b_delete )\r
- {\r
- val.i_int = es->i_id;\r
- var_Change( p_input, psz_var, VLC_VAR_DELCHOICE, &val, NULL );\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
- return;\r
- }\r
-\r
- /* Get the number of ES already added */\r
- var_Change( p_input, psz_var, VLC_VAR_CHOICESCOUNT, &val, NULL );\r
- if( val.i_int == 0 )\r
- {\r
- vlc_value_t val2;\r
-\r
- /* First one, we need to add the "Disable" choice */\r
- val2.i_int = -1; text.psz_string = _("Disable");\r
- var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val2, &text );\r
- val.i_int++;\r
- }\r
-\r
- /* Take care of the ES description */\r
- if( es->fmt.psz_description && *es->fmt.psz_description )\r
- {\r
- if( es->psz_language && *es->psz_language )\r
- {\r
- text.psz_string = malloc( strlen( es->fmt.psz_description) + strlen( es->psz_language ) + 10 );\r
- sprintf( text.psz_string, "%s - [%s]", es->fmt.psz_description, es->psz_language );\r
- }\r
- else text.psz_string = strdup( es->fmt.psz_description );\r
- }\r
- else\r
- {\r
- if( es->psz_language && *es->psz_language )\r
- {\r
- char *temp;\r
- text.psz_string = malloc( strlen( _("Track %i") )+ strlen( es->psz_language ) + 30 );\r
- asprintf( &temp, _("Track %i"), val.i_int );\r
- sprintf( text.psz_string, "%s - [%s]", temp, es->psz_language );\r
- free( temp );\r
- }\r
- else\r
- {\r
- text.psz_string = malloc( strlen( _("Track %i") ) + 20 );\r
- sprintf( text.psz_string, _("Track %i"), val.i_int );\r
- }\r
- }\r
-\r
- val.i_int = es->i_id;\r
- var_Change( p_input, psz_var, VLC_VAR_ADDCHOICE, &val, &text );\r
-\r
- free( text.psz_string );\r
-\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
-}\r
-\r
-/* EsOutProgramSelect:\r
- * Select a program and update the object variable\r
- */\r
-static void EsOutProgramSelect( es_out_t *out, es_out_pgrm_t *p_pgrm )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- vlc_value_t val;\r
- int i;\r
-\r
- if( p_sys->p_pgrm == p_pgrm )\r
- return; /* Nothing to do */\r
-\r
- if( p_sys->p_pgrm )\r
- {\r
- es_out_pgrm_t *old = p_sys->p_pgrm;\r
- msg_Dbg( p_input, "Unselecting program id=%d", old->i_id );\r
-\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_pgrm == old && p_sys->es[i]->p_dec &&\r
- p_sys->i_mode != ES_OUT_MODE_ALL )\r
- EsUnselect( out, p_sys->es[i], VLC_TRUE );\r
- }\r
-\r
- p_sys->p_es_audio = NULL;\r
- p_sys->p_es_sub = NULL;\r
- p_sys->p_es_video = NULL;\r
- }\r
-\r
- msg_Dbg( p_input, "Selecting program id=%d", p_pgrm->i_id );\r
-\r
- /* Mark it selected */\r
- p_pgrm->b_selected = VLC_TRUE;\r
-\r
- /* Switch master stream */\r
- if( p_sys->p_pgrm && p_sys->p_pgrm->clock.b_master )\r
- {\r
- p_sys->p_pgrm->clock.b_master = VLC_FALSE;\r
- }\r
- p_pgrm->clock.b_master = VLC_TRUE;\r
- p_sys->p_pgrm = p_pgrm;\r
-\r
- /* Update "program" */\r
- val.i_int = p_pgrm->i_id;\r
- var_Change( p_input, "program", VLC_VAR_SETVALUE, &val, NULL );\r
-\r
- /* Update "es-*" */\r
- var_Change( p_input, "audio-es", VLC_VAR_CLEARCHOICES, NULL, NULL );\r
- var_Change( p_input, "video-es", VLC_VAR_CLEARCHOICES, NULL, NULL );\r
- var_Change( p_input, "spu-es", VLC_VAR_CLEARCHOICES, NULL, NULL );\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_pgrm == p_sys->p_pgrm )\r
- EsOutESVarUpdate( out, p_sys->es[i], VLC_FALSE );\r
- EsOutSelect( out, p_sys->es[i], VLC_FALSE );\r
- }\r
-\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
-}\r
-\r
-/* EsOutAddProgram:\r
- * Add a program\r
- */\r
-static es_out_pgrm_t *EsOutProgramAdd( es_out_t *out, int i_group )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- vlc_value_t val;\r
-\r
- es_out_pgrm_t *p_pgrm = malloc( sizeof( es_out_pgrm_t ) );\r
-\r
- /* Init */\r
- p_pgrm->i_id = i_group;\r
- p_pgrm->i_es = 0;\r
- p_pgrm->b_selected = VLC_FALSE;\r
- input_ClockInit( &p_pgrm->clock, VLC_FALSE, p_input->input.i_cr_average );\r
-\r
- /* Append it */\r
- TAB_APPEND( p_sys->i_pgrm, p_sys->pgrm, p_pgrm );\r
-\r
- /* Update "program" variable */\r
- val.i_int = i_group;\r
- var_Change( p_input, "program", VLC_VAR_ADDCHOICE, &val, NULL );\r
-\r
- if( i_group == var_GetInteger( p_input, "program" ) )\r
- {\r
- EsOutProgramSelect( out, p_pgrm );\r
- }\r
- else\r
- {\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
- }\r
- return p_pgrm;\r
-}\r
-\r
-/* EsOutAdd:\r
- * Add an es_out\r
- */\r
-static es_out_id_t *EsOutAdd( es_out_t *out, es_format_t *fmt )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
-\r
- es_out_id_t *es = malloc( sizeof( es_out_id_t ) );\r
- es_out_pgrm_t *p_pgrm = NULL;\r
- int i;\r
-\r
- if( fmt->i_group < 0 )\r
- {\r
- msg_Err( p_input, "invalid group number" );\r
- return NULL;\r
- }\r
-\r
- /* Search the program */\r
- for( i = 0; i < p_sys->i_pgrm; i++ )\r
- {\r
- if( fmt->i_group == p_sys->pgrm[i]->i_id )\r
- {\r
- p_pgrm = p_sys->pgrm[i];\r
- break;\r
- }\r
- }\r
- if( p_pgrm == NULL )\r
- {\r
- /* Create a new one */\r
- p_pgrm = EsOutProgramAdd( out, fmt->i_group );\r
- }\r
-\r
- /* Increase ref count for program */\r
- p_pgrm->i_es++;\r
-\r
- /* Set up ES */\r
- if( fmt->i_id < 0 )\r
- fmt->i_id = out->p_sys->i_id;\r
- es->i_id = fmt->i_id;\r
- es->p_pgrm = p_pgrm;\r
- es_format_Copy( &es->fmt, fmt );\r
- es->i_preroll_end = -1;\r
-\r
- switch( fmt->i_cat )\r
- {\r
- case AUDIO_ES:\r
- es->i_channel = p_sys->i_audio;\r
- break;\r
-\r
- case VIDEO_ES:\r
- es->i_channel = p_sys->i_video;\r
- break;\r
-\r
- case SPU_ES:\r
- es->i_channel = p_sys->i_sub;\r
- break;\r
-\r
- default:\r
- es->i_channel = 0;\r
- break;\r
- }\r
- es->psz_language = LanguageGetName( fmt->psz_language ); /* remember so we only need to do it once */\r
- es->psz_language_code = LanguageGetCode( fmt->psz_language );\r
- es->p_dec = NULL;\r
-\r
- if( es->p_pgrm == p_sys->p_pgrm )\r
- EsOutESVarUpdate( out, es, VLC_FALSE );\r
-\r
- /* Select it if needed */\r
- EsOutSelect( out, es, VLC_FALSE );\r
-\r
-\r
- TAB_APPEND( out->p_sys->i_es, out->p_sys->es, es );\r
- p_sys->i_id++; /* always incremented */\r
- switch( fmt->i_cat )\r
- {\r
- case AUDIO_ES:\r
- p_sys->i_audio++;\r
- break;\r
- case SPU_ES:\r
- p_sys->i_sub++;\r
- break;\r
- case VIDEO_ES:\r
- p_sys->i_video++;\r
- break;\r
- }\r
-\r
- EsOutAddInfo( out, es );\r
-\r
- return es;\r
-}\r
-\r
-static void EsSelect( es_out_t *out, es_out_id_t *es )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- vlc_value_t val;\r
- char *psz_var;\r
-\r
- if( es->p_dec )\r
- {\r
- msg_Warn( p_input, "ES 0x%x is already selected", es->i_id );\r
- return;\r
- }\r
-\r
- if( es->fmt.i_cat == VIDEO_ES || es->fmt.i_cat == SPU_ES )\r
- {\r
- if( !var_GetBool( p_input, "video" ) ||\r
- ( p_input->p_sout && !var_GetBool( p_input, "sout-video" ) ) )\r
- {\r
- msg_Dbg( p_input, "video is disabled, not selecting ES 0x%x",\r
- es->i_id );\r
- return;\r
- }\r
- }\r
- else if( es->fmt.i_cat == AUDIO_ES )\r
- {\r
- var_Get( p_input, "audio", &val );\r
- if( !var_GetBool( p_input, "audio" ) ||\r
- ( p_input->p_sout && !var_GetBool( p_input, "sout-audio" ) ) )\r
- {\r
- msg_Dbg( p_input, "audio is disabled, not selecting ES 0x%x",\r
- es->i_id );\r
- return;\r
- }\r
- }\r
-\r
- es->i_preroll_end = -1;\r
- es->p_dec = input_DecoderNew( p_input, &es->fmt, VLC_FALSE );\r
- if( es->p_dec == NULL || es->p_pgrm != p_sys->p_pgrm )\r
- return;\r
-\r
- if( es->fmt.i_cat == VIDEO_ES )\r
- psz_var = "video-es";\r
- else if( es->fmt.i_cat == AUDIO_ES )\r
- psz_var = "audio-es";\r
- else if( es->fmt.i_cat == SPU_ES )\r
- psz_var = "spu-es";\r
- else\r
- return;\r
-\r
- /* Mark it as selected */\r
- val.i_int = es->i_id;\r
- var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );\r
-\r
-\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
-}\r
-\r
-static void EsUnselect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_update )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- vlc_value_t val;\r
- char *psz_var;\r
-\r
- if( es->p_dec == NULL )\r
- {\r
- msg_Warn( p_input, "ES 0x%x is already unselected", es->i_id );\r
- return;\r
- }\r
-\r
- input_DecoderDelete( es->p_dec );\r
- es->p_dec = NULL;\r
-\r
- if( !b_update )\r
- return;\r
-\r
- /* Update var */\r
- if( es->p_dec == NULL )\r
- return;\r
- if( es->fmt.i_cat == VIDEO_ES )\r
- psz_var = "video-es";\r
- else if( es->fmt.i_cat == AUDIO_ES )\r
- psz_var = "audio-es";\r
- else if( es->fmt.i_cat == SPU_ES )\r
- psz_var = "spu-es";\r
- else\r
- return;\r
-\r
- /* Mark it as selected */\r
- val.i_int = -1;\r
- var_Change( p_input, psz_var, VLC_VAR_SETVALUE, &val, NULL );\r
-\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
-}\r
-\r
-/**\r
- * Select an ES given the current mode\r
- * XXX: you need to take a the lock before (stream.stream_lock)\r
- *\r
- * \param out The es_out structure\r
- * \param es es_out_id structure\r
- * \param b_force ...\r
- * \return nothing\r
- */\r
-static void EsOutSelect( es_out_t *out, es_out_id_t *es, vlc_bool_t b_force )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
-\r
- int i_cat = es->fmt.i_cat;\r
-\r
- if( !p_sys->b_active ||\r
- ( !b_force && es->fmt.i_priority < 0 ) )\r
- {\r
- return;\r
- }\r
-\r
- if( p_sys->i_mode == ES_OUT_MODE_ALL || b_force )\r
- {\r
- if( !es->p_dec )\r
- EsSelect( out, es );\r
- }\r
- else if( p_sys->i_mode == ES_OUT_MODE_PARTIAL )\r
- {\r
- vlc_value_t val;\r
- int i;\r
- var_Get( p_sys->p_input, "programs", &val );\r
- for ( i = 0; i < val.p_list->i_count; i++ )\r
- {\r
- if ( val.p_list->p_values[i].i_int == es->p_pgrm->i_id || b_force )\r
- {\r
- if( !es->p_dec )\r
- EsSelect( out, es );\r
- break;\r
- }\r
- }\r
- var_Change( p_sys->p_input, "programs", VLC_VAR_FREELIST, &val, NULL );\r
- }\r
- else if( p_sys->i_mode == ES_OUT_MODE_AUTO )\r
- {\r
- int i_wanted = -1;\r
-\r
- if( es->p_pgrm != p_sys->p_pgrm )\r
- return;\r
-\r
- if( i_cat == AUDIO_ES )\r
- {\r
- int idx1 = LanguageArrayIndex( p_sys->ppsz_audio_language,\r
- es->psz_language_code );\r
-\r
- if( p_sys->p_es_audio &&\r
- p_sys->p_es_audio->fmt.i_priority >= es->fmt.i_priority )\r
- {\r
- int idx2 = LanguageArrayIndex( p_sys->ppsz_audio_language,\r
- p_sys->p_es_audio->psz_language_code );\r
-\r
- if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )\r
- return;\r
- i_wanted = es->i_channel;\r
- }\r
- else\r
- {\r
- /* Select audio if (no audio selected yet)\r
- * - no audio-language\r
- * - no audio code for the ES\r
- * - audio code in the requested list */\r
- if( idx1 >= 0 ||\r
- !strcmp( es->psz_language_code, "??" ) ||\r
- !p_sys->ppsz_audio_language )\r
- i_wanted = es->i_channel;\r
- }\r
-\r
- if( p_sys->i_audio_last >= 0 )\r
- i_wanted = p_sys->i_audio_last;\r
- }\r
- else if( i_cat == SPU_ES )\r
- {\r
- int idx1 = LanguageArrayIndex( p_sys->ppsz_sub_language,\r
- es->psz_language_code );\r
-\r
- if( p_sys->p_es_sub &&\r
- p_sys->p_es_sub->fmt.i_priority >= es->fmt.i_priority )\r
- {\r
- int idx2 = LanguageArrayIndex( p_sys->ppsz_sub_language,\r
- p_sys->p_es_sub->psz_language_code );\r
-\r
- msg_Dbg( p_sys->p_input, "idx1=%d(%s) idx2=%d(%s)",\r
- idx1, es->psz_language_code, idx2,\r
- p_sys->p_es_sub->psz_language_code );\r
-\r
- if( idx1 < 0 || ( idx2 >= 0 && idx2 <= idx1 ) )\r
- return;\r
- /* We found a SPU that matches our language request */\r
- i_wanted = es->i_channel;\r
- }\r
- else if( idx1 >= 0 )\r
- {\r
- msg_Dbg( p_sys->p_input, "idx1=%d(%s)",\r
- idx1, es->psz_language_code );\r
-\r
- i_wanted = es->i_channel;\r
- }\r
- if( p_sys->i_sub_last >= 0 )\r
- i_wanted = p_sys->i_sub_last;\r
- }\r
- else if( i_cat == VIDEO_ES )\r
- {\r
- i_wanted = es->i_channel;\r
- }\r
-\r
- if( i_wanted == es->i_channel && es->p_dec == NULL )\r
- EsSelect( out, es );\r
- }\r
-\r
- /* FIXME TODO handle priority here */\r
- if( es->p_dec )\r
- {\r
- if( i_cat == AUDIO_ES )\r
- {\r
- if( p_sys->i_mode == ES_OUT_MODE_AUTO &&\r
- p_sys->p_es_audio &&\r
- p_sys->p_es_audio != es &&\r
- p_sys->p_es_audio->p_dec )\r
- {\r
- EsUnselect( out, p_sys->p_es_audio, VLC_FALSE );\r
- }\r
- p_sys->p_es_audio = es;\r
- }\r
- else if( i_cat == SPU_ES )\r
- {\r
- if( p_sys->i_mode == ES_OUT_MODE_AUTO &&\r
- p_sys->p_es_sub &&\r
- p_sys->p_es_sub != es &&\r
- p_sys->p_es_sub->p_dec )\r
- {\r
- EsUnselect( out, p_sys->p_es_sub, VLC_FALSE );\r
- }\r
- p_sys->p_es_sub = es;\r
- }\r
- else if( i_cat == VIDEO_ES )\r
- {\r
- p_sys->p_es_video = es;\r
- }\r
- }\r
-}\r
-\r
-/**\r
- * Send a block for the given es_out\r
- *\r
- * \param out the es_out to send from\r
- * \param es the es_out_id\r
- * \param p_block the data block to send\r
- */\r
-static int EsOutSend( es_out_t *out, es_out_id_t *es, block_t *p_block )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- es_out_pgrm_t *p_pgrm = es->p_pgrm;\r
- int64_t i_delay;\r
-\r
- if( es->fmt.i_cat == AUDIO_ES )\r
- i_delay = p_sys->i_audio_delay;\r
- else if( es->fmt.i_cat == SPU_ES )\r
- i_delay = p_sys->i_spu_delay;\r
- else\r
- i_delay = 0;\r
-\r
- /* Mark preroll blocks */\r
- if( es->i_preroll_end >= 0 )\r
- {\r
- int64_t i_date = p_block->i_pts;\r
- if( i_date <= 0 )\r
- i_date = p_block->i_dts;\r
-\r
- if( i_date < es->i_preroll_end )\r
- p_block->i_flags |= BLOCK_FLAG_PREROLL;\r
- else\r
- es->i_preroll_end = -1;\r
- }\r
-\r
- /* +11 -> avoid null value with non null dts/pts */\r
- if( p_block->i_dts > 0 )\r
- {\r
- p_block->i_dts =\r
- input_ClockGetTS( p_input, &p_pgrm->clock,\r
- ( p_block->i_dts + 11 ) * 9 / 100 ) + i_delay;\r
- }\r
- if( p_block->i_pts > 0 )\r
- {\r
- p_block->i_pts =\r
- input_ClockGetTS( p_input, &p_pgrm->clock,\r
- ( p_block->i_pts + 11 ) * 9 / 100 ) + i_delay;\r
- }\r
- if ( es->fmt.i_codec == VLC_FOURCC( 't', 'e', 'l', 'x' ) )\r
- {\r
- mtime_t current_date = mdate();\r
- if( !p_block->i_pts\r
- || p_block->i_pts > current_date + 10000000\r
- || current_date > p_block->i_pts )\r
- {\r
- /* ETSI EN 300 472 Annex A : do not take into account the PTS\r
- * for teletext streams. */\r
- p_block->i_pts = current_date + 400000\r
- + p_input->i_pts_delay + i_delay;\r
- }\r
- }\r
-\r
- p_block->i_rate = p_input->i_rate;\r
-\r
- /* TODO handle mute */\r
- if( es->p_dec && ( es->fmt.i_cat != AUDIO_ES ||\r
- p_input->i_rate == INPUT_RATE_DEFAULT ) )\r
- {\r
- input_DecoderDecode( es->p_dec, p_block );\r
- }\r
- else\r
- {\r
- block_Release( p_block );\r
- }\r
-\r
- return VLC_SUCCESS;\r
-}\r
-\r
-/*****************************************************************************\r
- * EsOutDel:\r
- *****************************************************************************/\r
-static void EsOutDel( es_out_t *out, es_out_id_t *es )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
-\r
- /* We don't try to reselect */\r
- if( es->p_dec )\r
- EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );\r
-\r
- if( es->p_pgrm == p_sys->p_pgrm )\r
- EsOutESVarUpdate( out, es, VLC_TRUE );\r
-\r
- TAB_REMOVE( p_sys->i_es, p_sys->es, es );\r
-\r
- es->p_pgrm->i_es--;\r
- if( es->p_pgrm->i_es == 0 )\r
- {\r
- msg_Warn( p_sys->p_input, "Program doesn't contain anymore ES, "\r
- "TODO cleaning ?" );\r
- }\r
-\r
- if( p_sys->p_es_audio == es ) p_sys->p_es_audio = NULL;\r
- if( p_sys->p_es_video == es ) p_sys->p_es_video = NULL;\r
- if( p_sys->p_es_sub == es ) p_sys->p_es_sub = NULL;\r
-\r
- switch( es->fmt.i_cat )\r
- {\r
- case AUDIO_ES:\r
- p_sys->i_audio--;\r
- break;\r
- case SPU_ES:\r
- p_sys->i_sub--;\r
- break;\r
- case VIDEO_ES:\r
- p_sys->i_video--;\r
- break;\r
- }\r
-\r
- if( es->psz_language )\r
- free( es->psz_language );\r
- if( es->psz_language_code )\r
- free( es->psz_language_code );\r
-\r
- es_format_Clean( &es->fmt );\r
-\r
- free( es );\r
-}\r
-\r
-/**\r
- * Control query handler\r
- *\r
- * \param out the es_out to control\r
- * \param i_query A es_out query as defined in include/ninput.h\r
- * \param args a variable list of arguments for the query\r
- * \return VLC_SUCCESS or an error code\r
- */\r
-static int EsOutControl( es_out_t *out, int i_query, va_list args )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- vlc_bool_t b, *pb;\r
- int i, *pi;\r
-\r
- es_out_id_t *es;\r
-\r
- switch( i_query )\r
- {\r
- case ES_OUT_SET_ES_STATE:\r
- es = (es_out_id_t*) va_arg( args, es_out_id_t * );\r
- b = (vlc_bool_t) va_arg( args, vlc_bool_t );\r
- if( b && es->p_dec == NULL )\r
- {\r
- EsSelect( out, es );\r
- return es->p_dec ? VLC_SUCCESS : VLC_EGENERIC;\r
- }\r
- else if( !b && es->p_dec )\r
- {\r
- EsUnselect( out, es, es->p_pgrm == p_sys->p_pgrm );\r
- return VLC_SUCCESS;\r
- }\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_GET_ES_STATE:\r
- es = (es_out_id_t*) va_arg( args, es_out_id_t * );\r
- pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );\r
-\r
- *pb = es->p_dec ? VLC_TRUE : VLC_FALSE;\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_SET_ACTIVE:\r
- {\r
- b = (vlc_bool_t) va_arg( args, vlc_bool_t );\r
- p_sys->b_active = b;\r
- /* Needed ? */\r
- if( b )\r
- var_SetBool( p_sys->p_input, "intf-change", VLC_TRUE );\r
- return VLC_SUCCESS;\r
- }\r
-\r
- case ES_OUT_GET_ACTIVE:\r
- pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );\r
- *pb = p_sys->b_active;\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_SET_MODE:\r
- i = (int) va_arg( args, int );\r
- if( i == ES_OUT_MODE_NONE || i == ES_OUT_MODE_ALL ||\r
- i == ES_OUT_MODE_AUTO || i == ES_OUT_MODE_PARTIAL )\r
- {\r
- p_sys->i_mode = i;\r
-\r
- /* Reapply policy mode */\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec )\r
- {\r
- EsUnselect( out, p_sys->es[i],\r
- p_sys->es[i]->p_pgrm == p_sys->p_pgrm );\r
- }\r
- }\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- EsOutSelect( out, p_sys->es[i], VLC_FALSE );\r
- }\r
- return VLC_SUCCESS;\r
- }\r
- return VLC_EGENERIC;\r
-\r
- case ES_OUT_GET_MODE:\r
- pi = (int*) va_arg( args, int* );\r
- *pi = p_sys->i_mode;\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_SET_ES:\r
- es = (es_out_id_t*) va_arg( args, es_out_id_t * );\r
- /* Special case NULL, NULL+i_cat */\r
- if( es == NULL )\r
- {\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec )\r
- EsUnselect( out, p_sys->es[i],\r
- p_sys->es[i]->p_pgrm == p_sys->p_pgrm );\r
- }\r
- }\r
- else if( es == (es_out_id_t*)((uint8_t*)NULL+AUDIO_ES) )\r
- {\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec &&\r
- p_sys->es[i]->fmt.i_cat == AUDIO_ES )\r
- EsUnselect( out, p_sys->es[i],\r
- p_sys->es[i]->p_pgrm == p_sys->p_pgrm );\r
- }\r
- }\r
- else if( es == (es_out_id_t*)((uint8_t*)NULL+VIDEO_ES) )\r
- {\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec &&\r
- p_sys->es[i]->fmt.i_cat == VIDEO_ES )\r
- EsUnselect( out, p_sys->es[i],\r
- p_sys->es[i]->p_pgrm == p_sys->p_pgrm );\r
- }\r
- }\r
- else if( es == (es_out_id_t*)((uint8_t*)NULL+SPU_ES) )\r
- {\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( p_sys->es[i]->p_dec &&\r
- p_sys->es[i]->fmt.i_cat == SPU_ES )\r
- EsUnselect( out, p_sys->es[i],\r
- p_sys->es[i]->p_pgrm == p_sys->p_pgrm );\r
- }\r
- }\r
- else\r
- {\r
- for( i = 0; i < p_sys->i_es; i++ )\r
- {\r
- if( es == p_sys->es[i] )\r
- {\r
- EsOutSelect( out, es, VLC_TRUE );\r
- break;\r
- }\r
- }\r
- }\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_SET_PCR:\r
- case ES_OUT_SET_GROUP_PCR:\r
- {\r
- es_out_pgrm_t *p_pgrm = NULL;\r
- int i_group = 0;\r
- int64_t i_pcr;\r
-\r
- if( i_query == ES_OUT_SET_PCR )\r
- {\r
- p_pgrm = p_sys->p_pgrm;\r
- }\r
- else\r
- {\r
- int i;\r
- i_group = (int)va_arg( args, int );\r
- for( i = 0; i < p_sys->i_pgrm; i++ )\r
- {\r
- if( p_sys->pgrm[i]->i_id == i_group )\r
- {\r
- p_pgrm = p_sys->pgrm[i];\r
- break;\r
- }\r
- }\r
- }\r
- if( p_pgrm == NULL )\r
- p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */\r
-\r
- i_pcr = (int64_t)va_arg( args, int64_t );\r
- /* search program */\r
- /* 11 is a vodoo trick to avoid non_pcr*9/100 to be null */\r
- input_ClockSetPCR( p_sys->p_input, &p_pgrm->clock,\r
- (i_pcr + 11 ) * 9 / 100);\r
- return VLC_SUCCESS;\r
- }\r
-\r
- case ES_OUT_RESET_PCR:\r
- for( i = 0; i < p_sys->i_pgrm; i++ )\r
- {\r
- p_sys->pgrm[i]->clock.i_synchro_state = SYNCHRO_REINIT;\r
- p_sys->pgrm[i]->clock.last_pts = 0;\r
- }\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_GET_TS:\r
- if( p_sys->p_pgrm )\r
- {\r
- int64_t i_ts = (int64_t)va_arg( args, int64_t );\r
- int64_t *pi_ts = (int64_t *)va_arg( args, int64_t * );\r
- *pi_ts = input_ClockGetTS( p_sys->p_input,\r
- &p_sys->p_pgrm->clock,\r
- ( i_ts + 11 ) * 9 / 100 );\r
- return VLC_SUCCESS;\r
- }\r
- return VLC_EGENERIC;\r
-\r
- case ES_OUT_GET_GROUP:\r
- pi = (int*) va_arg( args, int* );\r
- if( p_sys->p_pgrm )\r
- *pi = p_sys->p_pgrm->i_id;\r
- else\r
- *pi = -1; /* FIXME */\r
- return VLC_SUCCESS;\r
-\r
- case ES_OUT_SET_GROUP:\r
- {\r
- int j;\r
- i = (int) va_arg( args, int );\r
- for( j = 0; j < p_sys->i_pgrm; j++ )\r
- {\r
- es_out_pgrm_t *p_pgrm = p_sys->pgrm[j];\r
- if( p_pgrm->i_id == i )\r
- {\r
- EsOutProgramSelect( out, p_pgrm );\r
- return VLC_SUCCESS;\r
- }\r
- }\r
- return VLC_EGENERIC;\r
- }\r
-\r
- case ES_OUT_SET_FMT:\r
- {\r
- /* This ain't pretty but is need by some demuxers (eg. Ogg )\r
- * to update the p_extra data */\r
- es_format_t *p_fmt;\r
- es = (es_out_id_t*) va_arg( args, es_out_id_t * );\r
- p_fmt = (es_format_t*) va_arg( args, es_format_t * );\r
- if( es == NULL ) return VLC_EGENERIC;\r
-\r
- if( p_fmt->i_extra )\r
- {\r
- es->fmt.i_extra = p_fmt->i_extra;\r
- es->fmt.p_extra = realloc( es->fmt.p_extra, p_fmt->i_extra );\r
- memcpy( es->fmt.p_extra, p_fmt->p_extra, p_fmt->i_extra );\r
-\r
- if( !es->p_dec ) return VLC_SUCCESS;\r
-\r
- es->p_dec->fmt_in.i_extra = p_fmt->i_extra;\r
- es->p_dec->fmt_in.p_extra =\r
- realloc( es->p_dec->fmt_in.p_extra, p_fmt->i_extra );\r
- memcpy( es->p_dec->fmt_in.p_extra,\r
- p_fmt->p_extra, p_fmt->i_extra );\r
- }\r
-\r
- return VLC_SUCCESS;\r
- }\r
-\r
- case ES_OUT_SET_NEXT_DISPLAY_TIME:\r
- {\r
- int64_t i_date;\r
-\r
- es = (es_out_id_t*) va_arg( args, es_out_id_t * );\r
- i_date = (int64_t)va_arg( args, int64_t );\r
-\r
- if( !es || !es->p_dec )\r
- return VLC_EGENERIC;\r
-\r
- es->i_preroll_end = i_date;\r
- input_DecoderPreroll( es->p_dec, i_date );\r
-\r
- return VLC_SUCCESS;\r
- }\r
-\r
- default:\r
- msg_Err( p_sys->p_input, "unknown query in es_out_Control" );\r
- return VLC_EGENERIC;\r
- }\r
-}\r
-\r
-/****************************************************************************\r
- * LanguageGetName: try to expend iso639 into plain name\r
- ****************************************************************************/\r
-static char *LanguageGetName( const char *psz_code )\r
-{\r
- const iso639_lang_t *pl;\r
-\r
- if( psz_code == NULL )\r
- {\r
- return strdup( "" );\r
- }\r
-\r
- if( strlen( psz_code ) == 2 )\r
- {\r
- pl = GetLang_1( psz_code );\r
- }\r
- else if( strlen( psz_code ) == 3 )\r
- {\r
- pl = GetLang_2B( psz_code );\r
- if( !strcmp( pl->psz_iso639_1, "??" ) )\r
- {\r
- pl = GetLang_2T( psz_code );\r
- }\r
- }\r
- else\r
- {\r
- return strdup( psz_code );\r
- }\r
-\r
- if( !strcmp( pl->psz_iso639_1, "??" ) )\r
- {\r
- return strdup( psz_code );\r
- }\r
- else\r
- {\r
- if( *pl->psz_native_name )\r
- {\r
- return strdup( pl->psz_native_name );\r
- }\r
- return strdup( pl->psz_eng_name );\r
- }\r
-}\r
-\r
-/* Get a 2 char code */\r
-static char *LanguageGetCode( const char *psz_lang )\r
-{\r
- const iso639_lang_t *pl;\r
-\r
- if( psz_lang == NULL || *psz_lang == '\0' )\r
- return strdup("??");\r
-\r
- for( pl = p_languages; pl->psz_iso639_1 != NULL; pl++ )\r
- {\r
- if( !strcasecmp( pl->psz_eng_name, psz_lang ) ||\r
- !strcasecmp( pl->psz_native_name, psz_lang ) ||\r
- !strcasecmp( pl->psz_iso639_1, psz_lang ) ||\r
- !strcasecmp( pl->psz_iso639_2T, psz_lang ) ||\r
- !strcasecmp( pl->psz_iso639_2B, psz_lang ) )\r
- break;\r
- }\r
-\r
- if( pl->psz_iso639_1 != NULL )\r
- return strdup( pl->psz_iso639_1 );\r
-\r
- return strdup("??");\r
-}\r
-\r
-static char **LanguageSplit( const char *psz_langs )\r
-{\r
- char *psz_dup;\r
- char *psz_parser;\r
- char **ppsz = NULL;\r
- int i_psz = 0;\r
-\r
- if( psz_langs == NULL )\r
- return NULL;\r
-\r
- psz_parser = psz_dup = strdup(psz_langs);\r
-\r
- while( psz_parser && *psz_parser )\r
- {\r
- char *psz;\r
- char *psz_code;\r
-\r
- psz = strchr(psz_parser, ',' );\r
- if( psz )\r
- {\r
- *psz++ = '\0';\r
- }\r
-\r
- psz_code = LanguageGetCode( psz_parser );\r
- if( strcmp( psz_code, "??" ) )\r
- {\r
- TAB_APPEND( i_psz, ppsz, psz_code );\r
- }\r
-\r
- psz_parser = psz;\r
- }\r
-\r
- if( i_psz )\r
- {\r
- TAB_APPEND( i_psz, ppsz, NULL );\r
- }\r
-\r
- return ppsz;\r
-}\r
-\r
-static int LanguageArrayIndex( char **ppsz_langs, char *psz_lang )\r
-{\r
- int i;\r
-\r
- if( !ppsz_langs || !psz_lang )\r
- return -1;\r
-\r
- for( i = 0; ppsz_langs[i]; i++ )\r
- if( !strcasecmp( ppsz_langs[i], psz_lang ) )\r
- return i;\r
-\r
- return -1;\r
-}\r
-\r
-/****************************************************************************\r
- * EsOutAddInfo:\r
- * - add meta info to the playlist item\r
- ****************************************************************************/\r
-static void EsOutAddInfo( es_out_t *out, es_out_id_t *es )\r
-{\r
- es_out_sys_t *p_sys = out->p_sys;\r
- input_thread_t *p_input = p_sys->p_input;\r
- es_format_t *fmt = &es->fmt;\r
- char *psz_cat;\r
-\r
- /* Add stream info */\r
- asprintf( &psz_cat, _("Stream %d"), out->p_sys->i_id - 1 );\r
-\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Codec"),\r
- "%.4s", (char*)&fmt->i_codec );\r
-\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Language"),\r
- "%s", es->psz_language );\r
-\r
- /* Add information */\r
- switch( fmt->i_cat )\r
- {\r
- case AUDIO_ES:\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Type"), _("Audio") );\r
-\r
- if( fmt->audio.i_channels > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Channels"),\r
- "%d", fmt->audio.i_channels );\r
-\r
- if( fmt->audio.i_rate > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Sample rate"),\r
- _("%d Hz"), fmt->audio.i_rate );\r
-\r
- if( fmt->audio.i_bitspersample > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Bits per sample"), "%d",\r
- fmt->audio.i_bitspersample );\r
-\r
- if( fmt->i_bitrate > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat, _("Bitrate"),\r
- _("%d kb/s"), fmt->i_bitrate / 1000 );\r
- break;\r
-\r
- case VIDEO_ES:\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Type"), _("Video") );\r
-\r
- if( fmt->video.i_width > 0 && fmt->video.i_height > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Resolution"), "%dx%d",\r
- fmt->video.i_width, fmt->video.i_height );\r
-\r
- if( fmt->video.i_visible_width > 0 &&\r
- fmt->video.i_visible_height > 0 )\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Display resolution"), "%dx%d",\r
- fmt->video.i_visible_width,\r
- fmt->video.i_visible_height);\r
- break;\r
-\r
- case SPU_ES:\r
- input_Control( p_input, INPUT_ADD_INFO, psz_cat,\r
- _("Type"), _("Subtitle") );\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
-\r
- free( psz_cat );\r
-}\r
+/*****************************************************************************
+ * es_out.c: Es Out handler for input.
+ *****************************************************************************
+ * Copyright (C) 2003-2004 VideoLAN
+ * $Id$
+ *
+ * Authors: Laurent Aimar <fenrir@via.ecp.fr>
+ *
+ * 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 <stdlib.h>
+
+#include <vlc/vlc.h>
+#include <vlc/input.h>
+#include <vlc/decoder.h>
+
+#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 );
+}