Commit e8f94533 authored by Rafaël Carré's avatar Rafaël Carré

Mozilla : use \n

parent a1fc0644
This source diff could not be displayed because it is too large. You can view the blob instead.
/***************************************************************************** /*****************************************************************************
* npolibvlc.h: official Javascript APIs * npolibvlc.h: official Javascript APIs
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2006 the VideoLAN team * Copyright (C) 2002-2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net> * Authors: Damien Fouilleul <damien.fouilleul@laposte.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/* /*
** defined runtime script objects ** defined runtime script objects
*/ */
#include <vlc/libvlc.h> #include <vlc/libvlc.h>
#include "nporuntime.h" #include "nporuntime.h"
class LibvlcRootNPObject: public RuntimeNPObject class LibvlcRootNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcRootNPObject>; friend class RuntimeNPClass<LibvlcRootNPObject>;
LibvlcRootNPObject(NPP instance, const NPClass *aClass) : LibvlcRootNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass), RuntimeNPObject(instance, aClass),
audioObj(NULL), audioObj(NULL),
inputObj(NULL), inputObj(NULL),
logObj(NULL), logObj(NULL),
playlistObj(NULL), playlistObj(NULL),
videoObj(NULL) {}; videoObj(NULL) {};
virtual ~LibvlcRootNPObject(); virtual ~LibvlcRootNPObject();
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
private: private:
NPObject *audioObj; NPObject *audioObj;
NPObject *inputObj; NPObject *inputObj;
NPObject *logObj; NPObject *logObj;
NPObject *playlistObj; NPObject *playlistObj;
NPObject *videoObj; NPObject *videoObj;
}; };
class LibvlcAudioNPObject: public RuntimeNPObject class LibvlcAudioNPObject: public RuntimeNPObject
{ {
protected: protected:
LibvlcAudioNPObject(NPP instance, const NPClass *aClass) : LibvlcAudioNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcAudioNPObject() {}; virtual ~LibvlcAudioNPObject() {};
friend class RuntimeNPClass<LibvlcAudioNPObject>; friend class RuntimeNPClass<LibvlcAudioNPObject>;
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
InvokeResult setProperty(int index, const NPVariant &value); InvokeResult setProperty(int index, const NPVariant &value);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
class LibvlcInputNPObject: public RuntimeNPObject class LibvlcInputNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcInputNPObject>; friend class RuntimeNPClass<LibvlcInputNPObject>;
LibvlcInputNPObject(NPP instance, const NPClass *aClass) : LibvlcInputNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcInputNPObject() {}; virtual ~LibvlcInputNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
InvokeResult setProperty(int index, const NPVariant &value); InvokeResult setProperty(int index, const NPVariant &value);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
}; };
class LibvlcMessageNPObject: public RuntimeNPObject class LibvlcMessageNPObject: public RuntimeNPObject
{ {
public: public:
void setMessage(struct libvlc_log_message_t &msg) void setMessage(struct libvlc_log_message_t &msg)
{ {
_msg = msg; _msg = msg;
}; };
protected: protected:
friend class RuntimeNPClass<LibvlcMessageNPObject>; friend class RuntimeNPClass<LibvlcMessageNPObject>;
LibvlcMessageNPObject(NPP instance, const NPClass *aClass) : LibvlcMessageNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessageNPObject() {}; virtual ~LibvlcMessageNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
private: private:
struct libvlc_log_message_t _msg; struct libvlc_log_message_t _msg;
}; };
class LibvlcLogNPObject; class LibvlcLogNPObject;
class LibvlcMessageIteratorNPObject: public RuntimeNPObject class LibvlcMessageIteratorNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>; friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>;
LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass); LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcMessageIteratorNPObject(); virtual ~LibvlcMessageIteratorNPObject();
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
private: private:
libvlc_log_iterator_t* _p_iter; libvlc_log_iterator_t* _p_iter;
}; };
class LibvlcMessagesNPObject: public RuntimeNPObject class LibvlcMessagesNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcMessagesNPObject>; friend class RuntimeNPClass<LibvlcMessagesNPObject>;
LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) : LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessagesNPObject() {}; virtual ~LibvlcMessagesNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
class LibvlcLogNPObject: public RuntimeNPObject class LibvlcLogNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcLogNPObject>; friend class RuntimeNPClass<LibvlcLogNPObject>;
LibvlcLogNPObject(NPP instance, const NPClass *aClass) : LibvlcLogNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass), RuntimeNPObject(instance, aClass),
messagesObj(NULL) {}; messagesObj(NULL) {};
virtual ~LibvlcLogNPObject(); virtual ~LibvlcLogNPObject();
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
InvokeResult setProperty(int index, const NPVariant &value); InvokeResult setProperty(int index, const NPVariant &value);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
private: private:
NPObject* messagesObj; NPObject* messagesObj;
}; };
class LibvlcPlaylistItemsNPObject: public RuntimeNPObject class LibvlcPlaylistItemsNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcPlaylistItemsNPObject>; friend class RuntimeNPClass<LibvlcPlaylistItemsNPObject>;
LibvlcPlaylistItemsNPObject(NPP instance, const NPClass *aClass) : LibvlcPlaylistItemsNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcPlaylistItemsNPObject() {}; virtual ~LibvlcPlaylistItemsNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
class LibvlcPlaylistNPObject: public RuntimeNPObject class LibvlcPlaylistNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcPlaylistNPObject>; friend class RuntimeNPClass<LibvlcPlaylistNPObject>;
LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) : LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass), RuntimeNPObject(instance, aClass),
playlistItemsObj(NULL) {}; playlistItemsObj(NULL) {};
virtual ~LibvlcPlaylistNPObject(); virtual ~LibvlcPlaylistNPObject();
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
void parseOptions(const NPString &s, int *i_options, char*** ppsz_options); void parseOptions(const NPString &s, int *i_options, char*** ppsz_options);
void parseOptions(NPObject *obj, int *i_options, char*** ppsz_options); void parseOptions(NPObject *obj, int *i_options, char*** ppsz_options);
private: private:
NPObject* playlistItemsObj; NPObject* playlistItemsObj;
}; };
class LibvlcVideoNPObject: public RuntimeNPObject class LibvlcVideoNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcVideoNPObject>; friend class RuntimeNPClass<LibvlcVideoNPObject>;
LibvlcVideoNPObject(NPP instance, const NPClass *aClass) : LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcVideoNPObject() {}; virtual ~LibvlcVideoNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result); InvokeResult getProperty(int index, NPVariant &result);
InvokeResult setProperty(int index, const NPVariant &value); InvokeResult setProperty(int index, const NPVariant &value);
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
/***************************************************************************** /*****************************************************************************
* npovlc.cpp: deprecated VLC apis implemented in late XPCOM interface * npovlc.cpp: deprecated VLC apis implemented in late XPCOM interface
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2006 the VideoLAN team * Copyright (C) 2002-2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net> * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
#endif #endif
#include <vlc/vlc.h> #include <vlc/vlc.h>
/* Mozilla stuff */ /* Mozilla stuff */
#ifdef HAVE_MOZILLA_CONFIG_H #ifdef HAVE_MOZILLA_CONFIG_H
# include <mozilla-config.h> # include <mozilla-config.h>
#endif #endif
#include "npovlc.h" #include "npovlc.h"
#include "vlcplugin.h" #include "vlcplugin.h"
/* /*
** implementation of vlc root object ** implementation of vlc root object
*/ */
const NPUTF8 * const VlcNPObject::propertyNames[] = const NPUTF8 * const VlcNPObject::propertyNames[] =
{ {
/* no properties */ /* no properties */
}; };
const int VlcNPObject::propertyCount = sizeof(VlcNPObject::propertyNames)/sizeof(NPUTF8 *); const int VlcNPObject::propertyCount = sizeof(VlcNPObject::propertyNames)/sizeof(NPUTF8 *);
const NPUTF8 * const VlcNPObject::methodNames[] = const NPUTF8 * const VlcNPObject::methodNames[] =
{ {
"play", /* deprecated */ "play", /* deprecated */
"pause", /* deprecated */ "pause", /* deprecated */
"stop", /* deprecated */ "stop", /* deprecated */
"fullscreen", /* deprecated */ "fullscreen", /* deprecated */
"set_volume", /* deprecated */ "set_volume", /* deprecated */
"get_volume", /* deprecated */ "get_volume", /* deprecated */
"mute", /* deprecated */ "mute", /* deprecated */
"get_int_variable", /* deprecated */ "get_int_variable", /* deprecated */
"set_int_variable", /* deprecated */ "set_int_variable", /* deprecated */
"get_bool_variable", /* deprecated */ "get_bool_variable", /* deprecated */
"set_bool_variable", /* deprecated */ "set_bool_variable", /* deprecated */
"get_str_variable", /* deprecated */ "get_str_variable", /* deprecated */
"set_str_variable", /* deprecated */ "set_str_variable", /* deprecated */
"clear_playlist", /* deprecated */ "clear_playlist", /* deprecated */
"add_item", /* deprecated */ "add_item", /* deprecated */
"next", /* deprecated */ "next", /* deprecated */
"previous", /* deprecated */ "previous", /* deprecated */
"isplaying", /* deprecated */ "isplaying", /* deprecated */
"get_length", /* deprecated */ "get_length", /* deprecated */
"get_position", /* deprecated */ "get_position", /* deprecated */
"get_time", /* deprecated */ "get_time", /* deprecated */
"seek", /* deprecated */ "seek", /* deprecated */
}; };
enum VlcNPObjectMethodIds enum VlcNPObjectMethodIds
{ {
ID_play = 0, ID_play = 0,
ID_pause, ID_pause,
ID_stop, ID_stop,
ID_fullscreen, ID_fullscreen,
ID_set_volume, ID_set_volume,
ID_get_volume, ID_get_volume,
ID_mute, ID_mute,
ID_get_int_variable, ID_get_int_variable,
ID_set_int_variable, ID_set_int_variable,
ID_get_bool_variable, ID_get_bool_variable,
ID_set_bool_variable, ID_set_bool_variable,
ID_get_str_variable, ID_get_str_variable,
ID_set_str_variable, ID_set_str_variable,
ID_clear_playlist, ID_clear_playlist,
ID_add_item, ID_add_item,
ID_next, ID_next,
ID_previous, ID_previous,
ID_isplaying, ID_isplaying,
ID_get_length, ID_get_length,
ID_get_position, ID_get_position,
ID_get_time, ID_get_time,
ID_seek, ID_seek,
}; };
const int VlcNPObject::methodCount = sizeof(VlcNPObject::methodNames)/sizeof(NPUTF8 *); const int VlcNPObject::methodCount = sizeof(VlcNPObject::methodNames)/sizeof(NPUTF8 *);
RuntimeNPObject::InvokeResult VlcNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) RuntimeNPObject::InvokeResult VlcNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{ {
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata); VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin ) if( p_plugin )
{ {
libvlc_exception_t ex; libvlc_exception_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
switch( index ) switch( index )
{ {
case ID_play: /* deprecated */ case ID_play: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex); libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_pause: /* deprecated */ case ID_pause: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_pause(p_plugin->getVLC(), &ex); libvlc_playlist_pause(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_stop: /* deprecated */ case ID_stop: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_stop(p_plugin->getVLC(), &ex); libvlc_playlist_stop(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_fullscreen: /* deprecated */ case ID_fullscreen: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
if( p_md ) if( p_md )
{ {
libvlc_toggle_fullscreen(p_md, &ex); libvlc_toggle_fullscreen(p_md, &ex);
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
{ {
/* cannot get input, probably not playing */ /* cannot get input, probably not playing */
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_set_volume: /* deprecated */ case ID_set_volume: /* deprecated */
if( (argCount == 1) && isNumberValue(args[0]) ) if( (argCount == 1) && isNumberValue(args[0]) )
{ {
libvlc_audio_set_volume(p_plugin->getVLC(), numberValue(args[0]), &ex); libvlc_audio_set_volume(p_plugin->getVLC(), numberValue(args[0]), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_volume: /* deprecated */ case ID_get_volume: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
int val = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); int val = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_mute: /* deprecated */ case ID_mute: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex); libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_int_variable: /* deprecated */ case ID_get_int_variable: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) ) if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) ) if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
{ {
delete s; delete s;
INT32_TO_NPVARIANT(val.i_int, result); INT32_TO_NPVARIANT(val.i_int, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_set_int_variable: /* deprecated */ case ID_set_int_variable: /* deprecated */
if( (argCount == 2) if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[0])
&& isNumberValue(args[1]) ) && isNumberValue(args[1]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
val.i_int = numberValue(args[1]); val.i_int = numberValue(args[1]);
if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) ) if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
{ {
delete s; delete s;
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_bool_variable: /* deprecated */ case ID_get_bool_variable: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) ) if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) ) if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
{ {
delete s; delete s;
BOOLEAN_TO_NPVARIANT(val.b_bool, result); BOOLEAN_TO_NPVARIANT(val.b_bool, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_set_bool_variable: /* deprecated */ case ID_set_bool_variable: /* deprecated */
if( (argCount == 2) if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[0])
&& NPVARIANT_IS_BOOLEAN(args[1]) ) && NPVARIANT_IS_BOOLEAN(args[1]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
val.b_bool = NPVARIANT_TO_BOOLEAN(args[1]); val.b_bool = NPVARIANT_TO_BOOLEAN(args[1]);
if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) ) if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
{ {
delete s; delete s;
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_str_variable: /* deprecated */ case ID_get_str_variable: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) ) if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) ) if( VLC_SUCCESS == VLC_VariableGet(vlc_id, s, &val) )
{ {
delete s; delete s;
if( val.psz_string ) if( val.psz_string )
{ {
int len = strlen(val.psz_string); int len = strlen(val.psz_string);
NPUTF8 *retval = (NPUTF8 *)NPN_MemAlloc(len); NPUTF8 *retval = (NPUTF8 *)NPN_MemAlloc(len);
if( retval ) if( retval )
{ {
memcpy(retval, val.psz_string, len); memcpy(retval, val.psz_string, len);
STRINGN_TO_NPVARIANT(retval, len, result); STRINGN_TO_NPVARIANT(retval, len, result);
free(val.psz_string); free(val.psz_string);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
} }
else else
{ {
/* null string */ /* null string */
NULL_TO_NPVARIANT(result); NULL_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_set_str_variable: /* deprecated */ case ID_set_str_variable: /* deprecated */
if( (argCount == 2) if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0]) && NPVARIANT_IS_STRING(args[0])
&& NPVARIANT_IS_STRING(args[1]) ) && NPVARIANT_IS_STRING(args[1]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC()); int vlc_id = libvlc_get_vlc_id(p_plugin->getVLC());
vlc_value_t val; vlc_value_t val;
val.psz_string = stringValue(NPVARIANT_TO_STRING(args[1])); val.psz_string = stringValue(NPVARIANT_TO_STRING(args[1]));
if( val.psz_string ) if( val.psz_string )
{ {
if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) ) if( VLC_SUCCESS == VLC_VariableSet(vlc_id, s, val) )
{ {
delete s; delete s;
delete val.psz_string; delete val.psz_string;
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
delete s; delete s;
delete val.psz_string; delete val.psz_string;
return INVOKERESULT_INVALID_ARGS; return INVOKERESULT_INVALID_ARGS;
} }
} }
else else
{ {
delete s; delete s;
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_clear_playlist: /* deprecated */ case ID_clear_playlist: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_clear(p_plugin->getVLC(), &ex); libvlc_playlist_clear(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_add_item: /* deprecated */ case ID_add_item: /* deprecated */
if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) ) if( (argCount == 1) && NPVARIANT_IS_STRING(args[0]) )
{ {
char *s = stringValue(NPVARIANT_TO_STRING(args[0])); char *s = stringValue(NPVARIANT_TO_STRING(args[0]));
if( s ) if( s )
{ {
char *url = p_plugin->getAbsoluteURL(s); char *url = p_plugin->getAbsoluteURL(s);
delete s; delete s;
if( ! url ) if( ! url )
// what happened ? // what happened ?
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
int item = libvlc_playlist_add(p_plugin->getVLC(), url, NULL, &ex); int item = libvlc_playlist_add(p_plugin->getVLC(), url, NULL, &ex);
free(url); free(url);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
INT32_TO_NPVARIANT(item, result); INT32_TO_NPVARIANT(item, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_next: /* deprecated */ case ID_next: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_next(p_plugin->getVLC(), &ex); libvlc_playlist_next(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_previous: /* deprecated */ case ID_previous: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_prev(p_plugin->getVLC(), &ex); libvlc_playlist_prev(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_isplaying: /* deprecated */ case ID_isplaying: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
int isplaying = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex); int isplaying = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
BOOLEAN_TO_NPVARIANT(isplaying, result); BOOLEAN_TO_NPVARIANT(isplaying, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_length: /* deprecated */ case ID_get_length: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
if( p_md ) if( p_md )
{ {
vlc_int64_t val = libvlc_media_player_get_length(p_md, &ex); vlc_int64_t val = libvlc_media_player_get_length(p_md, &ex);
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
INT32_TO_NPVARIANT((uint32_t)(val/1000LL), result); INT32_TO_NPVARIANT((uint32_t)(val/1000LL), result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
{ {
/* cannot get input, probably not playing */ /* cannot get input, probably not playing */
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_position: /* deprecated */ case ID_get_position: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
if( p_md ) if( p_md )
{ {
float val = libvlc_media_player_get_position(p_md, &ex); float val = libvlc_media_player_get_position(p_md, &ex);
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
DOUBLE_TO_NPVARIANT((double)val, result); DOUBLE_TO_NPVARIANT((double)val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
{ {
/* cannot get input, probably not playing */ /* cannot get input, probably not playing */
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_get_time: /* deprecated */ case ID_get_time: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
if( p_md ) if( p_md )
{ {
vlc_int64_t val = libvlc_media_player_get_time(p_md, &ex); vlc_int64_t val = libvlc_media_player_get_time(p_md, &ex);
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
else else
{ {
DOUBLE_TO_NPVARIANT((uint32_t)(val/1000LL), result); DOUBLE_TO_NPVARIANT((uint32_t)(val/1000LL), result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
else else
{ {
/* cannot get input, probably not playing */ /* cannot get input, probably not playing */
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_seek: /* deprecated */ case ID_seek: /* deprecated */
if( (argCount == 2) if( (argCount == 2)
&& isNumberValue(args[0]) && isNumberValue(args[0])
&& NPVARIANT_IS_BOOLEAN(args[1]) ) && NPVARIANT_IS_BOOLEAN(args[1]) )
{ {
libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex); libvlc_media_player_t *p_md = libvlc_playlist_get_media_player(p_plugin->getVLC(), &ex);
if( p_md ) if( p_md )
{ {
vlc_int64_t pos = 0; vlc_int64_t pos = 0;
if( NPVARIANT_IS_INT32(args[0]) ) if( NPVARIANT_IS_INT32(args[0]) )
pos = (vlc_int64_t)NPVARIANT_TO_INT32(args[0]); pos = (vlc_int64_t)NPVARIANT_TO_INT32(args[0]);
else else
pos = (vlc_int64_t)NPVARIANT_TO_DOUBLE(args[0]); pos = (vlc_int64_t)NPVARIANT_TO_DOUBLE(args[0]);
if( NPVARIANT_TO_BOOLEAN(args[1]) ) if( NPVARIANT_TO_BOOLEAN(args[1]) )
{ {
/* relative seek */ /* relative seek */
vlc_int64_t from = libvlc_media_player_get_time(p_md, &ex); vlc_int64_t from = libvlc_media_player_get_time(p_md, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
pos += from; pos += from;
} }
/* jump to time */ /* jump to time */
libvlc_media_player_set_time(p_md, pos, &ex); libvlc_media_player_set_time(p_md, pos, &ex);
libvlc_media_player_release(p_md); libvlc_media_player_release(p_md);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
VOID_TO_NPVARIANT(result); VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
else else
{ {
/* cannot get input, probably not playing */ /* cannot get input, probably not playing */
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
/***************************************************************************** /*****************************************************************************
* npovlc.h: deprecated APIs implemented in late XPCOM interface * npovlc.h: deprecated APIs implemented in late XPCOM interface
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2006 the VideoLAN team * Copyright (C) 2002-2006 the VideoLAN team
* *
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net> * Authors: Damien Fouilleul <damien.fouilleul@laposte.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
/* /*
** defined runtime script objects ** defined runtime script objects
*/ */
#include "nporuntime.h" #include "nporuntime.h"
class VlcNPObject: public RuntimeNPObject class VlcNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<VlcNPObject>; friend class RuntimeNPClass<VlcNPObject>;
VlcNPObject(NPP instance, const NPClass *aClass) : VlcNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~VlcNPObject() {}; virtual ~VlcNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
static const int methodCount; static const int methodCount;
static const NPUTF8 * const methodNames[]; static const NPUTF8 * const methodNames[];
virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result); virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment