Commit ffb98b35 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

activex: Remove unused wrappers & use libvlcpp

parent 61c98d59
...@@ -56,7 +56,7 @@ using namespace std; ...@@ -56,7 +56,7 @@ using namespace std;
#define THREADING_MODEL "Apartment" #define THREADING_MODEL "Apartment"
#define MISC_STATUS "131473" #define MISC_STATUS "131473"
#define PROGID_STR COMPANY_STR"."PROGRAM_STR #define PROGID_STR COMPANY_STR "." PROGRAM_STR
#define GUID_STRLEN 39 #define GUID_STRLEN 39
......
...@@ -43,17 +43,13 @@ VLCOleObject::~VLCOleObject() ...@@ -43,17 +43,13 @@ VLCOleObject::~VLCOleObject()
STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection) STDMETHODIMP VLCOleObject::Advise(IAdviseSink *pAdvSink, DWORD *dwConnection)
{ {
return _p_advise_holder->Advise(pAdvSink, dwConnection); return _p_advise_holder->Advise(pAdvSink, dwConnection);
}; }
STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption) STDMETHODIMP VLCOleObject::Close(DWORD dwSaveOption)
{ {
if( _p_instance->isRunning() ) _p_advise_holder->SendOnClose();
{ return _p_instance->onClose(dwSaveOption);
_p_advise_holder->SendOnClose(); }
return _p_instance->onClose(dwSaveOption);
}
return S_OK;
};
STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite, STDMETHODIMP VLCOleObject::DoVerb(LONG iVerb, LPMSG lpMsg, LPOLECLIENTSITE pActiveSite,
LONG, HWND hwndParent, LPCRECT lprcPosRect) LONG, HWND hwndParent, LPCRECT lprcPosRect)
......
...@@ -222,7 +222,6 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : ...@@ -222,7 +222,6 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
_WindowsManager(DllGetModule(), _ViewRC, this), _WindowsManager(DllGetModule(), _ViewRC, this),
_p_class(p_class), _p_class(p_class),
_i_ref(1UL), _i_ref(1UL),
_p_libvlc(NULL),
_i_codepage(CP_ACP), _i_codepage(CP_ACP),
_b_usermode(TRUE) _b_usermode(TRUE)
{ {
...@@ -280,18 +279,12 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) : ...@@ -280,18 +279,12 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter) :
// make sure that persistable properties are initialized // make sure that persistable properties are initialized
onInit(); onInit();
};
initVLC();
}
VLCPlugin::~VLCPlugin() VLCPlugin::~VLCPlugin()
{ {
if( vlc_player::is_open() )
{
if( isPlaying() )
playlist_stop();
player_unregister_events();
}
delete vlcSupportErrorInfo; delete vlcSupportErrorInfo;
delete vlcOleObject; delete vlcOleObject;
delete vlcDataObject; delete vlcDataObject;
...@@ -314,10 +307,8 @@ VLCPlugin::~VLCPlugin() ...@@ -314,10 +307,8 @@ VLCPlugin::~VLCPlugin()
SysFreeString(_bstr_mrl); SysFreeString(_bstr_mrl);
SysFreeString(_bstr_baseurl); SysFreeString(_bstr_baseurl);
if( _p_libvlc ) { libvlc_release(_p_libvlc); _p_libvlc=NULL; }
_p_class->Release(); _p_class->Release();
}; }
STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv) STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
{ {
...@@ -390,35 +381,30 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void) ...@@ -390,35 +381,30 @@ STDMETHODIMP_(ULONG) VLCPlugin::Release(void)
return 0; return 0;
} }
return _i_ref; return _i_ref;
}; }
////////////////////////////////////// //////////////////////////////////////
HRESULT VLCPlugin::onInit(void) HRESULT VLCPlugin::onInit(void)
{ {
if( NULL == _p_libvlc ) // initialize persistable properties
{ set_autoplay(true);
// initialize persistable properties _b_autoloop = FALSE;
set_autoplay(true); _bstr_baseurl = NULL;
_b_autoloop = FALSE; _bstr_mrl = NULL;
_bstr_baseurl = NULL; _b_visible = TRUE;
_bstr_mrl = NULL; _b_mute = FALSE;
_b_visible = TRUE; _i_volume = 50;
_b_mute = FALSE; _i_time = 0;
_i_volume = 50; _i_backcolor = 0;
_i_time = 0; // set default/preferred size (320x240) pixels in HIMETRIC
_i_backcolor = 0; HDC hDC = CreateDevDC(NULL);
// set default/preferred size (320x240) pixels in HIMETRIC _extent.cx = 320;
HDC hDC = CreateDevDC(NULL); _extent.cy = 240;
_extent.cx = 320; HimetricFromDP(hDC, (LPPOINT)&_extent, 1);
_extent.cy = 240; DeleteDC(hDC);
HimetricFromDP(hDC, (LPPOINT)&_extent, 1); return S_OK;
DeleteDC(hDC); }
return S_OK;
}
return CO_E_ALREADYINITIALIZED;
};
HRESULT VLCPlugin::onLoad(void) HRESULT VLCPlugin::onLoad(void)
{ {
...@@ -457,26 +443,30 @@ HRESULT VLCPlugin::onLoad(void) ...@@ -457,26 +443,30 @@ HRESULT VLCPlugin::onLoad(void)
} }
setDirty(FALSE); setDirty(FALSE);
return S_OK; return S_OK;
}; }
void VLCPlugin::initVLC() void VLCPlugin::initVLC()
{ {
static const char * const ppsz_argv[] = { try
"-vv", {
"--no-stats", static const char * const ppsz_argv[] = {
"--intf=dummy", "-vv",
"--no-video-title-show", "--no-stats",
}; "--intf=dummy",
"--no-video-title-show",
_p_libvlc = libvlc_new(sizeof(ppsz_argv) / sizeof(*ppsz_argv), ppsz_argv); };
if( !_p_libvlc )
return; auto instance = VLC::Instance( sizeof(ppsz_argv) / sizeof(*ppsz_argv), ppsz_argv );
if( !m_player.open( instance ) )
if( !vlc_player::open(_p_libvlc) ) return;
}
catch (std::runtime_error&)
{
return; return;
}
vlc_player::set_mode(_b_autoloop ? libvlc_playback_mode_loop : get_player().mlp().setPlaybackMode( _b_autoloop ? libvlc_playback_mode_loop :
libvlc_playback_mode_default); libvlc_playback_mode_default );
// register player events // register player events
player_register_events(); player_register_events();
...@@ -521,7 +511,7 @@ void VLCPlugin::initVLC() ...@@ -521,7 +511,7 @@ void VLCPlugin::initVLC()
options[i_options++] = timeBuffer; options[i_options++] = timeBuffer;
} }
// add default target to playlist // add default target to playlist
playlist_add_extended_untrusted(psz_mrl, i_options, options); m_player.add_item( psz_mrl, i_options, options);
CoTaskMemFree(psz_mrl); CoTaskMemFree(psz_mrl);
} }
} }
...@@ -630,7 +620,7 @@ HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID) ...@@ -630,7 +620,7 @@ HRESULT VLCPlugin::onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID)
break; break;
} }
return S_OK; return S_OK;
}; }
HRESULT VLCPlugin::onClose(DWORD) HRESULT VLCPlugin::onClose(DWORD)
{ {
...@@ -638,23 +628,14 @@ HRESULT VLCPlugin::onClose(DWORD) ...@@ -638,23 +628,14 @@ HRESULT VLCPlugin::onClose(DWORD)
{ {
onInPlaceDeactivate(); onInPlaceDeactivate();
} }
if( isRunning() ) vlcDataObject->onClose();
{
libvlc_instance_t* p_libvlc = _p_libvlc;
_p_libvlc = NULL;
vlcDataObject->onClose();
if( p_libvlc )
libvlc_release(p_libvlc);
}
return S_OK; return S_OK;
}; }
BOOL VLCPlugin::isInPlaceActive(void) BOOL VLCPlugin::isInPlaceActive(void)
{ {
return (NULL != _inplacewnd); return (NULL != _inplacewnd);
}; }
HRESULT VLCPlugin::onActivateInPlace(LPMSG, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect) HRESULT VLCPlugin::onActivateInPlace(LPMSG, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{ {
...@@ -701,15 +682,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG, HWND hwndParent, LPCRECT lprcPosRect ...@@ -701,15 +682,9 @@ HRESULT VLCPlugin::onActivateInPlace(LPMSG, HWND hwndParent, LPCRECT lprcPosRect
if( _b_usermode ) if( _b_usermode )
{ {
/* will run vlc if not done already */
libvlc_instance_t* p_libvlc;
HRESULT result = getVLC(&p_libvlc);
if( FAILED(result) )
return result;
if( get_autoplay() ) if( get_autoplay() )
{ {
vlc_player::play(0); get_player().play();
} }
} }
...@@ -726,9 +701,9 @@ void VLCPlugin::toggleFullscreen() ...@@ -726,9 +701,9 @@ void VLCPlugin::toggleFullscreen()
HRESULT VLCPlugin::onInPlaceDeactivate(void) HRESULT VLCPlugin::onInPlaceDeactivate(void)
{ {
if( isPlaying() ) if( m_player.mlp().isPlaying() )
{ {
playlist_stop(); m_player.mlp().stop();
fireOnStopEvent(); fireOnStopEvent();
} }
...@@ -766,16 +741,10 @@ void VLCPlugin::setVolume(int volume) ...@@ -766,16 +741,10 @@ void VLCPlugin::setVolume(int volume)
if( volume != _i_volume ) if( volume != _i_volume )
{ {
_i_volume = volume; _i_volume = volume;
if( isRunning() ) if ( m_player.get_mp().setVolume( volume ) )
{ setDirty(TRUE);
libvlc_media_player_t *p_md;
HRESULT hr = getMD(&p_md);
if( SUCCEEDED(hr) )
libvlc_audio_set_volume(p_md, _i_volume);
}
setDirty(TRUE);
} }
}; }
void VLCPlugin::setBackColor(OLE_COLOR backcolor) void VLCPlugin::setBackColor(OLE_COLOR backcolor)
{ {
...@@ -798,12 +767,9 @@ void VLCPlugin::setTime(int seconds) ...@@ -798,12 +767,9 @@ void VLCPlugin::setTime(int seconds)
if( seconds != _i_time ) if( seconds != _i_time )
{ {
setStartTime(_i_time); setStartTime(_i_time);
if( vlc_player::is_open() ) m_player.get_mp().setTime( _i_time );
{
vlc_player::set_time(_i_time);
}
} }
}; }
void VLCPlugin::setFocus(BOOL fFocus) void VLCPlugin::setFocus(BOOL fFocus)
{ {
...@@ -1082,47 +1048,6 @@ void VLCPlugin::fireOnMediaPlayerBackwardEvent() ...@@ -1082,47 +1048,6 @@ void VLCPlugin::fireOnMediaPlayerBackwardEvent()
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBackwardEvent, &dispparamsNoArgs); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerBackwardEvent, &dispparamsNoArgs);
}; };
static void handle_input_state_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
switch( event->type )
{
case libvlc_MediaPlayerMediaChanged:
plugin->fireOnMediaPlayerMediaChangedEvent();
break;
case libvlc_MediaPlayerNothingSpecial:
plugin->fireOnMediaPlayerNothingSpecialEvent();
break;
case libvlc_MediaPlayerOpening:
plugin->fireOnMediaPlayerOpeningEvent();
break;
case libvlc_MediaPlayerBuffering:
plugin->fireOnMediaPlayerBufferingEvent(event->u.media_player_buffering.new_cache);
break;
case libvlc_MediaPlayerPlaying:
plugin->fireOnMediaPlayerPlayingEvent();
break;
case libvlc_MediaPlayerPaused:
plugin->fireOnMediaPlayerPausedEvent();
break;
case libvlc_MediaPlayerStopped:
plugin->fireOnMediaPlayerStoppedEvent();
break;
case libvlc_MediaPlayerForward:
plugin->fireOnMediaPlayerForwardEvent();
break;
case libvlc_MediaPlayerBackward:
plugin->fireOnMediaPlayerBackwardEvent();
break;
case libvlc_MediaPlayerEndReached:
plugin->fireOnMediaPlayerEndReachedEvent();
break;
case libvlc_MediaPlayerEncounteredError:
plugin->fireOnMediaPlayerEncounteredErrorEvent();
break;
}
}
void VLCPlugin::fireOnMediaPlayerTimeChangedEvent(libvlc_time_t time) void VLCPlugin::fireOnMediaPlayerTimeChangedEvent(libvlc_time_t time)
{ {
DISPPARAMS params; DISPPARAMS params;
...@@ -1136,12 +1061,6 @@ void VLCPlugin::fireOnMediaPlayerTimeChangedEvent(libvlc_time_t time) ...@@ -1136,12 +1061,6 @@ void VLCPlugin::fireOnMediaPlayerTimeChangedEvent(libvlc_time_t time)
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTimeChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTimeChangedEvent, &params);
}; };
static void handle_time_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerTimeChangedEvent(event->u.media_player_time_changed.new_time);
}
void VLCPlugin::fireOnMediaPlayerPositionChangedEvent(float position) void VLCPlugin::fireOnMediaPlayerPositionChangedEvent(float position)
{ {
DISPPARAMS params; DISPPARAMS params;
...@@ -1155,13 +1074,6 @@ void VLCPlugin::fireOnMediaPlayerPositionChangedEvent(float position) ...@@ -1155,13 +1074,6 @@ void VLCPlugin::fireOnMediaPlayerPositionChangedEvent(float position)
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPositionChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPositionChangedEvent, &params);
}; };
static void handle_position_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerPositionChangedEvent(event->u.media_player_position_changed.new_position);
}
#define B(val) ((val) ? 0xFFFF : 0x0000)
void VLCPlugin::fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable) void VLCPlugin::fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable)
{ {
DISPPARAMS params; DISPPARAMS params;
...@@ -1173,12 +1085,6 @@ void VLCPlugin::fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable) ...@@ -1173,12 +1085,6 @@ void VLCPlugin::fireOnMediaPlayerSeekableChangedEvent(VARIANT_BOOL seekable)
params.rgdispidNamedArgs = NULL; params.rgdispidNamedArgs = NULL;
params.cNamedArgs = 0; params.cNamedArgs = 0;
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerSeekableChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerSeekableChangedEvent, &params);
};
static void handle_seekable_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerSeekableChangedEvent(B(event->u.media_player_seekable_changed.new_seekable));
} }
void VLCPlugin::fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable) void VLCPlugin::fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable)
...@@ -1194,13 +1100,6 @@ void VLCPlugin::fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable) ...@@ -1194,13 +1100,6 @@ void VLCPlugin::fireOnMediaPlayerPausableChangedEvent(VARIANT_BOOL pausable)
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPausableChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerPausableChangedEvent, &params);
}; };
static void handle_pausable_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerPausableChangedEvent(B(event->u.media_player_pausable_changed.new_pausable));
}
#undef B
void VLCPlugin::fireOnMediaPlayerTitleChangedEvent(int title) void VLCPlugin::fireOnMediaPlayerTitleChangedEvent(int title)
{ {
DISPPARAMS params; DISPPARAMS params;
...@@ -1214,12 +1113,6 @@ void VLCPlugin::fireOnMediaPlayerTitleChangedEvent(int title) ...@@ -1214,12 +1113,6 @@ void VLCPlugin::fireOnMediaPlayerTitleChangedEvent(int title)
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTitleChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerTitleChangedEvent, &params);
}; };
static void handle_title_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerTitleChangedEvent(event->u.media_player_title_changed.new_title);
}
void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length) void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length)
{ {
DISPPARAMS params; DISPPARAMS params;
...@@ -1231,12 +1124,6 @@ void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length) ...@@ -1231,12 +1124,6 @@ void VLCPlugin::fireOnMediaPlayerLengthChangedEvent(long length)
params.rgdispidNamedArgs = NULL; params.rgdispidNamedArgs = NULL;
params.cNamedArgs = 0; params.cNamedArgs = 0;
vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params); vlcConnectionPointContainer->fireEvent(DISPID_MediaPlayerLengthChangedEvent, &params);
};
static void handle_length_changed_event(const libvlc_event_t* event, void *param)
{
VLCPlugin *plugin = (VLCPlugin*)param;
plugin->fireOnMediaPlayerLengthChangedEvent(event->u.media_player_length_changed.new_length);
} }
/* */ /* */
...@@ -1246,56 +1133,62 @@ void VLCPlugin::set_player_window() ...@@ -1246,56 +1133,62 @@ void VLCPlugin::set_player_window()
_WindowsManager.LibVlcAttach( &get_player() ); _WindowsManager.LibVlcAttach( &get_player() );
} }
static vlcplugin_event_t vlcevents[] = { #define B(val) ((val) ? 0xFFFF : 0x0000)
{ libvlc_MediaPlayerMediaChanged, handle_input_state_event },
{ libvlc_MediaPlayerNothingSpecial, handle_input_state_event },
{ libvlc_MediaPlayerOpening, handle_input_state_event },
{ libvlc_MediaPlayerBuffering, handle_input_state_event },
{ libvlc_MediaPlayerPlaying, handle_input_state_event },
{ libvlc_MediaPlayerPaused, handle_input_state_event },
{ libvlc_MediaPlayerStopped, handle_input_state_event },
{ libvlc_MediaPlayerForward, handle_input_state_event },
{ libvlc_MediaPlayerBackward, handle_input_state_event },
{ libvlc_MediaPlayerEndReached, handle_input_state_event },
{ libvlc_MediaPlayerEncounteredError, handle_input_state_event },
{ libvlc_MediaPlayerTimeChanged, handle_time_changed_event },
{ libvlc_MediaPlayerPositionChanged, handle_position_changed_event },
{ libvlc_MediaPlayerSeekableChanged, handle_seekable_changed_event },
{ libvlc_MediaPlayerPausableChanged, handle_pausable_changed_event },
{ libvlc_MediaPlayerTitleChanged, handle_title_changed_event },
{ libvlc_MediaPlayerLengthChanged, handle_length_changed_event },
};
void VLCPlugin::player_register_events() void VLCPlugin::player_register_events()
{ {
libvlc_event_manager_t *eventManager = NULL; auto& em = m_player.get_mp().eventManager();
assert(vlc_player::is_open()); em.onMediaChanged([this](VLC::MediaPtr) {
fireOnMediaPlayerMediaChangedEvent();
eventManager = libvlc_media_player_event_manager(vlc_player::get_mp()); });
if(eventManager) { em.onNothingSpecial([this] {
/* attach all libvlc events we care about */ fireOnMediaPlayerNothingSpecialEvent();
for( size_t i = 0; i < ARRAY_SIZE(vlcevents); i++ ) });
{ em.onOpening([this] {
libvlc_event_attach( eventManager, vlcevents[i].libvlc_type, fireOnMediaPlayerOpeningEvent();
vlcevents[i].libvlc_callback, });
this ); em.onBuffering([this](float b) {
} fireOnMediaPlayerBufferingEvent(b);
} });
em.onPlaying([this] {
fireOnMediaPlayerPlayingEvent();
});
em.onPaused([this] {
fireOnMediaPlayerPausedEvent();
});
em.onStopped([this] {
fireOnMediaPlayerStoppedEvent();
});
em.onForward([this] {
fireOnMediaPlayerForwardEvent();
});
em.onBackward([this] {
fireOnMediaPlayerBackwardEvent();
});
em.onEndReached([this] {
fireOnMediaPlayerEndReachedEvent();
});
em.onEncounteredError([this] {
fireOnMediaPlayerEncounteredErrorEvent();
});
em.onTimeChanged([this] (int64_t time) {
fireOnMediaPlayerTimeChangedEvent( time );
});
em.onPositionChanged([this](float pos) {
fireOnMediaPlayerPositionChangedEvent( pos );
});
em.onSeekableChanged([this](bool b) {
fireOnMediaPlayerSeekableChangedEvent( B( b ) );
});
em.onPausableChanged([this](bool b) {
fireOnMediaPlayerPausableChangedEvent( B( b ) );
});
em.onTitleChanged([this](int t) {
fireOnMediaPlayerTitleChangedEvent( t );
});
em.onLengthChanged( [this]( int64_t length ) {
fireOnMediaPlayerLengthChangedEvent( length );
});
} }
void VLCPlugin::player_unregister_events() #undef B
{
libvlc_event_manager_t *eventManager = NULL;
assert(vlc_player::is_open());
eventManager = libvlc_media_player_event_manager(vlc_player::get_mp());
if(eventManager) {
/* detach all libvlc events we cared about */
for( size_t i = 0; i < ARRAY_SIZE(vlcevents); i++ )
{
libvlc_event_detach( eventManager, vlcevents[i].libvlc_type,
vlcevents[i].libvlc_callback,
this );
}
}
}
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <olectl.h> #include <olectl.h>
#include "../common/win32_fullscreen.h" #include "../common/win32_fullscreen.h"
#include "../common/vlc_player.h"
extern "C" const GUID CLSID_VLCPlugin; extern "C" const GUID CLSID_VLCPlugin;
extern "C" const GUID CLSID_VLCPlugin2; extern "C" const GUID CLSID_VLCPlugin2;
...@@ -39,11 +40,6 @@ extern "C" const GUID DIID_DVLCEvents; ...@@ -39,11 +40,6 @@ extern "C" const GUID DIID_DVLCEvents;
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
typedef struct {
const libvlc_event_type_t libvlc_type; /* libvlc event type */
libvlc_callback_t libvlc_callback; /* libvlc callback function */
} vlcplugin_event_t;
class VLCPluginClass : public IClassFactory class VLCPluginClass : public IClassFactory
{ {
...@@ -82,7 +78,7 @@ private: ...@@ -82,7 +78,7 @@ private:
}; };
class VLCPlugin class VLCPlugin
: public IUnknown, private vlc_player_options, private vlc_player : public IUnknown, private vlc_player_options
{ {
public: public:
VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter); VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
...@@ -99,8 +95,7 @@ public: ...@@ -99,8 +95,7 @@ public:
vlc_player& get_player() vlc_player& get_player()
{ {
if( !vlc_player::is_open() ) initVLC(); return m_player;
return *static_cast<vlc_player*>(this);
} }
vlc_player_options& get_options() vlc_player_options& get_options()
...@@ -129,10 +124,8 @@ public: ...@@ -129,10 +124,8 @@ public:
inline void setAutoLoop(BOOL autoloop) inline void setAutoLoop(BOOL autoloop)
{ {
_b_autoloop = autoloop; _b_autoloop = autoloop;
if( vlc_player::is_open() ){ get_player().mlp().setPlaybackMode( autoloop ? libvlc_playback_mode_loop :
vlc_player::set_mode(autoloop ? libvlc_playback_mode_loop : libvlc_playback_mode_default );
libvlc_playback_mode_default);
}
setDirty(TRUE); setDirty(TRUE);
}; };
inline BOOL getAutoLoop(void) { return _b_autoloop;}; inline BOOL getAutoLoop(void) { return _b_autoloop;};
...@@ -218,20 +211,6 @@ public: ...@@ -218,20 +211,6 @@ public:
inline BOOL isDirty(void) { return _b_dirty; }; inline BOOL isDirty(void) { return _b_dirty; };
inline void setDirty(BOOL dirty) { _b_dirty = dirty; }; inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
inline BOOL isRunning(void) { return NULL != _p_libvlc; };
HRESULT getVLC(libvlc_instance_t** pp_libvlc)
{
if( !isRunning() )
initVLC();
*pp_libvlc = _p_libvlc;
return _p_libvlc ? S_OK : E_FAIL;
}
HRESULT getMD(libvlc_media_player_t **pp_md)
{
*pp_md = get_player().get_mp();
return *pp_md ? S_OK : E_FAIL;
}
void setErrorInfo(REFIID riid, const char *description); void setErrorInfo(REFIID riid, const char *description);
// control geometry within container // control geometry within container
...@@ -288,58 +267,6 @@ public: ...@@ -288,58 +267,6 @@ public:
// controlling IUnknown interface // controlling IUnknown interface
LPUNKNOWN pUnkOuter; LPUNKNOWN pUnkOuter;
/*
** libvlc interface
*/
bool isPlaying()
{
return get_player().is_playing();
}
int playlist_get_current_index()
{
return get_player().current_item();
}
int playlist_add_extended_untrusted(const char *mrl, int optc, const char **optv)
{
return get_player().add_item(mrl, optc, optv);
}
void playlist_delete_item(int idx)
{
get_player().delete_item(idx);
}
void playlist_clear()
{
get_player().clear_items();
}
int playlist_count()
{
return get_player().items_count();
}
void playlist_pause()