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

npapi: Wrap return values with npapi::Variant

parent 556fc00e
...@@ -95,7 +95,7 @@ enum LibvlcRootNPObjectPropertyIds ...@@ -95,7 +95,7 @@ enum LibvlcRootNPObjectPropertyIds
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcRootNPObject::getProperty(int index, NPVariant &result) LibvlcRootNPObject::getProperty(int index, npapi::OutVariant &result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -104,30 +104,31 @@ LibvlcRootNPObject::getProperty(int index, NPVariant &result) ...@@ -104,30 +104,31 @@ LibvlcRootNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_root_audio: case ID_root_audio:
InstantObj<LibvlcAudioNPObject>( audioObj ); InstantObj<LibvlcAudioNPObject>( audioObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result); result = audioObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_input: case ID_root_input:
InstantObj<LibvlcInputNPObject>( inputObj ); InstantObj<LibvlcInputNPObject>( inputObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result); result = inputObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_playlist: case ID_root_playlist:
InstantObj<LibvlcPlaylistNPObject>( playlistObj ); InstantObj<LibvlcPlaylistNPObject>( playlistObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result); result = playlistObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_subtitle: case ID_root_subtitle:
InstantObj<LibvlcSubtitleNPObject>( subtitleObj ); InstantObj<LibvlcSubtitleNPObject>( subtitleObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(subtitleObj), result); result = subtitleObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_video: case ID_root_video:
InstantObj<LibvlcVideoNPObject>( videoObj ); InstantObj<LibvlcVideoNPObject>( videoObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result); result = videoObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
case ID_root_VersionInfo: case ID_root_VersionInfo:
return invokeResultString(libvlc_get_version(),result); result = libvlc_get_version();
return INVOKERESULT_NO_ERROR;
case ID_root_MediaDescription: case ID_root_MediaDescription:
{ {
InstantObj<LibvlcMediaDescriptionNPObject>( mediaDescriptionObj ); InstantObj<LibvlcMediaDescriptionNPObject>( mediaDescriptionObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(mediaDescriptionObj), result); result = mediaDescriptionObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
...@@ -153,7 +154,7 @@ enum LibvlcRootNPObjectMethodIds ...@@ -153,7 +154,7 @@ enum LibvlcRootNPObjectMethodIds
}; };
RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
const NPVariant *args, uint32_t argCount, NPVariant &result) const NPVariant *args, uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( !isPluginRunning() ) if( !isPluginRunning() )
...@@ -164,7 +165,8 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, ...@@ -164,7 +165,8 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
case ID_root_versionInfo: case ID_root_versionInfo:
if( 0 != argCount ) if( 0 != argCount )
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
return invokeResultString(libvlc_get_version(),result); result = libvlc_get_version();
return INVOKERESULT_NO_ERROR;
case ID_root_addeventlistener: case ID_root_addeventlistener:
case ID_root_removeeventlistener: case ID_root_removeeventlistener:
...@@ -194,8 +196,6 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, ...@@ -194,8 +196,6 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index,
{ {
p_plugin->unsubscribe( npapi::to_tmp_string( args[0] ), listener ); p_plugin->unsubscribe( npapi::to_tmp_string( args[0] ), listener );
} }
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -225,7 +225,7 @@ enum LibvlcAudioNPObjectPropertyIds ...@@ -225,7 +225,7 @@ enum LibvlcAudioNPObjectPropertyIds
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcAudioNPObject::getProperty(int index, NPVariant &result) LibvlcAudioNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -240,34 +240,27 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result) ...@@ -240,34 +240,27 @@ LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_audio_mute: case ID_audio_mute:
{ {
bool muted = mp.mute(); result = mp.mute();
BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_volume: case ID_audio_volume:
{ {
int volume = mp.volume(); result = mp.volume();
INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_track: case ID_audio_track:
{ {
int track = p_plugin->player().currentAudioTrack(); result = p_plugin->player().currentAudioTrack();
INT32_TO_NPVARIANT(track, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_count: case ID_audio_count:
{ {
// get the number of audio track available result = mp.audioTrackCount();
int i_track = mp.audioTrackCount();
// return it
INT32_TO_NPVARIANT(i_track, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_audio_channel: case ID_audio_channel:
{ {
int channel = mp.channel(); result = mp.channel();
INT32_TO_NPVARIANT(channel, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
...@@ -345,7 +338,7 @@ enum LibvlcAudioNPObjectMethodIds ...@@ -345,7 +338,7 @@ enum LibvlcAudioNPObjectMethodIds
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcAudioNPObject::invoke(int index, const NPVariant *args, LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, NPVariant &result) uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -361,7 +354,6 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args, ...@@ -361,7 +354,6 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
mp.toggleMute(); mp.toggleMute();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -376,7 +368,8 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args, ...@@ -376,7 +368,8 @@ LibvlcAudioNPObject::invoke(int index, const NPVariant *args,
if ( v >= tracks.size() ) if ( v >= tracks.size() )
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
/* display the name of the track chosen */ /* display the name of the track chosen */
return invokeResultString( tracks[v].name().c_str(), result ); result = tracks[v].name();
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
...@@ -415,7 +408,7 @@ enum LibvlcInputNPObjectPropertyIds ...@@ -415,7 +408,7 @@ enum LibvlcInputNPObjectPropertyIds
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcInputNPObject::getProperty(int index, NPVariant &result) LibvlcInputNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -429,7 +422,7 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result) ...@@ -429,7 +422,7 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
else else
{ {
/* for input state, return CLOSED rather than an exception */ /* for input state, return CLOSED rather than an exception */
INT32_TO_NPVARIANT(0, result); result = 0;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
...@@ -438,44 +431,37 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result) ...@@ -438,44 +431,37 @@ LibvlcInputNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_input_length: case ID_input_length:
{ {
double val = mp.length(); result = mp.length();
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_position: case ID_input_position:
{ {
double val = mp.position(); result = mp.position();
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_time: case ID_input_time:
{ {
double val = (double)mp.time(); result = mp.time();
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_state: case ID_input_state:
{ {
int val = mp.state(); result = (int)mp.state();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_rate: case ID_input_rate:
{ {
float val = mp.rate(); result = mp.rate();
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_fps: case ID_input_fps:
{ {
double val = mp.fps(); result = mp.fps();
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_input_hasvout: case ID_input_hasvout:
{ {
bool val = p_plugin->player().get_mp().hasVout() != 0; result = p_plugin->player().get_mp().hasVout() != 0;
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
...@@ -613,7 +599,7 @@ enum LibvlcMediaDescriptionNPObjectPropertyIds ...@@ -613,7 +599,7 @@ enum LibvlcMediaDescriptionNPObjectPropertyIds
ID_meta_trackID, ID_meta_trackID,
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcMediaDescriptionNPObject::getProperty(int index, NPVariant &result) LibvlcMediaDescriptionNPObject::getProperty(int index, npapi::OutVariant &result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -647,7 +633,8 @@ LibvlcMediaDescriptionNPObject::getProperty(int index, NPVariant &result) ...@@ -647,7 +633,8 @@ LibvlcMediaDescriptionNPObject::getProperty(int index, NPVariant &result)
case ID_meta_trackID: case ID_meta_trackID:
{ {
auto m = media->meta( (libvlc_meta_t)index ); auto m = media->meta( (libvlc_meta_t)index );
return invokeResultString(m.c_str(), result); result = m;
return INVOKERESULT_NO_ERROR;
} }
default: default:
; ;
...@@ -684,7 +671,7 @@ enum LibvlcPlaylistItemsNPObjectPropertyIds ...@@ -684,7 +671,7 @@ enum LibvlcPlaylistItemsNPObjectPropertyIds
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result) LibvlcPlaylistItemsNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -695,8 +682,7 @@ LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result) ...@@ -695,8 +682,7 @@ LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_playlistitems_count: case ID_playlistitems_count:
{ {
int val = p_plugin->player().items_count(); result = p_plugin->player().items_count();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
...@@ -721,7 +707,7 @@ enum LibvlcPlaylistItemsNPObjectMethodIds ...@@ -721,7 +707,7 @@ enum LibvlcPlaylistItemsNPObjectMethodIds
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args, LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, NPVariant &result) uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -734,7 +720,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args, ...@@ -734,7 +720,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().clear_items(); p_plugin->player().clear_items();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -747,7 +732,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args, ...@@ -747,7 +732,6 @@ LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
{ {
if( !p_plugin->player().delete_item( v ) ) if( !p_plugin->player().delete_item( v ) )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -788,7 +772,7 @@ enum LibvlcPlaylistNPObjectPropertyIds ...@@ -788,7 +772,7 @@ enum LibvlcPlaylistNPObjectPropertyIds
}; };
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result) LibvlcPlaylistNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -799,26 +783,23 @@ LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result) ...@@ -799,26 +783,23 @@ LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_playlist_itemcount: /* deprecated */ case ID_playlist_itemcount: /* deprecated */
{ {
int val = p_plugin->player().items_count(); result = p_plugin->player().items_count();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_playlist_isplaying: case ID_playlist_isplaying:
{ {
int val = p_plugin->player().mlp().isPlaying(); result = p_plugin->player().mlp().isPlaying();
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_playlist_currentitem: case ID_playlist_currentitem:
{ {
int val = p_plugin->player().current_item(); result = p_plugin->player().current_item();
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_playlist_items: case ID_playlist_items:
{ {
InstantObj<LibvlcPlaylistItemsNPObject>( playlistItemsObj ); InstantObj<LibvlcPlaylistItemsNPObject>( playlistItemsObj );
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result); result = playlistItemsObj;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default: default:
...@@ -859,7 +840,7 @@ enum LibvlcPlaylistNPObjectMethodIds ...@@ -859,7 +840,7 @@ enum LibvlcPlaylistNPObjectMethodIds
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, NPVariant &result) uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -940,14 +921,13 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -940,14 +921,13 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
} }
free(ppsz_options); free(ppsz_options);
INT32_TO_NPVARIANT(item, result); result = item;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_playlist_play: case ID_playlist_play:
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().play(); p_plugin->player().play();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -959,7 +939,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -959,7 +939,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if ( v.is<int>() ) if ( v.is<int>() )
{ {
p_plugin->player().mlp().playItemAtIndex( v ); p_plugin->player().mlp().playItemAtIndex( v );
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -968,7 +947,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -968,7 +947,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().get_mp().setPause( true ); p_plugin->player().get_mp().setPause( true );
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -976,7 +954,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -976,7 +954,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().mlp().pause(); p_plugin->player().mlp().pause();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -984,7 +961,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -984,7 +961,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().mlp().stop(); p_plugin->player().mlp().stop();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -992,7 +968,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -992,7 +968,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().mlp().next(); p_plugin->player().mlp().next();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -1000,7 +975,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -1000,7 +975,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().mlp().previous(); p_plugin->player().mlp().previous();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -1008,7 +982,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -1008,7 +982,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
if( argCount == 0 ) if( argCount == 0 )
{ {
p_plugin->player().clear_items(); p_plugin->player().clear_items();
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -1021,7 +994,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, ...@@ -1021,7 +994,6 @@ LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
{ {
if( !p_plugin->player().delete_item( v ) ) if( !p_plugin->player().delete_item( v ) )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -1184,7 +1156,7 @@ enum LibvlcSubtitleNPObjectPropertyIds ...@@ -1184,7 +1156,7 @@ enum LibvlcSubtitleNPObjectPropertyIds
COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames); COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result) LibvlcSubtitleNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -1199,16 +1171,14 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result) ...@@ -1199,16 +1171,14 @@ LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
case ID_subtitle_track: case ID_subtitle_track:
{ {
/* get the current internal subtitles track ID */ /* get the current internal subtitles track ID */
int actualTrack = p_plugin->player().currentSubtitleTrack(); result = p_plugin->player().currentSubtitleTrack();
INT32_TO_NPVARIANT(actualTrack, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_subtitle_count: case ID_subtitle_count:
{ {
/* get the number of subtitles available */ /* get the number of subtitles available */
int i_spu = mp.spuCount(); result = mp.spuCount();
/* return it */ /* return it */
INT32_TO_NPVARIANT(i_spu, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
...@@ -1260,7 +1230,7 @@ enum LibvlcSubtitleNPObjectMethodIds ...@@ -1260,7 +1230,7 @@ enum LibvlcSubtitleNPObjectMethodIds
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args, LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
uint32_t argCount, NPVariant &result) uint32_t argCount, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -1283,7 +1253,8 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args, ...@@ -1283,7 +1253,8 @@ LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
if ( v >= tracks.size() ) if ( v >= tracks.size() )
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
/* display the name of the track chosen */ /* display the name of the track chosen */
return invokeResultString( tracks[v].name().c_str(), result ); result = tracks[v].name();
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
...@@ -1338,7 +1309,7 @@ enum LibvlcVideoNPObjectPropertyIds ...@@ -1338,7 +1309,7 @@ enum LibvlcVideoNPObjectPropertyIds
COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames); COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
RuntimeNPObject::InvokeResult RuntimeNPObject::InvokeResult
LibvlcVideoNPObject::getProperty(int index, NPVariant &result) LibvlcVideoNPObject::getProperty(int index, npapi::OutVariant& result)
{ {
/* is plugin still running */ /* is plugin still running */
if( isPluginRunning() ) if( isPluginRunning() )
...@@ -1352,22 +1323,21 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result) ...@@ -1352,22 +1323,21 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
{ {
case ID_video_fullscreen: case ID_video_fullscreen:
{ {
int val = p_plugin->get_fullscreen(); result = p_plugin->get_fullscreen();
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_height: case ID_video_height:
{ {
unsigned width, height; unsigned width, height;
mp.size( 0, &width, &height ); mp.size( 0, &width, &height );
INT32_TO_NPVARIANT(height, result); result = height;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_width: case ID_video_width:
{ {
unsigned width, height; unsigned width, height;
mp.size( 0, &width, &height ); mp.size( 0, &width, &height );
INT32_TO_NPVARIANT(width, result); result = width;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_aspectratio: case ID_video_aspectratio:
...@@ -1376,13 +1346,12 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result) ...@@ -1376,13 +1346,12 @@ LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
if( ar.empty() ) if( ar.empty() )
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(ar.c_str(), result); result = ar;
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_video_subtitle: case ID_video_subtitle:
{ {
int i_spu = mp.spu(); result = mp.spu();
INT32_TO_NPVARIANT(i_spu,