]> git.sesse.net Git - vlc/blobdiff - activex/vlccontrol2.cpp
Also remove --rc-unix from Win32 port for obvious reasons
[vlc] / activex / vlccontrol2.cpp
old mode 100755 (executable)
new mode 100644 (file)
index de0b288..4d88247
@@ -4,6 +4,7 @@
  * Copyright (C) 2006 the VideoLAN team
  *
  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
+ *          Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 
 #include "utils.h"
 
+#include <shlwapi.h>
+#include <wininet.h>
+#include <tchar.h>
+
 using namespace std;
 
 VLCAudio::~VLCAudio()
@@ -83,7 +88,7 @@ STDMETHODIMP VLCAudio::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
+STDMETHODIMP VLCAudio::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
         UINT cNames, LCID lcid, DISPID* rgDispID)
 {
     if( SUCCEEDED(loadTypeInfo()) )
@@ -150,7 +155,7 @@ STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
     return hr;
 };
 
-STDMETHODIMP VLCAudio::get_volume(int* volume)
+STDMETHODIMP VLCAudio::get_volume(long* volume)
 {
     if( NULL == volume )
         return E_POINTER;
@@ -174,7 +179,7 @@ STDMETHODIMP VLCAudio::get_volume(int* volume)
     return hr;
 };
 
-STDMETHODIMP VLCAudio::put_volume(int volume)
+STDMETHODIMP VLCAudio::put_volume(long volume)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -186,7 +191,106 @@ STDMETHODIMP VLCAudio::put_volume(int volume)
         libvlc_audio_set_volume(p_libvlc, volume, &ex);
         if( libvlc_exception_raised(&ex) )
         {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                         libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::get_track(long* track)
+{
+    if( NULL == track )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        *track = libvlc_audio_get_track(p_input, &ex);
+        libvlc_input_free(p_input);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                         libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::put_track(long track)
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        libvlc_audio_set_track(p_input, track, &ex);
+        libvlc_input_free(p_input);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                         libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::get_channel(long *channel)
+{
+    if( NULL == channel )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        *channel = libvlc_audio_get_channel(p_libvlc, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                        libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::put_channel(long channel)
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_audio_set_channel(p_libvlc, channel, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                         libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
@@ -207,7 +311,8 @@ STDMETHODIMP VLCAudio::toggleMute()
         libvlc_audio_toggle_mute(p_libvlc, &ex);
         if( libvlc_exception_raised(&ex) )
         {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
+            _p_instance->setErrorInfo(IID_IVLCAudio,
+                         libvlc_exception_get_message(&ex));
             libvlc_exception_clear(&ex);
             return E_FAIL;
         }
@@ -273,7 +378,7 @@ STDMETHODIMP VLCInput::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
+STDMETHODIMP VLCInput::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
         UINT cNames, LCID lcid, DISPID* rgDispID)
 {
     if( SUCCEEDED(loadTypeInfo()) )
@@ -324,7 +429,7 @@ STDMETHODIMP VLCInput::get_length(double* length)
     return hr;
 };
 
-STDMETHODIMP VLCInput::get_position(float* position)
+STDMETHODIMP VLCInput::get_position(double* position)
 {
     if( NULL == position )
         return E_POINTER;
@@ -353,7 +458,7 @@ STDMETHODIMP VLCInput::get_position(float* position)
     return hr;
 };
 
-STDMETHODIMP VLCInput::put_position(float position)
+STDMETHODIMP VLCInput::put_position(double position)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -434,7 +539,7 @@ STDMETHODIMP VLCInput::put_time(double time)
     return hr;
 };
 
-STDMETHODIMP VLCInput::get_state(int* state)
+STDMETHODIMP VLCInput::get_state(long* state)
 {
     if( NULL == state )
         return E_POINTER;
@@ -464,7 +569,7 @@ STDMETHODIMP VLCInput::get_state(int* state)
     return hr;
 };
 
-STDMETHODIMP VLCInput::get_rate(float* rate)
+STDMETHODIMP VLCInput::get_rate(double* rate)
 {
     if( NULL == rate )
         return E_POINTER;
@@ -493,7 +598,7 @@ STDMETHODIMP VLCInput::get_rate(float* rate)
     return hr;
 };
 
-STDMETHODIMP VLCInput::put_rate(float rate)
+STDMETHODIMP VLCInput::put_rate(double rate)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -519,11 +624,12 @@ STDMETHODIMP VLCInput::put_rate(float rate)
     return hr;
 };
 
-STDMETHODIMP VLCInput::get_fps(float* fps)
+STDMETHODIMP VLCInput::get_fps(double* fps)
 {
     if( NULL == fps )
         return E_POINTER;
 
+    *fps = 0.0;
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
@@ -541,18 +647,884 @@ STDMETHODIMP VLCInput::get_fps(float* fps)
                 return NOERROR;
             }
         }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
+{
+    if( NULL == hasVout )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            *hasVout = libvlc_input_has_vout(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                return NOERROR;
+            }
+        }
+        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+/*******************************************************************************/
+
+VLCLog::~VLCLog()
+{
+    delete _p_vlcmessages;
+    if( _p_log )
+        libvlc_log_close(_p_log, NULL);
+
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCLog::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCLog, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCLog::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCLog::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCLog::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCLog::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCLog::get_messages(IVLCMessages** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcmessages;
+    if( NULL != _p_vlcmessages )
+    {
+        _p_vlcmessages->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
+STDMETHODIMP VLCLog::get_verbosity(long* level)
+{
+    if( NULL == level )
+        return E_POINTER;
+
+    if( _p_log )
+    {
+        libvlc_instance_t* p_libvlc;
+        HRESULT hr = _p_instance->getVLC(&p_libvlc);
+        if( SUCCEEDED(hr) )
+        {
+            libvlc_exception_t ex;
+            libvlc_exception_init(&ex);
+
+            *level = libvlc_get_log_verbosity(p_libvlc, &ex);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        return hr;
+    }
+    else
+    {
+        /* log is not enabled, return -1 */
+        *level = -1;
+        return NOERROR;
+    }
+};
+
+STDMETHODIMP VLCLog::put_verbosity(long verbosity)
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        if( verbosity >= 0 )
+        {
+            if( ! _p_log )
+            {
+                _p_log = libvlc_log_open(p_libvlc, &ex);
+                if( libvlc_exception_raised(&ex) )
+                {
+                    _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
+                    libvlc_exception_clear(&ex);
+                    return E_FAIL;
+                }
+            }
+            libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        else if( _p_log )
+        {
+            /* close log  when verbosity is set to -1 */
+            libvlc_log_close(_p_log, &ex);
+            _p_log = NULL;
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+    }
+    return hr;
+};
+
+/*******************************************************************************/
+
+/* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
+
+class VLCMessageSTLIterator
+{
+
+public:
+
+    VLCMessageSTLIterator(IVLCMessageIterator* iter) : iter(iter), msg(NULL)
+    {
+        // get first message
+        operator++();
+    };
+
+    VLCMessageSTLIterator(const VLCMessageSTLIterator& other)
+    {
+        iter = other.iter;
+        if( iter )
+            iter->AddRef();
+        msg = other.msg;
+        if( msg )
+            msg->AddRef();
+    };
+
+    virtual ~VLCMessageSTLIterator()
+    {
+        if( msg )
+            msg->Release();
+
+        if( iter )
+            iter->Release();
+    };
+
+    // we only need prefix ++ operator
+    VLCMessageSTLIterator& operator++()
+    {
+        VARIANT_BOOL hasNext = VARIANT_FALSE;
+        if( iter )
+        {
+            iter->get_hasNext(&hasNext);
+
+            if( msg )
+            {
+                msg->Release();
+                msg = NULL;
+            }
+            if( VARIANT_TRUE == hasNext ) {
+                iter->next(&msg);
+            }
+        }
+        return *this;
+    };
+
+    VARIANT operator*() const
+    {
+        VARIANT v;
+        VariantInit(&v);
+        if( msg )
+        {
+            if( SUCCEEDED(msg->QueryInterface(IID_IDispatch, (LPVOID*)&V_DISPATCH(&v))) )
+            {
+                V_VT(&v) = VT_DISPATCH;
+            }
+        }
+        return v;
+    };
+
+    bool operator==(const VLCMessageSTLIterator& other) const
+    {
+        return msg == other.msg;
+    };
+
+    bool operator!=(const VLCMessageSTLIterator& other) const
+    {
+        return msg != other.msg;
+    };
+
+private:
+    IVLCMessageIterator* iter;
+    IVLCMessage*         msg;
+};
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+VLCMessages::~VLCMessages()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMessages::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessages, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMessages::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessages::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessages::get__NewEnum(LPUNKNOWN* _NewEnum)
+{
+    if( NULL == _NewEnum )
+        return E_POINTER;
+
+    IVLCMessageIterator* iter = NULL;
+    iterator(&iter);
+
+    *_NewEnum= new VLCEnumIterator<IID_IEnumVARIANT,
+                       IEnumVARIANT,
+                       VARIANT,
+                       VLCMessageSTLIterator>
+                       (VLCMessageSTLIterator(iter), VLCMessageSTLIterator(NULL));
+
+    return *_NewEnum ? S_OK : E_OUTOFMEMORY;
+};
+
+STDMETHODIMP VLCMessages::clear()
+{
+    libvlc_log_t *p_log = _p_vlclog->_p_log;
+    if( p_log )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_log_clear(p_log, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+    }
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessages::get_count(long* count)
+{
+    if( NULL == count )
+        return E_POINTER;
+
+    libvlc_log_t *p_log = _p_vlclog->_p_log;
+    if( p_log )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        *count = libvlc_log_count(p_log, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCMessages, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+    }
+    else
+        *count = 0;
+    return S_OK;
+};
+
+STDMETHODIMP VLCMessages::iterator(IVLCMessageIterator** iter)
+{
+    if( NULL == iter )
+        return E_POINTER;
+
+    *iter = new VLCMessageIterator(_p_instance, _p_vlclog);
+
+    return *iter ? S_OK : E_OUTOFMEMORY;
+};
+
+/*******************************************************************************/
+
+VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog ) :
+    _p_instance(p_instance),
+    _p_typeinfo(NULL),
+    _refcount(1),
+    _p_vlclog(p_vlclog)
+{
+    if( p_vlclog->_p_log )
+    {
+        _p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
+    }
+    else
+        _p_iter = NULL;
+};
+
+VLCMessageIterator::~VLCMessageIterator()
+{
+    if( _p_iter )
+        libvlc_log_iterator_free(_p_iter, NULL);
+
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMessageIterator::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessageIterator, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMessageIterator::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessageIterator::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
+{
+    if( NULL == hasNext )
+        return E_POINTER;
+
+    if( _p_iter &&  _p_vlclog->_p_log )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        *hasNext = libvlc_log_iterator_has_next(_p_iter, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+    }
+    else
+    {
+        *hasNext = VARIANT_FALSE;
+    }
+    return S_OK;
+};
+
+STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
+{
+    if( NULL == message )
+        return E_POINTER;
+
+    if( _p_iter &&  _p_vlclog->_p_log )
+    {
+        struct libvlc_log_message_t buffer;
+
+        buffer.sizeof_msg = sizeof(buffer);
+
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_log_iterator_next(_p_iter, &buffer, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCMessageIterator, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        *message = new VLCMessage(_p_instance, buffer);
+        return *message ? NOERROR : E_OUTOFMEMORY;
+    }
+    return E_FAIL;
+};
+
+/*******************************************************************************/
+
+VLCMessage::~VLCMessage()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMessage::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCMessage, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMessage::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessage::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCMessage::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+inline const char *msgSeverity(int sev)
+{
+    switch( sev )
+    {
+        case 0:
+            return "info";
+        case 1:
+            return "error";
+        case 2:
+            return "warning";
+        default:
+            return "debug";
+    }
+};
+
+STDMETHODIMP VLCMessage::get__Value(VARIANT* _Value)
+{
+    if( NULL == _Value )
+        return E_POINTER;
+
+    char buffer[256];
+
+    snprintf(buffer, sizeof(buffer), "%s %s %s: %s",
+        _msg.psz_type, _msg.psz_name, msgSeverity(_msg.i_severity), _msg.psz_message);
+
+    V_VT(_Value) = VT_BSTR;
+    V_BSTR(_Value) = BSTRFromCStr(CP_UTF8, buffer);
+
+    return S_OK;
+};
+
+STDMETHODIMP VLCMessage::get_severity(long* level)
+{
+    if( NULL == level )
+        return E_POINTER;
+
+    *level = _msg.i_severity;
+
+    return S_OK;
+};
+
+STDMETHODIMP VLCMessage::get_type(BSTR* type)
+{
+    if( NULL == type )
+        return E_POINTER;
+
+    *type = BSTRFromCStr(CP_UTF8, _msg.psz_type);
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_name(BSTR* name)
+{
+    if( NULL == name )
+        return E_POINTER;
+
+    *name = BSTRFromCStr(CP_UTF8, _msg.psz_name);
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_header(BSTR* header)
+{
+    if( NULL == header )
+        return E_POINTER;
+
+    *header = BSTRFromCStr(CP_UTF8, _msg.psz_header);
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMessage::get_message(BSTR* message)
+{
+    if( NULL == message )
+        return E_POINTER;
+
+    *message = BSTRFromCStr(CP_UTF8, _msg.psz_message);
+
+    return NOERROR;
+};
+
+/*******************************************************************************/
+
+VLCPlaylistItems::~VLCPlaylistItems()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCPlaylistItems::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
+    {
+        ITypeLib *p_typelib;
+
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
+        {
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCPlaylistItems, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
+        }
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
+{
+    if( NULL == ppTInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        _p_typeinfo->AddRef();
+        *ppTInfo = _p_typeinfo;
+        return NOERROR;
+    }
+    *ppTInfo = NULL;
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
+        UINT cNames, LCID lcid, DISPID* rgDispID)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispGetIDsOfNames(_p_typeinfo, rgszNames, cNames, rgDispID);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::Invoke(DISPID dispIdMember, REFIID riid,
+        LCID lcid, WORD wFlags, DISPPARAMS* pDispParams,
+        VARIANT* pVarResult, EXCEPINFO* pExcepInfo, UINT* puArgErr)
+{
+    if( SUCCEEDED(loadTypeInfo()) )
+    {
+        return DispInvoke(this, _p_typeinfo, dispIdMember, wFlags, pDispParams,
+                pVarResult, pExcepInfo, puArgErr);
+    }
+    return E_NOTIMPL;
+};
+
+STDMETHODIMP VLCPlaylistItems::get_count(long* count)
+{
+    if( NULL == count )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        *count = libvlc_playlist_items_count(p_libvlc, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+                libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCPlaylistItems::clear()
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_playlist_clear(p_libvlc, &ex);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+                libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
     }
     return hr;
 };
 
-STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
+STDMETHODIMP VLCPlaylistItems::remove(long item)
 {
-    if( NULL == hasVout )
-        return E_POINTER;
-
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
     if( SUCCEEDED(hr) )
@@ -560,19 +1532,15 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
+        libvlc_playlist_delete_item(p_libvlc, item, &ex);
+        if( libvlc_exception_raised(&ex) )
         {
-            *hasVout = libvlc_input_has_vout(p_input, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-            libvlc_input_free(p_input);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
+            _p_instance->setErrorInfo(IID_IVLCPlaylistItems,
+                libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
         }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        return NOERROR;
     }
     return hr;
 };
@@ -581,6 +1549,7 @@ STDMETHODIMP VLCInput::get_hasVout(VARIANT_BOOL* hasVout)
 
 VLCPlaylist::~VLCPlaylist()
 {
+    delete _p_vlcplaylistitems;
     if( _p_typeinfo )
         _p_typeinfo->Release();
 };
@@ -634,7 +1603,7 @@ STDMETHODIMP VLCPlaylist::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInf
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
+STDMETHODIMP VLCPlaylist::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
         UINT cNames, LCID lcid, DISPID* rgDispID)
 {
     if( SUCCEEDED(loadTypeInfo()) )
@@ -656,7 +1625,7 @@ STDMETHODIMP VLCPlaylist::Invoke(DISPID dispIdMember, REFIID riid,
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCPlaylist::get_itemCount(int* count)
+STDMETHODIMP VLCPlaylist::get_itemCount(long* count)
 {
     if( NULL == count )
         return E_POINTER;
@@ -706,7 +1675,7 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, int* item)
+STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* item)
 {
     if( NULL == item )
         return E_POINTER;
@@ -721,18 +1690,44 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, int* item
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
+        char *psz_uri = NULL;
+        if( SysStringLen(_p_instance->getBaseURL()) > 0 )
+        {
+            /*
+            ** if the MRL a relative URL, we should end up with an absolute URL
+            */
+            LPWSTR abs_url = CombineURL(_p_instance->getBaseURL(), uri);
+            if( NULL != abs_url )
+            {
+                psz_uri = CStrFromWSTR(CP_UTF8, abs_url, wcslen(abs_url));
+                CoTaskMemFree(abs_url);
+            }
+            else
+            {
+                psz_uri = CStrFromBSTR(CP_UTF8, uri);
+            }
+        }
+        else
+        {
+            /*
+            ** baseURL is empty, assume MRL is absolute
+            */
+            psz_uri = CStrFromBSTR(CP_UTF8, uri);
+        }
+
+        if( NULL == psz_uri )
+        {
+            return E_OUTOFMEMORY;
+        }
+
         int i_options;
         char **ppsz_options;
 
         hr = VLCControl::CreateTargetOptions(CP_UTF8, &options, &ppsz_options, &i_options);
         if( FAILED(hr) )
-            return hr;
-
-        char *psz_uri = CStrFromBSTR(CP_UTF8, uri);
-        if( NULL == psz_uri )
         {
-            VLCControl::FreeTargetOptions(ppsz_options, i_options);
-            return E_OUTOFMEMORY;
+            CoTaskMemFree(psz_uri);
+            return hr;
         }
 
         char *psz_name = NULL;
@@ -747,11 +1742,11 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, int* item
         }
 
         *item = libvlc_playlist_add_extended(p_libvlc,
-            psz_uri,
-            psz_name,
-            i_options,
-            const_cast<const char **>(ppsz_options),
-            &ex);
+                    psz_uri,
+                    psz_name,
+                    i_options,
+                    const_cast<const char **>(ppsz_options),
+                    &ex);
 
         VLCControl::FreeTargetOptions(ppsz_options, i_options);
         CoTaskMemFree(psz_uri);
@@ -789,7 +1784,7 @@ STDMETHODIMP VLCPlaylist::play()
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::playItem(int item)
+STDMETHODIMP VLCPlaylist::playItem(long item)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -921,7 +1916,7 @@ STDMETHODIMP VLCPlaylist::clear()
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::removeItem(int item)
+STDMETHODIMP VLCPlaylist::removeItem(long item)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -943,6 +1938,20 @@ STDMETHODIMP VLCPlaylist::removeItem(int item)
     return hr;
 };
 
+STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcplaylistitems;
+    if( NULL != _p_vlcplaylistitems )
+    {
+        _p_vlcplaylistitems->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 /*******************************************************************************/
 
 VLCVideo::~VLCVideo()
@@ -1000,7 +2009,7 @@ STDMETHODIMP VLCVideo::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInfo)
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
+STDMETHODIMP VLCVideo::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
         UINT cNames, LCID lcid, DISPID* rgDispID)
 {
     if( SUCCEEDED(loadTypeInfo()) )
@@ -1077,7 +2086,7 @@ STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
     return hr;
 };
 
-STDMETHODIMP VLCVideo::get_width(int* width)
+STDMETHODIMP VLCVideo::get_width(long* width)
 {
     if( NULL == width )
         return E_POINTER;
@@ -1106,7 +2115,7 @@ STDMETHODIMP VLCVideo::get_width(int* width)
     return hr;
 };
 
-STDMETHODIMP VLCVideo::get_height(int* height)
+STDMETHODIMP VLCVideo::get_height(long* height)
 {
     if( NULL == height )
         return E_POINTER;
@@ -1135,6 +2144,323 @@ STDMETHODIMP VLCVideo::get_height(int* height)
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
+{
+    if( NULL == aspect )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
+
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                if( NULL == psz_aspect )
+                    return E_OUTOFMEMORY;
+
+                *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
+                free( psz_aspect );
+                psz_aspect = NULL;
+                return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
+            }
+            if( psz_aspect ) free( psz_aspect );
+            psz_aspect = NULL;
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::put_aspectRatio(BSTR aspect)
+{
+    if( NULL == aspect )
+        return E_POINTER;
+
+    if( 0 == SysStringLen(aspect) )
+        return E_INVALIDARG;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
+            if( NULL == psz_aspect )
+            {
+                return E_OUTOFMEMORY;
+            }
+
+            libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
+
+            CoTaskMemFree(psz_aspect);
+            libvlc_input_free(p_input);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCVideo,
+                    libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::get_subtitle(long* spu)
+{
+    if( NULL == spu )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            *spu = libvlc_video_get_spu(p_input, &ex);
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                return NOERROR;
+            }
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::put_subtitle(long spu)
+{
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        libvlc_video_set_spu(p_input, spu, &ex);
+        libvlc_input_free(p_input);
+        if( libvlc_exception_raised(&ex) )
+        {
+            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+            libvlc_exception_clear(&ex);
+            return E_FAIL;
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
+{
+    if( NULL == geometry )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_geometry = libvlc_video_get_crop_geometry(p_input, &ex);
+
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                if( NULL == psz_geometry )
+                    return E_OUTOFMEMORY;
+
+                *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
+                free( psz_geometry );
+                psz_geometry = NULL;
+                return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
+            }
+            if( psz_geometry ) free( psz_geometry );
+            psz_geometry = NULL;
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
+{
+    if( NULL == geometry )
+        return E_POINTER;
+
+    if( 0 == SysStringLen(geometry) )
+        return E_INVALIDARG;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
+            if( NULL == psz_geometry )
+            {
+                return E_OUTOFMEMORY;
+            }
+
+            libvlc_video_set_crop_geometry(p_input, psz_geometry, &ex);
+
+            CoTaskMemFree(psz_geometry);
+            libvlc_input_free(p_input);
+            if( libvlc_exception_raised(&ex) )
+            {
+                _p_instance->setErrorInfo(IID_IVLCVideo,
+                    libvlc_exception_get_message(&ex));
+                libvlc_exception_clear(&ex);
+                return E_FAIL;
+            }
+        }
+        return NOERROR;
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
+{
+    if( NULL == picture )
+        return E_POINTER;
+
+    libvlc_instance_t* p_libvlc;
+    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_input_t *p_input = libvlc_playlist_get_input(p_libvlc, &ex);
+        if( ! libvlc_exception_raised(&ex) )
+        {
+            static int uniqueId = 0;
+            TCHAR path[MAX_PATH+1];
+
+            int pathlen = GetTempPath(MAX_PATH-24, path);
+            if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
+                return E_FAIL;
+
+            /* check temp directory path by openning it */
+            {
+                HANDLE dirHandle = CreateFile(path,
+                                              GENERIC_READ,
+                                              FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
+                                              NULL,
+                                              OPEN_EXISTING,
+                                              FILE_FLAG_BACKUP_SEMANTICS, NULL);
+                if( INVALID_HANDLE_VALUE == dirHandle )
+                {
+                    _p_instance->setErrorInfo(IID_IVLCVideo,
+                            "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
+                    return E_FAIL;
+                }
+                else
+                {
+                    BY_HANDLE_FILE_INFORMATION bhfi;
+                    BOOL res = GetFileInformationByHandle(dirHandle, &bhfi);
+                    CloseHandle(dirHandle);
+                    if( !res || !(bhfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
+                    {
+                        _p_instance->setErrorInfo(IID_IVLCVideo,
+                                "Invalid temporary directory for snapshot images, check values of TMP, TEMP envars.");
+                        return E_FAIL;
+                    }
+                }
+            }
+
+            TCHAR filepath[MAX_PATH+1];
+
+            _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
+                     path, GetCurrentProcessId(), ++uniqueId);
+
+#ifdef _UNICODE
+            /* reuse path storage for UTF8 string */
+            char *psz_filepath = (char *)path;
+            WCHAR* wpath = filepath;
+#else
+            char *psz_filepath = path;
+            /* first convert to unicode using current code page */
+            WCHAR wpath[MAX_PATH+1];
+            if( 0 == MultiByteToWideChar(CP_ACP, 0, filepath, -1, wpath, sizeof(wpath)/sizeof(WCHAR)) )
+                return E_FAIL;
+#endif
+            /* convert to UTF8 */
+            pathlen = WideCharToMultiByte(CP_UTF8, 0, wpath, -1, psz_filepath, sizeof(path), NULL, NULL);
+            // fail if path is 0 or too short (i.e pathlen is the same as storage size)
+            if( (0 == pathlen) || (sizeof(path) == pathlen) )
+                return E_FAIL;
+
+            /* take snapshot into file */
+            libvlc_video_take_snapshot(p_input, psz_filepath, &ex);
+            libvlc_input_free(p_input);
+            if( ! libvlc_exception_raised(&ex) )
+            {
+                hr = E_FAIL;
+                /* open snapshot file */
+                HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP,0, 0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
+                if( snapPic )
+                {
+                    PICTDESC snapDesc;
+
+                    snapDesc.cbSizeofstruct = sizeof(PICTDESC);
+                    snapDesc.picType        = PICTYPE_BITMAP;
+                    snapDesc.bmp.hbitmap    = (HBITMAP)snapPic;
+                    snapDesc.bmp.hpal       = NULL;
+
+                    hr = OleCreatePictureIndirect(&snapDesc, IID_IPictureDisp, TRUE, (LPVOID*)picture);
+                    if( FAILED(hr) )
+                    {
+                        *picture = NULL;
+                        DeleteObject(snapPic);
+                    }
+                }
+                DeleteFile(filepath);
+                return hr;
+            }
+        }
+        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
+        libvlc_exception_clear(&ex);
+        return E_FAIL;
+    }
+    return hr;
+};
+
 STDMETHODIMP VLCVideo::toggleFullscreen()
 {
     libvlc_instance_t* p_libvlc;
@@ -1173,6 +2499,7 @@ VLCControl2::VLCControl2(VLCPlugin *p_instance) :
 {
     _p_vlcaudio     = new VLCAudio(p_instance);
     _p_vlcinput     = new VLCInput(p_instance);
+    _p_vlclog       = new VLCLog(p_instance);
     _p_vlcplaylist  = new VLCPlaylist(p_instance);
     _p_vlcvideo     = new VLCVideo(p_instance);
 };
@@ -1181,6 +2508,7 @@ VLCControl2::~VLCControl2()
 {
     delete _p_vlcvideo;
     delete _p_vlcplaylist;
+    delete _p_vlclog;
     delete _p_vlcinput;
     delete _p_vlcaudio;
     if( _p_typeinfo )
@@ -1236,7 +2564,7 @@ STDMETHODIMP VLCControl2::GetTypeInfo(UINT iTInfo, LCID lcid, LPTYPEINFO* ppTInf
     return E_NOTIMPL;
 };
 
-STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames, 
+STDMETHODIMP VLCControl2::GetIDsOfNames(REFIID riid, LPOLESTR* rgszNames,
         UINT cNames, LCID lcid, DISPID* rgDispID)
 {
     if( SUCCEEDED(loadTypeInfo()) )
@@ -1322,7 +2650,7 @@ STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
     return S_OK;
 };
 
-STDMETHODIMP VLCControl2::get_StartTime(int *seconds)
+STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
 {
     if( NULL == seconds )
         return E_POINTER;
@@ -1331,14 +2659,14 @@ STDMETHODIMP VLCControl2::get_StartTime(int *seconds)
 
     return S_OK;
 };
-     
-STDMETHODIMP VLCControl2::put_StartTime(int seconds)
+
+STDMETHODIMP VLCControl2::put_StartTime(long seconds)
 {
     _p_instance->setStartTime(seconds);
 
     return NOERROR;
 };
-        
+
 STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
 {
     if( NULL == version )
@@ -1347,14 +2675,14 @@ STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
     const char *versionStr = VLC_Version();
     if( NULL != versionStr )
     {
-        *version = BSTRFromCStr(_p_instance->getCodePage(), versionStr);
-        
+        *version = BSTRFromCStr(CP_UTF8, versionStr);
+
         return NULL == *version ? E_OUTOFMEMORY : NOERROR;
     }
     *version = NULL;
     return E_FAIL;
 };
+
 STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
 {
     if( NULL == isVisible )
@@ -1364,7 +2692,7 @@ STDMETHODIMP VLCControl2::get_Visible(VARIANT_BOOL *isVisible)
 
     return NOERROR;
 };
-        
+
 STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
 {
     _p_instance->setVisible(isVisible != VARIANT_FALSE);
@@ -1372,7 +2700,7 @@ STDMETHODIMP VLCControl2::put_Visible(VARIANT_BOOL isVisible)
     return NOERROR;
 };
 
-STDMETHODIMP VLCControl2::get_Volume(int *volume)
+STDMETHODIMP VLCControl2::get_Volume(long *volume)
 {
     if( NULL == volume )
         return E_POINTER;
@@ -1380,8 +2708,8 @@ STDMETHODIMP VLCControl2::get_Volume(int *volume)
     *volume  = _p_instance->getVolume();
     return NOERROR;
 };
-        
-STDMETHODIMP VLCControl2::put_Volume(int volume)
+
+STDMETHODIMP VLCControl2::put_Volume(long volume)
 {
     _p_instance->setVolume(volume);
     return NOERROR;
@@ -1415,6 +2743,20 @@ STDMETHODIMP VLCControl2::get_input(IVLCInput** obj)
     return E_OUTOFMEMORY;
 };
 
+STDMETHODIMP VLCControl2::get_log(IVLCLog** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlclog;
+    if( NULL != _p_vlclog )
+    {
+        _p_vlclog->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
 {
     if( NULL == obj )
@@ -1442,4 +2784,3 @@ STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
     }
     return E_OUTOFMEMORY;
 };
-