Commit d2310f2a authored by Damien Fouilleul's avatar Damien Fouilleul

all: reworked ActiveX plugin, which now works properly with .NET (tested with...

all: reworked ActiveX plugin, which now works properly  with .NET (tested with Visual Basic Express 2005)
     added persistent properties such as MRL, AutoPlay, AutoLoop which allows a user to play a default target
     without programming.
parent a4fe07f8
......@@ -33,11 +33,14 @@ library AXVLC
interface IVLCControl;
dispinterface DVLCEvents;
enum VLCPlaylistMode {
enum VLCPlaylistMode
{
VLCPlayListInsert = 1,
VLCPlayListInsertAndGo = 9,
VLCPlayListReplace = 2,
VLCPlayListReplaceAndGo = 10,
VLCPlayListAppend = 4,
VLCPlayListGo = 8,
VLCPlayListAppendAndGo = 12,
VLCPlayListCheckInsert = 16
};
......@@ -45,16 +48,15 @@ library AXVLC
const int VLCPlayListEnd = -666;
// DISPID definitions
const int DISPID_Visible = 1;
const int DISPID_Playing = 2;
const int DISPID_Position = 3;
const int DISPID_Time = 4;
const int DISPID_Length = 5;
const int DISPID_Volume = 6;
const int DISPID_PlayEvent = 1;
const int DISPID_PauseEvent = 2;
const int DISPID_StopEvent = 3;
const int DISPID_Visible = 100;
const int DISPID_Playing = 101;
const int DISPID_Position = 102;
const int DISPID_Time = 103;
const int DISPID_Length = 104;
const int DISPID_Volume = 105;
const int DISPID_MRL = 106;
const int DISPID_AutoPlay = 107;
const int DISPID_AutoLoop = 108;
[
odl,
......@@ -64,8 +66,8 @@ library AXVLC
hidden,
oleautomation
]
interface IVLCControl : IDispatch {
interface IVLCControl : IDispatch
{
[id(DISPID_Visible), propget, bindable, helpstring("Shows or hides plugin.")]
HRESULT Visible([out, retval] VARIANT_BOOL* visible);
[id(DISPID_Visible), propput, bindable, helpstring("Shows or hides plugin.")]
......@@ -76,13 +78,11 @@ library AXVLC
HRESULT pause();
[helpstring("Stop playback.")]
HRESULT stop();
[id(DISPID_Playing), bindable, propget, helpstring("Specifies whether VLC is playing.")]
[id(DISPID_Playing), hidden, propget, helpstring("Returns whether VLC is playing.")]
HRESULT Playing([out, retval] VARIANT_BOOL* isPlaying);
[id(DISPID_Playing), bindable, propput, helpstring("Specifies whether VLC is playing.")]
HRESULT Playing([in] VARIANT_BOOL isPlaying);
[id(DISPID_Position), bindable, propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propget, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([out, retval] float* position);
[id(DISPID_Position), bindable, propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
[id(DISPID_Position), propput, helpstring("Specifies playback position within current target in playlist, position is a relative value ranging from 0.0 to 1.0.")]
HRESULT Position([in] float position);
[id(DISPID_Time), propget, helpstring("Specifies playback time relative to the start of current target in playlist.")]
HRESULT Time([out, retval] int* seconds);
......@@ -92,15 +92,15 @@ library AXVLC
HRESULT shuttle([in] int seconds);
[helpstring("Switch between normal and fullscreen video.")]
HRESULT fullscreen();
[id(DISPID_Length), bindable, propget, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
[id(DISPID_Length), propget, hidden, helpstring("Returns total length in seconds of current target in playlist, may be unknown.")]
HRESULT Length([out, retval] int* seconds);
[helpstring("Increases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playFaster();
[helpstring("Decreases playback speed, one of 1x, 2x, 4x, 8x.")]
HRESULT playSlower();
[id(DISPID_Volume), bindable, propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propget, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([out, retval] int* volume);
[id(DISPID_Volume), bindable, propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
[id(DISPID_Volume), propput, helpstring("Specifies playback sound volume, ranges from 0 to 200%.")]
HRESULT Volume([in] int volume);
[helpstring("Mute/unmute playback sound volume.")]
HRESULT toggleMute();
......@@ -126,24 +126,41 @@ library AXVLC
HRESULT playlistPrev();
[helpstring("Remove all items from playlist.")]
HRESULT playlistClear();
[propget, helpstring("Returns VLC Version.")]
[propget, hidden, helpstring("Returns VLC Version.")]
HRESULT VersionInfo([out, retval] BSTR* version);
[id(DISPID_MRL), propget, helpstring("Returns initial MRL in default playlist")]
HRESULT MRL([out, retval] BSTR* mrl);
[id(DISPID_MRL), propput, helpstring("Specifies initial MRL in default playlist")]
HRESULT MRL([in] BSTR mrl);
[id(DISPID_AutoPlay), propget, helpstring("Specifies whether default playlist is played on startup")]
HRESULT AutoPlay([out, retval] VARIANT_BOOL* autoplay);
[id(DISPID_AutoPlay), propput, helpstring("Returns whether default playlist is played on startup")]
HRESULT AutoPlay([in] VARIANT_BOOL autoplay);
[id(DISPID_AutoLoop), propget, helpstring("Specifies whether default playlist is looped")]
HRESULT AutoLoop([out, retval] VARIANT_BOOL* autoloop);
[id(DISPID_AutoLoop), propput, helpstring("Returns whether default playlist is looped")]
HRESULT AutoLoop([in] VARIANT_BOOL autoloop);
};
const int DISPID_PlayEvent = 100;
const int DISPID_PauseEvent = 101;
const int DISPID_StopEvent = 102;
[
uuid(DF48072F-5EF8-434e-9B40-E2F3AE759B5F),
helpstring("Event interface for VLC control"),
hidden
]
dispinterface DVLCEvents {
dispinterface DVLCEvents
{
properties:
methods:
[id(DISPID_PlayEvent), helpstring("Playback in progress")]
void Play();
void play();
[id(DISPID_PauseEvent), helpstring("Playback has paused")]
void Pause();
void pause();
[id(DISPID_StopEvent), helpstring("Playback has stopped")]
void Stop();
void stop();
};
[
......@@ -151,7 +168,8 @@ library AXVLC
helpstring("VLC control"),
control
]
coclass VLCPlugin {
coclass VLCPlugin
{
[default] interface IVLCControl;
[default, source] dispinterface DVLCEvents;
};
......
No preview for this file type
......@@ -5,7 +5,7 @@
/* File created by MIDL compiler version 5.01.0164 */
/* at Tue May 10 21:24:51 2005
/* at Sun Aug 21 17:16:22 2005
*/
/* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......
......@@ -2,7 +2,7 @@
/* File created by MIDL compiler version 5.01.0164 */
/* at Tue May 10 21:24:51 2005
/* at Sun Aug 21 17:16:22 2005
*/
/* Compiler settings for axvlc.idl:
Oicf (OptLev=i2), W1, Zp8, env=Win32, ms_ext, c_ext
......@@ -67,30 +67,38 @@ void __RPC_USER MIDL_user_free( void __RPC_FAR * );
enum VLCPlaylistMode
{ VLCPlayListInsert = 1,
VLCPlayListInsertAndGo = 9,
VLCPlayListReplace = 2,
VLCPlayListReplaceAndGo = 10,
VLCPlayListAppend = 4,
VLCPlayListGo = 8,
VLCPlayListAppendAndGo = 12,
VLCPlayListCheckInsert = 16
};
#define VLCPlayListEnd ( -666 )
#define DISPID_Visible ( 1 )
#define DISPID_Visible ( 100 )
#define DISPID_Playing ( 2 )
#define DISPID_Playing ( 101 )
#define DISPID_Position ( 3 )
#define DISPID_Position ( 102 )
#define DISPID_Time ( 4 )
#define DISPID_Time ( 103 )
#define DISPID_Length ( 5 )
#define DISPID_Length ( 104 )
#define DISPID_Volume ( 6 )
#define DISPID_Volume ( 105 )
#define DISPID_PlayEvent ( 1 )
#define DISPID_MRL ( 106 )
#define DISPID_PauseEvent ( 2 )
#define DISPID_AutoPlay ( 107 )
#define DISPID_StopEvent ( 3 )
#define DISPID_AutoLoop ( 108 )
#define DISPID_PlayEvent ( 100 )
#define DISPID_PauseEvent ( 101 )
#define DISPID_StopEvent ( 102 )
EXTERN_C const IID LIBID_AXVLC;
......@@ -122,16 +130,13 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE stop( void) = 0;
virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Playing(
virtual /* [helpstring][propget][hidden][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(
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Position(
/* [retval][out] */ float __RPC_FAR *position) = 0;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Position(
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_Position(
/* [in] */ float position) = 0;
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Time(
......@@ -145,17 +150,17 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE fullscreen( void) = 0;
virtual /* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE get_Length(
virtual /* [helpstring][hidden][propget][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(
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_Volume(
/* [retval][out] */ int __RPC_FAR *volume) = 0;
virtual /* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE put_Volume(
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_Volume(
/* [in] */ int volume) = 0;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE toggleMute( void) = 0;
......@@ -186,9 +191,27 @@ EXTERN_C const IID IID_IVLCControl;
virtual /* [helpstring] */ HRESULT STDMETHODCALLTYPE playlistClear( void) = 0;
virtual /* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE get_VersionInfo(
virtual /* [helpstring][hidden][propget] */ HRESULT STDMETHODCALLTYPE get_VersionInfo(
/* [retval][out] */ BSTR __RPC_FAR *version) = 0;
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_MRL(
/* [retval][out] */ BSTR __RPC_FAR *mrl) = 0;
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_MRL(
/* [in] */ BSTR mrl) = 0;
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_AutoPlay(
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoplay) = 0;
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_AutoPlay(
/* [in] */ VARIANT_BOOL autoplay) = 0;
virtual /* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE get_AutoLoop(
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoloop) = 0;
virtual /* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE put_AutoLoop(
/* [in] */ VARIANT_BOOL autoloop) = 0;
};
#else /* C style interface */
......@@ -254,19 +277,15 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *stop )(
IVLCControl __RPC_FAR * This);
/* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Playing )(
/* [helpstring][propget][hidden][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 )(
/* [helpstring][propget][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 )(
/* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Position )(
IVLCControl __RPC_FAR * This,
/* [in] */ float position);
......@@ -285,7 +304,7 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *fullscreen )(
IVLCControl __RPC_FAR * This);
/* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Length )(
/* [helpstring][hidden][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Length )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ int __RPC_FAR *seconds);
......@@ -295,11 +314,11 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playSlower )(
IVLCControl __RPC_FAR * This);
/* [helpstring][propget][bindable][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_Volume )(
/* [helpstring][propget][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 )(
/* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_Volume )(
IVLCControl __RPC_FAR * This,
/* [in] */ int volume);
......@@ -340,10 +359,34 @@ EXTERN_C const IID IID_IVLCControl;
/* [helpstring] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *playlistClear )(
IVLCControl __RPC_FAR * This);
/* [helpstring][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_VersionInfo )(
/* [helpstring][hidden][propget] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_VersionInfo )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ BSTR __RPC_FAR *version);
/* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_MRL )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ BSTR __RPC_FAR *mrl);
/* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_MRL )(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR mrl);
/* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_AutoPlay )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoplay);
/* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_AutoPlay )(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT_BOOL autoplay);
/* [helpstring][propget][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *get_AutoLoop )(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoloop);
/* [helpstring][propput][id] */ HRESULT ( STDMETHODCALLTYPE __RPC_FAR *put_AutoLoop )(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT_BOOL autoloop);
END_INTERFACE
} IVLCControlVtbl;
......@@ -398,9 +441,6 @@ EXTERN_C const IID IID_IVLCControl;
#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)
......@@ -464,6 +504,24 @@ EXTERN_C const IID IID_IVLCControl;
#define IVLCControl_get_VersionInfo(This,version) \
(This)->lpVtbl -> get_VersionInfo(This,version)
#define IVLCControl_get_MRL(This,mrl) \
(This)->lpVtbl -> get_MRL(This,mrl)
#define IVLCControl_put_MRL(This,mrl) \
(This)->lpVtbl -> put_MRL(This,mrl)
#define IVLCControl_get_AutoPlay(This,autoplay) \
(This)->lpVtbl -> get_AutoPlay(This,autoplay)
#define IVLCControl_put_AutoPlay(This,autoplay) \
(This)->lpVtbl -> put_AutoPlay(This,autoplay)
#define IVLCControl_get_AutoLoop(This,autoloop) \
(This)->lpVtbl -> get_AutoLoop(This,autoloop)
#define IVLCControl_put_AutoLoop(This,autoloop) \
(This)->lpVtbl -> put_AutoLoop(This,autoloop)
#endif /* COBJMACROS */
......@@ -528,7 +586,7 @@ void __RPC_STUB IVLCControl_stop_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Playing_Proxy(
/* [helpstring][propget][hidden][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Playing_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *isPlaying);
......@@ -540,19 +598,7 @@ void __RPC_STUB IVLCControl_get_Playing_Stub(
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(
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Position_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ float __RPC_FAR *position);
......@@ -564,7 +610,7 @@ void __RPC_STUB IVLCControl_get_Position_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Position_Proxy(
/* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Position_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ float position);
......@@ -623,7 +669,7 @@ void __RPC_STUB IVLCControl_fullscreen_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Length_Proxy(
/* [helpstring][hidden][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Length_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ int __RPC_FAR *seconds);
......@@ -657,7 +703,7 @@ void __RPC_STUB IVLCControl_playSlower_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propget][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Volume_Proxy(
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_Volume_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ int __RPC_FAR *volume);
......@@ -669,7 +715,7 @@ void __RPC_STUB IVLCControl_get_Volume_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propput][bindable][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Volume_Proxy(
/* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_Volume_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ int volume);
......@@ -790,7 +836,7 @@ void __RPC_STUB IVLCControl_playlistClear_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_VersionInfo_Proxy(
/* [helpstring][hidden][propget] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_VersionInfo_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ BSTR __RPC_FAR *version);
......@@ -802,6 +848,78 @@ void __RPC_STUB IVLCControl_get_VersionInfo_Stub(
DWORD *_pdwStubPhase);
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_MRL_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ BSTR __RPC_FAR *mrl);
void __RPC_STUB IVLCControl_get_MRL_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_MRL_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ BSTR mrl);
void __RPC_STUB IVLCControl_put_MRL_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_AutoPlay_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoplay);
void __RPC_STUB IVLCControl_get_AutoPlay_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_AutoPlay_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT_BOOL autoplay);
void __RPC_STUB IVLCControl_put_AutoPlay_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propget][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_get_AutoLoop_Proxy(
IVLCControl __RPC_FAR * This,
/* [retval][out] */ VARIANT_BOOL __RPC_FAR *autoloop);
void __RPC_STUB IVLCControl_get_AutoLoop_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
/* [helpstring][propput][id] */ HRESULT STDMETHODCALLTYPE IVLCControl_put_AutoLoop_Proxy(
IVLCControl __RPC_FAR * This,
/* [in] */ VARIANT_BOOL autoloop);
void __RPC_STUB IVLCControl_put_AutoLoop_Stub(
IRpcStubBuffer *This,
IRpcChannelBuffer *_pRpcChannelBuffer,
PRPC_MESSAGE _pRpcMessage,
DWORD *_pdwStubPhase);
#endif /* __IVLCControl_INTERFACE_DEFINED__ */
......
......@@ -192,18 +192,16 @@ HRESULT VLCDataObject::getMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedi
SIZEL size = _p_instance->getExtent();
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
pMetaFilePict->mm = MM_ANISOTROPIC;
pMetaFilePict->xExt = size.cx;
pMetaFilePict->yExt = size.cy;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
SetMapMode(hdcMeta, MM_ANISOTROPIC);
SetWindowOrgEx(hdcMeta, 0, 0, NULL);
SetWindowExtEx(hdcMeta, width, height, NULL);
SetWindowExtEx(hdcMeta, size.cx, size.cy, NULL);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMetaFilePict->hMF = CloseMetaFile(hdcMeta);
......@@ -230,10 +228,9 @@ HRESULT VLCDataObject::getEnhMetaFileData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pM
{
RECTL wBounds = { 0L, 0L, size.cx, size.cy };
LONG width = size.cx*GetDeviceCaps(hicTargetDev, LOGPIXELSX)/2540L;
LONG height = size.cy*GetDeviceCaps(hicTargetDev, LOGPIXELSY)/2540L;
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
RECTL bounds = { 0L, 0L, width, height };
RECTL bounds = { 0L, 0L, size.cx, size.cy };
_p_instance->onDraw(pFormatEtc->ptd, hicTargetDev, hdcMeta, &bounds, &wBounds);
pMedium->hEnhMetaFile = CloseEnhMetaFile(hdcMeta);
......@@ -279,6 +276,11 @@ STDMETHODIMP VLCDataObject::SetData(LPFORMATETC pFormatEtc, LPSTGMEDIUM pMedium,
return E_NOTIMPL;
};
/*void VLCDataObject::onDataChange(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, 0);
};*/
void VLCDataObject::onClose(void)
{
_p_adviseHolder->SendOnDataChange(this, 0, ADVF_DATAONSTOP);
......
......@@ -96,7 +96,7 @@ static LPCTSTR TStrFromGUID(REFGUID clsid)
if( len > 0 )
{
clsidStr = (wchar_t *)CoTaskMemAlloc(len*sizeof(wchar_t));
WideCharToMultiByte(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
MultiByteToWideChar(CP_ACP, 0, oleStr, -1, pct_CLSID, len);
}
#endif
CoTaskMemFree(oleStr);
......
......@@ -23,8 +23,6 @@
#include "plugin.h"
#include "olecontrol.h"
#include "utils.h"
using namespace std;
STDMETHODIMP VLCOleControl::GetControlInfo(CONTROLINFO *pCI)
......@@ -45,12 +43,12 @@ STDMETHODIMP VLCOleControl::OnMnemonic(LPMSG pMsg)
return E_NOTIMPL;
};
static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v)
STDMETHODIMP VLCOleControl::OnAmbientPropertyChange(DISPID dispID)
{
HRESULT hr;
IOleObject *oleObj;
hr = instance.QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
hr = QueryInterface(IID_IOleObject, (LPVOID *)&oleObj);
if( SUCCEEDED(hr) )
{
IOleClientSite *clientSite;
......@@ -58,70 +56,11 @@ static HRESULT getAmbientProperty(VLCPlugin& instance, DISPID dispID, VARIANT& v
hr = oleObj->GetClientSite(&clientSite);
if( SUCCEEDED(hr) && (NULL != clientSite) )
{
hr = GetObjectProperty(clientSite, dispID, v);
_p_instance->onAmbientChanged(clientSite, dispID);
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;
};
......
......@@ -28,18 +28,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceActiveObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceActiveObject::EnableModeless(BOOL fEnable)
......
......@@ -30,18 +30,15 @@ using namespace std;
STDMETHODIMP VLCOleInPlaceObject::GetWindow(HWND *pHwnd)
{
if( NULL == pHwnd )
return E_INVALIDARG;
return E_POINTER;
*pHwnd = NULL;
if( _p_instance->isInPlaceActive() )
{
if( NULL != (*pHwnd = _p_instance->getInPlaceWindow()) )
return S_OK;
return E_FAIL;
}
*pHwnd = NULL;
return E_UNEXPECTED;
return E_FAIL;
};
STDMETHODIMP VLCOleInPlaceObject::ContextSensitiveHelp(BOOL fEnterMode)
......@@ -54,6 +51,7 @@ STDMETHODIMP VLCOleInPlaceObject::InPlaceDeactivate(void)
if( _p_instance->isInPlaceActive() )
{
UIDeactivate();
_p_instance->onInPlaceDeactivate();
LPOLEOBJECT p_oleObject;
......@@ -85,26 +83,26 @@ STDMETHODIMP VLCOleInPlaceObject::UIDeactivate(void)
if( _p_instance->hasFocus() )
{
_p_instance->setFocus(FALSE);
}
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
LPOLEOBJECT p_oleObject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (void**)&p_oleObject)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
{
LPOLECLIENTSITE p_clientSite;
if( SUCCEEDED(p_oleObject->GetClientSite(&p_clientSite)) )
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
LPOLEINPLACESITE p_inPlaceSite;
if( SUCCEEDED(p_clientSite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) )
{
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_clientSite->Release();
p_inPlaceSite->OnUIDeactivate(FALSE);
p_inPlaceSite->Release();
}
p_oleObject->Release();
p_clientSite->Release();
}
return S_OK;
p_oleObject->Release();
}
return S_OK;
}
return E_UNEXPECTED;
};
......
......@@ -37,8 +37,9 @@ _p_clientsite(NULL), _p_instance(p_instance)
VLCOleObject::~VLCOleObject()
{
SetClientSite(NULL);
Close(OLECLOSE_NOSAVE);
_p_advise_holder->Release();
SetClientSite(NULL);
};
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
......@@ -48,8 +49,12 @@ STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
if( _p_instance->isRunning() )
{
_p_advise_holder->SendOnClose();
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
......@@ -115,6 +120,7 @@ HRESULT VLCOleObject::doInPlaceActivate(LPMSG lpMsg, LPOLECLIENTSITE pActiveSite
LPOLEINPLACEUIWINDOW p_inPlaceUIWindow;
OLEINPLACEFRAMEINFO oleFrameInfo;
oleFrameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
if( SUCCEEDED(p_inPlaceSite->GetWindowContext(&p_inPlaceFrame, &p_inPlaceUIWindow, &posRect, &clipRect, &oleFrameInfo)) )
{
lprcPosRect = &posRect;
......@@ -302,29 +308,16 @@ STDMETHODIMP VLCOleObject::IsUpToDate(void)
STDMETHODIMP VLCOleObject::SetClientSite(LPOLECLIENTSITE pClientSite)
{
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);
}
}
if( NULL != _p_clientsite )
_p_clientsite->Release();
_p_clientsite = pClientSite;
_p_instance->onClientSiteChanged(pClientSite);
if( NULL != pClientSite )
{
pClientSite->AddRef();
_p_instance->onAmbientChanged(pClientSite, DISPID_UNKNOWN);
}
return S_OK;
};
......
......@@ -45,59 +45,95 @@ STDMETHODIMP VLCPersistPropertyBag::InitNew(void)
STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
{
if( NULL == pPropBag )
return E_POINTER;
HRESULT hr = _p_instance->onInit();
if( FAILED(hr) )
return hr;
if( NULL == pPropBag )
return E_INVALIDARG;
VARIANT value;
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("mrl"), &value, pErrorLog) )
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
{
_p_instance->setSourceURL(src);
free(src);
}
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
else
{
char *src = CStrFromBSTR(_p_instance->getCodePage(), V_BSTR(&value));
if( NULL != src )
/*
** try alternative syntax
*/
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("src"), &value, pErrorLog) )
{
_p_instance->setSourceURL(src);
free(src);
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
else
{
V_VT(&value) = VT_BSTR;
if( S_OK == pPropBag->Read(OLESTR("filename"), &value, pErrorLog) )
{
_p_instance->setMRL(V_BSTR(&value));
VariantClear(&value);
}
}
VariantClear(&value);
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autoplay"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
{
_p_instance->setAutoPlay(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("autostart"), &value, pErrorLog) )
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentwidth"), &value, pErrorLog) )
{
size.cx = V_I4(&value);
VariantClear(&value);
}
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("extentheight"), &value, pErrorLog) )
{
_p_instance->setAutoStart(V_BOOL(&value) != VARIANT_FALSE);
size.cy = V_I4(&value);
VariantClear(&value);
}
_p_instance->setExtent(size);
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("autoloop"), &value, pErrorLog) )
{
_p_instance->setLoopMode(V_BOOL(&value) != VARIANT_FALSE);
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("loop"), &value, pErrorLog) )
{
_p_instance->setAutoLoop(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("mute"), &value, pErrorLog) )
......@@ -107,19 +143,81 @@ STDMETHODIMP VLCPersistPropertyBag::Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErr
}
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
if( S_OK == pPropBag->Read(OLESTR("visible"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
else
{
/*
** try alternative syntax
*/
V_VT(&value) = VT_BOOL;
if( S_OK == pPropBag->Read(OLESTR("showdisplay"), &value, pErrorLog) )
{
_p_instance->setVisible(V_BOOL(&value) != VARIANT_FALSE);
VariantClear(&value);
}
}
int i_vlc = _p_instance->getVLCObject();
V_VT(&value) = VT_I4;
if( S_OK == pPropBag->Read(OLESTR("volume"), &value, pErrorLog) )
{
VLC_VolumeSet(i_vlc, V_I4(&value));
VariantClear(&value);
}
return _p_instance->onLoad();
};
STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
{
if( NULL == pPropBag )
return E_POINTER;
return E_INVALIDARG;
VARIANT value;
VariantInit(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoLoop()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoLoop"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getAutoPlay()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("AutoPlay"), &value);
VariantClear(&value);
SIZEL size = _p_instance->getExtent();
V_VT(&value) = VT_I4;
V_I4(&value) = size.cx;
pPropBag->Write(OLESTR("ExtentWidth"), &value);
V_I4(&value) = size.cy;
pPropBag->Write(OLESTR("ExtentHeight"), &value);
V_VT(&value) = VT_BSTR;
V_BSTR(&value) = SysAllocString(_p_instance->getMRL());
pPropBag->Write(OLESTR("MRL"), &value);
VariantClear(&value);
V_VT(&value) = VT_BOOL;
V_BOOL(&value) = _p_instance->getVisible()? VARIANT_TRUE : VARIANT_FALSE;
pPropBag->Write(OLESTR("Visible"), &value);
VariantClear(&value);
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
V_VT(&value) = VT_I4;
V_I4(&value) = VLC_VolumeGet(i_vlc);
pPropBag->Write(OLESTR("Volume"), &value);
VariantClear(&value);
}
if( fClearDirty )
_p_instance->setDirty(FALSE);
return S_OK;
};
......
......@@ -37,31 +37,63 @@ STDMETHODIMP VLCPersistStorage::GetClassID(LPCLSID pClsID)
STDMETHODIMP VLCPersistStorage::IsDirty(void)
{
return S_FALSE;
return _p_instance->isDirty() ? S_OK : S_FALSE;
};
STDMETHODIMP VLCPersistStorage::InitNew(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return _p_instance->onInit();
};
STDMETHODIMP VLCPersistStorage::Load(IStorage *pStg)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return _p_instance->onInit();
LPSTREAM pStm = NULL;
HRESULT result = pStg->OpenStream(L"VideoLAN ActiveX Plugin Data", NULL,
STGM_READ|STGM_SHARE_EXCLUSIVE, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Load(pStm);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
STDMETHODIMP VLCPersistStorage::Save(IStorage *pStg, BOOL fSameAsLoad)
{
if( NULL == pStg )
return E_POINTER;
return E_INVALIDARG;
return S_OK;
if( fSameAsLoad && (S_FALSE == IsDirty()) )
return S_OK;
LPSTREAM pStm = NULL;
HRESULT result = pStg->CreateStream(L"VideoLAN ActiveX Plugin Data",
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, 0, 0, &pStm);
if( FAILED(result) )
return result;
LPPERSISTSTREAMINIT pPersistStreamInit;
if( SUCCEEDED(QueryInterface(IID_IPersistStreamInit, (void **)&pPersistStreamInit)) )
{
result = pPersistStreamInit->Save(pStm, fSameAsLoad);
pPersistStreamInit->Release();
}
pStm->Release();
return result;
};
STDMETHODIMP VLCPersistStorage::SaveCompleted(IStorage *pStg)
......
......@@ -23,8 +23,473 @@
#include "plugin.h"
#include "persiststreaminit.h"
#include "utils.h"
#include <map>
#include <malloc.h>
#include <wchar.h>
using namespace std;
class AxVLCVariant
{
public:
AxVLCVariant(void)
{
VariantInit(&_v);
};
~AxVLCVariant(void)
{
VariantClear(&_v);
}
AxVLCVariant(VARIANTARG &v)
{
//VariantInit(&_v);
//VariantCopy(&_v, &v);
_v = v;
};
AxVLCVariant(VARIANTARG *v)
{
VariantInit(&_v);
VariantCopy(&_v, v);
};
AxVLCVariant(const AxVLCVariant &vv)
{
VariantInit(&_v);
VariantCopy(&_v, const_cast<VARIANTARG *>(&(vv._v)));
};
AxVLCVariant(int i)
{
V_VT(&_v) = VT_I4;
V_I4(&_v) = i;
};
AxVLCVariant(BSTR bstr)
{
VARIANT arg;
V_VT(&arg) = VT_BSTR;
V_BSTR(&arg) = bstr;
VariantCopy(&_v, &arg);
};
inline const VARIANTARG *variantArg(void) const {
return &_v;
}
inline void swap(AxVLCVariant &v1, AxVLCVariant &v2)
{
VARIANTARG tmp = v1._v;
v1._v = v2._v;
v2._v = tmp;
};
private:
VARIANTARG _v;
};
class AxVLCWSTR
{
public:
AxVLCWSTR(void) : _data(NULL) {};
virtual ~AxVLCWSTR()
{
if( NULL != _data )
{
ULONG refcount = InterlockedDecrement(&(_data->refcount));
if( 0 == refcount )
CoTaskMemFree(_data);
}
};
AxVLCWSTR(LPCWSTR s)
{
if( NULL != s )
{
size_t len = wcslen(s);
if( len > 0 )
{
size_t size = len*sizeof(WCHAR);
_data = (struct data *)CoTaskMemAlloc(sizeof(struct data)+size);
if( NULL != _data )
{
_data->len = len;
_data->refcount = 1;
memcpy(_data->wstr, s, size);
_data->wstr[len]=L'\0';
return;
}
}
}
_data = NULL;
};
AxVLCWSTR(const AxVLCWSTR &s)
{
_data = s._data;
if( NULL != _data )
InterlockedIncrement(&(_data->refcount));
};
inline bool operator<(const AxVLCWSTR &s) const
{
return compareNoCase(s.wstr()) < 0;
};
inline bool operator<(LPCWSTR s) const
{
return compareNoCase(s) < 0;
};
inline bool operator==(const AxVLCWSTR &s) const
{
return compareNoCase(s.wstr()) == 0;
};
inline bool operator==(LPCWSTR s) const
{
return compareNoCase(s) == 0;
};
LPCWSTR wstr(void) const
{
return (NULL != _data) ? _data->wstr : NULL;
};
size_t size(void) const
{
return (NULL != _data) ? _data->len : 0;
};
private:
inline int compareNoCase(LPCWSTR s) const
{
if( NULL == _data )
{
return (NULL == s) ? 0 : -1;
}
if( NULL == s )
return 1;
return _wcsicmp(_data->wstr, s);
};
struct data {
size_t len;
LONG refcount;
wchar_t wstr[1];
} *_data;
};
typedef pair<class AxVLCWSTR, class AxVLCVariant> AxVLCPropertyPair;
typedef map<class AxVLCWSTR, class AxVLCVariant> AxVLCPropertyMap;
///////////////////////////
class VLCPropertyBag : public IPropertyBag
{
public:
VLCPropertyBag(void) : _i_ref(1) {};
virtual ~VLCPropertyBag() {};
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( NULL == ppv )
return E_POINTER;
if( (IID_IUnknown == riid)
&& (IID_IPropertyBag == riid) )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
}
// standalone object
return E_NOINTERFACE;
};
STDMETHODIMP_(ULONG) AddRef(void)
{ return InterlockedIncrement(&_i_ref); };
STDMETHODIMP_(ULONG) Release(void)
{
ULONG refcount = InterlockedDecrement(&_i_ref);
if( 0 == refcount )
{
delete this;
return 0;
}
return refcount;
};
// IPropertyBag methods
STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)
{
if( (NULL == pszPropName) || (NULL == pVar) )
return E_POINTER;
AxVLCPropertyMap::const_iterator notfound = _pm.end();
AxVLCPropertyMap::const_iterator iter = _pm.find(pszPropName);
if( notfound != iter )
{
VARTYPE vtype = V_VT(pVar);
VariantCopy(pVar, const_cast<VARIANTARG*>((*iter).second.variantArg()));
if( (V_VT(pVar) != vtype) && FAILED(VariantChangeType(pVar, pVar, 0, vtype)) )
{
VariantClear(pVar);
return E_FAIL;
}
return S_OK;
}
else
return E_INVALIDARG;
};
STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar)
{
if( (NULL == pszPropName) || (NULL == pVar) )
return E_POINTER;
AxVLCPropertyPair val(pszPropName, pVar);
pair<AxVLCPropertyMap::iterator, bool> p = _pm.insert(val);
if( false == p.second )
// replace existing key value
(*p.first).second = val.second;
return S_OK;
};
// custom methods
HRESULT Load(LPSTREAM pStm)
{
if( NULL == pStm )
return E_INVALIDARG;
HRESULT result;
AxVLCPropertyPair *val;
result = ReadProperty(pStm, &val);
if( SUCCEEDED(result) )
{
if( (val->first == L"(Count)") && (VT_I4 == V_VT(val->second.variantArg())) )
{
size_t count = V_I4(val->second.variantArg());
delete val;
while( count-- )
{
result = ReadProperty(pStm, &val);
if( FAILED(result) )
return result;
pair<AxVLCPropertyMap::iterator, bool> p = _pm.insert(*val);
if( false == p.second )
// replace existing key value
(*p.first).second = val->second;
delete val;
}
}
}
return result;
};
HRESULT Save(LPSTREAM pStm)
{
if( NULL == pStm )
return E_INVALIDARG;
HRESULT result;
AxVLCPropertyPair header(L"(Count)", _pm.size());
result = WriteProperty(pStm, header);
if( SUCCEEDED(result) )
{
AxVLCPropertyMap::const_iterator iter = _pm.begin();
AxVLCPropertyMap::const_iterator end = _pm.end();
while( iter != end )
{
result = WriteProperty(pStm, *(iter++));
if( FAILED(result) )
return result;
}
}
return result;
};
BOOL IsEmpty()
{
return _pm.size() == 0;
}
private:
HRESULT WriteProperty(LPSTREAM pStm, const AxVLCPropertyPair &prop)
{
HRESULT result;
const AxVLCWSTR propName = prop.first;
ULONG len = propName.size();
if( 0 == len )
return E_INVALIDARG;
result = pStm->Write(&len, sizeof(len), NULL);
if( FAILED(result) )
return result;
result = pStm->Write(propName.wstr(), len*sizeof(WCHAR), NULL);
if( FAILED(result) )
return result;
const VARIANTARG *propValue = prop.second.variantArg();
VARTYPE vtype = V_VT(propValue);
switch( vtype )
{
case VT_BOOL:
result = pStm->Write(&vtype, sizeof(vtype), NULL);
if( FAILED(result) )
return result;
result = pStm->Write(&V_BOOL(propValue), sizeof(V_BOOL(propValue)), NULL);
if( FAILED(result) )
return result;
break;
case VT_I4:
result = pStm->Write(&vtype, sizeof(vtype), NULL);
if( FAILED(result) )
return result;
result = pStm->Write(&V_I4(propValue), sizeof(V_I4(propValue)), NULL);
if( FAILED(result) )
return result;
break;
case VT_BSTR:
result = pStm->Write(&vtype, sizeof(vtype), NULL);
if( FAILED(result) )
return result;
len = SysStringLen(V_BSTR(propValue));
result = pStm->Write(&len, sizeof(len), NULL);
if( FAILED(result) )
return result;
if( len > 0 )
{
result = pStm->Write(V_BSTR(propValue), len*sizeof(OLECHAR), NULL);
if( FAILED(result) )
return result;
}
break;
default:
vtype = VT_EMPTY;
result = pStm->Write(&vtype, sizeof(vtype), NULL);
if( FAILED(result) )
return result;
}
return result;
};
static HRESULT ReadProperty(LPSTREAM pStm, AxVLCPropertyPair **prop)
{
HRESULT result;
ULONG len;
result = pStm->Read(&len, sizeof(len), NULL);
if( FAILED(result) )
return result;
if( 0 == len )
return E_INVALIDARG;
LPWSTR propName = (LPOLESTR)::alloca((len+1)*sizeof(WCHAR));
if( NULL == propName )
return E_OUTOFMEMORY;
result = pStm->Read(propName, len*sizeof(WCHAR), NULL);
if( FAILED(result) )
return result;
propName[len] = L'\0';
VARIANTARG propValue;
VARTYPE vtype;
result = pStm->Read(&vtype, sizeof(vtype), NULL);
if( FAILED(result) )
return result;
switch( vtype )
{
case VT_BOOL:
V_VT(&propValue) = vtype;
result = pStm->Read(&V_BOOL(&propValue), sizeof(V_BOOL(&propValue)), NULL);
if( FAILED(result) )
return result;
break;
case VT_I4:
V_VT(&propValue) = vtype;
result = pStm->Read(&V_I4(&propValue), sizeof(V_I4(&propValue)), NULL);
if( FAILED(result) )
return result;
break;
case VT_BSTR:
V_VT(&propValue) = vtype;
result = pStm->Read(&len, sizeof(len), NULL);
if( FAILED(result) )
return result;
V_BSTR(&propValue) = NULL;
if( len > 0 )
{
V_BSTR(&propValue) = SysAllocStringLen(NULL, len);
if( NULL == V_BSTR(&propValue) )
return E_OUTOFMEMORY;
result = pStm->Read(V_BSTR(&propValue), len*sizeof(OLECHAR), NULL);
if( FAILED(result) )
{
SysFreeString(V_BSTR(&propValue));
return result;
}
}
break;
default:
VariantInit(&propValue);
}
*prop = new AxVLCPropertyPair(propName, propValue);
return S_OK;
};
AxVLCPropertyMap _pm;
LONG _i_ref;
};
///////////////////////////
VLCPersistStreamInit::VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance)
{
_p_props = new VLCPropertyBag();
};
VLCPersistStreamInit::~VLCPersistStreamInit()
{
_p_props->Release();
};
STDMETHODIMP VLCPersistStreamInit::GetClassID(LPCLSID pClsID)
{
if( NULL == pClsID )
......@@ -42,28 +507,46 @@ STDMETHODIMP VLCPersistStreamInit::InitNew(void)
STDMETHODIMP VLCPersistStreamInit::Load(LPSTREAM pStm)
{
if( NULL == pStm )
return E_POINTER;
HRESULT result = _p_props->Load(pStm);
if( FAILED(result) )
return result;
return _p_instance->onInit();
LPPERSISTPROPERTYBAG pPersistPropBag;
if( FAILED(QueryInterface(IID_IPersistPropertyBag, (void**)&pPersistPropBag)) )
return E_FAIL;
result = pPersistPropBag->Load(_p_props, NULL);
pPersistPropBag->Release();
return result;
};
STDMETHODIMP VLCPersistStreamInit::Save(LPSTREAM pStm, BOOL fClearDirty)
{
if( NULL == pStm )
return E_POINTER;
return E_INVALIDARG;
return S_OK;
LPPERSISTPROPERTYBAG pPersistPropBag;
if( FAILED(QueryInterface(IID_IPersistPropertyBag, (void**)&pPersistPropBag)) )
return E_FAIL;
HRESULT result = pPersistPropBag->Save(_p_props, fClearDirty, _p_props->IsEmpty());
pPersistPropBag->Release();
if( FAILED(result) )
return result;
return _p_props->Save(pStm);
};
STDMETHODIMP VLCPersistStreamInit::IsDirty(void)
{
return S_FALSE;
return _p_instance->isDirty() ? S_OK : S_FALSE;
};
STDMETHODIMP VLCPersistStreamInit::GetSizeMax(ULARGE_INTEGER *pcbSize)
{
pcbSize->QuadPart = 0ULL;
pcbSize->HighPart = 0UL;
pcbSize->LowPart = 4096UL; // just a guess
return S_OK;
};
......
......@@ -30,8 +30,8 @@ class VLCPersistStreamInit : public IPersistStreamInit
public:
VLCPersistStreamInit(VLCPlugin *p_instance) : _p_instance(p_instance) {};
virtual ~VLCPersistStreamInit() {};
VLCPersistStreamInit(VLCPlugin *p_instance);
virtual ~VLCPersistStreamInit();
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
......@@ -63,6 +63,7 @@ public:
private:
VLCPlugin *_p_instance;
class VLCPropertyBag *_p_props;
};
#endif
......
......@@ -40,6 +40,10 @@
#include <string.h>
#include <winreg.h>
#include <winuser.h>
#include <servprov.h>
#include <shlwapi.h>
#include <wininet.h>
using namespace std;
......@@ -104,7 +108,7 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :
if( ! GetClassInfo(hInstance, getInPlaceWndClassName(), &wClass) )
{
wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS;
wClass.style = CS_NOCLOSE|CS_DBLCLKS;
wClass.lpfnWndProc = VLCInPlaceClassWndProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
......@@ -124,7 +128,7 @@ VLCPluginClass::VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance) :
if( ! GetClassInfo(hInstance, getVideoWndClassName(), &wClass) )
{
wClass.style = CS_NOCLOSE|CS_HREDRAW|CS_VREDRAW;
wClass.style = CS_NOCLOSE;
wClass.lpfnWndProc = VLCVideoClassWndProc;
wClass.cbClsExtra = 0;
wClass.cbWndExtra = 0;
......@@ -241,17 +245,17 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_inplacewnd(NULL),
_p_class(p_class),
_i_ref(1UL),
_codepage(CP_ACP),
_psz_src(NULL),
_b_autostart(TRUE),
_b_loopmode(FALSE),
_i_codepage(CP_ACP),
_b_usermode(TRUE),
_bstr_mrl(NULL),
_b_autoplay(TRUE),
_b_autoloop(FALSE),
_b_visible(TRUE),
_b_mute(FALSE),
_i_vlc(0)
{
p_class->AddRef();
vlcOleObject = new VLCOleObject(this);
vlcOleControl = new VLCOleControl(this);
vlcOleInPlaceObject = new VLCOleInPlaceObject(this);
vlcOleInPlaceActiveObject = new VLCOleInPlaceActiveObject(this);
......@@ -264,29 +268,28 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
vlcControl = new VLCControl(this);
vlcViewObject = new VLCViewObject(this);
vlcDataObject = new VLCDataObject(this);
vlcOleObject = new VLCOleObject(this);
// configure controlling IUnknown interface for implemented interfaces
this->pUnkOuter = (NULL != pUnkOuter) ? pUnkOuter : dynamic_cast<LPUNKNOWN>(this);
// default picure
_pict = p_class->getInPlacePict();
_p_pict = p_class->getInPlacePict();
// set default/preferred size (320x240) pixels in HIMETRIC
HDC hDC = CreateDevDC(NULL);
_extent.cx = (320*2540L)/GetDeviceCaps(hDC, LOGPIXELSX);
_extent.cy = (240*2540L)/GetDeviceCaps(hDC, LOGPIXELSY);
_extent.cx = 320;
_extent.cy = 240;
HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
DeleteDC(hDC);
};
VLCPlugin::~VLCPlugin()
{
vlcOleInPlaceObject->UIDeactivate();
vlcOleInPlaceObject->InPlaceDeactivate();
delete vlcOleObject;
delete vlcDataObject;
delete vlcViewObject;
delete vlcControl;
delete vlcObjectSafety;
delete vlcConnectionPointContainer;
delete vlcProvideClassInfo;
delete vlcPersistPropertyBag;
......@@ -294,14 +297,13 @@ VLCPlugin::~VLCPlugin()
delete vlcPersistStorage;
delete vlcOleInPlaceActiveObject;
delete vlcOleInPlaceObject;
delete vlcOleControl;
delete vlcOleObject;
delete vlcObjectSafety;
if( _pict )
_pict->Release();
delete vlcOleControl;
if( _p_pict )
_p_pict->Release();
if( _psz_src )
free(_psz_src);
SysFreeString(_bstr_mrl),
_p_class->Release();
};
......@@ -324,7 +326,7 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
else if( IID_IOleInPlaceActiveObject == riid )
*ppv = reinterpret_cast<LPVOID>(vlcOleInPlaceActiveObject);
else if( IID_IPersist == riid )
*ppv = reinterpret_cast<LPVOID>(vlcPersistPropertyBag);
*ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
else if( IID_IPersistStreamInit == riid )
*ppv = reinterpret_cast<LPVOID>(vlcPersistStreamInit);
else if( IID_IPersistStorage == riid )
......@@ -471,8 +473,9 @@ HRESULT VLCPlugin::onInit(void)
{
if( 0 == _i_vlc )
{
#ifdef ACTIVEX_DEBUG
char *ppsz_argv[] = { "vlc", "-vvv", "--fast-mutex", "--win9x-cv-method=1" };
//#ifdef ACTIVEX_DEBUG
#if 1
char *ppsz_argv[] = { "vlc", "-vv", "--fast-mutex", "--win9x-cv-method=1" };
#else
char *ppsz_argv[] = { "vlc", "-vv" };
#endif
......@@ -494,7 +497,7 @@ HRESULT VLCPlugin::onInit(void)
RegCloseKey( h_key );
}
#if 0
#if 1
ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc";
#endif
......@@ -516,33 +519,144 @@ HRESULT VLCPlugin::onLoad(void)
if( _b_mute )
VLC_VolumeMute(_i_vlc);
if( NULL != _psz_src )
if( NULL != _bstr_mrl )
{
// add default target to playlist
char *cOptions[1];
int cOptionsCount = 0;
/*
** try to combine MRL with client site moniker, which for Internet Explorer
** is the URL of the page the plugin is embedded into. Hence, if the MRL
** is a relative URL, we should end up with an absolute URL
*/
IOleClientSite *pClientSite;
if( SUCCEEDED(vlcOleObject->GetClientSite(&pClientSite)) )
{
IBindCtx *pBC = 0;
if( SUCCEEDED(CreateBindCtx(0, &pBC)) )
{
LPMONIKER pContMoniker = NULL;
if( SUCCEEDED(pClientSite->GetMoniker(OLEGETMONIKER_ONLYIFTHERE,
OLEWHICHMK_CONTAINER, &pContMoniker)) )
{
LPOLESTR name;
if( SUCCEEDED(pContMoniker->GetDisplayName(pBC, NULL, &name)) )
{
if( UrlIsW(name, URLIS_URL) )
{
LPOLESTR url = (LPOLESTR)CoTaskMemAlloc(sizeof(OLECHAR)*INTERNET_MAX_URL_LENGTH);
if( NULL != url )
{
DWORD len = INTERNET_MAX_URL_LENGTH;
if( SUCCEEDED(UrlCombineW(name, _bstr_mrl, url, &len,
URL_ESCAPE_UNSAFE)) )
{
SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(url);
}
CoTaskMemFree(url);
}
}
CoTaskMemFree(name);
}
pContMoniker->Release();
}
pBC->Release();
}
pClientSite->Release();
}
if( _b_loopmode )
char *psz_mrl = CStrFromBSTR(CP_UTF8, _bstr_mrl);
if( NULL != psz_mrl )
{
cOptions[cOptionsCount++] = "loop";
// add default target to playlist
char *cOptions[1];
int cOptionsCount = 0;
if( _b_autoloop )
{
cOptions[cOptionsCount++] = "loop";
}
VLC_AddTarget(_i_vlc, psz_mrl, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
CoTaskMemFree(psz_mrl);
}
VLC_AddTarget(_i_vlc, _psz_src, (const char **)&cOptions, cOptionsCount, PLAYLIST_APPEND, PLAYLIST_END);
}
setDirty(FALSE);
return S_OK;
};
HRESULT VLCPlugin::onClientSiteChanged(LPOLECLIENTSITE pActiveSite)
HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
{
if( NULL != pActiveSite )
VARIANT v;
switch( dispID )
{
/*
** object is embedded in container
** try to activate in place if it has already been initialized
*/
if( _i_vlc )
{
vlcOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pActiveSite, 0, NULL, NULL);
}
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:
VariantInit(&v);
V_VT(&v) = VT_BOOL;
if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
{
setUserMode(V_BOOL(&v) != VARIANT_FALSE);
VariantClear(&v);
}
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:
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
{
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;
case DISPID_UNKNOWN:
VariantInit(&v);
V_VT(&v) = VT_BOOL;
if( SUCCEEDED(GetObjectProperty(pContainer, DISPID_AMBIENT_USERMODE, v)) )
{
setUserMode(V_BOOL(&v) != VARIANT_FALSE);
VariantClear(&v);
}
VariantInit(&v);
V_VT(&v) = VT_I4;
if( SUCCEEDED(GetObjectProperty(pContainer, dispID, v)) )
{
setCodePage(V_I4(&v));
}
break;
}
return S_OK;
};
......@@ -593,7 +707,7 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
*/
_inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(),
"VLC Plugin In-Place Window",
WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP,
WS_CHILD|WS_CLIPCHILDREN|WS_CLIPSIBLINGS,
clipRect.left,
clipRect.top,
clipRect.right-clipRect.left,
......@@ -642,8 +756,12 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprc
vlc_value_t val;
val.i_int = reinterpret_cast<int>(_videownd);
VLC_VariableSet(_i_vlc, "drawable", val);
val.i_int = posRect.right-posRect.left;
VLC_VariableSet(_i_vlc, "width", val);
val.i_int = posRect.bottom-posRect.top;
VLC_VariableSet(_i_vlc, "height", val);
if( _b_autostart & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
if( _b_usermode && _b_autoplay & (VLC_PlaylistNumberOfItems(_i_vlc) > 0) )
{
VLC_Play(_i_vlc);
fireOnPlayEvent();
......@@ -691,18 +809,6 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
long width = lprcBounds->right-lprcBounds->left;
long height = lprcBounds->bottom-lprcBounds->top;
SIZEL devSize;
if( NULL != hicTargetDev ) {
devSize.cx = GetDeviceCaps(hicTargetDev, LOGPIXELSX);
devSize.cy = GetDeviceCaps(hicTargetDev, LOGPIXELSY);
}
else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
{
devSize.cx = GetDeviceCaps(hicTargetDev, LOGPIXELSX);
devSize.cy = GetDeviceCaps(hicTargetDev, LOGPIXELSY);
DeleteDC(hicTargetDev);
}
RECT bounds = { lprcBounds->left, lprcBounds->top, lprcBounds->right, lprcBounds->bottom };
FillRect(hdcDraw, &bounds, (HBRUSH)GetStockObject(WHITE_BRUSH));
......@@ -715,25 +821,34 @@ void VLCPlugin::onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
pict->get_Width(&picWidth);
pict->get_Height(&picHeight);
POINT dstSize = { picWidth*devSize.cx/2540L, picHeight*devSize.cy/2540L };
SIZEL picSize = { picWidth, picHeight };
DPtoLP(hdcDraw, &dstSize, 1);
if( dstSize.x > width-4 )
dstSize.x = width-4;
if( dstSize.y > height-4 )
dstSize.y = height-4;
if( NULL != hicTargetDev )
{
DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
}
else if( NULL != (hicTargetDev = CreateDevDC(ptd)) )
{
DPFromHimetric(hicTargetDev, (LPPOINT)&picSize, 1);
DeleteDC(hicTargetDev);
}
if( picSize.cx > width-4 )
picSize.cx = width-4;
if( picSize.cy > height-4 )
picSize.cy = height-4;
long dstX = lprcBounds->left+(width-dstSize.x)/2;
long dstY = lprcBounds->top+(height-dstSize.y)/2;
LONG dstX = lprcBounds->left+(width-picSize.cx)/2;
LONG dstY = lprcBounds->top+(height-picSize.cy)/2;
if( NULL != lprcWBounds )
{
RECT wBounds = { lprcWBounds->left, lprcWBounds->top, lprcWBounds->right, lprcWBounds->bottom };
pict->Render(hdcDraw, dstX, dstY, dstSize.x, dstSize.y,
pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
0L, picHeight, picWidth, -picHeight, &wBounds);
}
else
pict->Render(hdcDraw, dstX, dstY, dstSize.x, dstSize.y,
pict->Render(hdcDraw, dstX, dstY, picSize.cx, picSize.cy,
0L, picHeight, picWidth, -picHeight, NULL);
pict->Release();
......@@ -755,27 +870,41 @@ void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &clipRect)
{
/** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo*/
HDC hdcPict = CreateCompatibleDC(hdc);
if( NULL != hdcPict )
HDC hdcDraw = CreateCompatibleDC(hdc);
if( NULL != hdcDraw )
{
SIZEL size = getExtent();
DPFromHimetric(hdc, (LPPOINT)&size, 1);
RECTL posRect = { 0, 0, size.cx, size.cy };
int width = bounds.right-bounds.left;
int height = bounds.bottom-bounds.top;
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, width, height);
if( NULL != hBitmap )
{
HBITMAP oldBmp = (HBITMAP)SelectObject(hdcPict, hBitmap);
HBITMAP oldBmp = (HBITMAP)SelectObject(hdcDraw, hBitmap);
RECTL rcBounds = { bounds.left, bounds.top, bounds.right, bounds.bottom };
if( (size.cx != width) || (size.cx != height) )
{
// needs to scale canvas
SetMapMode(hdcDraw, MM_ANISOTROPIC);
SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
SetViewportExtEx(hdcDraw, width, height, NULL);
}
onDraw(NULL, hdc, hdcPict, &rcBounds, NULL);
onDraw(NULL, hdc, hdcDraw, &posRect, NULL);
BitBlt(hdc, bounds.left, bounds.top, width, height,
hdcPict, 0, 0, SRCCOPY);
SetMapMode(hdcDraw, MM_TEXT);
BitBlt(hdc, bounds.left, bounds.top,
width, height,
hdcDraw, 0, 0,
SRCCOPY);
SelectObject(hdcPict, oldBmp);
SelectObject(hdcDraw, oldBmp);
DeleteObject(hBitmap);
}
DeleteDC(hdcPict);
DeleteDC(hdcDraw);
}
}
};
......@@ -785,16 +914,11 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
RECT clipRect = *lprcClipRect;
RECT posRect = *lprcPosRect;
/*
** tell container that previous area needs redrawing
*/
InvalidateRect(GetParent(_inplacewnd), &_posRect, TRUE);
//RedrawWindow(GetParent(_inplacewnd), &_posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
/*
** record keeping of control geometry within container
*/
_posRect = posRect;
/*
......@@ -805,35 +929,35 @@ void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
/*
** change in-place window geometry to match clipping region
*/
MoveWindow(_inplacewnd,
SetWindowPos(_inplacewnd, NULL,
clipRect.left,
clipRect.top,
clipRect.right-clipRect.left,
clipRect.bottom-clipRect.top,
FALSE);
SWP_NOACTIVATE|
SWP_NOCOPYBITS|
SWP_NOZORDER|
SWP_NOOWNERZORDER );
/*
** change video window geometry to match object bounds within clipping region
*/
MoveWindow(_videownd,
SetWindowPos(_videownd, NULL,
posRect.left,
posRect.top,
posRect.right-posRect.left,
posRect.bottom-posRect.top,
FALSE);
SWP_NOACTIVATE|
SWP_NOCOPYBITS|
SWP_NOZORDER|
SWP_NOOWNERZORDER );
/*
** force a full refresh of control content
*/
RECT updateRect;
updateRect.left = -posRect.left;
updateRect.top = -posRect.top;
updateRect.right = posRect.right-posRect.left;
updateRect.bottom = posRect.bottom-posRect.top;
ValidateRect(_videownd, NULL);
InvalidateRect(_videownd, &updateRect, FALSE);
UpdateWindow(_videownd);
//RedrawWindow(_videownd, &posRect, NULL, RDW_INVALIDATE|RDW_ERASE|RDW_ALLCHILDREN);
vlc_value_t val;
val.i_int = posRect.right-posRect.left;
VLC_VariableSet(_i_vlc, "width", val);
val.i_int = posRect.bottom-posRect.top;
VLC_VariableSet(_i_vlc, "height", val);
};
void VLCPlugin::freezeEvents(BOOL freeze)
......
......@@ -80,58 +80,109 @@ public:
STDMETHODIMP_(ULONG) Release(void);
/* custom methods */
HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)
{ return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
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 onInit(void);
HRESULT onLoad(void);
HRESULT onClientSiteChanged(LPOLECLIENTSITE pActiveSite);
HRESULT onClose(DWORD dwSaveOption);
/*
** persistant properties
*/
void setMRL(BSTR mrl)
{
SysFreeString(_bstr_mrl);
_bstr_mrl = SysAllocString(mrl);
setDirty(TRUE);
};
const BSTR getMRL(void) { return _bstr_mrl; };
inline void setAutoPlay(BOOL autoplay)
{
_b_autoplay = autoplay;
setDirty(TRUE);
};
inline BOOL getAutoPlay(void) { return _b_autoplay; };
inline void setAutoLoop(BOOL autoloop)
{
_b_autoloop = autoloop;
setDirty(TRUE);
};
inline BOOL getAutoLoop(void) { return _b_autoloop;};
BOOL isInPlaceActive(void);
HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
HRESULT onInPlaceDeactivate(void);
HWND getInPlaceWindow(void) const { return _inplacewnd; };
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
// control size in HIMETRIC
inline void setExtent(const SIZEL& extent)
{
_extent = extent;
setDirty(TRUE);
};
const SIZEL& getExtent(void) { return _extent; };
// transient properties
inline void setMute(BOOL mute) { _b_mute = mute; };
inline void setPicture(LPPICTURE pict)
{
if( NULL != _p_pict )
_p_pict->Release();
if( NULL != pict )
_p_pict->AddRef();
_p_pict = pict;
};
inline LPPICTURE getPicture(void)
{
if( NULL != _p_pict )
_p_pict->AddRef();
return _p_pict;
};
BOOL hasFocus(void);
void setFocus(BOOL fFocus);
UINT getCodePage(void) { return _codepage; };
void setCodePage(UINT cp) { _codepage = cp; };
inline UINT getCodePage(void) { return _i_codepage; };
inline void setCodePage(UINT cp) { _i_codepage = cp; };
int getVLCObject(void) { return _i_vlc; };
inline BOOL isUserMode(void) { return _b_usermode; };
inline void setUserMode(BOOL um) { _b_usermode = um; };
// persistent control properties, may be overriden by HTML & javascript
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) { _b_mute = mute; };
void setVisible(BOOL fVisible);
BOOL getVisible(void) { return _b_visible; };
LPPICTURE getPicture(void) { if( NULL != _pict ) _pict->AddRef(); return _pict; };
// container events
inline BOOL isDirty(void) { return _b_dirty; };
inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return 0 != _i_vlc; };
// control geometry within container
RECT getPosRect(void) { return _posRect; };
inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
BOOL isInPlaceActive(void);
inline int getVLCObject(void) const { return _i_vlc; };
/*
** container events
*/
HRESULT onInit(void);
HRESULT onLoad(void);
HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
HRESULT onInPlaceDeactivate(void);
HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
HRESULT onClose(DWORD dwSaveOption);
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
// control events
/*
** control events
*/
void freezeEvents(BOOL freeze);
void firePropChangedEvent(DISPID dispid);
void fireOnPlayEvent(void);
void fireOnPauseEvent(void);
void fireOnStopEvent(void);
// control size in HIMETRIC
const SIZEL& getExtent(void) { return _extent; };
void setExtent(const SIZEL& extent) { _extent = extent; };
// control geometry within container
RECT getPosRect(void) { return _posRect; };
// controlling IUnknown interface
LPUNKNOWN pUnkOuter;
......@@ -164,13 +215,15 @@ private:
VLCPluginClass *_p_class;
ULONG _i_ref;
LPPICTURE _pict;
UINT _codepage;
char *_psz_src;
BOOL _b_autostart;
BOOL _b_loopmode;
LPPICTURE _p_pict;
UINT _i_codepage;
BOOL _b_usermode;
BSTR _bstr_mrl;
BOOL _b_autoplay;
BOOL _b_autoloop;
BOOL _b_visible;
BOOL _b_mute;
BOOL _b_dirty;
int _i_vlc;
SIZEL _extent;
......
......@@ -13,9 +13,9 @@ Insert VideoLAN.VLCPlugin.1 activex control
-->
<OBJECT classid="clsid:E23FE9C6-778E-49D4-B537-38FCDE4887D8" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab"
width="640" height="480" id="vlc" events="True">
<param name="Src" value="" />
<param name="MRL" value="" />
<param name="ShowDisplay" value="True" />
<param name="Loop" value="False" />
<param name="AutoLoop" value="False" />
<param name="AutoPlay" value="False" />
</OBJECT>
</TD></TR>
......@@ -123,7 +123,7 @@ function doUpdate()
};
function doGo(targetURL)
{
var options = new Array(":input-repeat=1");
var options = new Array(":input-repeat=0");
document.vlc.addTarget(targetURL, options, 4+8, -666);
};
function doPlayOrPause()
......@@ -137,7 +137,7 @@ function doPlayOrPause()
document.vlc.play();
}
};
function vlc::play()
function vlc::Play()
{
if( ! sliderTimerId )
{
......@@ -145,7 +145,7 @@ function vlc::play()
}
onPlay();
};
function vlc::pause()
function vlc::Pause()
{
if( sliderTimerId )
{
......@@ -154,7 +154,7 @@ function vlc::pause()
}
onPause();
};
function vlc::stop()
function vlc::Stop()
{
if( sliderTimerId )
{
......
......@@ -40,7 +40,10 @@ char *CStrFromBSTR(int codePage, BSTR bstr)
char *buffer = (char *)CoTaskMemAlloc(mblen+1);
ZeroMemory(buffer, mblen+1);
if( WideCharToMultiByte(codePage, 0, bstr, len, buffer, mblen, NULL, NULL) )
{
buffer[mblen] = '\0';
return buffer;
}
}
}
return NULL;
......@@ -130,4 +133,29 @@ errReturn:
return hdc;
};
#define HIMETRIC_PER_INCH 2540
void DPFromHimetric(HDC hdc, LPPOINT pt, int count)
{
LONG lpX = GetDeviceCaps(hdc, LOGPIXELSX);
LONG lpY = GetDeviceCaps(hdc, LOGPIXELSY);
while( count-- )
{
pt->x = pt->x*lpX/HIMETRIC_PER_INCH;
pt->y = pt->y*lpY/HIMETRIC_PER_INCH;
++pt;
}
};
void HimetricFromDP(HDC hdc, LPPOINT pt, int count)
{
LONG lpX = GetDeviceCaps(hdc, LOGPIXELSX);
LONG lpY = GetDeviceCaps(hdc, LOGPIXELSY);
while( count-- )
{
pt->x = pt->x*HIMETRIC_PER_INCH/lpX;
pt->y = pt->y*HIMETRIC_PER_INCH/lpY;
++pt;
}
};
......@@ -36,6 +36,9 @@ extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v);
// properties
extern HDC CreateDevDC(DVTARGETDEVICE *ptd);
extern void DPFromHimetric(HDC hdc, LPPOINT pt, int count);
extern void HimetricFromDP(HDC hdc, LPPOINT pt, int count);
// enumeration
template<class T> class VLCEnum : IUnknown
......
......@@ -33,7 +33,35 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
{
if( dwAspect & DVASPECT_CONTENT )
{
_p_instance->onDraw(ptd, hicTargetDev, hdcDraw, lprcBounds, lprcWBounds);
if( NULL == lprcBounds )
return E_INVALIDARG;
BOOL releaseDC = FALSE;
SIZEL size = _p_instance->getExtent();
if( NULL == ptd )
{
hicTargetDev = CreateDevDC(NULL);
releaseDC = TRUE;
}
DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
RECTL bounds = { 0L, 0L, size.cx, size.cy };
int sdc = SaveDC(hdcDraw);
SetMapMode(hdcDraw, MM_ANISOTROPIC);
SetWindowOrgEx(hdcDraw, 0, 0, NULL);
SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
lprcBounds->bottom-lprcBounds->top, NULL);
_p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
RestoreDC(hdcDraw, sdc);
if( releaseDC )
DeleteDC(hicTargetDev);
return S_OK;
}
return E_NOTIMPL;
......
......@@ -126,26 +126,6 @@ STDMETHODIMP VLCControl::play(void)
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
if( ! _p_instance->isInPlaceActive() )
{
/*
** object has not yet been activated. try doing it by ourself
** if parent container is known
*/
LPOLEOBJECT p_oleobject;
if( SUCCEEDED(QueryInterface(IID_IOleObject, (LPVOID *)&p_oleobject)) )
{
LPOLECLIENTSITE p_clientsite;
if( SUCCEEDED(p_oleobject->GetClientSite(&p_clientsite)
&& (NULL != p_clientsite)) )
{
p_oleobject->DoVerb(OLEIVERB_INPLACEACTIVATE,
NULL, p_clientsite, 0, NULL, NULL);
p_clientsite->Release();
}
p_oleobject->Release();
}
}
VLC_Play(i_vlc);
_p_instance->fireOnPlayEvent();
return NOERROR;
......@@ -175,7 +155,7 @@ STDMETHODIMP VLCControl::stop(void)
return NOERROR;
}
return E_UNEXPECTED;
}
};
STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
{
......@@ -192,26 +172,6 @@ STDMETHODIMP VLCControl::get_Playing(VARIANT_BOOL *isPlaying)
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 )
......@@ -360,7 +320,7 @@ STDMETHODIMP VLCControl::toggleMute(void)
return E_UNEXPECTED;
};
STDMETHODIMP VLCControl::setVariable( BSTR name, VARIANT value)
STDMETHODIMP VLCControl::setVariable(BSTR name, VARIANT value)
{
if( 0 == SysStringLen(name) )
return E_INVALIDARG;
......@@ -755,27 +715,26 @@ STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistM
int i_vlc = _p_instance->getVLCObject();
if( i_vlc )
{
int codePage = _p_instance->getCodePage();
char *cUri = CStrFromBSTR(codePage, uri);
char *cUri = CStrFromBSTR(CP_UTF8, uri);
if( NULL == cUri )
return E_OUTOFMEMORY;
int cOptionsCount;
char **cOptions;
if( FAILED(createTargetOptions(codePage, &options, &cOptions, &cOptionsCount)) )
if( FAILED(createTargetOptions(CP_UTF8, &options, &cOptions, &cOptionsCount)) )
return E_INVALIDARG;
if( VLC_SUCCESS <= VLC_AddTarget(i_vlc, cUri, (const char **)cOptions, cOptionsCount, mode, position) )
{
hr = NOERROR;
if( mode & VLCPlayListGo )
if( mode & PLAYLIST_GO )
_p_instance->fireOnPlayEvent();
}
else
{
hr = E_FAIL;
if( mode & VLCPlayListGo )
if( mode & PLAYLIST_GO )
_p_instance->fireOnStopEvent();
}
......@@ -861,3 +820,49 @@ STDMETHODIMP VLCControl::get_VersionInfo(BSTR *version)
return E_FAIL;
};
STDMETHODIMP VLCControl::get_MRL(BSTR *mrl)
{
if( NULL == mrl )
return E_POINTER;
*mrl = SysAllocString(_p_instance->getMRL());
return NOERROR;
};
STDMETHODIMP VLCControl::put_MRL(BSTR mrl)
{
_p_instance->setMRL(mrl);
return S_OK;
};
STDMETHODIMP VLCControl::get_AutoPlay(VARIANT_BOOL *autoplay)
{
if( NULL == autoplay )
return E_POINTER;
*autoplay = _p_instance->getAutoPlay() ? VARIANT_TRUE: VARIANT_FALSE;
return S_OK;
};
STDMETHODIMP VLCControl::put_AutoPlay(VARIANT_BOOL autoplay)
{
_p_instance->setAutoPlay((VARIANT_FALSE != autoplay) ? TRUE: FALSE);
return S_OK;
};
STDMETHODIMP VLCControl::get_AutoLoop(VARIANT_BOOL *autoloop)
{
if( NULL == autoloop )
return E_POINTER;
*autoloop = _p_instance->getAutoLoop() ? VARIANT_TRUE: VARIANT_FALSE;
return S_OK;
};
STDMETHODIMP VLCControl::put_AutoLoop(VARIANT_BOOL autoloop)
{
_p_instance->setAutoLoop((VARIANT_FALSE != autoloop) ? TRUE: FALSE);
return S_OK;
};
......@@ -64,7 +64,6 @@ public:
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);
......@@ -86,6 +85,12 @@ public:
STDMETHODIMP playlistPrev(void);
STDMETHODIMP playlistClear(void);
STDMETHODIMP get_VersionInfo(BSTR *version);
STDMETHODIMP get_MRL(BSTR *mrl);
STDMETHODIMP put_MRL(BSTR mrl);
STDMETHODIMP get_AutoLoop(VARIANT_BOOL *autoloop);
STDMETHODIMP put_AutoLoop(VARIANT_BOOL autoloop);
STDMETHODIMP get_AutoPlay(VARIANT_BOOL *autoplay);
STDMETHODIMP put_AutoPlay(VARIANT_BOOL autoplay);
private:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment