#define RETURN_ON_EXCEPTION(this,ex) \
do { if( libvlc_exception_raised(&ex) ) \
{ \
- NPN_SetException(this, libvlc_exception_get_message(&ex)); \
+ NPN_SetException(this, libvlc_errmsg()); \
libvlc_exception_clear(&ex); \
return INVOKERESULT_GENERIC_ERROR; \
} } while(false)
{
if( audioObj ) NPN_ReleaseObject(audioObj);
if( inputObj ) NPN_ReleaseObject(inputObj);
- if( logObj ) NPN_ReleaseObject(logObj);
if( playlistObj ) NPN_ReleaseObject(playlistObj);
if( videoObj ) NPN_ReleaseObject(videoObj);
}
{
"audio",
"input",
- "log",
"playlist",
+ "subtitle",
"video",
"VersionInfo",
};
{
ID_root_audio = 0,
ID_root_input,
- ID_root_log,
ID_root_playlist,
+ ID_root_subtitle,
ID_root_video,
ID_root_VersionInfo,
};
RuntimeNPClass<LibvlcInputNPObject>::getClass());
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
return INVOKERESULT_NO_ERROR;
- case ID_root_log:
- // create child object in lazyman fashion to avoid
- // ownership problem with firefox
- if( ! logObj )
- logObj = NPN_CreateObject(_instance,
- RuntimeNPClass<LibvlcLogNPObject>::getClass());
- OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
- return INVOKERESULT_NO_ERROR;
case ID_root_playlist:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
RuntimeNPClass<LibvlcPlaylistNPObject>::getClass());
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
return INVOKERESULT_NO_ERROR;
+ case ID_root_subtitle:
+ // create child object in lazyman fashion to avoid
+ // ownership problem with firefox
+ if( ! subtitleObj )
+ subtitleObj = NPN_CreateObject(_instance,
+ RuntimeNPClass<LibvlcSubtitleNPObject>::getClass());
+ OBJECT_TO_NPVARIANT(NPN_RetainObject(subtitleObj), result);
+ return INVOKERESULT_NO_ERROR;
case ID_root_video:
// create child object in lazyman fashion to avoid
// ownership problem with firefox
"mute",
"volume",
"track",
+ "count",
"channel",
};
COUNTNAMES(LibvlcAudioNPObject,propertyCount,propertyNames);
ID_audio_mute,
ID_audio_volume,
ID_audio_track,
+ ID_audio_count,
ID_audio_channel,
};
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);
+ // 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);
const NPUTF8 * const LibvlcAudioNPObject::methodNames[] =
{
"toggleMute",
+ "description",
};
COUNTNAMES(LibvlcAudioNPObject,methodCount,methodNames);
enum LibvlcAudioNPObjectMethodIds
{
ID_audio_togglemute,
+ ID_audio_description,
};
RuntimeNPObject::InvokeResult
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
+ case ID_audio_description:
+ {
+ if( argCount == 1)
+ {
+ char *psz_name;
+ 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);
+ 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);
+
+ /* check if a number is given by the user
+ * and get the track number */
+ if( isNumberValue(args[0]) )
+ i_trackID = numberValue(args[0]);
+ else
+ return INVOKERESULT_INVALID_VALUE;
+
+ /* if bad number is given return invalid value */
+ if ( ( i_trackID > ( i_limit - 1 ) ) || ( i_trackID < 0 ) )
+ return INVOKERESULT_INVALID_VALUE;
+
+ /* get the good trackDesc */
+ for( i = 0 ; i < i_trackID ; i++ )
+ {
+ p_trackDesc = p_trackDesc->p_next;
+ }
+ psz_name = p_trackDesc->psz_name;
+
+ /* display the name of the track chosen */
+ return invokeResultString( psz_name, result );
+ }
+ return INVOKERESULT_NO_SUCH_METHOD;
+ }
default:
;
}
{
if( index != ID_input_state )
{
- NPN_SetException(this, libvlc_exception_get_message(&ex));
+ NPN_SetException(this, libvlc_errmsg());
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
const NPUTF8 * const LibvlcInputNPObject::methodNames[] =
{
/* no methods */
+ "none",
};
-
COUNTNAMES(LibvlcInputNPObject,methodCount,methodNames);
-/*
-** implementation of libvlc message object
-*/
-
-const NPUTF8 * const LibvlcMessageNPObject::propertyNames[] =
-{
- "severity",
- "type",
- "name",
- "header",
- "message",
-};
-COUNTNAMES(LibvlcMessageNPObject,propertyCount,propertyNames);
-
-enum LibvlcMessageNPObjectPropertyIds
+enum LibvlcInputNPObjectMethodIds
{
- ID_message_severity,
- ID_message_type,
- ID_message_name,
- ID_message_header,
- ID_message_message,
+ ID_none,
};
RuntimeNPObject::InvokeResult
-LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
+LibvlcInputNPObject::invoke(int index, const NPVariant *args,
+ uint32_t argCount, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
{
switch( index )
{
- case ID_message_severity:
- {
- INT32_TO_NPVARIANT(_msg.i_severity, result);
- return INVOKERESULT_NO_ERROR;
- }
- case ID_message_type:
- return invokeResultString(_msg.psz_type,result);
- case ID_message_name:
- return invokeResultString(_msg.psz_name,result);
- case ID_message_header:
- return invokeResultString(_msg.psz_header,result);
- case ID_message_message:
- return invokeResultString(_msg.psz_message,result);
+ case ID_none:
+ return INVOKERESULT_NO_SUCH_METHOD;
default:
;
}
return INVOKERESULT_GENERIC_ERROR;
}
-const NPUTF8 * const LibvlcMessageNPObject::methodNames[] =
-{
- /* no methods */
-};
-COUNTNAMES(LibvlcMessageNPObject,methodCount,methodNames);
-
/*
-** implementation of libvlc message iterator object
+** implementation of libvlc playlist items object
*/
-LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance,
- const NPClass *aClass) :
- RuntimeNPObject(instance, aClass),
- _p_iter(NULL)
-{
- // XXX FIXME use _instance or instance in this method?
-
- /* is plugin still running */
- if( instance->pdata )
- {
- VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
- libvlc_log_t *p_log = p_plugin->getLog();
- if( p_log )
- {
- _p_iter = libvlc_log_get_iterator(p_log, NULL);
- }
- }
-};
-
-LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
-{
- if( _p_iter )
- libvlc_log_iterator_free(_p_iter, NULL);
-}
-
-const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
-{
- "hasNext",
-};
-COUNTNAMES(LibvlcMessageIteratorNPObject,propertyCount,propertyNames);
-
-enum LibvlcMessageIteratorNPObjectPropertyIds
-{
- ID_messageiterator_hasNext,
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
-{
- /* is plugin still running */
- if( isPluginRunning() )
- {
- VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
- switch( index )
- {
- case ID_messageiterator_hasNext:
- {
- if( _p_iter && p_plugin->getLog() )
- {
- libvlc_exception_t ex;
- libvlc_exception_init(&ex);
-
- BOOLEAN_TO_NPVARIANT(
- libvlc_log_iterator_has_next(_p_iter, &ex), result );
- RETURN_ON_EXCEPTION(this,ex);
- }
- else
- {
- BOOLEAN_TO_NPVARIANT(0, result);
- }
- return INVOKERESULT_NO_ERROR;
- }
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-const NPUTF8 * const LibvlcMessageIteratorNPObject::methodNames[] =
+const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
{
- "next",
+ "count",
};
-COUNTNAMES(LibvlcMessageIteratorNPObject,methodCount,methodNames);
+COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
-enum LibvlcMessageIteratorNPObjectMethodIds
+enum LibvlcPlaylistItemsNPObjectPropertyIds
{
- ID_messageiterator_next,
+ ID_playlistitems_count,
};
RuntimeNPObject::InvokeResult
-LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args,
- uint32_t argCount, NPVariant &result)
+LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
switch( index )
{
- case ID_messageiterator_next:
- if( argCount == 0 )
- {
- if( _p_iter && p_plugin->getLog() )
- {
- struct libvlc_log_message_t buffer;
-
- buffer.sizeof_msg = sizeof(buffer);
-
- libvlc_log_iterator_next(_p_iter, &buffer, &ex);
- RETURN_ON_EXCEPTION(this,ex);
-
- LibvlcMessageNPObject* message =
- static_cast<LibvlcMessageNPObject*>(
- NPN_CreateObject(_instance, RuntimeNPClass<
- LibvlcMessageNPObject>::getClass()));
- if( message )
- {
- message->setMessage(buffer);
- OBJECT_TO_NPVARIANT(message, result);
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_OUT_OF_MEMORY;
- }
- return INVOKERESULT_GENERIC_ERROR;
- }
- return INVOKERESULT_NO_SUCH_METHOD;
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-/*
-** implementation of libvlc message object
-*/
-
-const NPUTF8 * const LibvlcMessagesNPObject::propertyNames[] =
-{
- "count",
-};
-COUNTNAMES(LibvlcMessagesNPObject,propertyCount,propertyNames);
-
-enum LibvlcMessagesNPObjectPropertyIds
-{
- ID_messages_count,
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
-{
- /* is plugin still running */
- if( isPluginRunning() )
- {
- VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
- switch( index )
- {
- case ID_messages_count:
+ case ID_playlistitems_count:
{
- libvlc_log_t *p_log = p_plugin->getLog();
- if( p_log )
- {
- libvlc_exception_t ex;
- libvlc_exception_init(&ex);
-
- INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
- RETURN_ON_EXCEPTION(this,ex);
- }
- else
- {
- INT32_TO_NPVARIANT(0, result);
- }
+ int val = p_plugin->playlist_count(&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
default:
return INVOKERESULT_GENERIC_ERROR;
}
-const NPUTF8 * const LibvlcMessagesNPObject::methodNames[] =
+const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
{
"clear",
- "iterator",
+ "remove",
};
-COUNTNAMES(LibvlcMessagesNPObject,methodCount,methodNames);
+COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
-enum LibvlcMessagesNPObjectMethodIds
+enum LibvlcPlaylistItemsNPObjectMethodIds
{
- ID_messages_clear,
- ID_messages_iterator,
+ ID_playlistitems_clear,
+ ID_playlistitems_remove,
};
RuntimeNPObject::InvokeResult
-LibvlcMessagesNPObject::invoke(int index, const NPVariant *args,
- uint32_t argCount, NPVariant &result)
+LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
+ uint32_t argCount, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
switch( index )
{
- case ID_messages_clear:
+ case ID_playlistitems_clear:
if( argCount == 0 )
{
- libvlc_log_t *p_log = p_plugin->getLog();
- if( p_log )
- {
- libvlc_log_clear(p_log, &ex);
- RETURN_ON_EXCEPTION(this,ex);
- }
+ p_plugin->playlist_clear(&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
-
- case ID_messages_iterator:
- if( argCount == 0 )
+ case ID_playlistitems_remove:
+ if( (argCount == 1) && isNumberValue(args[0]) )
{
- LibvlcMessageIteratorNPObject* iter =
- static_cast<LibvlcMessageIteratorNPObject*>(
- NPN_CreateObject(_instance, RuntimeNPClass<
- LibvlcMessageIteratorNPObject>::getClass()));
- if( iter )
- {
- OBJECT_TO_NPVARIANT(iter, result);
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_OUT_OF_MEMORY;
+ p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ VOID_TO_NPVARIANT(result);
+ return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
-
default:
;
}
}
/*
-** implementation of libvlc message object
+** implementation of libvlc playlist object
*/
-LibvlcLogNPObject::~LibvlcLogNPObject()
+LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
{
- if( isValid() )
- {
- if( messagesObj ) NPN_ReleaseObject(messagesObj);
- }
+ // Why the isValid()?
+ if( isValid() && playlistItemsObj )
+ NPN_ReleaseObject(playlistItemsObj);
};
-const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
{
- "messages",
- "verbosity",
+ "itemCount", /* deprecated */
+ "isPlaying",
+ "items",
};
-COUNTNAMES(LibvlcLogNPObject,propertyCount,propertyNames);
+COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
-enum LibvlcLogNPObjectPropertyIds
+enum LibvlcPlaylistNPObjectPropertyIds
{
- ID_log_messages,
- ID_log_verbosity,
+ ID_playlist_itemcount,
+ ID_playlist_isplaying,
+ ID_playlist_items,
};
RuntimeNPObject::InvokeResult
-LibvlcLogNPObject::getProperty(int index, NPVariant &result)
+LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
switch( index )
{
- case ID_log_messages:
+ case ID_playlist_itemcount: /* deprecated */
{
- // create child object in lazyman fashion to avoid
- // ownership problem with firefox
- if( ! messagesObj )
- messagesObj = NPN_CreateObject(_instance,
- RuntimeNPClass<LibvlcMessagesNPObject>::getClass());
- OBJECT_TO_NPVARIANT(NPN_RetainObject(messagesObj), result);
+ int val = p_plugin->playlist_count(&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
- case ID_log_verbosity:
+ case ID_playlist_isplaying:
{
- if( p_plugin->getLog() )
- {
- INT32_TO_NPVARIANT( libvlc_get_log_verbosity(
- p_plugin->getVLC(), &ex), result);
- RETURN_ON_EXCEPTION(this,ex);
- }
- else
- {
- /* log is not enabled, return -1 */
- DOUBLE_TO_NPVARIANT(-1.0, result);
- }
+ int val = p_plugin->playlist_isplaying(&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ BOOLEAN_TO_NPVARIANT(val, result);
+ return INVOKERESULT_NO_ERROR;
+ }
+ case ID_playlist_items:
+ {
+ // create child object in lazyman fashion to avoid
+ // ownership problem with firefox
+ if( ! playlistItemsObj )
+ playlistItemsObj =
+ NPN_CreateObject(_instance, RuntimeNPClass<
+ LibvlcPlaylistItemsNPObject>::getClass());
+ OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
return INVOKERESULT_NO_ERROR;
}
default:
return INVOKERESULT_GENERIC_ERROR;
}
+const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
+{
+ "add",
+ "play",
+ "playItem",
+ "togglePause",
+ "stop",
+ "next",
+ "prev",
+ "clear", /* deprecated */
+ "removeItem", /* deprecated */
+};
+COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
+
+enum LibvlcPlaylistNPObjectMethodIds
+{
+ ID_playlist_add,
+ ID_playlist_play,
+ ID_playlist_playItem,
+ ID_playlist_togglepause,
+ ID_playlist_stop,
+ ID_playlist_next,
+ ID_playlist_prev,
+ ID_playlist_clear,
+ ID_playlist_removeitem
+};
+
RuntimeNPObject::InvokeResult
-LibvlcLogNPObject::setProperty(int index, const NPVariant &value)
-{
- /* is plugin still running */
- if( isPluginRunning() )
- {
- VlcPlugin* p_plugin = getPrivate<VlcPlugin>();
- libvlc_exception_t ex;
- libvlc_exception_init(&ex);
-
- switch( index )
- {
- case ID_log_verbosity:
- if( isNumberValue(value) )
- {
- libvlc_instance_t* p_libvlc = p_plugin->getVLC();
- libvlc_log_t *p_log = p_plugin->getLog();
- int verbosity = numberValue(value);
- if( verbosity >= 0 )
- {
- if( !p_log )
- {
- p_log = libvlc_log_open(p_libvlc, &ex);
- RETURN_ON_EXCEPTION(this,ex);
- p_plugin->setLog(p_log);
- }
- libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
- RETURN_ON_EXCEPTION(this,ex);
- }
- else if( p_log )
- {
- /* close log when verbosity is set to -1 */
- p_plugin->setLog(NULL);
- libvlc_log_close(p_log, &ex);
- RETURN_ON_EXCEPTION(this,ex);
- }
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_INVALID_VALUE;
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
-{
- /* no methods */
-};
-COUNTNAMES(LibvlcLogNPObject,methodCount,methodNames);
-
-/*
-** implementation of libvlc playlist items object
-*/
-
-const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
-{
- "count",
-};
-COUNTNAMES(LibvlcPlaylistItemsNPObject,propertyCount,propertyNames);
-
-enum LibvlcPlaylistItemsNPObjectPropertyIds
-{
- ID_playlistitems_count,
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
-{
- /* is plugin still running */
- 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);
- INT32_TO_NPVARIANT(val, result);
- return INVOKERESULT_NO_ERROR;
- }
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
-{
- "clear",
- "remove",
-};
-COUNTNAMES(LibvlcPlaylistItemsNPObject,methodCount,methodNames);
-
-enum LibvlcPlaylistItemsNPObjectMethodIds
-{
- ID_playlistitems_clear,
- ID_playlistitems_remove,
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args,
- uint32_t argCount, NPVariant &result)
-{
- /* is plugin still running */
- 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);
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_NO_SUCH_METHOD;
- case ID_playlistitems_remove:
- if( (argCount == 1) && isNumberValue(args[0]) )
- {
- p_plugin->playlist_delete_item(numberValue(args[0]),&ex);
- RETURN_ON_EXCEPTION(this,ex);
- VOID_TO_NPVARIANT(result);
- return INVOKERESULT_NO_ERROR;
- }
- return INVOKERESULT_NO_SUCH_METHOD;
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-/*
-** implementation of libvlc playlist object
-*/
-
-LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
-{
- // Why the isValid()?
- if( isValid() && playlistItemsObj )
- NPN_ReleaseObject(playlistItemsObj);
-};
-
-const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
-{
- "itemCount", /* deprecated */
- "isPlaying",
- "items",
-};
-COUNTNAMES(LibvlcPlaylistNPObject,propertyCount,propertyNames);
-
-enum LibvlcPlaylistNPObjectPropertyIds
-{
- ID_playlist_itemcount,
- ID_playlist_isplaying,
- ID_playlist_items,
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
-{
- /* is plugin still running */
- 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);
- 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);
- BOOLEAN_TO_NPVARIANT(val, result);
- return INVOKERESULT_NO_ERROR;
- }
- case ID_playlist_items:
- {
- // create child object in lazyman fashion to avoid
- // ownership problem with firefox
- if( ! playlistItemsObj )
- playlistItemsObj =
- NPN_CreateObject(_instance, RuntimeNPClass<
- LibvlcPlaylistItemsNPObject>::getClass());
- OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistItemsObj), result);
- return INVOKERESULT_NO_ERROR;
- }
- default:
- ;
- }
- }
- return INVOKERESULT_GENERIC_ERROR;
-}
-
-const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
-{
- "add",
- "play",
- "playItem",
- "togglePause",
- "stop",
- "next",
- "prev",
- "clear", /* deprecated */
- "removeItem", /* deprecated */
-};
-COUNTNAMES(LibvlcPlaylistNPObject,methodCount,methodNames);
-
-enum LibvlcPlaylistNPObjectMethodIds
-{
- ID_playlist_add,
- ID_playlist_play,
- ID_playlist_playItem,
- ID_playlist_togglepause,
- ID_playlist_stop,
- ID_playlist_next,
- ID_playlist_prev,
- ID_playlist_clear,
- ID_playlist_removeitem
-};
-
-RuntimeNPObject::InvokeResult
-LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
- uint32_t argCount, NPVariant &result)
+LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args,
+ uint32_t argCount, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
{
if( (argCount < 1) || (argCount > 3) )
return INVOKERESULT_NO_SUCH_METHOD;
-
- char *url = NULL;
+ if( !NPVARIANT_IS_STRING(args[0]) )
+ return INVOKERESULT_NO_SUCH_METHOD;
// grab URL
- if( NPVARIANT_IS_STRING(args[0]) )
- {
- char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
- if( s )
- {
- url = p_plugin->getAbsoluteURL(s);
- if( url )
- free(s);
- else
- // problem with combining url, use argument
- url = s;
- }
- else
- return INVOKERESULT_OUT_OF_MEMORY;
- }
- else
+ if( NPVARIANT_IS_NULL(args[0]) )
return INVOKERESULT_NO_SUCH_METHOD;
+ char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
+ if( !s )
+ return INVOKERESULT_OUT_OF_MEMORY;
+
+ char *url = p_plugin->getAbsoluteURL(s);
+ if( url )
+ free(s);
+ else
+ // problem with combining url, use argument
+ url = s;
+
char *name = NULL;
// grab name if available
if( ! moreOptions )
{
/* failed to allocate more memory */
- free(s);
+ free(s);
/* return what we got so far */
*i_options = nOptions;
*ppsz_options = options;
}
options[nOptions++] = stringValue(value);
+ NPN_ReleaseVariantValue(&value);
}
*i_options = nOptions;
*ppsz_options = options;
}
/*
-** implementation of libvlc video object
+** implementation of libvlc subtitle object
*/
-const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
+const NPUTF8 * const LibvlcSubtitleNPObject::propertyNames[] =
{
- "fullscreen",
- "height",
- "width",
- "aspectRatio",
- "subtitle",
- "crop",
- "teletext"
+ "track",
+ "count",
};
-enum LibvlcVideoNPObjectPropertyIds
+enum LibvlcSubtitleNPObjectPropertyIds
{
- ID_video_fullscreen,
- ID_video_height,
- ID_video_width,
- ID_video_aspectratio,
- ID_video_subtitle,
- ID_video_crop,
- ID_video_teletext
+ ID_subtitle_track,
+ ID_subtitle_count,
};
-COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
+COUNTNAMES(LibvlcSubtitleNPObject,propertyCount,propertyNames);
RuntimeNPObject::InvokeResult
-LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
+LibvlcSubtitleNPObject::getProperty(int index, NPVariant &result)
+{
+ /* is plugin still running */
+ 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);
+
+ 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);
+ /* return it */
+ INT32_TO_NPVARIANT(i_spu, result);
+ return INVOKERESULT_NO_ERROR;
+ }
+ 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);
+ /* return it */
+ INT32_TO_NPVARIANT(i_spu, result);
+ return INVOKERESULT_NO_ERROR;
+ }
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+RuntimeNPObject::InvokeResult
+LibvlcSubtitleNPObject::setProperty(int index, const NPVariant &value)
+{
+ /* is plugin still running */
+ 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);
+
+ switch( index )
+ {
+ case ID_subtitle_track:
+ {
+ if( isNumberValue(value) )
+ {
+ /* set the new subtitle track to show */
+ libvlc_video_set_spu(p_md, numberValue(value), &ex);
+ RETURN_ON_EXCEPTION(this,ex);
+
+ return INVOKERESULT_NO_ERROR;
+ }
+ return INVOKERESULT_INVALID_VALUE;
+ }
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+const NPUTF8 * const LibvlcSubtitleNPObject::methodNames[] =
+{
+ "description"
+};
+COUNTNAMES(LibvlcSubtitleNPObject,methodCount,methodNames);
+
+enum LibvlcSubtitleNPObjectMethodIds
+{
+ ID_subtitle_description
+};
+
+RuntimeNPObject::InvokeResult
+LibvlcSubtitleNPObject::invoke(int index, const NPVariant *args,
+ uint32_t argCount, NPVariant &result)
+{
+ /* is plugin still running */
+ 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);
+
+ switch( index )
+ {
+ case ID_subtitle_description:
+ {
+ if( argCount == 1)
+ {
+ char *psz_name;
+ int i_spuID, i_limit, i;
+ libvlc_track_description_t *p_spuDesc;
+
+ /* get subtitles description */
+ p_spuDesc = libvlc_video_get_spu_description(p_md, &ex);
+ RETURN_ON_EXCEPTION(this,ex);
+ 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);
+
+ /* check if a number is given by the user
+ * and get the subtitle number */
+ if( isNumberValue(args[0]) )
+ i_spuID = numberValue(args[0]);
+ else
+ return INVOKERESULT_INVALID_VALUE;
+
+ /* if bad number is given return invalid value */
+ if ( ( i_spuID > ( i_limit -1 ) ) || ( i_spuID < 0 ) )
+ return INVOKERESULT_INVALID_VALUE;
+
+ /* get the good spuDesc */
+ for( i = 0 ; i < i_spuID ; i++ )
+ {
+ p_spuDesc = p_spuDesc->p_next;
+ }
+ psz_name = p_spuDesc->psz_name;
+
+ /* return the name of the track chosen */
+ return invokeResultString(psz_name, result);
+ }
+ return INVOKERESULT_NO_SUCH_METHOD;
+ }
+ default:
+ return INVOKERESULT_NO_SUCH_METHOD;
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+/*
+** implementation of libvlc video object
+*/
+
+const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
+{
+ "fullscreen",
+ "height",
+ "width",
+ "aspectRatio",
+ "subtitle",
+ "crop",
+ "teletext",
+ "marquee"
+};
+
+enum LibvlcVideoNPObjectPropertyIds
+{
+ ID_video_fullscreen,
+ ID_video_height,
+ ID_video_width,
+ ID_video_aspectratio,
+ ID_video_subtitle,
+ ID_video_crop,
+ ID_video_teletext,
+ ID_video_marquee
+};
+COUNTNAMES(LibvlcVideoNPObject,propertyCount,propertyNames);
+
+RuntimeNPObject::InvokeResult
+LibvlcVideoNPObject::getProperty(int index, NPVariant &result)
{
/* is plugin still running */
if( isPluginRunning() )
INT32_TO_NPVARIANT(i_page, result);
return INVOKERESULT_NO_ERROR;
}
+ case ID_video_marquee:
+ {
+ if( ! marqueeObj )
+ marqueeObj = NPN_CreateObject(_instance,
+ RuntimeNPClass<LibvlcMarqueeNPObject>::getClass());
+ OBJECT_TO_NPVARIANT(NPN_RetainObject(marqueeObj), result);
+ return INVOKERESULT_NO_ERROR;
+ }
}
}
return INVOKERESULT_GENERIC_ERROR;
const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
{
"toggleFullscreen",
- "toggleTeletext"
+ "toggleTeletext",
+ "deinterlaceEnable",
+ "deinterlaceDisable"
};
COUNTNAMES(LibvlcVideoNPObject,methodCount,methodNames);
enum LibvlcVideoNPObjectMethodIds
{
ID_video_togglefullscreen,
- ID_video_toggleteletext
+ ID_video_toggleteletext,
+ ID_video_deinterlaceenable,
+ ID_video_deinterlacedisable
};
RuntimeNPObject::InvokeResult
switch( index )
{
case ID_video_togglefullscreen:
+ {
if( argCount == 0 )
{
p_plugin->toggle_fullscreen(&ex);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
+ }
case ID_video_toggleteletext:
+ {
if( argCount == 0 )
{
libvlc_toggle_teletext(p_md, &ex);
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;
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+/*
+** implementation of libvlc marquee object
+*/
+
+const NPUTF8 * const LibvlcMarqueeNPObject::propertyNames[] =
+{
+};
+
+enum LibvlcMarqueeNPObjectPropertyIds
+{
+};
+COUNTNAMES(LibvlcMarqueeNPObject,propertyCount,propertyNames);
+
+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);
+
+ libvlc_media_player_t *p_md = p_plugin->getMD(&ex);
+ RETURN_ON_EXCEPTION(this,ex);
+
+ switch( index )
+ {
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+RuntimeNPObject::InvokeResult
+LibvlcMarqueeNPObject::setProperty(int index, const NPVariant &value)
+{
+ /* is plugin still running */
+ 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);
+
+ switch( index )
+ {
+ }
+ }
+ return INVOKERESULT_GENERIC_ERROR;
+}
+
+const NPUTF8 * const LibvlcMarqueeNPObject::methodNames[] =
+{
+ "enable",
+ "disable",
+ "color",
+ "opacity",
+ "position",
+ "refresh",
+ "size",
+ "text",
+ "timeout",
+ "x",
+ "y"
+};
+COUNTNAMES(LibvlcMarqueeNPObject,methodCount,methodNames);
+
+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() )
+ {
+ 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);
+
+ switch( index )
+ {
+ 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;
}