]> git.sesse.net Git - vlc/blobdiff - projects/activex/vlccontrol2.cpp
Replace libvlc_exception_get_message with libvlc_errmsg
[vlc] / projects / activex / vlccontrol2.cpp
index d319b546254ede34eb352b6001620493d141a86c..2acec96e03ae5590085504745145ce7f3e296d7d 100644 (file)
@@ -16,9 +16,9 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "plugin.h"
 
 #include "utils.h"
 
+#include <stdio.h>
 #include <shlwapi.h>
 #include <wininet.h>
 #include <tchar.h>
 
-using namespace std;
+
+static inline
+HRESULT _exception_bridge(VLCPlugin *p,REFIID riid, libvlc_exception_t *ex)
+{
+    if( libvlc_exception_raised(ex) )
+    {
+        p->setErrorInfo(riid,libvlc_errmsg());
+        libvlc_exception_clear(ex);
+        return E_FAIL;
+    }
+    return NOERROR;
+}
+
+#define EMIT_EXCEPTION_BRIDGE( classname ) \
+    HRESULT classname::exception_bridge( libvlc_exception_t *ex ) \
+    { return _exception_bridge( _p_instance, IID_I##classname, ex ); }
+
+EMIT_EXCEPTION_BRIDGE( VLCAudio )
+EMIT_EXCEPTION_BRIDGE( VLCInput )
+EMIT_EXCEPTION_BRIDGE( VLCMarquee )
+EMIT_EXCEPTION_BRIDGE( VLCMessageIterator )
+EMIT_EXCEPTION_BRIDGE( VLCMessages )
+EMIT_EXCEPTION_BRIDGE( VLCLog )
+EMIT_EXCEPTION_BRIDGE( VLCPlaylistItems )
+EMIT_EXCEPTION_BRIDGE( VLCPlaylist )
+EMIT_EXCEPTION_BRIDGE( VLCVideo )
+EMIT_EXCEPTION_BRIDGE( VLCSubtitle )
+
+#undef  EMIT_EXCEPTION_BRIDGE
+
 
 VLCAudio::~VLCAudio()
 {
@@ -122,14 +152,9 @@ STDMETHODIMP VLCAudio::get_mute(VARIANT_BOOL* mute)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        *mute = libvlc_audio_get_mute(p_libvlc, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        *mute = libvlc_audio_get_mute(p_libvlc, &ex) ?
+                        VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -144,13 +169,7 @@ STDMETHODIMP VLCAudio::put_mute(VARIANT_BOOL mute)
         libvlc_exception_init(&ex);
 
         libvlc_audio_set_mute(p_libvlc, VARIANT_FALSE != mute, &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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -168,13 +187,7 @@ STDMETHODIMP VLCAudio::get_volume(long* volume)
         libvlc_exception_init(&ex);
 
         *volume = libvlc_audio_get_volume(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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -189,14 +202,7 @@ STDMETHODIMP VLCAudio::put_volume(long volume)
         libvlc_exception_init(&ex);
 
         libvlc_audio_set_volume(p_libvlc, volume, &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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -206,48 +212,101 @@ STDMETHODIMP VLCAudio::get_track(long* track)
     if( NULL == track )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
         *track = libvlc_audio_get_track(p_md, &ex);
-        libvlc_media_instance_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCAudio::put_track(long track)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
         libvlc_audio_set_track(p_md, track, &ex);
-        libvlc_media_instance_release(p_md);
-        if( libvlc_exception_raised(&ex) )
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCAudio::get_count(long* trackNumber)
+{
+    if( NULL == trackNumber )
+        return E_POINTER;
+
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+        // get the number of audio track available and return it
+        *trackNumber = libvlc_audio_get_track_count(p_md, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+
+STDMETHODIMP VLCAudio::description(long trackID, BSTR* name)
+{
+    if( NULL == name )
+        return E_POINTER;
+
+    libvlc_media_player_t* p_md;
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        int i, i_limit;
+        const char *psz_name;
+        libvlc_track_description_t *p_trackDesc;
+
+        // get tracks description
+        p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
+        hr = exception_bridge(&ex);
+        if( FAILED(hr) )
+            return hr;
+
+        //get the number of available track
+        i_limit = libvlc_audio_get_track_count(p_md, &ex);
+        hr = exception_bridge(&ex);
+        if( FAILED(hr) )
+            return hr;
+
+        // check if the number given is a good one
+        if ( ( trackID > ( i_limit -1 ) ) || ( trackID < 0 ) )
+                return E_FAIL;
+
+        // get the good trackDesc
+        for( i = 0 ; i < trackID ; i++ )
         {
-            _p_instance->setErrorInfo(IID_IVLCAudio,
-                         libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
+            p_trackDesc = p_trackDesc->p_next;
         }
-        return NOERROR;
+        // get the track name
+        psz_name = p_trackDesc->psz_name;
+
+        // return it
+        if( psz_name != NULL )
+        {
+            *name = BSTRFromCStr(CP_UTF8, psz_name);
+            return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
+        }
+        *name = NULL;
+        return E_FAIL;
     }
     return hr;
 };
@@ -265,14 +324,7 @@ STDMETHODIMP VLCAudio::get_channel(long *channel)
         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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -287,14 +339,7 @@ STDMETHODIMP VLCAudio::put_channel(long channel)
         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;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -309,14 +354,7 @@ STDMETHODIMP VLCAudio::toggleMute()
         libvlc_exception_init(&ex);
 
         libvlc_audio_toggle_mute(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;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -404,27 +442,17 @@ STDMETHODIMP VLCInput::get_length(double* length)
 {
     if( NULL == length )
         return E_POINTER;
+    *length = 0;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *length = (double)libvlc_media_instance_get_length(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *length = (double)libvlc_media_player_get_length(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -434,52 +462,31 @@ STDMETHODIMP VLCInput::get_position(double* position)
     if( NULL == position )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    *position = 0.0f;
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *position = libvlc_media_instance_get_position(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *position = libvlc_media_player_get_position(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_position(double position)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_instance_set_position(p_md, position, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_position(p_md, position, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -489,52 +496,30 @@ STDMETHODIMP VLCInput::get_time(double* time)
     if( NULL == time )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *time = (double)libvlc_media_instance_get_time(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *time = (double)libvlc_media_player_get_time(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_time(double time)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_instance_set_time(p_md, (vlc_int64_t)time, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_time(p_md, (int64_t)time, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -544,27 +529,20 @@ STDMETHODIMP VLCInput::get_state(long* state)
     if( NULL == state )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
+        *state = libvlc_media_player_get_state(p_md, &ex);
+        if( libvlc_exception_raised(&ex) )
         {
-            *state = libvlc_media_instance_get_state(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
+            // don't fail, just return the idle state
+            *state = 0;
+            libvlc_exception_clear(&ex);
         }
-        libvlc_exception_clear(&ex);
-        // don't fail, just return the idle state
-        *state = 0;
-        return NOERROR;
     }
     return hr;
 };
@@ -574,52 +552,30 @@ STDMETHODIMP VLCInput::get_rate(double* rate)
     if( NULL == rate )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *rate = libvlc_media_instance_get_rate(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *rate = libvlc_media_player_get_rate(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCInput::put_rate(double rate)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_media_instance_set_rate(p_md, rate, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_media_player_set_rate(p_md, rate, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -630,26 +586,15 @@ STDMETHODIMP VLCInput::get_fps(double* fps)
         return E_POINTER;
 
     *fps = 0.0;
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *fps = libvlc_media_instance_get_fps(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *fps = libvlc_media_player_get_fps(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -659,26 +604,16 @@ 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);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *hasVout = libvlc_media_instance_has_vout(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCInput, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *hasVout = libvlc_media_player_has_vout(p_md, &ex) ?
+                                VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -689,7 +624,7 @@ VLCLog::~VLCLog()
 {
     delete _p_vlcmessages;
     if( _p_log )
-        libvlc_log_close(_p_log, NULL);
+        libvlc_log_close(_p_log);
 
     if( _p_typeinfo )
         _p_typeinfo->Release();
@@ -790,18 +725,7 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
         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;
-            }
-        }
+            *level = libvlc_get_log_verbosity(p_libvlc);
         return hr;
     }
     else
@@ -814,49 +738,280 @@ STDMETHODIMP VLCLog::get_verbosity(long* level)
 
 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) )
     {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
         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;
+                hr = exception_bridge(&ex);
             }
+            if( SUCCEEDED(hr) )
+                libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity);
         }
         else if( _p_log )
         {
             /* close log  when verbosity is set to -1 */
-            libvlc_log_close(_p_log, &ex);
+            libvlc_log_close(_p_log);
             _p_log = NULL;
-            if( libvlc_exception_raised(&ex) )
+        }
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+/*******************************************************************************/
+
+VLCMarquee::~VLCMarquee()
+{
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCMarquee::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_IVLCMarquee, &_p_typeinfo);
+            if( FAILED(hr) )
             {
-                _p_instance->setErrorInfo(IID_IVLCLog, libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
+                _p_typeinfo = NULL;
             }
+            p_typelib->Release();
         }
     }
     return hr;
 };
 
+STDMETHODIMP VLCMarquee::GetTypeInfoCount(UINT* pctInfo)
+{
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCMarquee::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 VLCMarquee::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 VLCMarquee::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 VLCMarquee::enable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::disable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::color(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::opacity(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::position(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::refresh(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::size(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::text(BSTR text)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        char *psz_text = CStrFromBSTR(CP_UTF8, text);
+        libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
+        hr = exception_bridge(&ex);
+        CoTaskMemFree(psz_text);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::timeout(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::x(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCMarquee::y(long val)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, val, &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
 /*******************************************************************************/
 
 /* STL forward iterator used by VLCEnumIterator class to implement IEnumVARIANT */
@@ -917,7 +1072,8 @@ public:
         VariantInit(&v);
         if( msg )
         {
-            if( SUCCEEDED(msg->QueryInterface(IID_IDispatch, (LPVOID*)&V_DISPATCH(&v))) )
+            if( SUCCEEDED(msg->QueryInterface(IID_IDispatch,
+                          (LPVOID*)&V_DISPATCH(&v))) )
             {
                 V_VT(&v) = VT_DISPATCH;
             }
@@ -1040,18 +1196,7 @@ 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;
-        }
-    }
+        libvlc_log_clear(p_log);
     return NOERROR;
 };
 
@@ -1061,21 +1206,7 @@ STDMETHODIMP VLCMessages::get_count(long* 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;
+    *count = libvlc_log_count(p_log);
     return S_OK;
 };
 
@@ -1108,7 +1239,7 @@ VLCMessageIterator::VLCMessageIterator(VLCPlugin *p_instance, VLCLog* p_vlclog )
 VLCMessageIterator::~VLCMessageIterator()
 {
     if( _p_iter )
-        libvlc_log_iterator_free(_p_iter, NULL);
+        libvlc_log_iterator_free(_p_iter);
 
     if( _p_typeinfo )
         _p_typeinfo->Release();
@@ -1192,16 +1323,8 @@ STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
 
     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;
-        }
+        *hasNext = libvlc_log_iterator_has_next(_p_iter) ?
+                   VARIANT_TRUE : VARIANT_FALSE;
     }
     else
     {
@@ -1212,6 +1335,8 @@ STDMETHODIMP VLCMessageIterator::get_hasNext(VARIANT_BOOL* hasNext)
 
 STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
 {
+    HRESULT hr = S_OK;
+
     if( NULL == message )
         return E_POINTER;
 
@@ -1221,20 +1346,12 @@ STDMETHODIMP VLCMessageIterator::next(IVLCMessage** message)
 
         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;
-        }
+        libvlc_log_iterator_next(_p_iter, &buffer);
         *message = new VLCMessage(_p_instance, buffer);
-        return *message ? NOERROR : E_OUTOFMEMORY;
+        if( !message )
+            hr = E_OUTOFMEMORY;
     }
-    return E_FAIL;
+    return hr;
 };
 
 /*******************************************************************************/
@@ -1481,46 +1598,20 @@ 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);
+    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;
+    *count = _p_instance->playlist_count(&ex);
+    return exception_bridge(&ex);
 };
 
 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_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;
+    _p_instance->playlist_clear(&ex);
+    return exception_bridge(&ex);
 };
 
 STDMETHODIMP VLCPlaylistItems::remove(long item)
@@ -1532,15 +1623,8 @@ STDMETHODIMP VLCPlaylistItems::remove(long item)
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_delete_item(p_libvlc, item, &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;
+        _p_instance->playlist_delete_item(item, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -1630,24 +1714,12 @@ STDMETHODIMP VLCPlaylist::get_itemCount(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 = 0;
+    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_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
-    }
-    return hr;
+    *count = _p_instance->playlist_count(&ex);
+    return exception_bridge(&ex);
 };
 
 STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
@@ -1655,22 +1727,16 @@ STDMETHODIMP VLCPlaylist::get_isPlaying(VARIANT_BOOL* isPlaying)
     if( NULL == isPlaying )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        *isPlaying = libvlc_playlist_isplaying(p_libvlc, &ex) ? VARIANT_TRUE: VARIANT_FALSE;
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        *isPlaying = libvlc_media_player_is_playing(p_md, &ex) ?
+                     VARIANT_TRUE: VARIANT_FALSE;
+        libvlc_exception_clear(&ex);
     }
     return hr;
 };
@@ -1741,72 +1807,94 @@ STDMETHODIMP VLCPlaylist::add(BSTR uri, VARIANT name, VARIANT options, long* ite
             VariantClear(&v_name);
         }
 
-        *item = libvlc_playlist_add_extended(p_libvlc,
-                    psz_uri,
-                    psz_name,
-                    i_options,
-                    const_cast<const char **>(ppsz_options),
-                    &ex);
+        *item = _p_instance->playlist_add_extended_untrusted(psz_uri,
+                    i_options, const_cast<const char **>(ppsz_options), &ex);
 
         VLCControl::FreeTargetOptions(ppsz_options, i_options);
         CoTaskMemFree(psz_uri);
-        if( psz_name )
+        if( psz_name ) /* XXX Do we even need to check? */
             CoTaskMemFree(psz_name);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCPlaylist::play()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_play(&ex);
+    return exception_bridge(&ex);
+};
+
+STDMETHODIMP VLCPlaylist::playItem(long item)
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_play_item(item,&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::togglePause()
+{
+    libvlc_media_player_t* p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_play(p_libvlc, -1, 0, NULL, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        libvlc_media_player_pause(p_md, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::playItem(long item)
+STDMETHODIMP VLCPlaylist::stop()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_play(p_libvlc, item, 0, NULL, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        libvlc_media_player_stop(p_md, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::togglePause()
+STDMETHODIMP VLCPlaylist::next()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_next(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::prev()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_prev(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::clear()
+{
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    _p_instance->playlist_clear(&ex);
+    return exception_bridge(&ex);;
+};
+
+STDMETHODIMP VLCPlaylist::removeItem(long item)
 {
     libvlc_instance_t* p_libvlc;
     HRESULT hr = _p_instance->getVLC(&p_libvlc);
@@ -1815,147 +1903,214 @@ STDMETHODIMP VLCPlaylist::togglePause()
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_pause(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        _p_instance->playlist_delete_item(item, &ex);
+        hr = exception_bridge(&ex);;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::stop()
+STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
-    if( SUCCEEDED(hr) )
-    {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+    if( NULL == obj )
+        return E_POINTER;
 
-        libvlc_playlist_stop(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
+    *obj = _p_vlcplaylistitems;
+    if( NULL != _p_vlcplaylistitems )
+    {
+        _p_vlcplaylistitems->AddRef();
         return NOERROR;
     }
-    return hr;
+    return E_OUTOFMEMORY;
 };
 
-STDMETHODIMP VLCPlaylist::next()
+/*******************************************************************************/
+
+VLCSubtitle::~VLCSubtitle()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
-    if( SUCCEEDED(hr) )
+    if( _p_typeinfo )
+        _p_typeinfo->Release();
+};
+
+HRESULT VLCSubtitle::loadTypeInfo(void)
+{
+    HRESULT hr = NOERROR;
+    if( NULL == _p_typeinfo )
     {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+        ITypeLib *p_typelib;
 
-        libvlc_playlist_next(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
+        hr = _p_instance->getTypeLib(LOCALE_USER_DEFAULT, &p_typelib);
+        if( SUCCEEDED(hr) )
         {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
+            hr = p_typelib->GetTypeInfoOfGuid(IID_IVLCSubtitle, &_p_typeinfo);
+            if( FAILED(hr) )
+            {
+                _p_typeinfo = NULL;
+            }
+            p_typelib->Release();
         }
-        return NOERROR;
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::prev()
+STDMETHODIMP VLCSubtitle::GetTypeInfoCount(UINT* pctInfo)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( NULL == pctInfo )
+        return E_INVALIDARG;
+
+    if( SUCCEEDED(loadTypeInfo()) )
+        *pctInfo = 1;
+    else
+        *pctInfo = 0;
+
+    return NOERROR;
+};
+
+STDMETHODIMP VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::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 VLCSubtitle::get_track(long* spu)
+{
+    if( NULL == spu )
+        return E_POINTER;
+
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_playlist_prev(p_libvlc, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        *spu = libvlc_video_get_spu(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::clear()
+STDMETHODIMP VLCSubtitle::put_track(long spu)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     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_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        libvlc_video_set_spu(p_md, spu, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::removeItem(long item)
+STDMETHODIMP VLCSubtitle::get_count(long* spuNumber)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    if( NULL == spuNumber )
+        return E_POINTER;
+
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
-
-        libvlc_playlist_delete_item(p_libvlc, item, &ex);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCPlaylist,
-                libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        // get the number of video subtitle available and return it
+        *spuNumber = libvlc_video_get_spu_count(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
-STDMETHODIMP VLCPlaylist::get_items(IVLCPlaylistItems** obj)
+
+STDMETHODIMP VLCSubtitle::description(long nameID, BSTR* name)
 {
-    if( NULL == obj )
-        return E_POINTER;
+    if( NULL == name )
+       return E_POINTER;
 
-    *obj = _p_vlcplaylistitems;
-    if( NULL != _p_vlcplaylistitems )
+    libvlc_media_player_t* p_md;
+    libvlc_exception_t ex;
+    libvlc_exception_init(&ex);
+
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
     {
-        _p_vlcplaylistitems->AddRef();
-        return NOERROR;
+        int i, i_limit;
+        const char *psz_name;
+        libvlc_track_description_t *p_spuDesc;
+
+        // get subtitles description
+        p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
+        hr = exception_bridge(&ex);
+        if( FAILED(hr) )
+            return hr;
+
+        // get the number of available subtitle
+        i_limit = libvlc_video_get_spu_count(p_md, &ex);
+        hr = exception_bridge(&ex);
+        if( FAILED(hr) )
+            return hr;
+
+        // check if the number given is a good one
+        if ( ( nameID > ( i_limit -1 ) ) || ( nameID < 0 ) )
+            return E_FAIL;
+
+        // get the good spuDesc
+        for( i = 0 ; i < nameID ; i++ )
+        {
+            p_spuDesc = p_spuDesc->p_next;
+        }
+        // get the subtitle name
+        psz_name = p_spuDesc->psz_name;
+
+        // return it
+        if( psz_name != NULL )
+        {
+            *name = BSTRFromCStr(CP_UTF8, psz_name);
+            return (NULL == *name) ? E_OUTOFMEMORY : NOERROR;
+        }
+        *name = NULL;
+        return E_FAIL;
     }
-    return E_OUTOFMEMORY;
+    return hr;
 };
 
 /*******************************************************************************/
 
 VLCVideo::~VLCVideo()
 {
+    delete _p_vlcmarquee;
     if( _p_typeinfo )
         _p_typeinfo->Release();
 };
@@ -2036,52 +2191,31 @@ STDMETHODIMP VLCVideo::get_fullscreen(VARIANT_BOOL* fullscreen)
     if( NULL == fullscreen )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *fullscreen = libvlc_get_fullscreen(p_md, &ex) ? VARIANT_TRUE : VARIANT_FALSE;
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *fullscreen = libvlc_get_fullscreen(p_md, &ex) ?
+                      VARIANT_TRUE : VARIANT_FALSE;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_fullscreen(VARIANT_BOOL fullscreen)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_set_fullscreen(p_md, VARIANT_FALSE != fullscreen, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2091,26 +2225,15 @@ STDMETHODIMP VLCVideo::get_width(long* width)
     if( NULL == width )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *width = libvlc_video_get_width(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *width = libvlc_video_get_width(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2120,26 +2243,15 @@ STDMETHODIMP VLCVideo::get_height(long* height)
     if( NULL == height )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *height = libvlc_video_get_height(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *height = libvlc_video_get_height(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2149,35 +2261,23 @@ STDMETHODIMP VLCVideo::get_aspectRatio(BSTR* aspect)
     if( NULL == aspect )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
-
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                if( NULL == psz_aspect )
-                    return E_OUTOFMEMORY;
+        char *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
 
-                *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
-                free( psz_aspect );
-                psz_aspect = NULL;
-                return (NULL == *aspect) ? E_OUTOFMEMORY : NOERROR;
-            }
-            free( psz_aspect );
-            psz_aspect = NULL;
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(hr) && NULL != psz_aspect )
+        {
+            *aspect = BSTRFromCStr(CP_UTF8, psz_aspect);
+            if( NULL == *aspect )
+                hr = E_OUTOFMEMORY;
+        } else if( NULL == psz_aspect) hr = E_OUTOFMEMORY; // strdup("") failed
+        free( psz_aspect );
     }
     return hr;
 };
@@ -2187,38 +2287,23 @@ 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);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
+        char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
+        if( NULL == psz_aspect )
         {
-            char *psz_aspect = CStrFromBSTR(CP_UTF8, aspect);
-            if( NULL == psz_aspect )
-            {
-                return E_OUTOFMEMORY;
-            }
+            return E_OUTOFMEMORY;
+        }
 
-            libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
+        libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
 
-            CoTaskMemFree(psz_aspect);
-            libvlc_media_instance_release(p_md);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCVideo,
-                    libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
-        }
-        return NOERROR;
+        CoTaskMemFree(psz_aspect);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2228,49 +2313,30 @@ STDMETHODIMP VLCVideo::get_subtitle(long* spu)
     if( NULL == spu )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *spu = libvlc_video_get_spu(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *spu = libvlc_video_get_spu(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_subtitle(long spu)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
         libvlc_video_set_spu(p_md, spu, &ex);
-        libvlc_media_instance_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2280,35 +2346,22 @@ STDMETHODIMP VLCVideo::get_crop(BSTR* geometry)
     if( NULL == geometry )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
-
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                if( NULL == psz_geometry )
-                    return E_OUTOFMEMORY;
+        char *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
 
-                *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
-                free( psz_geometry );
-                psz_geometry = NULL;
-                return (NULL == geometry) ? E_OUTOFMEMORY : NOERROR;
-            }
-            free( psz_geometry );
-            psz_geometry = NULL;
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(&ex) && NULL != psz_geometry )
+        {
+            *geometry = BSTRFromCStr(CP_UTF8, psz_geometry);
+            if( NULL == geometry ) hr = E_OUTOFMEMORY;
+        } else if( NULL == psz_geometry ) hr = E_OUTOFMEMORY;
+        free( psz_geometry );
     }
     return hr;
 };
@@ -2321,35 +2374,23 @@ STDMETHODIMP VLCVideo::put_crop(BSTR geometry)
     if( 0 == SysStringLen(geometry) )
         return E_INVALIDARG;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
+        char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
+        if( NULL == psz_geometry )
         {
-            char *psz_geometry = CStrFromBSTR(CP_UTF8, geometry);
-            if( NULL == psz_geometry )
-            {
-                return E_OUTOFMEMORY;
-            }
+            return E_OUTOFMEMORY;
+        }
 
-            libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
+        libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
 
-            CoTaskMemFree(psz_geometry);
-            libvlc_media_instance_release(p_md);
-            if( libvlc_exception_raised(&ex) )
-            {
-                _p_instance->setErrorInfo(IID_IVLCVideo,
-                    libvlc_exception_get_message(&ex));
-                libvlc_exception_clear(&ex);
-                return E_FAIL;
-            }
-        }
-        return NOERROR;
+        CoTaskMemFree(psz_geometry);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
@@ -2359,49 +2400,63 @@ STDMETHODIMP VLCVideo::get_teletext(long* page)
     if( NULL == page )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            *page = libvlc_video_get_teletext(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        *page = libvlc_video_get_teletext(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::put_teletext(long page)
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
         libvlc_video_set_teletext(p_md, page, &ex);
-        libvlc_media_instance_release(p_md);
-        if( libvlc_exception_raised(&ex) )
-        {
-            _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-            libvlc_exception_clear(&ex);
-            return E_FAIL;
-        }
-        return NOERROR;
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::deinterlaceDisable()
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+
+        libvlc_video_set_deinterlace(p_md, 0, "", &ex);
+        hr = exception_bridge(&ex);
+    }
+    return hr;
+};
+
+STDMETHODIMP VLCVideo::deinterlaceEnable(BSTR mode)
+{
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
+    if( SUCCEEDED(hr) )
+    {
+        libvlc_exception_t ex;
+        libvlc_exception_init(&ex);
+        /* get deinterlace mode from the user */
+        char *psz_mode = CStrFromBSTR(CP_UTF8, mode);
+        /* enable deinterlace filter if possible */
+        libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
+        hr = exception_bridge(&ex);
+        CoTaskMemFree(psz_mode);
     }
     return hr;
 };
@@ -2411,160 +2466,146 @@ STDMETHODIMP VLCVideo::takeSnapshot(LPPICTUREDISP* picture)
     if( NULL == picture )
         return E_POINTER;
 
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            static int uniqueId = 0;
-            TCHAR path[MAX_PATH+1];
+        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;
+        int pathlen = GetTempPath(MAX_PATH-24, path);
+        if( (0 == pathlen) || (pathlen > (MAX_PATH-24)) )
+            return E_FAIL;
 
-            /* check temp directory path by openning it */
+        /* 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
             {
-                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 )
+                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;
                 }
-                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];
+        TCHAR filepath[MAX_PATH+1];
 
-            _stprintf(filepath, TEXT("%sAXVLC%lXS%lX.bmp"),
-                     path, GetCurrentProcessId(), ++uniqueId);
+        _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;
+        /* 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;
+        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;
+        /* 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_md, psz_filepath, 0, 0, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
+        /* take snapshot into file */
+        libvlc_video_take_snapshot(p_md, psz_filepath, 0, 0, &ex);
+        hr = exception_bridge(&ex);
+        if( SUCCEEDED(hr) )
+        {
+            /* open snapshot file */
+            HANDLE snapPic = LoadImage(NULL, filepath, IMAGE_BITMAP, 0, 0,
+                                       LR_CREATEDIBSECTION|LR_LOADFROMFILE);
+            if( snapPic )
             {
-                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) )
                 {
-                    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);
-                    }
+                    *picture = NULL;
+                    DeleteObject(snapPic);
                 }
-                DeleteFile(filepath);
-                return hr;
             }
+            DeleteFile(filepath);
         }
-        _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;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_toggle_fullscreen(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_toggle_fullscreen(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
 STDMETHODIMP VLCVideo::toggleTeletext()
 {
-    libvlc_instance_t* p_libvlc;
-    HRESULT hr = _p_instance->getVLC(&p_libvlc);
+    libvlc_media_player_t *p_md;
+    HRESULT hr = _p_instance->getMD(&p_md);
     if( SUCCEEDED(hr) )
     {
         libvlc_exception_t ex;
         libvlc_exception_init(&ex);
 
-        libvlc_media_instance_t *p_md = libvlc_playlist_get_media_instance(p_libvlc, &ex);
-        if( ! libvlc_exception_raised(&ex) )
-        {
-            libvlc_toggle_teletext(p_md, &ex);
-            libvlc_media_instance_release(p_md);
-            if( ! libvlc_exception_raised(&ex) )
-            {
-                return NOERROR;
-            }
-        }
-        _p_instance->setErrorInfo(IID_IVLCVideo, libvlc_exception_get_message(&ex));
-        libvlc_exception_clear(&ex);
-        return E_FAIL;
+        libvlc_toggle_teletext(p_md, &ex);
+        hr = exception_bridge(&ex);
     }
     return hr;
 };
 
+STDMETHODIMP VLCVideo::get_marquee(IVLCMarquee** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcmarquee;
+    if( NULL != _p_vlcmarquee )
+    {
+        _p_vlcmarquee->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 /*******************************************************************************/
 
 VLCControl2::VLCControl2(VLCPlugin *p_instance) :
@@ -2573,18 +2614,21 @@ VLCControl2::VLCControl2(VLCPlugin *p_instance) :
     _p_vlcaudio(NULL),
     _p_vlcinput(NULL),
     _p_vlcplaylist(NULL),
+    _p_vlcsubtitle(NULL),
     _p_vlcvideo(NULL)
 {
     _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_vlcsubtitle  = new VLCSubtitle(p_instance);
     _p_vlcvideo     = new VLCVideo(p_instance);
 };
 
 VLCControl2::~VLCControl2()
 {
     delete _p_vlcvideo;
+    delete _p_vlcsubtitle;
     delete _p_vlcplaylist;
     delete _p_vlclog;
     delete _p_vlcinput;
@@ -2728,6 +2772,38 @@ STDMETHODIMP VLCControl2::put_MRL(BSTR mrl)
     return S_OK;
 };
 
+
+STDMETHODIMP VLCControl2::get_Toolbar(VARIANT_BOOL *visible)
+{
+    if( NULL == visible )
+        return E_POINTER;
+
+    /*
+     * Note to developers
+     *
+     * Returning the _b_toolbar is closer to the method specification.
+     * But returning True when toolbar is not implemented so not displayed
+     * could be bad for ActiveX users which rely on this value to show their
+     * own toolbar if not provided by the ActiveX.
+     *
+     * This is the reason why FALSE is returned, until toolbar get implemented.
+     */
+
+    /* DISABLED for now */
+    //  *visible = _p_instance->getShowToolbar() ? VARIANT_TRUE: VARIANT_FALSE;
+
+    *visible = VARIANT_FALSE;
+
+    return S_OK;
+};
+
+STDMETHODIMP VLCControl2::put_Toolbar(VARIANT_BOOL visible)
+{
+    _p_instance->setShowToolbar((VARIANT_FALSE != visible) ? TRUE: FALSE);
+    return S_OK;
+};
+
+
 STDMETHODIMP VLCControl2::get_StartTime(long *seconds)
 {
     if( NULL == seconds )
@@ -2750,12 +2826,12 @@ STDMETHODIMP VLCControl2::get_VersionInfo(BSTR *version)
     if( NULL == version )
         return E_POINTER;
 
-    const char *versionStr = VLC_Version();
+    const char *versionStr = libvlc_get_version();
     if( NULL != versionStr )
     {
         *version = BSTRFromCStr(CP_UTF8, versionStr);
 
-        return NULL == *version ? E_OUTOFMEMORY : NOERROR;
+        return (NULL == *version) ? E_OUTOFMEMORY : NOERROR;
     }
     *version = NULL;
     return E_FAIL;
@@ -2864,6 +2940,20 @@ STDMETHODIMP VLCControl2::get_playlist(IVLCPlaylist** obj)
     return E_OUTOFMEMORY;
 };
 
+STDMETHODIMP VLCControl2::get_subtitle(IVLCSubtitle** obj)
+{
+    if( NULL == obj )
+        return E_POINTER;
+
+    *obj = _p_vlcsubtitle;
+    if( NULL != _p_vlcsubtitle )
+    {
+        _p_vlcsubtitle->AddRef();
+        return NOERROR;
+    }
+    return E_OUTOFMEMORY;
+};
+
 STDMETHODIMP VLCControl2::get_video(IVLCVideo** obj)
 {
     if( NULL == obj )