]> git.sesse.net Git - vlc/blobdiff - projects/mozilla/control/npolibvlc.cpp
Untracked API change utf8 to UTF8
[vlc] / projects / mozilla / control / npolibvlc.cpp
index fd3970056ccecb112f47bb18081966cae65f1bed..4affd41b81aba91e2a6d5a9ce0bb148d8dd10ca0 100644 (file)
@@ -2,9 +2,10 @@
  * npolibvlc.cpp: official Javascript APIs
  *****************************************************************************
  * Copyright (C) 2002-2009 the VideoLAN team
+ * Copyright (C) 2010 M2X BV
  *
  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
- *          JP Dinger <jpd@m2x.nl>
+ *          JP Dinger <jpd@videolan.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -16,9 +17,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 "config.h"
 #include "vlcplugin.h"
 #include "npolibvlc.h"
 
+#include "position.h"
+
 /*
 ** Local helper macros and function
 */
 #define COUNTNAMES(a,b,c) const int a::b = sizeof(a::c)/sizeof(NPUTF8 *)
-#define RETURN_ON_EXCEPTION(this,ex) \
-    do { if( libvlc_exception_raised(&ex) ) \
-    { \
-        NPN_SetException(this, libvlc_errmsg()); \
-        libvlc_exception_clear(&ex); \
-        return INVOKERESULT_GENERIC_ERROR; \
-    } } while(false)
+#define RETURN_ON_ERROR                             \
+    do {                                            \
+        NPN_SetException(this, libvlc_errmsg());    \
+        return INVOKERESULT_GENERIC_ERROR;          \
+    }while(0)
+
+#define ERROR_EVENT_NOT_FOUND "ERROR: One or more events could not be found."
+#define ERROR_API_VERSION "ERROR: NPAPI version not high enough. (Gecko >= 1.9 needed)"
+
+// Make a copy of an NPVariant.
+NPVariant copyNPVariant(const NPVariant& original)
+{
+    NPVariant res;
+
+    if (NPVARIANT_IS_STRING(original))
+        STRINGZ_TO_NPVARIANT(strdup(NPVARIANT_TO_STRING(original).utf8characters), res);
+    else if (NPVARIANT_IS_INT32(original))
+        INT32_TO_NPVARIANT(NPVARIANT_TO_INT32(original), res);
+    else if (NPVARIANT_IS_DOUBLE(original))
+        DOUBLE_TO_NPVARIANT(NPVARIANT_TO_DOUBLE(original), res);
+    else if (NPVARIANT_IS_OBJECT(original))
+    {
+        NPObject *obj = NPVARIANT_TO_OBJECT(original);
+        NPN_RetainObject(obj);
+        OBJECT_TO_NPVARIANT(obj, res);
+    }
+    else if (NPVARIANT_IS_BOOLEAN(original))
+        BOOLEAN_TO_NPVARIANT(NPVARIANT_TO_BOOLEAN(original), res);
+
+    return res;
+}
 
 /*
 ** implementation of libvlc root object
@@ -66,6 +93,7 @@ LibvlcRootNPObject::~LibvlcRootNPObject()
         if( audioObj    ) NPN_ReleaseObject(audioObj);
         if( inputObj    ) NPN_ReleaseObject(inputObj);
         if( playlistObj ) NPN_ReleaseObject(playlistObj);
+        if( subtitleObj ) NPN_ReleaseObject(subtitleObj);
         if( videoObj    ) NPN_ReleaseObject(videoObj);
     }
 }
@@ -131,34 +159,62 @@ LibvlcRootNPObject::getProperty(int index, NPVariant &result)
 const NPUTF8 * const LibvlcRootNPObject::methodNames[] =
 {
     "versionInfo",
+    "addEventListener",
+    "removeEventListener",
 };
 COUNTNAMES(LibvlcRootNPObject,methodCount,methodNames);
 
 enum LibvlcRootNPObjectMethodIds
 {
     ID_root_versionInfo,
+    ID_root_addeventlistener,
+    ID_root_removeeventlistener,
 };
 
 RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
                   const NPVariant *args, uint32_t argCount, NPVariant &result)
 {
     /* is plugin still running */
-    if( isPluginRunning() )
-    {
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
 
-        switch( index )
+    switch( index )
+    {
+    case ID_root_versionInfo:
+        if( 0 != argCount )
+            return INVOKERESULT_NO_SUCH_METHOD;
+        return invokeResultString(libvlc_get_version(),result);
+
+    case ID_root_addeventlistener:
+    case ID_root_removeeventlistener:
+        if( (3 != argCount) ||
+            !NPVARIANT_IS_STRING(args[0]) ||
+            !NPVARIANT_IS_OBJECT(args[1]) ||
+            !NPVARIANT_IS_BOOLEAN(args[2]) )
+            break;
+
+        if( !VlcPlugin::canUseEventListener() )
         {
-            case ID_root_versionInfo:
-                if( 0 != argCount )
-                    return INVOKERESULT_NO_SUCH_METHOD;
-                return invokeResultString(libvlc_get_version(),result);
-            default:
-                ;
+            NPN_SetException(this, ERROR_API_VERSION);
+            return INVOKERESULT_GENERIC_ERROR;
         }
+
+        NPObject *listener = NPVARIANT_TO_OBJECT(args[1]);
+        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+
+        bool b;
+        if(ID_root_removeeventlistener!=index)
+            b = p_plugin->events.insert(NPVARIANT_TO_STRING(args[0]),
+                                     listener, NPVARIANT_TO_BOOLEAN(args[2]));
+        else
+            b = p_plugin->events.remove(NPVARIANT_TO_STRING(args[0]),
+                                     listener, NPVARIANT_TO_BOOLEAN(args[2]));
+
+        VOID_TO_NPVARIANT(result);
+
+        return b ? INVOKERESULT_NO_ERROR : INVOKERESULT_GENERIC_ERROR;
     }
-    return INVOKERESULT_GENERIC_ERROR;
+    return INVOKERESULT_NO_SUCH_METHOD;
 }
 
 /*
@@ -191,47 +247,42 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
             case ID_audio_mute:
             {
-                bool muted = libvlc_audio_get_mute(p_plugin->getVLC());
+                bool muted = libvlc_audio_get_mute(p_md);
                 BOOLEAN_TO_NPVARIANT(muted, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_audio_volume:
             {
-                int volume = libvlc_audio_get_volume(p_plugin->getVLC());
+                int volume = libvlc_audio_get_volume(p_md);
                 INT32_TO_NPVARIANT(volume, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_audio_track:
             {
-                libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
-                int track = libvlc_audio_get_track(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int track = libvlc_audio_get_track(p_md);
                 INT32_TO_NPVARIANT(track, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_audio_count:
             {
-                libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
                 // get the number of audio track available
-                int i_track = libvlc_audio_get_track_count(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_track = libvlc_audio_get_track_count(p_md);
                 // return it
                 INT32_TO_NPVARIANT(i_track, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_audio_channel:
             {
-                int channel = libvlc_audio_get_channel(p_plugin->getVLC(), &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int channel = libvlc_audio_get_channel(p_md);
                 INT32_TO_NPVARIANT(channel, result);
                 return INVOKERESULT_NO_ERROR;
             }
@@ -249,15 +300,17 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
             case ID_audio_mute:
                 if( NPVARIANT_IS_BOOLEAN(value) )
                 {
-                    libvlc_audio_set_mute(p_plugin->getVLC(),
+                    libvlc_audio_set_mute(p_md,
                                           NPVARIANT_TO_BOOLEAN(value));
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -265,28 +318,21 @@ LibvlcAudioNPObject::setProperty(int index, const NPVariant &value)
             case ID_audio_volume:
                 if( isNumberValue(value) )
                 {
-                    libvlc_audio_set_volume(p_plugin->getVLC(),
-                                            numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_audio_set_volume(p_md, numberValue(value));
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;
             case ID_audio_track:
                 if( isNumberValue(value) )
                 {
-                    libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
-                    libvlc_audio_set_track(p_md, numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_audio_set_track(p_md, numberValue(value));
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;
             case ID_audio_channel:
                 if( isNumberValue(value) )
                 {
-                    libvlc_audio_set_channel(p_plugin->getVLC(),
-                                             numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_audio_set_channel(p_md, numberValue(value));
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;
@@ -318,15 +364,16 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
             case ID_audio_togglemute:
                 if( argCount == 0 )
                 {
-                    libvlc_audio_toggle_mute(p_plugin->getVLC());
+                    libvlc_audio_toggle_mute(p_md);
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -339,18 +386,13 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
                     int i_trackID, i_limit, i;
                     libvlc_track_description_t *p_trackDesc;
 
-                    libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
-
                     /* get tracks description */
-                    p_trackDesc = libvlc_audio_get_track_description(p_md, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_trackDesc = libvlc_audio_get_track_description(p_md);
                     if( !p_trackDesc )
                         return INVOKERESULT_GENERIC_ERROR;
 
                     /* get the number of track available */
-                    i_limit = libvlc_audio_get_track_count(p_md, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    i_limit = libvlc_audio_get_track_count(p_md);
 
                     /* check if a number is given by the user
                      * and get the track number */
@@ -416,23 +458,15 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        if( libvlc_exception_raised(&ex) )
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
         {
             if( index != ID_input_state )
-            {
-                NPN_SetException(this, libvlc_errmsg());
-                libvlc_exception_clear(&ex);
-                return INVOKERESULT_GENERIC_ERROR;
-            }
+                RETURN_ON_ERROR;
             else
             {
                 /* for input state, return CLOSED rather than an exception */
                 INT32_TO_NPVARIANT(0, result);
-                libvlc_exception_clear(&ex);
                 return INVOKERESULT_NO_ERROR;
             }
         }
@@ -441,50 +475,43 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
         {
             case ID_input_length:
             {
-                double val = (double)libvlc_media_player_get_length(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                double val = (double)libvlc_media_player_get_length(p_md);
                 DOUBLE_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_position:
             {
-                double val = libvlc_media_player_get_position(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                double val = libvlc_media_player_get_position(p_md);
                 DOUBLE_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_time:
             {
-                double val = (double)libvlc_media_player_get_time(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                double val = (double)libvlc_media_player_get_time(p_md);
                 DOUBLE_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_state:
             {
-                int val = libvlc_media_player_get_state(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = libvlc_media_player_get_state(p_md);
                 INT32_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_rate:
             {
-                float val = libvlc_media_player_get_rate(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                float val = libvlc_media_player_get_rate(p_md);
                 DOUBLE_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_fps:
             {
-                double val = libvlc_media_player_get_fps(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                double val = libvlc_media_player_get_fps(p_md);
                 DOUBLE_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_hasvout:
             {
-                bool val = p_plugin->player_has_vout(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                bool val = p_plugin->player_has_vout();
                 BOOLEAN_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
@@ -502,11 +529,9 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -518,8 +543,7 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
                 }
 
                 float val = (float)NPVARIANT_TO_DOUBLE(value);
-                libvlc_media_player_set_position(p_md, val, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                libvlc_media_player_set_position(p_md, val);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_time:
@@ -534,8 +558,7 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
                     return INVOKERESULT_INVALID_VALUE;
                 }
 
-                libvlc_media_player_set_time(p_md, val, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                libvlc_media_player_set_time(p_md, val);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_input_rate:
@@ -550,8 +573,7 @@ LibvlcInputNPObject::setProperty(int index, const NPVariant &value)
                     return INVOKERESULT_INVALID_VALUE;
                 }
 
-                libvlc_media_player_set_rate(p_md, val, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                libvlc_media_player_set_rate(p_md, val);
                 return INVOKERESULT_NO_ERROR;
             }
             default:
@@ -613,15 +635,12 @@ LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
 
         switch( index )
         {
             case ID_playlistitems_count:
             {
-                int val = p_plugin->playlist_count(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = p_plugin->playlist_count();
                 INT32_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
@@ -653,16 +672,13 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
 
         switch( index )
         {
             case ID_playlistitems_clear:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_clear(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_clear();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -670,8 +686,8 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
             case ID_playlistitems_remove:
                 if( (argCount == 1) && isNumberValue(args[0]) )
                 {
-                    p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    if( !p_plugin->playlist_delete_item(numberValue(args[0])) )
+                        return INVOKERESULT_GENERIC_ERROR;
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -716,22 +732,18 @@ LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
 
         switch( index )
         {
             case ID_playlist_itemcount: /* deprecated */
             {
-                int val = p_plugin->playlist_count(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = p_plugin->playlist_count();
                 INT32_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_playlist_isplaying:
             {
-                int val = p_plugin->playlist_isplaying(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = p_plugin->playlist_isplaying();
                 BOOLEAN_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
@@ -783,8 +795,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
 
         switch( index )
         {
@@ -861,24 +871,25 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
                 }
 
                 int item = p_plugin->playlist_add_extended_untrusted(url, name,
-                      i_options, const_cast<const char **>(ppsz_options), &ex);
+                      i_options, const_cast<const char **>(ppsz_options));
                 free(url);
                 free(name);
+                if( item == -1 )
+                    RETURN_ON_ERROR;
+
                 for( int i=0; i< i_options; ++i )
                 {
                     free(ppsz_options[i]);
                 }
                 free(ppsz_options);
 
-                RETURN_ON_EXCEPTION(this,ex);
                 INT32_TO_NPVARIANT(item, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_playlist_play:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_play(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_play();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -886,8 +897,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_playItem:
                 if( (argCount == 1) && isNumberValue(args[0]) )
                 {
-                    p_plugin->playlist_play_item(numberValue(args[0]),&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_play_item(numberValue(args[0]));
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -895,8 +905,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_togglepause:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_pause(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_pause();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -904,8 +913,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_stop:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_stop(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_stop();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -913,8 +921,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_next:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_next(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_next();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -922,8 +929,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_prev:
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_prev(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_prev();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -931,8 +937,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_clear: /* deprecated */
                 if( argCount == 0 )
                 {
-                    p_plugin->playlist_clear(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->playlist_clear();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -940,8 +945,8 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
             case ID_playlist_removeitem: /* deprecated */
                 if( (argCount == 1) && isNumberValue(args[0]) )
                 {
-                    p_plugin->playlist_delete_item(numberValue(args[0]), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    if( !p_plugin->playlist_delete_item(numberValue(args[0])) )
+                        return INVOKERESULT_GENERIC_ERROR;
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -962,7 +967,7 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
 void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
                                          int *i_options, char*** ppsz_options)
 {
-    if( nps.utf8length )
+    if( nps.UTF8Length )
     {
         char *s = stringValue(nps);
         char *val = s;
@@ -974,7 +979,7 @@ void LibvlcPlaylistNPObject::parseOptions(const NPString &nps,
             {
                 int nOptions = 0;
 
-                char *end = val + nps.utf8length;
+                char *end = val + nps.UTF8Length;
                 while( val < end )
                 {
                     // skip leading blanks
@@ -1115,19 +1120,16 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
             case ID_subtitle_track:
             {
                 /* get the current subtitle ID */
-                int i_spu = libvlc_video_get_spu(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_spu = libvlc_video_get_spu(p_md);
                 /* return it */
                 INT32_TO_NPVARIANT(i_spu, result);
                 return INVOKERESULT_NO_ERROR;
@@ -1135,8 +1137,7 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
             case ID_subtitle_count:
             {
                 /* get the number of subtitles available */
-                int i_spu = libvlc_video_get_spu_count(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_spu = libvlc_video_get_spu_count(p_md);
                 /* return it */
                 INT32_TO_NPVARIANT(i_spu, result);
                 return INVOKERESULT_NO_ERROR;
@@ -1153,11 +1154,9 @@ LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -1166,8 +1165,7 @@ LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
                 if( isNumberValue(value) )
                 {
                     /* set the new subtitle track to show */
-                    libvlc_video_set_spu(p_md, numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_video_set_spu(p_md, numberValue(value));
 
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -1197,11 +1195,9 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -1214,14 +1210,12 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
                     libvlc_track_description_t *p_spuDesc;
 
                     /* get subtitles description */
-                    p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_spuDesc = libvlc_video_get_spu_description(p_md);
                     if( !p_spuDesc )
                         return INVOKERESULT_GENERIC_ERROR;
 
                     /* get the number of subtitle available */
-                    i_limit = libvlc_video_get_spu_count(p_md, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    i_limit = libvlc_video_get_spu_count(p_md);
 
                     /* check if a number is given by the user
                      * and get the subtitle number */
@@ -1257,6 +1251,16 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
 ** implementation of libvlc video object
 */
 
+LibvlcVideoNPObject::~LibvlcVideoNPObject()
+{
+    if( isValid() )
+    {
+        if( marqueeObj ) NPN_ReleaseObject(marqueeObj);
+        if( logoObj    ) NPN_ReleaseObject(logoObj);
+        if( deintObj   ) NPN_ReleaseObject(deintObj);
+    }
+}
+
 const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
 {
     "fullscreen",
@@ -1266,7 +1270,9 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
     "subtitle",
     "crop",
     "teletext",
-    "marquee"
+    "marquee",
+    "logo",
+    "deinterlace",
 };
 
 enum LibvlcVideoNPObjectPropertyIds
@@ -1278,7 +1284,9 @@ enum LibvlcVideoNPObjectPropertyIds
     ID_video_subtitle,
     ID_video_crop,
     ID_video_teletext,
-    ID_video_marquee
+    ID_video_marquee,
+    ID_video_logo,
+    ID_video_deinterlace,
 };
 COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
 
@@ -1289,39 +1297,33 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
             case ID_video_fullscreen:
             {
-                int val = p_plugin->get_fullscreen(&ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = p_plugin->get_fullscreen();
                 BOOLEAN_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_height:
             {
-                int val = libvlc_video_get_height(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = libvlc_video_get_height(p_md);
                 INT32_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_width:
             {
-                int val = libvlc_video_get_width(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int val = libvlc_video_get_width(p_md);
                 INT32_TO_NPVARIANT(val, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_aspectratio:
             {
-                NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_md);
                 if( !psz_aspect )
                     return INVOKERESULT_GENERIC_ERROR;
 
@@ -1330,15 +1332,13 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
             }
             case ID_video_subtitle:
             {
-                int i_spu = libvlc_video_get_spu(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_spu = libvlc_video_get_spu(p_md);
                 INT32_TO_NPVARIANT(i_spu, result);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_crop:
             {
-                NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                NPUTF8 *psz_geometry = libvlc_video_get_crop_geometry(p_md);
                 if( !psz_geometry )
                     return INVOKERESULT_GENERIC_ERROR;
 
@@ -1347,8 +1347,9 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
             }
             case ID_video_teletext:
             {
-                int i_page = libvlc_video_get_teletext(p_md, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                int i_page = libvlc_video_get_teletext(p_md);
+                if( i_page < 0 )
+                    return INVOKERESULT_GENERIC_ERROR;
                 INT32_TO_NPVARIANT(i_page, result);
                 return INVOKERESULT_NO_ERROR;
             }
@@ -1358,6 +1359,18 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
                 OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
                 return INVOKERESULT_NO_ERROR;
             }
+            case ID_video_logo:
+            {
+                InstantObj<LibvlcLogoNPObject>( logoObj );
+                OBJECT_TO_NPVARIANT(NPN_RetainObject(logoObj), result);
+                return INVOKERESULT_NO_ERROR;
+            }
+            case ID_video_deinterlace:
+            {
+                InstantObj<LibvlcDeinterlaceNPObject>( deintObj );
+                OBJECT_TO_NPVARIANT(NPN_RetainObject(deintObj), result);
+                return INVOKERESULT_NO_ERROR;
+            }
         }
     }
     return INVOKERESULT_GENERIC_ERROR;
@@ -1370,11 +1383,9 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -1386,8 +1397,7 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
                 }
 
                 int val = NPVARIANT_TO_BOOLEAN(value);
-                p_plugin->set_fullscreen(val, &ex);
-                RETURN_ON_EXCEPTION(this,ex);
+                p_plugin->set_fullscreen(val);
                 return INVOKERESULT_NO_ERROR;
             }
             case ID_video_aspectratio:
@@ -1405,9 +1415,8 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
                     return INVOKERESULT_GENERIC_ERROR;
                 }
 
-                libvlc_video_set_aspect_ratio(p_md, psz_aspect, &ex);
+                libvlc_video_set_aspect_ratio(p_md, psz_aspect);
                 free(psz_aspect);
-                RETURN_ON_EXCEPTION(this,ex);
 
                 return INVOKERESULT_NO_ERROR;
             }
@@ -1415,8 +1424,7 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
             {
                 if( isNumberValue(value) )
                 {
-                    libvlc_video_set_spu(p_md, numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_video_set_spu(p_md, numberValue(value));
 
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -1437,9 +1445,8 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
                     return INVOKERESULT_GENERIC_ERROR;
                 }
 
-                libvlc_video_set_crop_geometry(p_md, psz_geometry, &ex);
+                libvlc_video_set_crop_geometry(p_md, psz_geometry);
                 free(psz_geometry);
-                RETURN_ON_EXCEPTION(this,ex);
 
                 return INVOKERESULT_NO_ERROR;
             }
@@ -1447,9 +1454,7 @@ LibvlcVideoNPObject::setProperty(int index, const NPVariant &value)
             {
                 if( isNumberValue(value) )
                 {
-                    libvlc_video_set_teletext(p_md, numberValue(value), &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
-
+                    libvlc_video_set_teletext(p_md, numberValue(value));
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_INVALID_VALUE;
@@ -1463,8 +1468,6 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
 {
     "toggleFullscreen",
     "toggleTeletext",
-    "deinterlaceEnable",
-    "deinterlaceDisable"
 };
 COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
 
@@ -1472,8 +1475,6 @@ enum LibvlcVideoNPObjectMethodIds
 {
     ID_video_togglefullscreen,
     ID_video_toggleteletext,
-    ID_video_deinterlaceenable,
-    ID_video_deinterlacedisable
 };
 
 RuntimeNPObject::InvokeResult
@@ -1484,11 +1485,9 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
     if( isPluginRunning() )
     {
         VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
-
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+        libvlc_media_player_t *p_md = p_plugin->getMD();
+        if( !p_md )
+            RETURN_ON_ERROR;
 
         switch( index )
         {
@@ -1496,8 +1495,7 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
             {
                 if( argCount == 0 )
                 {
-                    p_plugin->toggle_fullscreen(&ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    p_plugin->toggle_fullscreen();
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
@@ -1507,39 +1505,12 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
             {
                 if( argCount == 0 )
                 {
-                    libvlc_toggle_teletext(p_md, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
+                    libvlc_toggle_teletext(p_md);
                     VOID_TO_NPVARIANT(result);
                     return INVOKERESULT_NO_ERROR;
                 }
                 return INVOKERESULT_NO_SUCH_METHOD;
             }
-            case ID_video_deinterlacedisable:
-            {
-                libvlc_video_set_deinterlace(p_md, 0, "", &ex);
-                RETURN_ON_EXCEPTION(this,ex);
-                return INVOKERESULT_NO_ERROR;
-            }
-            case ID_video_deinterlaceenable:
-            {
-                if(argCount == 1)
-                {
-                    if( NPVARIANT_IS_STRING( args[0] ) )
-                    {
-                        /* get deinterlace mode from the user */
-                        char *psz_mode = stringValue( NPVARIANT_TO_STRING( args[0] ) );
-                        /* enable deinterlace filter if possible */
-                        libvlc_video_set_deinterlace(p_md, 1, psz_mode, &ex);
-                        free(psz_mode);
-                        RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                    {
-                        return INVOKERESULT_INVALID_VALUE;
-                    }
-                }
-            }
             default:
                 return INVOKERESULT_NO_SUCH_METHOD;
         }
@@ -1553,29 +1524,86 @@ LibvlcVideoNPObject::invoke(int index, const NPVariant *args,
 
 const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
 {
+    "color",
+    "opacity",
+    "position",
+    "refresh",
+    "size",
+    "text",
+    "timeout",
+    "x",
+    "y",
 };
 
 enum LibvlcMarqueeNPObjectPropertyIds
 {
+    ID_marquee_color,
+    ID_marquee_opacity,
+    ID_marquee_position,
+    ID_marquee_refresh,
+    ID_marquee_size,
+    ID_marquee_text,
+    ID_marquee_timeout,
+    ID_marquee_x,
+    ID_marquee_y,
 };
+
 COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
 
+static const unsigned char marquee_idx[] = {
+    libvlc_marquee_Color,
+    libvlc_marquee_Opacity,
+    libvlc_marquee_Position,
+    libvlc_marquee_Refresh,
+    libvlc_marquee_Size,
+    0,
+    libvlc_marquee_Timeout,
+    libvlc_marquee_X,
+    libvlc_marquee_Y,
+};
+
 RuntimeNPObject::InvokeResult
 LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
 {
-    /* is plugin still running */
-    if( isPluginRunning() )
-    {
-        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+    char *psz;
 
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
 
-        switch( index )
+    VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+    libvlc_media_player_t *p_md = p_plugin->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
+    {
+    case ID_marquee_color:
+    case ID_marquee_opacity:
+    case ID_marquee_refresh:
+    case ID_marquee_timeout:
+    case ID_marquee_size:
+    case ID_marquee_x:
+    case ID_marquee_y:
+        INT32_TO_NPVARIANT(
+            libvlc_video_get_marquee_int(p_md, marquee_idx[index]),
+            result );
+        return INVOKERESULT_NO_ERROR;
+
+    case ID_marquee_position:
+        STRINGZ_TO_NPVARIANT( position_bynumber(
+            libvlc_video_get_marquee_int(p_md, libvlc_marquee_Position) ),
+            result );
+
+        break;
+
+    case ID_marquee_text:
+        psz = libvlc_video_get_marquee_string(p_md, libvlc_marquee_Text);
+        if( psz )
         {
+            STRINGZ_TO_NPVARIANT(psz, result);
+            return INVOKERESULT_NO_ERROR;
         }
+        break;
     }
     return INVOKERESULT_GENERIC_ERROR;
 }
@@ -1583,36 +1611,58 @@ LibvlcMarqueeNPObject::getProperty(int index, NPVariant &result)
 RuntimeNPObject::InvokeResult
 LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
 {
-    /* is plugin still running */
-    if( isPluginRunning() )
+    size_t i;
+
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+    libvlc_media_player_t *p_md = p_plugin->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
     {
-        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+    case ID_marquee_color:
+    case ID_marquee_opacity:
+    case ID_marquee_refresh:
+    case ID_marquee_timeout:
+    case ID_marquee_x:
+    case ID_marquee_y:
+        if( NPVARIANT_IS_INT32( value ) )
+        {
+            libvlc_video_set_marquee_int(p_md, marquee_idx[index],
+                                         NPVARIANT_TO_INT32( value ));
+            return INVOKERESULT_NO_ERROR;
+        }
+        break;
 
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+    case ID_marquee_position:
+        if( !NPVARIANT_IS_STRING(value) ||
+            !position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) )
+            return INVOKERESULT_INVALID_VALUE;
 
-        switch( index )
+        libvlc_video_set_marquee_int(p_md, libvlc_marquee_Position, i);
+        return INVOKERESULT_NO_ERROR;
+
+    case ID_marquee_text:
+        if( NPVARIANT_IS_STRING( value ) )
         {
+            char *psz_text = stringValue( NPVARIANT_TO_STRING( value ) );
+            libvlc_video_set_marquee_string(p_md, libvlc_marquee_Text,
+                                            psz_text);
+            free(psz_text);
+            return INVOKERESULT_NO_ERROR;
         }
+        break;
     }
-    return INVOKERESULT_GENERIC_ERROR;
+    return INVOKERESULT_NO_SUCH_METHOD;
 }
 
 const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
 {
     "enable",
     "disable",
-    "color",
-    "opacity",
-    "position",
-    "refresh",
-    "size",
-    "text",
-    "timeout",
-    "x",
-    "y"
 };
 COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
 
@@ -1620,193 +1670,266 @@ enum LibvlcMarqueeNPObjectMethodIds
 {
     ID_marquee_enable,
     ID_marquee_disable,
-    ID_marquee_color,
-    ID_marquee_opacity,
-    ID_marquee_position,
-    ID_marquee_refresh,
-    ID_marquee_size,
-    ID_marquee_text,
-    ID_marquee_timeout,
-    ID_marquee_x,
-    ID_marquee_y
 };
 
 RuntimeNPObject::InvokeResult
 LibvlcMarqueeNPObject::invoke(int index, const NPVariant *args,
                             uint32_t argCount, NPVariant &result)
 {
-    /* is plugin still running */
-    if( isPluginRunning() )
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+    libvlc_media_player_t *p_md = p_plugin->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
     {
-        VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
-        libvlc_exception_t ex;
-        libvlc_exception_init(&ex);
+    case ID_marquee_enable:
+    case ID_marquee_disable:
+        libvlc_video_set_marquee_int(p_md, libvlc_marquee_Enable,
+                                     index!=ID_marquee_disable);
+        VOID_TO_NPVARIANT(result);
+        return INVOKERESULT_NO_ERROR;
+    }
+    return INVOKERESULT_NO_SUCH_METHOD;
+}
 
-        libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
-        RETURN_ON_EXCEPTION(this,ex);
+const NPUTF8 * const LibvlcLogoNPObject::propertyNames[] = {
+    "delay",
+    "repeat",
+    "opacity",
+    "position",
+    "x",
+    "y",
+};
+enum LibvlcLogoNPObjectPropertyIds {
+    ID_logo_delay,
+    ID_logo_repeat,
+    ID_logo_opacity,
+    ID_logo_position,
+    ID_logo_x,
+    ID_logo_y,
+};
+COUNTNAMES(LibvlcLogoNPObject,propertyCount,propertyNames);
+static const unsigned char logo_idx[] = {
+    libvlc_logo_delay,
+    libvlc_logo_repeat,
+    libvlc_logo_opacity,
+    0,
+    libvlc_logo_x,
+    libvlc_logo_y,
+};
 
-        switch( index )
+RuntimeNPObject::InvokeResult
+LibvlcLogoNPObject::getProperty(int index, NPVariant &result)
+{
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+    libvlc_media_player_t *p_md = p_plugin->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
+    {
+    case ID_logo_delay:
+    case ID_logo_repeat:
+    case ID_logo_opacity:
+    case ID_logo_x:
+    case ID_logo_y:
+
+        INT32_TO_NPVARIANT(
+            libvlc_video_get_logo_int(p_md, logo_idx[index]), result);
+        break;
+
+    case ID_logo_position:
+        STRINGZ_TO_NPVARIANT( position_bynumber(
+            libvlc_video_get_logo_int(p_md, libvlc_logo_position) ),
+            result );
+        break;
+    default:
+        return INVOKERESULT_GENERIC_ERROR;
+    }
+    return INVOKERESULT_NO_ERROR;
+}
+
+RuntimeNPObject::InvokeResult
+LibvlcLogoNPObject::setProperty(int index, const NPVariant &value)
+{
+    size_t i;
+
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
+    libvlc_media_player_t *p_md = p_plugin->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
+    {
+    case ID_logo_delay:
+    case ID_logo_repeat:
+    case ID_logo_opacity:
+    case ID_logo_x:
+    case ID_logo_y:
+        if( !NPVARIANT_IS_INT32(value) )
+            return INVOKERESULT_INVALID_VALUE;
+
+        libvlc_video_set_logo_int(p_md, logo_idx[index],
+                                  NPVARIANT_TO_INT32( value ));
+        break;
+
+    case ID_logo_position:
+        if( !NPVARIANT_IS_STRING(value) ||
+            !position_byname( NPVARIANT_TO_STRING(value).utf8characters, i ) )
+            return INVOKERESULT_INVALID_VALUE;
+
+        libvlc_video_set_logo_int(p_md, libvlc_logo_position, i);
+        break;
+    default:
+        return INVOKERESULT_GENERIC_ERROR;
+    }
+    return INVOKERESULT_NO_ERROR;
+}
+
+
+const NPUTF8 * const LibvlcLogoNPObject::methodNames[] = {
+    "enable",
+    "disable",
+    "file",
+};
+enum LibvlcLogoNPObjectMethodIds {
+    ID_logo_enable,
+    ID_logo_disable,
+    ID_logo_file,
+};
+COUNTNAMES(LibvlcLogoNPObject,methodCount,methodNames);
+
+RuntimeNPObject::InvokeResult
+LibvlcLogoNPObject::invoke(int index, const NPVariant *args,
+                           uint32_t argCount, NPVariant &result)
+{
+    char *buf, *h;
+    size_t i, len;
+
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
+    {
+    case ID_logo_enable:
+    case ID_logo_disable:
+        if( argCount != 0 )
+            return INVOKERESULT_GENERIC_ERROR;
+
+        libvlc_video_set_logo_int(p_md, libvlc_logo_enable,
+                                  index != ID_logo_disable);
+        VOID_TO_NPVARIANT(result);
+        break;
+
+    case ID_logo_file:
+        if( argCount == 0 )
+            return INVOKERESULT_GENERIC_ERROR;
+
+        for( len=0,i=0;i<argCount;++i )
         {
-            case ID_marquee_enable:
-            {
-                libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, true, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
-                return INVOKERESULT_NO_ERROR;
-            }
-            case ID_marquee_disable:
-            {
-                libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Enabled, false, &ex);
-                    RETURN_ON_EXCEPTION(this,ex);
-                return INVOKERESULT_NO_ERROR;
-            }
-            case ID_marquee_color:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_color = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Color, i_color, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_opacity:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_opacity = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Opacity, i_opacity, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_position:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_position = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Position, i_position, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_refresh:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_refresh = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Refresh, i_refresh, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_size:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_size = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Size, i_size, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_text:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_STRING( args[0] ) )
-                    {
-                        char *psz_text = stringValue( NPVARIANT_TO_STRING( args[0] ) );
-                        libvlc_video_set_marquee_option_as_string(p_md, libvlc_marquee_Text, psz_text, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        free(psz_text);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_timeout:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_timeout = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Timeout, i_timeout, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_x:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_x = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_X, i_x, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            case ID_marquee_y:
-            {
-                if( argCount == 1)
-                {
-                    if( NPVARIANT_IS_INT32( args[0] ) )
-                    {
-                        int i_y = NPVARIANT_TO_INT32( args[0] );
-                        libvlc_video_set_marquee_option_as_int(p_md, libvlc_marquee_Y, i_y, &ex);
-                            RETURN_ON_EXCEPTION(this,ex);
-                        return INVOKERESULT_NO_ERROR;
-                    }
-                    else
-                        return INVOKERESULT_GENERIC_ERROR;
-                }
-                return INVOKERESULT_NO_SUCH_METHOD;
-            }
-            default:
-                return INVOKERESULT_NO_SUCH_METHOD;
+            if( !NPVARIANT_IS_STRING(args[i]) )
+                return INVOKERESULT_INVALID_VALUE;
+            len+=NPVARIANT_TO_STRING(args[i]).utf8length+1;
+        }
+
+        buf = (char *)malloc( len+1 );
+        if( !buf )
+            return INVOKERESULT_OUT_OF_MEMORY;
+
+        for( h=buf,i=0;i<argCount;++i )
+        {
+            if(i) *h++=';';
+            len=NPVARIANT_TO_STRING(args[i]).utf8length;
+            memcpy(h,NPVARIANT_TO_STRING(args[i]).utf8characters,len);
+            h+=len;
         }
+        *h='\0';
+
+        libvlc_video_set_logo_string(p_md, libvlc_logo_file, buf);
+        free( buf );
+        VOID_TO_NPVARIANT(result);
+        break;
+    default:
+        return INVOKERESULT_NO_SUCH_METHOD;
     }
+    return INVOKERESULT_NO_ERROR;
+}
+
+
+const NPUTF8 * const LibvlcDeinterlaceNPObject::propertyNames[] = {
+};
+enum LibvlcDeinterlaceNPObjectPropertyIds {
+};
+COUNTNAMES(LibvlcDeinterlaceNPObject,propertyCount,propertyNames);
+
+RuntimeNPObject::InvokeResult
+LibvlcDeinterlaceNPObject::getProperty(int index, NPVariant &result)
+{
     return INVOKERESULT_GENERIC_ERROR;
 }
+
+RuntimeNPObject::InvokeResult
+LibvlcDeinterlaceNPObject::setProperty(int index, const NPVariant &value)
+{
+    return INVOKERESULT_GENERIC_ERROR;
+}
+
+
+const NPUTF8 * const LibvlcDeinterlaceNPObject::methodNames[] = {
+    "enable",
+    "disable",
+};
+enum LibvlcDeinterlaceNPObjectMethodIds {
+    ID_deint_enable,
+    ID_deint_disable,
+};
+COUNTNAMES(LibvlcDeinterlaceNPObject,methodCount,methodNames);
+
+RuntimeNPObject::InvokeResult
+LibvlcDeinterlaceNPObject::invoke(int index, const NPVariant *args,
+                           uint32_t argCount, NPVariant &result)
+{
+    char *psz;
+
+    if( !isPluginRunning() )
+        return INVOKERESULT_GENERIC_ERROR;
+
+    libvlc_media_player_t *p_md = getPrivate<VlcPlugin>()->getMD();
+    if( !p_md )
+        RETURN_ON_ERROR;
+
+    switch( index )
+    {
+    case ID_deint_disable:
+        libvlc_video_set_deinterlace(p_md, NULL);
+        break;
+
+    case ID_deint_enable:
+        if( argCount != 1 || !NPVARIANT_IS_STRING( args[0] ) )
+            return INVOKERESULT_INVALID_VALUE;
+
+        psz = stringValue( NPVARIANT_TO_STRING( args[0] ) );
+        libvlc_video_set_deinterlace(p_md, psz);
+        free(psz);
+        break;
+
+    default:
+        return INVOKERESULT_NO_SUCH_METHOD;
+    }
+    return INVOKERESULT_NO_ERROR;
+}
+