Commit ec077666 authored by Damien Fouilleul's avatar Damien Fouilleul

mozilla: backporting from 0.8.6

parent fc9b8e56
......@@ -6,7 +6,7 @@ noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
MOSTLYCLEANFILES = $(npvlc_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES)
EXTRA_DIST = $(DIST_sources) npvlc_rc.rc vlc.r
EXTRA_DIST = $(DIST_sources) install.js npvlc_rc.rc vlc.r
SOURCES_mozilla_common = \
vlcshell.cpp \
......
......@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
{
"audio",
"input",
"log",
"playlist",
"video",
"VersionInfo",
......@@ -70,39 +71,55 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert
enum LibvlcRootNPObjectPropertyIds
{
ID_audio = 0,
ID_input,
ID_playlist,
ID_video,
ID_VersionInfo,
ID_root_audio = 0,
ID_root_input,
ID_root_log,
ID_root_playlist,
ID_root_video,
ID_root_VersionInfo,
};
RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_audio:
case ID_root_audio:
OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
return INVOKERESULT_NO_ERROR;
case ID_input:
case ID_root_input:
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
return INVOKERESULT_NO_ERROR;
case ID_playlist:
case ID_root_log:
OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
return INVOKERESULT_NO_ERROR;
case ID_root_playlist:
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
return INVOKERESULT_NO_ERROR;
case ID_video:
case ID_root_video:
OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
return INVOKERESULT_NO_ERROR;
case ID_VersionInfo:
NPUTF8 *versionStr = NULL;
versionStr = strdup( VLC_Version() );
if (!versionStr)
return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(versionStr, result);
case ID_root_VersionInfo:
{
int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam
enum LibvlcRootNPObjectMethodIds
{
ID_version,
ID_root_versionInfo,
};
RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -128,21 +145,25 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVari
switch( index )
{
case ID_version:
case ID_root_versionInfo:
if( argCount == 0 )
{
NPUTF8 *versionStr = NULL;
versionStr = strdup( VLC_Version() );
if (!versionStr)
return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(versionStr, result);
int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope
enum LibvlcAudioNPObjectPropertyIds
{
ID_mute,
ID_volume,
ID_audio_mute,
ID_audio_volume,
};
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
......@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
switch( index )
{
case ID_mute:
case ID_audio_mute:
{
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR;
}
case ID_volume:
case ID_audio_volume:
{
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
switch( index )
{
case ID_mute:
case ID_audio_mute:
if( NPVARIANT_IS_BOOLEAN(value) )
{
libvlc_audio_set_mute(p_plugin->getVLC(),
......@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
case ID_volume:
case ID_audio_volume:
if( isNumberValue(value) )
{
libvlc_audio_set_volume(p_plugin->getVLC(),
......@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN
enum LibvlcAudioNPObjectMethodIds
{
ID_togglemute,
ID_audio_togglemute,
};
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -270,7 +295,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
switch( index )
{
case ID_togglemute:
case ID_audio_togglemute:
if( argCount == 0 )
{
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
......@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope
enum LibvlcInputNPObjectPropertyIds
{
ID_length,
ID_position,
ID_time,
ID_state,
ID_rate,
ID_fps,
ID_hasvout,
ID_input_length,
ID_input_position,
ID_input_time,
ID_input_state,
ID_input_rate,
ID_input_fps,
ID_input_hasvout,
};
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)
......@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
if( index != ID_state )
if( index != ID_input_state )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
......@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
switch( index )
{
case ID_length:
case ID_input_length:
{
double val = (double)libvlc_input_get_length(p_input, &ex);
libvlc_input_free(p_input);
......@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_position:
case ID_input_position:
{
double val = libvlc_input_get_position(p_input, &ex);
libvlc_input_free(p_input);
......@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_time:
case ID_input_time:
{
double val = (double)libvlc_input_get_time(p_input, &ex);
libvlc_input_free(p_input);
......@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_state:
case ID_input_state:
{
int val = libvlc_input_get_state(p_input, &ex);
libvlc_input_free(p_input);
......@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
case ID_input_rate:
{
float val = libvlc_input_get_rate(p_input, &ex);
libvlc_input_free(p_input);
......@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_fps:
case ID_input_fps:
{
double val = libvlc_input_get_fps(p_input, &ex);
libvlc_input_free(p_input);
......@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_hasvout:
case ID_input_hasvout:
{
vlc_bool_t val = libvlc_input_has_vout(p_input, &ex);
libvlc_input_free(p_input);
......@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
libvlc_input_free(p_input);
}
......@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
switch( index )
{
case ID_position:
case ID_input_position:
{
if( ! NPVARIANT_IS_DOUBLE(value) )
{
......@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_time:
case ID_input_time:
{
vlc_int64_t val;
if( NPVARIANT_IS_INT32(value) )
......@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_rate:
case ID_input_rate:
{
float val;
if( NPVARIANT_IS_INT32(value) )
......@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
libvlc_input_free(p_input);
}
......@@ -559,23 +588,26 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p
enum LibvlcMessageNPObjectPropertyIds
{
ID_severity,
ID_type,
ID_name,
ID_header,
ID_message,
ID_message_severity,
ID_message_type,
ID_message_name,
ID_message_header,
ID_message_message,
};
RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_severity:
case ID_message_severity:
{
INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
}
case ID_type:
case ID_message_type:
{
if( _msg.psz_type )
{
......@@ -593,7 +625,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_name:
case ID_message_name:
{
if( _msg.psz_name )
{
......@@ -611,7 +643,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_header:
case ID_message_header:
{
if( _msg.psz_header )
{
......@@ -629,7 +661,7 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
case ID_message:
case ID_message_message:
{
if( _msg.psz_message )
{
......@@ -647,6 +679,9 @@ RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVa
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met
** implementation of libvlc message iterator object
*/
void LibvlcMessageIteratorNPObject::setLog(LibvlcLogNPObject* p_vlclog)
LibvlcMessageIteratorNPObject::LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass),
_p_iter(NULL)
{
_p_vlclog = p_vlclog;
if( p_vlclog->_p_log )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
_p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL);
_p_iter = libvlc_log_get_iterator(p_log, NULL);
}
}
else
_p_iter = NULL;
};
LibvlcMessageIteratorNPObject::~LibvlcMessageIteratorNPObject()
{
if( _p_iter )
libvlc_log_iterator_free(_p_iter, NULL);
}
const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
{
"hasNext",
......@@ -682,16 +727,19 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte
enum LibvlcMessageIteratorNPObjectPropertyIds
{
ID_hasNext,
ID_messageiterator_hasNext,
};
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_hasNext:
case ID_messageiterator_hasNext:
{
if( _p_iter && _p_vlclog->_p_log )
if( _p_iter && p_plugin->getLog() )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -710,6 +758,9 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int ind
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -728,7 +779,8 @@ enum LibvlcMessageIteratorNPObjectMethodIds
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{
if( _p_iter && _p_vlclog->_p_log )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -737,6 +789,8 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c
{
case ID_messageiterator_next:
if( argCount == 0 )
{
if( _p_iter && p_plugin->getLog() )
{
struct libvlc_log_message_t buffer;
......@@ -762,8 +816,11 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c
return INVOKERESULT_OUT_OF_MEMORY;
}
}
default:
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -782,16 +839,19 @@ const int LibvlcMessagesNPObject::propertyCount = sizeof(LibvlcMessagesNPObject:
enum LibvlcMessagesNPObjectPropertyIds
{
ID_count,
ID_messages_count,
};
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
switch( index )
{
case ID_count:
case ID_messages_count:
{
libvlc_log_t *p_log = _p_vlclog->_p_log;
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
libvlc_exception_t ex;
......@@ -811,6 +871,9 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPV
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
......@@ -826,11 +889,14 @@ const int LibvlcMessagesNPObject::methodCount = sizeof(LibvlcMessagesNPObject::m
enum LibvlcMessagesNPObjectMethodIds
{
ID_messages_clear,
ID_iterator,
ID_messages_iterator,
};
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
......@@ -839,7 +905,7 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
case ID_messages_clear:
if( argCount == 0 )
{
libvlc_log_t *p_log = _p_vlclog->_p_log;
libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
libvlc_log_clear(p_log, &ex);
......@@ -854,14 +920,13 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_iterator:
case ID_messages_iterator:
if( argCount == 0 )
{
LibvlcMessageIteratorNPObject* iter =
static_cast<LibvlcMessageIteratorNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageIteratorNPObject>::getClass()));
if( iter )
{
iter->setLog(_p_vlclog);
OBJECT_TO_NPVARIANT(iter, result);
return INVOKERESULT_NO_ERROR;
}
......@@ -870,15 +935,29 @@ RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NP
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
/*
** implementation of libvlc message object
*/
LibvlcLogNPObject::LibvlcLogNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass)
{
_p_vlcmessages = static_cast<LibvlcMessagesNPObject*>(NPN_CreateObject(instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass()));
};
LibvlcLogNPObject::~LibvlcLogNPObject()
{
NPN_ReleaseObject(_p_vlcmessages);
};
const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
{
"messages",
......@@ -889,8 +968,8 @@ const int LibvlcLogNPObject::propertyCount = sizeof(LibvlcLogNPObject::propertyN
enum LibvlcLogNPObjectPropertyIds
{
ID_messages,
ID_verbosity,
ID_log_messages,
ID_log_verbosity,
};
RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVariant &result)
......@@ -903,14 +982,14 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
switch( index )
{
case ID_messages:
case ID_log_messages:
{
OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcmessages), result);
return INVOKERESULT_NO_ERROR;
}
case ID_verbosity:
case ID_log_verbosity:
{
if( _p_log )
if( p_plugin->getLog() )
{
INT32_TO_NPVARIANT(libvlc_get_log_verbosity(p_plugin->getVLC(),
&ex), result);
......@@ -928,6 +1007,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
}
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -943,22 +1024,24 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
switch( index )
{
case ID_verbosity:
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 )
if( ! p_log )
{
_p_log = libvlc_log_open(p_libvlc, &ex);
p_log = libvlc_log_open(p_libvlc, &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
p_plugin->setLog(p_log);
}
libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
if( libvlc_exception_raised(&ex) )
......@@ -968,11 +1051,11 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_GENERIC_ERROR;
}
}
else if( _p_log )
else if( p_log )
{
/* close log when verbosity is set to -1 */
libvlc_log_close(_p_log, &ex);
_p_log = NULL;
p_plugin->setLog(NULL);
libvlc_log_close(p_log, &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
......@@ -983,6 +1066,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_INVALID_VALUE;
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -995,23 +1080,146 @@ const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
const int LibvlcLogNPObject::methodCount = sizeof(LibvlcLogNPObject::methodNames)/sizeof(NPUTF8 *);
/*
** implementation of libvlc playlist items object
*/
const NPUTF8 * const LibvlcPlaylistItemsNPObject::propertyNames[] =
{
"count",
};
const int LibvlcPlaylistItemsNPObject::propertyCount = sizeof(LibvlcPlaylistItemsNPObject::propertyNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistItemsNPObjectPropertyIds
{
ID_playlistitems_count,
};
RuntimeNPObject::InvokeResult LibvlcPlaylistItemsNPObject::getProperty(int index, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index )
{
case ID_playlistitems_count:
{
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
}
const NPUTF8 * const LibvlcPlaylistItemsNPObject::methodNames[] =
{
"clear",
"remove",
};
const int LibvlcPlaylistItemsNPObject::methodCount = sizeof(LibvlcPlaylistItemsNPObject::methodNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistItemsNPObjectMethodIds
{
ID_playlistitems_clear,
ID_playlistitems_remove,
};
RuntimeNPObject::InvokeResult LibvlcPlaylistItemsNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
switch( index )
{
case ID_playlistitems_clear:
if( argCount == 0 )
{
libvlc_playlist_clear(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
VOID_TO_NPVARIANT(result);
return INVOKERESULT_NO_ERROR;
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playlistitems_remove:
if( (argCount == 1) && isNumberValue(args[0]) )
{
libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
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(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass)
{
_p_vlcplaylistitems = static_cast<LibvlcPlaylistItemsNPObject*>(NPN_CreateObject(instance, RuntimeNPClass<LibvlcPlaylistItemsNPObject>::getClass()));
};
LibvlcPlaylistNPObject::~LibvlcPlaylistNPObject()
{
NPN_ReleaseObject(_p_vlcplaylistitems);
};
const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
{
"itemCount",
"itemCount", /* deprecated */
"isPlaying",
"items",
};
const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistNPObjectPropertyIds
{
ID_itemcount,
ID_isplaying,
ID_playlist_itemcount,
ID_playlist_isplaying,
ID_playlist_items,
};
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
......@@ -1024,7 +1232,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
switch( index )
{
case ID_itemcount:
case ID_playlist_itemcount: /* deprecated */
{
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -1036,7 +1244,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_isplaying:
case ID_playlist_isplaying:
{
int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) )
......@@ -1048,6 +1256,13 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_playlist_items:
{
OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcplaylistitems), result);
return INVOKERESULT_NO_ERROR;
}
default:
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -1062,23 +1277,23 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
"stop",
"next",
"prev",
"clear",
"removeItem"
"clear", /* deprecated */
"removeItem", /* deprecated */
};
const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistNPObjectMethodIds
{
ID_add,
ID_play,
ID_playItem,
ID_togglepause,
ID_stop,
ID_next,
ID_prev,
ID_clear,
ID_removeitem
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)
......@@ -1091,7 +1306,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
switch( index )
{
case ID_add:
case ID_playlist_add:
{
if( (argCount < 1) || (argCount > 3) )
return INVOKERESULT_NO_SUCH_METHOD;
......@@ -1105,10 +1320,11 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
if( s )
{
url = p_plugin->getAbsoluteURL(s);
if( url )
delete s;
if( ! url )
// what happened ?
return INVOKERESULT_GENERIC_ERROR;
else
// problem with combining url, use argument
url = s;
}
else
return INVOKERESULT_OUT_OF_MEMORY;
......@@ -1181,7 +1397,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
return INVOKERESULT_NO_ERROR;
}
}
case ID_play:
case ID_playlist_play:
if( argCount == 0 )
{
libvlc_playlist_play(p_plugin->getVLC(), -1, 0, NULL, &ex);
......@@ -1198,7 +1414,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_playItem:
case ID_playlist_playItem:
if( (argCount == 1) && isNumberValue(args[0]) )
{
libvlc_playlist_play(p_plugin->getVLC(), numberValue(args[0]), 0, NULL, &ex);
......@@ -1215,7 +1431,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_togglepause:
case ID_playlist_togglepause:
if( argCount == 0 )
{
libvlc_playlist_pause(p_plugin->getVLC(), &ex);
......@@ -1232,7 +1448,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_stop:
case ID_playlist_stop:
if( argCount == 0 )
{
libvlc_playlist_stop(p_plugin->getVLC(), &ex);
......@@ -1249,7 +1465,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_next:
case ID_playlist_next:
if( argCount == 0 )
{
libvlc_playlist_next(p_plugin->getVLC(), &ex);
......@@ -1266,7 +1482,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_prev:
case ID_playlist_prev:
if( argCount == 0 )
{
libvlc_playlist_prev(p_plugin->getVLC(), &ex);
......@@ -1283,7 +1499,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_clear:
case ID_playlist_clear: /* deprecated */
if( argCount == 0 )
{
libvlc_playlist_clear(p_plugin->getVLC(), &ex);
......@@ -1300,7 +1516,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_removeitem:
case ID_playlist_removeitem: /* deprecated */
if( (argCount == 1) && isNumberValue(args[0]) )
{
libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);
......@@ -1318,7 +1534,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
return INVOKERESULT_NO_SUCH_METHOD;
default:
return INVOKERESULT_NO_SUCH_METHOD;
;
}
}
return INVOKERESULT_GENERIC_ERROR;
......@@ -1465,10 +1681,10 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
enum LibvlcVideoNPObjectPropertyIds
{
ID_fullscreen,
ID_height,
ID_width,
ID_aspectratio
ID_video_fullscreen,
ID_video_height,
ID_video_width,
ID_video_aspectratio
};
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
......@@ -1491,7 +1707,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
switch( index )
{
case ID_fullscreen:
case ID_video_fullscreen:
{
int val = libvlc_get_fullscreen(p_input, &ex);
libvlc_input_free(p_input);
......@@ -1504,7 +1720,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_height:
case ID_video_height:
{
int val = libvlc_video_get_height(p_input, &ex);
libvlc_input_free(p_input);
......@@ -1517,7 +1733,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_width:
case ID_video_width:
{
int val = libvlc_video_get_width(p_input, &ex);
libvlc_input_free(p_input);
......@@ -1530,7 +1746,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR;
}
case ID_aspectratio:
case ID_video_aspectratio:
{
NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
libvlc_input_free(p_input);
......@@ -1570,7 +1786,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
switch( index )
{
case ID_fullscreen:
case ID_video_fullscreen:
{
if( ! NPVARIANT_IS_BOOLEAN(value) )
{
......@@ -1589,7 +1805,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
}
return INVOKERESULT_NO_ERROR;
}
case ID_aspectratio:
case ID_video_aspectratio:
{
char *psz_aspect = NULL;
......@@ -1629,7 +1845,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
enum LibvlcVideoNPObjectMethodIds
{
ID_togglefullscreen,
ID_video_togglefullscreen,
};
const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *);
......@@ -1652,7 +1868,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar
switch( index )
{
case ID_togglefullscreen:
case ID_video_togglefullscreen:
if( argCount == 0 )
{
libvlc_toggle_fullscreen(p_input, &ex);
......
......@@ -125,16 +125,11 @@ class LibvlcLogNPObject;
class LibvlcMessageIteratorNPObject: public RuntimeNPObject
{
public:
void setLog(LibvlcLogNPObject* p_vlclog);
protected:
friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>;
LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessageIteratorNPObject() {};
LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcMessageIteratorNPObject();
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
......@@ -147,23 +142,15 @@ protected:
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
private:
LibvlcLogNPObject* _p_vlclog;
libvlc_log_iterator_t* _p_iter;
};
class LibvlcMessagesNPObject: public RuntimeNPObject
{
public:
void setLog(LibvlcLogNPObject *p_log)
{
_p_vlclog = p_log;
}
protected:
friend class RuntimeNPClass<LibvlcMessagesNPObject>;
LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :
_p_vlclog(NULL),
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessagesNPObject() {};
......@@ -177,32 +164,15 @@ protected:
static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
private:
LibvlcLogNPObject* _p_vlclog;
};
class LibvlcLogNPObject: public RuntimeNPObject
{
protected:
friend class RuntimeNPClass<LibvlcLogNPObject>;
friend class LibvlcMessagesNPObject;
friend class LibvlcMessageIteratorNPObject;
libvlc_log_t *_p_log;
LibvlcLogNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass),
_p_log(NULL)
{
_p_vlcmessages = static_cast<LibvlcMessagesNPObject*>(NPN_CreateObject(instance, RuntimeNPClass<LibvlcMessagesNPObject>::getClass()));
_p_vlcmessages->setLog(this);
};
virtual ~LibvlcLogNPObject()
{
NPN_ReleaseObject(_p_vlcmessages);
};
LibvlcLogNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcLogNPObject();
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
......@@ -217,14 +187,33 @@ private:
LibvlcMessagesNPObject* _p_vlcmessages;
};
class LibvlcPlaylistItemsNPObject: public RuntimeNPObject
{
protected:
friend class RuntimeNPClass<LibvlcPlaylistItemsNPObject>;
LibvlcPlaylistItemsNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcPlaylistItemsNPObject() {};
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount;
static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result);
};
class LibvlcPlaylistNPObject: public RuntimeNPObject
{
protected:
friend class RuntimeNPClass<LibvlcPlaylistNPObject>;
LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcPlaylistNPObject() {};
LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcPlaylistNPObject();
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
......@@ -238,6 +227,9 @@ protected:
void parseOptions(const NPString &s, int *i_options, char*** ppsz_options);
void parseOptions(NPObject *obj, int *i_options, char*** ppsz_options);
private:
LibvlcPlaylistItemsNPObject* _p_vlcplaylistitems;
};
class LibvlcVideoNPObject: public RuntimeNPObject
......
......@@ -110,4 +110,3 @@ bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result)
}
return false;
}
......@@ -31,17 +31,17 @@ BEGIN
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "ProductName", "VLC multimedia plugin\0"
VALUE "ProductName", "VLC Multimedia Plugin\0"
VALUE "ProductVersion", STRINGIFY( VERSION )
VALUE "OriginalFilename", "npvlc.dll\0"
VALUE "FileVersion", STRINGIFY( VERSION )
VALUE "FileDescription", "VLC multimedia plugin Version "STRINGIFY( VERSION )"<br><br>VideoLAN WWW: <a href=""http://www.videolan.org/"">http://www.videolan.org/</a>\0"
VALUE "FileDescription", "Version " STRINGIFY( VERSION ) ", copyright 1996-2006 The VideoLAN Team<br><a href=""http://www.videolan.org/"">http://www.videolan.org/</a>\0"
VALUE "InternalName", "npvlc\0"
VALUE "CompanyName", "VideoLAN Team\0"
VALUE "LegalCopyright", "Copyright VideoLAN \251 1996-2006\0"
VALUE "MIMEType", "audio/mpeg|audio/x-mpeg|video/mpeg|video/x-mpeg|video/mpeg-system|video/x-mpeg-system|video/mpeg4|audio/mpeg4|application/mpeg4-iod|application/mpeg4-muxcodetable|video/x-msvideo|video/quicktime|application/x-ogg|application/ogg|application/x-vlc-plugin|video/x-ms-asf-plugin|video/x-ms-asf|application/x-mplayer2|video/x-ms-wmv|application/x-google-vlc-plugin|audio/wav|audio/x-wav\0"
VALUE "FileExtents", "mp2,mp3,mpga,mpega|mp2,mp3,mpga,mpega|mpg,mpeg,mpe|mpg,mpeg,mpe|mpg,mpeg,vob|mpg,mpeg,vob|mp4,mpg4|mp4,mpg4|mp4,mpg4|mp4,mpg4|avi|mov,qt|ogg|ogg|vlc||||wmv||wav|wav\0"
VALUE "FileOpenName", "MPEG audio|MPEG audio|MPEG video|MPEG video|MPEG video|MPEG video|MPEG-4 video|MPEG-4 audio|MPEG-4 video|MPEG-4 video|AVI video|QuickTime video|Ogg stream|Ogg stream|VLC plugin|||||Google VLC plugin|WAV audio|WAV audio\0"
VALUE "LegalCopyright", "Copyright \251 1996-2006 The VideoLAN Team\0"
VALUE "MIMEType", "audio/mpeg|audio/x-mpeg|video/mpeg|video/x-mpeg|video/mpeg-system|video/x-mpeg-system|video/mpeg4|audio/mpeg4|application/mpeg4-iod|application/mpeg4-muxcodetable|video/x-msvideo|video/quicktime|application/x-ogg|application/ogg|application/x-vlc-plugin|video/x-ms-asf-plugin|video/x-ms-asf|application/x-mplayer2|video/x-ms-wmv|application/x-google-vlc-plugin|audio/wav|audio/x-wav|audio/3gpp|video/3gpp|audio/3gpp2|video/3gpp2\0"
VALUE "FileExtents", "mp2,mp3,mpga,mpega|mp2,mp3,mpga,mpega|mpg,mpeg,mpe|mpg,mpeg,mpe|mpg,mpeg,vob|mpg,mpeg,vob|mp4,mpg4|mp4,mpg4|mp4,mpg4|mp4,mpg4|avi|mov,qt|ogg|ogg|vlc|asf,asx|asf,asx||wmv||wav|wav|3gp,3gpp|3gp,3gpp|3g2,3gpp2|3g2,3gpp2\0"
VALUE "FileOpenName", "MPEG audio|MPEG audio|MPEG video|MPEG video|MPEG video|MPEG video|MPEG-4 video|MPEG-4 audio|MPEG-4 video|MPEG-4 video|AVI video|QuickTime video|Ogg stream|Ogg stream|VLC plugin|Windows Media video|Windows Media video|Windows Media plugin|Windows Media video|Google VLC plugin|WAV audio|WAV audio|3GPP audio|3GPP video|3GPP2 audio|3GPP2 video\0"
END
END
BLOCK "VarFileInfo"
......
......@@ -97,7 +97,7 @@
#if defined(XP_MACOSX) && defined(__POWERPC__) && (!defined(TARGET_RT_MAC_CFM))
// glue for mapping outgoing Macho function pointers to TVectors
struct TFPtoTVGlue{
struct TFPtoTVGlue {
void* glue[2];
};
......@@ -633,7 +633,6 @@ void Private_Shutdown(void)
ExitCodeResource();
}
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{
EnterCodeResource();
......@@ -721,7 +720,6 @@ void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
ExitCodeResource();
}
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{
NPError err;
......@@ -923,7 +921,6 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
err = NPERR_INCOMPATIBLE_VERSION_ERROR;
}
if (err == NPERR_NO_ERROR)
{
//
......@@ -1069,7 +1066,6 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
if (nsTable->size < sizeof(NPNetscapeFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
int navMinorVers = nsTable->version & 0xFF;
/*
......
......@@ -13,7 +13,7 @@ data 'carb' (0)
resource 'STR#' (126)
{
{
"Version 0.8.6, Copyright 2006, The VideoLAN Team"
"Version 0.9.0, copyright 1996-2006 The VideoLAN Team"
"<BR><A HREF='http://www.videolan.org'>http://www.videolan.org</A>",
"VLC Multimedia Plugin"
};
......@@ -23,28 +23,43 @@ resource 'STR#' (126)
resource 'STR#' (127)
{
{
/* MPEG-1 and MPEG-2 */
"MPEG audio",
"MPEG audio",
"MPEG video",
"MPEG video",
"MPEG video",
"MPEG video",
/* MPEG-4 */
"MPEG-4 video",
"MPEG-4 audio",
"MPEG-4 video",
"MPEG-4 video",
/* AVI */
"AVI video",
/* Quicktime */
/* "QuickTime video", */
/* OGG */
"Ogg stream",
"Ogg stream",
/* VLC */
"VLC plugin",
"ASF stream",
"ASF stream",
"",
"",
"Google VLC Plugin",
/* Windows Media */
"Windows Media video",
"Windows Media video",
"Windows Media plugin",
"Windows Media video",
/* Google VLC */
"Google VLC plugin",
/* WAV audio */
"WAV audio",
"WAV audio"
"WAV audio",
/* 3GPP */
"3GPP audio",
"3GPP video",
/* 3GPP2 */
"3GPP2 audio",
"3GPP2 video",
};
};
......@@ -52,28 +67,43 @@ resource 'STR#' (127)
resource 'STR#' (128,"MIME Type")
{
{
/* MPEG-1 and MPEG-2 */
"audio/mpeg", "mp2,mp3,mpga,mpega",
"audio/x-mpeg", "mp2,mp3,mpga,mpega",
"video/mpeg", "mpg,mpeg,mpe",
"video/x-mpeg", "mpg,mpeg,mpe",
"video/mpeg-system", "mpg,mpeg,vob",
"video/x-mpeg-system", "mpg,mpeg,vob",
/* MPEG-4 */
"video/mpeg4", "mp4,mpg4",
"audio/mpeg4", "mp4,mpg4",
"application/mpeg4-iod", "mp4,mpg4",
"application/mpeg4-muxcodetable", "mp4,mpg4",
/* AVI */
"video/x-msvideo", "avi",
/* "video/quicktime", "mov, qt", */
/* Quicktime */
/* "video/quicktime", "mov,qt", */
/* OGG */
"application/ogg", "ogg",
"application/x-ogg", "ogg",
/* VLC */
"application/x-vlc-plugin", "vlc",
"video/x-ms-asf-plugin", "",
"video/x-ms-asf", "",
/* Windows Media */
"video/x-ms-asf-plugin", "asf,asx",
"video/x-ms-asf", "asf,asx",
"application/x-mplayer2", "",
"video/x-ms-wmv", "wmv",
/* Google VLC */
"video/x-google-vlc-plugin", "",
/* WAV audio */
"audio/wav", "wav",
"audio/x-wav", "wav",
/* 3GPP */
"audio/3gpp", "3gp,3gpp",
"video/3gpp", "3gp,3gpp",
/* 3GPP2 */
"audio/3gpp2", "3g2,3gpp2",
"video/3gpp2", "3g2,3gpp2",
};
};
......@@ -35,16 +35,20 @@
#include "control/npovlc.h"
#include "control/npolibvlc.h"
#include <ctype.h>
/*****************************************************************************
* VlcPlugin constructor and destructor
*****************************************************************************/
VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
i_npmode(mode),
b_stream(0),
b_autoplay(0),
b_autoplay(1),
psz_target(NULL),
libvlc_instance(NULL),
scriptClass(NULL),
libvlc_log(NULL),
p_scriptClass(NULL),
p_scriptObject(NULL),
p_browser(instance),
psz_baseURL(NULL)
#if XP_WIN
......@@ -58,7 +62,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
memset(&npwindow, 0, sizeof(NPWindow));
}
static int boolValue(const char *value) {
static bool boolValue(const char *value) {
return ( !strcmp(value, "1") ||
!strcasecmp(value, "true") ||
!strcasecmp(value, "yes") );
......@@ -123,7 +127,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
ppsz_argv[ppsz_argc++] = "--intf";
ppsz_argv[ppsz_argc++] = "dummy";
const char *version = NULL;
const char *progid = NULL;
/* parse plugin arguments */
for( int i = 0; i < argc ; i++ )
......@@ -172,9 +176,10 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
ppsz_argv[ppsz_argc++] = "--no-loop";
}
}
else if( !strcmp( argn[i], "version") )
else if( !strcmp( argn[i], "version")
|| !strcmp( argn[i], "progid") )
{
version = argv[i];
progid = argv[i];
}
}
......@@ -224,19 +229,20 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
if( psz_target )
{
// get absolute URL from src
psz_target = getAbsoluteURL(psz_target);
char *psz_absurl = getAbsoluteURL(psz_target);
psz_target = psz_absurl ? psz_absurl : strdup(psz_target);
}
/* assign plugin script root class */
if( (NULL != version) && (!strcmp(version, "VideoLAN.VLCPlugin.2")) )
if( (NULL != progid) && (!strcmp(progid, "VideoLAN.VLCPlugin.2")) )
{
/* new APIs */
scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
}
else
{
/* legacy APIs */
scriptClass = RuntimeNPClass<VlcNPObject>::getClass();
p_scriptClass = RuntimeNPClass<VlcNPObject>::getClass();
}
return NPERR_NO_ERROR;
......@@ -279,6 +285,10 @@ VlcPlugin::~VlcPlugin()
{
delete psz_baseURL;
delete psz_target;
if( p_scriptObject )
NPN_ReleaseObject(p_scriptObject);
if( libvlc_log )
libvlc_log_close(libvlc_log, NULL);
if( libvlc_instance )
libvlc_destroy(libvlc_instance, NULL );
}
......@@ -298,20 +308,22 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
// validate protocol header
const char *start = url;
while( start != end ) {
char c = *start | 0x20;
char c = tolower(*start);
if( (c < 'a') || (c > 'z') )
// not valid protocol header, assume relative URL
break;
goto relativeurl;
++start;
}
/* we have a protocol header, therefore URL is absolute */
return strdup(url);
}
relativeurl:
if( psz_baseURL )
{
size_t baseLen = strlen(psz_baseURL);
char *href = new char[baseLen+strlen(url)];
char *href = new char[baseLen+strlen(url)+1];
if( href )
{
/* prepend base URL */
......@@ -331,6 +343,8 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
/* skip over protocol part */
char *pathstart = strchr(href, ':');
char *pathend;
if( pathstart )
{
if( '/' == *(++pathstart) )
{
if( '/' == *(++pathstart) )
......@@ -347,6 +361,18 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
pathstart = pathend;
*pathstart = '/';
}
}
else
{
/* baseURL is just a UNIX path */
if( '/' != *href )
{
/* baseURL is not an absolute path */
return NULL;
}
pathstart = href;
pathend = href+baseLen;
}
/* relative URL made of an absolute path ? */
if( '/' == *url )
......@@ -357,7 +383,8 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
}
/* find last path component and replace it */
while( '/' != *pathend) --pathend;
while( '/' != *pathend)
--pathend;
/*
** if relative url path starts with one or more '../',
......@@ -370,17 +397,43 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
if( '.' != *p )
break;
++p;
if( '\0' == *p )
{
/* relative url is just '.' */
url = p;
break;
}
if( '/' == *p )
{
/* relative url starts with './' */
url = ++p;
continue;
}
if( '.' != *p )
break;
++p;
if( '\0' == *p )
{
/* relative url is '..' */
}
else
{
if( '/' != *p )
break;
/* relative url starts with '../' */
++p;
}
url = p;
while( '/' != *pathend ) --pathend;
do
{
--pathend;
}
while( '/' != *pathend );
}
/* skip over '/' separator */
++pathend;
/* concatenate remaining base URL and relative URL */
strcpy(pathend+1, url);
strcpy(pathend, url);
}
return href;
}
......@@ -388,6 +441,15 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
return NULL;
}
NPObject* VlcPlugin::getScriptObject()
{
if( NULL == p_scriptObject )
{
p_scriptObject = NPN_CreateObject(p_browser, p_scriptClass);
}
return NPN_RetainObject(p_scriptObject);
}
#if XP_UNIX
int VlcPlugin::setSize(unsigned width, unsigned height)
{
......
......@@ -71,9 +71,12 @@ public:
void setWindow(const NPWindow *window)
{ npwindow = *window; };
NPClass* getScriptClass()
{ return scriptClass; };
NPObject* getScriptObject();
void setLog(libvlc_log_t *log)
{ libvlc_log = log; };
libvlc_log_t* getLog()
{ return libvlc_log; };
#if XP_WIN
WNDPROC getWindowProc()
{ return pf_wndproc; };
......@@ -95,7 +98,9 @@ public:
private:
/* VLC reference */
libvlc_instance_t *libvlc_instance;
NPClass *scriptClass;
libvlc_log_t *libvlc_log;
NPClass *p_scriptClass;
NPObject *p_scriptObject;
/* browser reference */
NPP p_browser;
......@@ -114,12 +119,10 @@ private:
/*******************************************************************************
* Plugin properties.
******************************************************************************/
#define PLUGIN_NAME "VLC multimedia plugin"
#define PLUGIN_NAME "VLC Multimedia Plugin"
#define PLUGIN_DESCRIPTION \
"VLC multimedia plugin <br>" \
" <br>" \
"version %s <br>" \
"VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
"Version %s, copyright 1996-2006 The VideoLAN Team" \
"<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
#define PLUGIN_MIMETYPES \
/* MPEG-1 and MPEG-2 */ \
......@@ -138,20 +141,26 @@ private:
"video/x-msvideo:avi:AVI video;" \
/* QuickTime */ \
"video/quicktime:mov,qt:QuickTime video;" \
/* Ogg */ \
/* OGG */ \
"application/x-ogg:ogg:Ogg stream;" \
"application/ogg:ogg:Ogg stream;" \
/* explicit plugin call */ \
"application/x-vlc-plugin::VLC plugin;" \
/* windows media */ \
/* VLC */ \
"application/x-vlc-plugin:vlc:VLC plugin;" \
/* Windows Media */ \
"video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
"video/x-ms-asf:asf,asx:Windows Media Video;" \
"application/x-mplayer2::Windows Media;" \
"video/x-ms-wmv:wmv:Windows Media;" \
/* Google VLC mime */ \
"application/x-google-vlc-plugin::Google VLC plugin" \
/* Misc */ \
"audio/wav::WAV audio" \
"audio/x-wav::WAV audio" \
/* Google VLC */ \
"application/x-google-vlc-plugin::Google VLC plugin;" \
/* WAV audio */ \
"audio/wav:wav:WAV audio;" \
"audio/x-wav:wav:WAV audio;" \
/* 3GPP */ \
"audio/3gpp:3gp,3gpp:3GPP audio;" \
"video/3gpp:3gp,3gpp:3GPP video;" \
/* 3GPP2 */ \
"audio/3gpp2:3g2,3gpp2:3GPP2 audio;" \
"video/3gpp2:3g2,3gpp2:3GPP2 video;" \
#endif
......@@ -120,7 +120,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
{
case NPPVpluginScriptableNPObject:
/* create an instance and return it */
*(NPObject**)value = NPN_CreateObject(instance, p_plugin->getScriptClass());
*(NPObject**)value = p_plugin->getScriptObject();
if( NULL == *(NPObject**)value )
{
return NPERR_OUT_OF_MEMORY_ERROR;
......@@ -139,6 +139,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
#ifdef XP_MACOSX
int16 NPP_HandleEvent( NPP instance, void * event )
{
static UInt32 lastMouseUp = 0;
if( instance == NULL )
{
return false;
......@@ -152,7 +154,29 @@ int16 NPP_HandleEvent( NPP instance, void * event )
case nullEvent:
break;
case mouseDown:
{
if( (myEvent->when - lastMouseUp) < GetDblTime() )
{
/* double click */
libvlc_instance_t *p_vlc = p_plugin->getVLC();
if( p_vlc )
{
if( libvlc_playlist_isplaying(p_vlc, NULL) )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_vlc, NULL);
if( p_input )
{
libvlc_toggle_fullscreen(p_input, NULL);
libvlc_input_free(p_input);
}
}
}
}
return true;
}
case mouseUp:
lastMouseUp = myEvent->when;
return true;
case keyUp:
case keyDown:
......@@ -268,12 +292,14 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
NPError NPP_Destroy( NPP instance, NPSavedData** save )
{
if( instance == NULL )
{
if( NULL == instance )
return NPERR_INVALID_INSTANCE_ERROR;
}
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
if( NULL == p_plugin )
return NPERR_NO_ERROR;
instance->pdata = NULL;
#if XP_WIN
HWND win = (HWND)p_plugin->getWindow()->window;
......@@ -288,8 +314,6 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
if( p_plugin )
delete p_plugin;
instance->pdata = NULL;
return NPERR_NO_ERROR;
}
......@@ -433,14 +457,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
if( p_plugin->psz_target )
{
if( VLC_SUCCESS == libvlc_playlist_add( p_vlc, p_plugin->psz_target, NULL, NULL ) )
if( libvlc_playlist_add( p_vlc, p_plugin->psz_target, NULL, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL);
}
p_plugin->b_stream = VLC_TRUE;
}
p_plugin->b_stream = VLC_TRUE;
}
}
return NPERR_NO_ERROR;
......@@ -506,7 +530,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata);
if( VLC_SUCCESS == libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) )
if( libvlc_playlist_add( p_plugin->getVLC(), fname, stream->url, NULL ) != -1 )
{
if( p_plugin->b_autoplay )
{
......
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