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) ...@@ -6,7 +6,7 @@ noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
MOSTLYCLEANFILES = $(npvlc_DATA) MOSTLYCLEANFILES = $(npvlc_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES) 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 = \ SOURCES_mozilla_common = \
vlcshell.cpp \ vlcshell.cpp \
......
...@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] = ...@@ -61,6 +61,7 @@ const NPUTF8 * const LibvlcRootNPObject::propertyNames[] =
{ {
"audio", "audio",
"input", "input",
"log",
"playlist", "playlist",
"video", "video",
"VersionInfo", "VersionInfo",
...@@ -70,38 +71,54 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert ...@@ -70,38 +71,54 @@ const int LibvlcRootNPObject::propertyCount = sizeof(LibvlcRootNPObject::propert
enum LibvlcRootNPObjectPropertyIds enum LibvlcRootNPObjectPropertyIds
{ {
ID_audio = 0, ID_root_audio = 0,
ID_input, ID_root_input,
ID_playlist, ID_root_log,
ID_video, ID_root_playlist,
ID_VersionInfo, ID_root_video,
ID_root_VersionInfo,
}; };
RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcRootNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_audio: switch( index )
OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result); {
return INVOKERESULT_NO_ERROR; case ID_root_audio:
case ID_input: OBJECT_TO_NPVARIANT(NPN_RetainObject(audioObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_input:
case ID_playlist: OBJECT_TO_NPVARIANT(NPN_RetainObject(inputObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_log:
case ID_video: OBJECT_TO_NPVARIANT(NPN_RetainObject(logObj), result);
OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result); return INVOKERESULT_NO_ERROR;
return INVOKERESULT_NO_ERROR; case ID_root_playlist:
case ID_VersionInfo: OBJECT_TO_NPVARIANT(NPN_RetainObject(playlistObj), result);
NPUTF8 *versionStr = NULL; return INVOKERESULT_NO_ERROR;
case ID_root_video:
versionStr = strdup( VLC_Version() ); OBJECT_TO_NPVARIANT(NPN_RetainObject(videoObj), result);
if (!versionStr) return INVOKERESULT_NO_ERROR;
return INVOKERESULT_GENERIC_ERROR; case ID_root_VersionInfo:
{
STRINGZ_TO_NPVARIANT(versionStr, result); int len = strlen(VLC_Version());
return INVOKERESULT_NO_ERROR; 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; return INVOKERESULT_GENERIC_ERROR;
} }
...@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam ...@@ -115,7 +132,7 @@ const int LibvlcRootNPObject::methodCount = sizeof(LibvlcRootNPObject::methodNam
enum LibvlcRootNPObjectMethodIds enum LibvlcRootNPObjectMethodIds
{ {
ID_version, ID_root_versionInfo,
}; };
RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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 ...@@ -128,21 +145,25 @@ RuntimeNPObject::InvokeResult LibvlcRootNPObject::invoke(int index, const NPVari
switch( index ) switch( index )
{ {
case ID_version: case ID_root_versionInfo:
if( argCount == 0 ) if( argCount == 0 )
{ {
NPUTF8 *versionStr = NULL; int len = strlen(VLC_Version());
NPUTF8 *retval =(NPUTF8*)NPN_MemAlloc(len);
versionStr = strdup( VLC_Version() ); if( retval )
if (!versionStr) {
return INVOKERESULT_GENERIC_ERROR; memcpy(retval, VLC_Version(), len);
STRINGN_TO_NPVARIANT(retval, len, result);
STRINGZ_TO_NPVARIANT(versionStr, result); }
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope ...@@ -162,8 +183,8 @@ const int LibvlcAudioNPObject::propertyCount = sizeof(LibvlcAudioNPObject::prope
enum LibvlcAudioNPObjectPropertyIds enum LibvlcAudioNPObjectPropertyIds
{ {
ID_mute, ID_audio_mute,
ID_volume, ID_audio_volume,
}; };
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVariant &result)
...@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -176,7 +197,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
switch( index ) switch( index )
{ {
case ID_mute: case ID_audio_mute:
{ {
vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex); vlc_bool_t muted = libvlc_audio_get_mute(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -188,7 +209,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(muted, result); BOOLEAN_TO_NPVARIANT(muted, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_volume: case ID_audio_volume:
{ {
int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex); int volume = libvlc_audio_get_volume(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari ...@@ -200,6 +221,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(volume, result); INT32_TO_NPVARIANT(volume, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -215,7 +238,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
switch( index ) switch( index )
{ {
case ID_mute: case ID_audio_mute:
if( NPVARIANT_IS_BOOLEAN(value) ) if( NPVARIANT_IS_BOOLEAN(value) )
{ {
libvlc_audio_set_mute(p_plugin->getVLC(), libvlc_audio_set_mute(p_plugin->getVLC(),
...@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -229,7 +252,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
case ID_volume: case ID_audio_volume:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_audio_set_volume(p_plugin->getVLC(), libvlc_audio_set_volume(p_plugin->getVLC(),
...@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const ...@@ -243,6 +266,8 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::setProperty(int index, const
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN ...@@ -257,7 +282,7 @@ const int LibvlcAudioNPObject::methodCount = sizeof(LibvlcAudioNPObject::methodN
enum LibvlcAudioNPObjectMethodIds enum LibvlcAudioNPObjectMethodIds
{ {
ID_togglemute, ID_audio_togglemute,
}; };
RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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 ...@@ -270,7 +295,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
switch( index ) switch( index )
{ {
case ID_togglemute: case ID_audio_togglemute:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex); libvlc_audio_toggle_mute(p_plugin->getVLC(), &ex);
...@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar ...@@ -288,7 +313,7 @@ RuntimeNPObject::InvokeResult LibvlcAudioNPObject::invoke(int index, const NPVar
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope ...@@ -313,13 +338,13 @@ const int LibvlcInputNPObject::propertyCount = sizeof(LibvlcInputNPObject::prope
enum LibvlcInputNPObjectPropertyIds enum LibvlcInputNPObjectPropertyIds
{ {
ID_length, ID_input_length,
ID_position, ID_input_position,
ID_time, ID_input_time,
ID_state, ID_input_state,
ID_rate, ID_input_rate,
ID_fps, ID_input_fps,
ID_hasvout, ID_input_hasvout,
}; };
RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVariant &result)
...@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -333,7 +358,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex); libvlc_input_t *p_input = libvlc_playlist_get_input(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{ {
if( index != ID_state ) if( index != ID_input_state )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex); libvlc_exception_clear(&ex);
...@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -349,7 +374,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
switch( index ) switch( index )
{ {
case ID_length: case ID_input_length:
{ {
double val = (double)libvlc_input_get_length(p_input, &ex); double val = (double)libvlc_input_get_length(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -362,7 +387,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_position: case ID_input_position:
{ {
double val = libvlc_input_get_position(p_input, &ex); double val = libvlc_input_get_position(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -375,7 +400,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_time: case ID_input_time:
{ {
double val = (double)libvlc_input_get_time(p_input, &ex); double val = (double)libvlc_input_get_time(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -388,7 +413,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_state: case ID_input_state:
{ {
int val = libvlc_input_get_state(p_input, &ex); int val = libvlc_input_get_state(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -401,7 +426,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_rate: case ID_input_rate:
{ {
float val = libvlc_input_get_rate(p_input, &ex); float val = libvlc_input_get_rate(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -414,7 +439,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_fps: case ID_input_fps:
{ {
double val = libvlc_input_get_fps(p_input, &ex); double val = libvlc_input_get_fps(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -427,7 +452,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
DOUBLE_TO_NPVARIANT(val, result); DOUBLE_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_hasvout: case ID_input_hasvout:
{ {
vlc_bool_t val = libvlc_input_has_vout(p_input, &ex); vlc_bool_t val = libvlc_input_has_vout(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari ...@@ -440,6 +465,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result); BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -464,7 +491,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
switch( index ) switch( index )
{ {
case ID_position: case ID_input_position:
{ {
if( ! NPVARIANT_IS_DOUBLE(value) ) if( ! NPVARIANT_IS_DOUBLE(value) )
{ {
...@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -483,7 +510,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_time: case ID_input_time:
{ {
vlc_int64_t val; vlc_int64_t val;
if( NPVARIANT_IS_INT32(value) ) if( NPVARIANT_IS_INT32(value) )
...@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -506,7 +533,7 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_rate: case ID_input_rate:
{ {
float val; float val;
if( NPVARIANT_IS_INT32(value) ) if( NPVARIANT_IS_INT32(value) )
...@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const ...@@ -529,6 +556,8 @@ RuntimeNPObject::InvokeResult LibvlcInputNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -559,93 +588,99 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p ...@@ -559,93 +588,99 @@ const int LibvlcMessageNPObject::propertyCount = sizeof(LibvlcMessageNPObject::p
enum LibvlcMessageNPObjectPropertyIds enum LibvlcMessageNPObjectPropertyIds
{ {
ID_severity, ID_message_severity,
ID_type, ID_message_type,
ID_name, ID_message_name,
ID_header, ID_message_header,
ID_message, ID_message_message,
}; };
RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessageNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_severity: switch( index )
{
INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
}
case ID_type:
{ {
if( _msg.psz_type ) case ID_message_severity:
{
int len = strlen(_msg.psz_type);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_type, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{ {
NULL_TO_NPVARIANT(result); INT32_TO_NPVARIANT(_msg.i_severity, result);
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; case ID_message_type:
}
case ID_name:
{
if( _msg.psz_name )
{ {
int len = strlen(_msg.psz_name); if( _msg.psz_type )
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_name, len); int len = strlen(_msg.psz_type);
STRINGN_TO_NPVARIANT(retval, len, result); NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_type, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
} }
} else
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
}
case ID_header:
{
if( _msg.psz_header )
{
int len = strlen(_msg.psz_header);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_header, len); NULL_TO_NPVARIANT(result);
STRINGN_TO_NPVARIANT(retval, len, result);
} }
return INVOKERESULT_NO_ERROR;
} }
else case ID_message_name:
{ {
NULL_TO_NPVARIANT(result); if( _msg.psz_name )
{
int len = strlen(_msg.psz_name);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_name, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; case ID_message_header:
}
case ID_message:
{
if( _msg.psz_message )
{ {
int len = strlen(_msg.psz_message); if( _msg.psz_header )
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{ {
memcpy(retval, _msg.psz_message, len); int len = strlen(_msg.psz_header);
STRINGN_TO_NPVARIANT(retval, len, result); NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_header, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
} }
return INVOKERESULT_NO_ERROR;
} }
else case ID_message_message:
{ {
NULL_TO_NPVARIANT(result); if( _msg.psz_message )
{
int len = strlen(_msg.psz_message);
NPUTF8* retval = (NPUTF8*)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, _msg.psz_message, len);
STRINGN_TO_NPVARIANT(retval, len, result);
}
}
else
{
NULL_TO_NPVARIANT(result);
}
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met ...@@ -662,17 +697,27 @@ const int LibvlcMessageNPObject::methodCount = sizeof(LibvlcMessageNPObject::met
** implementation of libvlc message iterator object ** 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; VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_vlclog->_p_log ) if( p_plugin )
{ {
_p_iter = libvlc_log_get_iterator(p_vlclog->_p_log, NULL); libvlc_log_t *p_log = p_plugin->getLog();
if( p_log )
{
_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[] = const NPUTF8 * const LibvlcMessageIteratorNPObject::propertyNames[] =
{ {
"hasNext", "hasNext",
...@@ -682,33 +727,39 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte ...@@ -682,33 +727,39 @@ const int LibvlcMessageIteratorNPObject::propertyCount = sizeof(LibvlcMessageIte
enum LibvlcMessageIteratorNPObjectPropertyIds enum LibvlcMessageIteratorNPObjectPropertyIds
{ {
ID_hasNext, ID_messageiterator_hasNext,
}; };
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_hasNext: switch( index )
{ {
if( _p_iter && _p_vlclog->_p_log ) case ID_messageiterator_hasNext:
{ {
libvlc_exception_t ex; if( _p_iter && p_plugin->getLog() )
libvlc_exception_init(&ex); {
libvlc_exception_t ex;
libvlc_exception_init(&ex);
BOOLEAN_TO_NPVARIANT(libvlc_log_iterator_has_next(_p_iter, &ex), result); BOOLEAN_TO_NPVARIANT(libvlc_log_iterator_has_next(_p_iter, &ex), result);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
}
else
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); BOOLEAN_TO_NPVARIANT(0, result);
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
} }
return INVOKERESULT_NO_ERROR;
} }
else default:
{ ;
BOOLEAN_TO_NPVARIANT(0, result);
}
return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -728,7 +779,8 @@ enum LibvlcMessageIteratorNPObjectMethodIds ...@@ -728,7 +779,8 @@ enum LibvlcMessageIteratorNPObjectMethodIds
RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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_t ex;
libvlc_exception_init(&ex); libvlc_exception_init(&ex);
...@@ -738,32 +790,37 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c ...@@ -738,32 +790,37 @@ RuntimeNPObject::InvokeResult LibvlcMessageIteratorNPObject::invoke(int index, c
case ID_messageiterator_next: case ID_messageiterator_next:
if( argCount == 0 ) if( argCount == 0 )
{ {
struct libvlc_log_message_t buffer; if( _p_iter && p_plugin->getLog() )
{
struct libvlc_log_message_t buffer;
buffer.sizeof_msg = sizeof(buffer); buffer.sizeof_msg = sizeof(buffer);
libvlc_log_iterator_next(_p_iter, &buffer, &ex); libvlc_log_iterator_next(_p_iter, &buffer, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
else
{
LibvlcMessageNPObject* message =
static_cast<LibvlcMessageNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageNPObject>::getClass()));
if( message )
{ {
message->setMessage(buffer); NPN_SetException(this, libvlc_exception_get_message(&ex));
OBJECT_TO_NPVARIANT(message, result); libvlc_exception_clear(&ex);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_GENERIC_ERROR;
}
else
{
LibvlcMessageNPObject* message =
static_cast<LibvlcMessageNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageNPObject>::getClass()));
if( message )
{
message->setMessage(buffer);
OBJECT_TO_NPVARIANT(message, result);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_GENERIC_ERROR;
} }
default:
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -782,34 +839,40 @@ const int LibvlcMessagesNPObject::propertyCount = sizeof(LibvlcMessagesNPObject: ...@@ -782,34 +839,40 @@ const int LibvlcMessagesNPObject::propertyCount = sizeof(LibvlcMessagesNPObject:
enum LibvlcMessagesNPObjectPropertyIds enum LibvlcMessagesNPObjectPropertyIds
{ {
ID_count, ID_messages_count,
}; };
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::getProperty(int index, NPVariant &result)
{ {
switch( index ) VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
if( p_plugin )
{ {
case ID_count: switch( index )
{ {
libvlc_log_t *p_log = _p_vlclog->_p_log; case ID_messages_count:
if( p_log )
{ {
libvlc_exception_t ex; libvlc_log_t *p_log = p_plugin->getLog();
libvlc_exception_init(&ex); if( p_log )
{
libvlc_exception_t ex;
libvlc_exception_init(&ex);
INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result); INT32_TO_NPVARIANT(libvlc_log_count(p_log, &ex), result);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
}
else
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); INT32_TO_NPVARIANT(0, result);
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
} }
return INVOKERESULT_NO_ERROR;
} }
else default:
{ ;
INT32_TO_NPVARIANT(0, result);
}
return INVOKERESULT_NO_ERROR;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -826,59 +889,75 @@ const int LibvlcMessagesNPObject::methodCount = sizeof(LibvlcMessagesNPObject::m ...@@ -826,59 +889,75 @@ const int LibvlcMessagesNPObject::methodCount = sizeof(LibvlcMessagesNPObject::m
enum LibvlcMessagesNPObjectMethodIds enum LibvlcMessagesNPObjectMethodIds
{ {
ID_messages_clear, ID_messages_clear,
ID_iterator, ID_messages_iterator,
}; };
RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcMessagesNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
{ {
libvlc_exception_t ex; VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(_instance->pdata);
libvlc_exception_init(&ex); if( p_plugin )
switch( index )
{ {
case ID_messages_clear: libvlc_exception_t ex;
if( argCount == 0 ) libvlc_exception_init(&ex);
{
libvlc_log_t *p_log = _p_vlclog->_p_log; switch( index )
if( p_log ) {
case ID_messages_clear:
if( argCount == 0 )
{ {
libvlc_log_clear(p_log, &ex); libvlc_log_t *p_log = p_plugin->getLog();
if( libvlc_exception_raised(&ex) ) if( p_log )
{ {
NPN_SetException(this, libvlc_exception_get_message(&ex)); libvlc_log_clear(p_log, &ex);
libvlc_exception_clear(&ex); if( libvlc_exception_raised(&ex) )
return INVOKERESULT_GENERIC_ERROR; {
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
} }
return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_SUCH_METHOD;
}
return INVOKERESULT_NO_SUCH_METHOD;
case ID_iterator: case ID_messages_iterator:
if( argCount == 0 ) if( argCount == 0 )
{
LibvlcMessageIteratorNPObject* iter =
static_cast<LibvlcMessageIteratorNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageIteratorNPObject>::getClass()));
if( iter )
{ {
iter->setLog(_p_vlclog); LibvlcMessageIteratorNPObject* iter =
OBJECT_TO_NPVARIANT(iter, result); static_cast<LibvlcMessageIteratorNPObject*>(NPN_CreateObject(_instance, RuntimeNPClass<LibvlcMessageIteratorNPObject>::getClass()));
return INVOKERESULT_NO_ERROR; if( iter )
{
OBJECT_TO_NPVARIANT(iter, result);
return INVOKERESULT_NO_ERROR;
}
return INVOKERESULT_OUT_OF_MEMORY;
} }
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_NO_SUCH_METHOD;
}
return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
}
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
/* /*
** implementation of libvlc message object ** 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[] = const NPUTF8 * const LibvlcLogNPObject::propertyNames[] =
{ {
"messages", "messages",
...@@ -889,8 +968,8 @@ const int LibvlcLogNPObject::propertyCount = sizeof(LibvlcLogNPObject::propertyN ...@@ -889,8 +968,8 @@ const int LibvlcLogNPObject::propertyCount = sizeof(LibvlcLogNPObject::propertyN
enum LibvlcLogNPObjectPropertyIds enum LibvlcLogNPObjectPropertyIds
{ {
ID_messages, ID_log_messages,
ID_verbosity, ID_log_verbosity,
}; };
RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVariant &result)
...@@ -903,14 +982,14 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian ...@@ -903,14 +982,14 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
switch( index ) switch( index )
{ {
case ID_messages: case ID_log_messages:
{ {
OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcmessages), result); OBJECT_TO_NPVARIANT(NPN_RetainObject(_p_vlcmessages), result);
return INVOKERESULT_NO_ERROR; 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(), INT32_TO_NPVARIANT(libvlc_get_log_verbosity(p_plugin->getVLC(),
&ex), result); &ex), result);
...@@ -928,6 +1007,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian ...@@ -928,6 +1007,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::getProperty(int index, NPVarian
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -943,22 +1024,24 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP ...@@ -943,22 +1024,24 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
switch( index ) switch( index )
{ {
case ID_verbosity: case ID_log_verbosity:
if( isNumberValue(value) ) if( isNumberValue(value) )
{ {
libvlc_instance_t* p_libvlc = p_plugin->getVLC(); libvlc_instance_t* p_libvlc = p_plugin->getVLC();
libvlc_log_t *p_log = p_plugin->getLog();
int verbosity = numberValue(value); int verbosity = numberValue(value);
if( verbosity >= 0 ) 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) ) 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;
} }
p_plugin->setLog(p_log);
} }
libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex); libvlc_set_log_verbosity(p_libvlc, (unsigned)verbosity, &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -968,11 +1051,11 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP ...@@ -968,11 +1051,11 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
} }
else if( _p_log ) else if( p_log )
{ {
/* close log when verbosity is set to -1 */ /* close log when verbosity is set to -1 */
libvlc_log_close(_p_log, &ex); p_plugin->setLog(NULL);
_p_log = NULL; libvlc_log_close(p_log, &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));
...@@ -983,6 +1066,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP ...@@ -983,6 +1066,8 @@ RuntimeNPObject::InvokeResult LibvlcLogNPObject::setProperty(int index, const NP
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
return INVOKERESULT_INVALID_VALUE; return INVOKERESULT_INVALID_VALUE;
default:
;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -995,23 +1080,146 @@ const NPUTF8 * const LibvlcLogNPObject::methodNames[] = ...@@ -995,23 +1080,146 @@ const NPUTF8 * const LibvlcLogNPObject::methodNames[] =
const int LibvlcLogNPObject::methodCount = sizeof(LibvlcLogNPObject::methodNames)/sizeof(NPUTF8 *); 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 ** 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[] = const NPUTF8 * const LibvlcPlaylistNPObject::propertyNames[] =
{ {
"itemCount", "itemCount", /* deprecated */
"isPlaying", "isPlaying",
"items",
}; };
const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *); const int LibvlcPlaylistNPObject::propertyCount = sizeof(LibvlcPlaylistNPObject::propertyNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistNPObjectPropertyIds enum LibvlcPlaylistNPObjectPropertyIds
{ {
ID_itemcount, ID_playlist_itemcount,
ID_isplaying, ID_playlist_isplaying,
ID_playlist_items,
}; };
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPVariant &result)
...@@ -1024,7 +1232,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV ...@@ -1024,7 +1232,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
switch( index ) switch( index )
{ {
case ID_itemcount: case ID_playlist_itemcount: /* deprecated */
{ {
int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex); int val = libvlc_playlist_items_count(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -1036,7 +1244,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV ...@@ -1036,7 +1244,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_isplaying: case ID_playlist_isplaying:
{ {
int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex); int val = libvlc_playlist_isplaying(p_plugin->getVLC(), &ex);
if( libvlc_exception_raised(&ex) ) if( libvlc_exception_raised(&ex) )
...@@ -1048,6 +1256,13 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV ...@@ -1048,6 +1256,13 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::getProperty(int index, NPV
BOOLEAN_TO_NPVARIANT(val, result); BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; 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; return INVOKERESULT_GENERIC_ERROR;
...@@ -1062,23 +1277,23 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] = ...@@ -1062,23 +1277,23 @@ const NPUTF8 * const LibvlcPlaylistNPObject::methodNames[] =
"stop", "stop",
"next", "next",
"prev", "prev",
"clear", "clear", /* deprecated */
"removeItem" "removeItem", /* deprecated */
}; };
const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *); const int LibvlcPlaylistNPObject::methodCount = sizeof(LibvlcPlaylistNPObject::methodNames)/sizeof(NPUTF8 *);
enum LibvlcPlaylistNPObjectMethodIds enum LibvlcPlaylistNPObjectMethodIds
{ {
ID_add, ID_playlist_add,
ID_play, ID_playlist_play,
ID_playItem, ID_playlist_playItem,
ID_togglepause, ID_playlist_togglepause,
ID_stop, ID_playlist_stop,
ID_next, ID_playlist_next,
ID_prev, ID_playlist_prev,
ID_clear, ID_playlist_clear,
ID_removeitem ID_playlist_removeitem
}; };
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) 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 ...@@ -1091,7 +1306,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
switch( index ) switch( index )
{ {
case ID_add: case ID_playlist_add:
{ {
if( (argCount < 1) || (argCount > 3) ) if( (argCount < 1) || (argCount > 3) )
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
...@@ -1105,10 +1320,11 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1105,10 +1320,11 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
if( s ) if( s )
{ {
url = p_plugin->getAbsoluteURL(s); url = p_plugin->getAbsoluteURL(s);
delete s; if( url )
if( ! url ) delete s;
// what happened ? else
return INVOKERESULT_GENERIC_ERROR; // problem with combining url, use argument
url = s;
} }
else else
return INVOKERESULT_OUT_OF_MEMORY; return INVOKERESULT_OUT_OF_MEMORY;
...@@ -1181,7 +1397,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1181,7 +1397,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
} }
case ID_play: case ID_playlist_play:
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);
...@@ -1198,7 +1414,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1198,7 +1414,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_playItem: case ID_playlist_playItem:
if( (argCount == 1) && isNumberValue(args[0]) ) if( (argCount == 1) && isNumberValue(args[0]) )
{ {
libvlc_playlist_play(p_plugin->getVLC(), numberValue(args[0]), 0, NULL, &ex); libvlc_playlist_play(p_plugin->getVLC(), numberValue(args[0]), 0, NULL, &ex);
...@@ -1215,7 +1431,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1215,7 +1431,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_togglepause: case ID_playlist_togglepause:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_pause(p_plugin->getVLC(), &ex); libvlc_playlist_pause(p_plugin->getVLC(), &ex);
...@@ -1232,7 +1448,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1232,7 +1448,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_stop: case ID_playlist_stop:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_stop(p_plugin->getVLC(), &ex); libvlc_playlist_stop(p_plugin->getVLC(), &ex);
...@@ -1249,7 +1465,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1249,7 +1465,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_next: case ID_playlist_next:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_next(p_plugin->getVLC(), &ex); libvlc_playlist_next(p_plugin->getVLC(), &ex);
...@@ -1266,7 +1482,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1266,7 +1482,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_prev: case ID_playlist_prev:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_prev(p_plugin->getVLC(), &ex); libvlc_playlist_prev(p_plugin->getVLC(), &ex);
...@@ -1283,7 +1499,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1283,7 +1499,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_clear: case ID_playlist_clear: /* deprecated */
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_playlist_clear(p_plugin->getVLC(), &ex); libvlc_playlist_clear(p_plugin->getVLC(), &ex);
...@@ -1300,7 +1516,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1300,7 +1516,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
case ID_removeitem: case ID_playlist_removeitem: /* deprecated */
if( (argCount == 1) && isNumberValue(args[0]) ) if( (argCount == 1) && isNumberValue(args[0]) )
{ {
libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex); libvlc_playlist_delete_item(p_plugin->getVLC(), numberValue(args[0]), &ex);
...@@ -1318,7 +1534,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1318,7 +1534,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
return INVOKERESULT_NO_SUCH_METHOD; return INVOKERESULT_NO_SUCH_METHOD;
default: default:
return INVOKERESULT_NO_SUCH_METHOD; ;
} }
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
...@@ -1465,10 +1681,10 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = ...@@ -1465,10 +1681,10 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
enum LibvlcVideoNPObjectPropertyIds enum LibvlcVideoNPObjectPropertyIds
{ {
ID_fullscreen, ID_video_fullscreen,
ID_height, ID_video_height,
ID_width, ID_video_width,
ID_aspectratio ID_video_aspectratio
}; };
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *); const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
...@@ -1491,7 +1707,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1491,7 +1707,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
switch( index ) switch( index )
{ {
case ID_fullscreen: case ID_video_fullscreen:
{ {
int val = libvlc_get_fullscreen(p_input, &ex); int val = libvlc_get_fullscreen(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -1504,7 +1720,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1504,7 +1720,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
BOOLEAN_TO_NPVARIANT(val, result); BOOLEAN_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_height: case ID_video_height:
{ {
int val = libvlc_video_get_height(p_input, &ex); int val = libvlc_video_get_height(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -1517,7 +1733,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1517,7 +1733,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_width: case ID_video_width:
{ {
int val = libvlc_video_get_width(p_input, &ex); int val = libvlc_video_get_width(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -1530,7 +1746,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1530,7 +1746,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_aspectratio: case ID_video_aspectratio:
{ {
NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex); NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
libvlc_input_free(p_input); libvlc_input_free(p_input);
...@@ -1570,7 +1786,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const ...@@ -1570,7 +1786,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
switch( index ) switch( index )
{ {
case ID_fullscreen: case ID_video_fullscreen:
{ {
if( ! NPVARIANT_IS_BOOLEAN(value) ) if( ! NPVARIANT_IS_BOOLEAN(value) )
{ {
...@@ -1589,7 +1805,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const ...@@ -1589,7 +1805,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_aspectratio: case ID_video_aspectratio:
{ {
char *psz_aspect = NULL; char *psz_aspect = NULL;
...@@ -1629,7 +1845,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] = ...@@ -1629,7 +1845,7 @@ const NPUTF8 * const LibvlcVideoNPObject::methodNames[] =
enum LibvlcVideoNPObjectMethodIds enum LibvlcVideoNPObjectMethodIds
{ {
ID_togglefullscreen, ID_video_togglefullscreen,
}; };
const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *); const int LibvlcVideoNPObject::methodCount = sizeof(LibvlcVideoNPObject::methodNames)/sizeof(NPUTF8 *);
...@@ -1652,7 +1868,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar ...@@ -1652,7 +1868,7 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::invoke(int index, const NPVar
switch( index ) switch( index )
{ {
case ID_togglefullscreen: case ID_video_togglefullscreen:
if( argCount == 0 ) if( argCount == 0 )
{ {
libvlc_toggle_fullscreen(p_input, &ex); libvlc_toggle_fullscreen(p_input, &ex);
......
...@@ -125,16 +125,11 @@ class LibvlcLogNPObject; ...@@ -125,16 +125,11 @@ class LibvlcLogNPObject;
class LibvlcMessageIteratorNPObject: public RuntimeNPObject class LibvlcMessageIteratorNPObject: public RuntimeNPObject
{ {
public:
void setLog(LibvlcLogNPObject* p_vlclog);
protected: protected:
friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>; friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>;
LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) : LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass);
RuntimeNPObject(instance, aClass) {}; virtual ~LibvlcMessageIteratorNPObject();
virtual ~LibvlcMessageIteratorNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
...@@ -147,23 +142,15 @@ protected: ...@@ -147,23 +142,15 @@ protected:
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:
LibvlcLogNPObject* _p_vlclog;
libvlc_log_iterator_t* _p_iter; libvlc_log_iterator_t* _p_iter;
}; };
class LibvlcMessagesNPObject: public RuntimeNPObject class LibvlcMessagesNPObject: public RuntimeNPObject
{ {
public:
void setLog(LibvlcLogNPObject *p_log)
{
_p_vlclog = p_log;
}
protected: protected:
friend class RuntimeNPClass<LibvlcMessagesNPObject>; friend class RuntimeNPClass<LibvlcMessagesNPObject>;
LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) : LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :
_p_vlclog(NULL),
RuntimeNPObject(instance, aClass) {}; RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessagesNPObject() {}; virtual ~LibvlcMessagesNPObject() {};
...@@ -177,32 +164,15 @@ protected: ...@@ -177,32 +164,15 @@ protected:
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:
LibvlcLogNPObject* _p_vlclog;
}; };
class LibvlcLogNPObject: public RuntimeNPObject class LibvlcLogNPObject: public RuntimeNPObject
{ {
protected: protected:
friend class RuntimeNPClass<LibvlcLogNPObject>; friend class RuntimeNPClass<LibvlcLogNPObject>;
friend class LibvlcMessagesNPObject;
friend class LibvlcMessageIteratorNPObject;
libvlc_log_t *_p_log; LibvlcLogNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcLogNPObject();
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);
};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
...@@ -217,14 +187,33 @@ private: ...@@ -217,14 +187,33 @@ private:
LibvlcMessagesNPObject* _p_vlcmessages; 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 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) {}; virtual ~LibvlcPlaylistNPObject();
virtual ~LibvlcPlaylistNPObject() {};
static const int propertyCount; static const int propertyCount;
static const NPUTF8 * const propertyNames[]; static const NPUTF8 * const propertyNames[];
...@@ -238,6 +227,9 @@ protected: ...@@ -238,6 +227,9 @@ protected:
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:
LibvlcPlaylistItemsNPObject* _p_vlcplaylistitems;
}; };
class LibvlcVideoNPObject: public RuntimeNPObject class LibvlcVideoNPObject: public RuntimeNPObject
......
...@@ -110,4 +110,3 @@ bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result) ...@@ -110,4 +110,3 @@ bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result)
} }
return false; return false;
} }
...@@ -31,17 +31,17 @@ BEGIN ...@@ -31,17 +31,17 @@ BEGIN
BEGIN BEGIN
BLOCK "040904e4" BLOCK "040904e4"
BEGIN BEGIN
VALUE "ProductName", "VLC multimedia plugin\0" VALUE "ProductName", "VLC Multimedia Plugin\0"
VALUE "ProductVersion", STRINGIFY( VERSION ) VALUE "ProductVersion", STRINGIFY( VERSION )
VALUE "OriginalFilename", "npvlc.dll\0" VALUE "OriginalFilename", "npvlc.dll\0"
VALUE "FileVersion", STRINGIFY( VERSION ) 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 "InternalName", "npvlc\0"
VALUE "CompanyName", "VideoLAN Team\0" VALUE "CompanyName", "VideoLAN Team\0"
VALUE "LegalCopyright", "Copyright VideoLAN \251 1996-2006\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\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||||wmv||wav|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|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|||||Google VLC plugin|WAV audio|WAV audio\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
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
......
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
#if defined(XP_MACOSX) && defined(__POWERPC__) && (!defined(TARGET_RT_MAC_CFM)) #if defined(XP_MACOSX) && defined(__POWERPC__) && (!defined(TARGET_RT_MAC_CFM))
// glue for mapping outgoing Macho function pointers to TVectors // glue for mapping outgoing Macho function pointers to TVectors
struct TFPtoTVGlue{ struct TFPtoTVGlue {
void* glue[2]; void* glue[2];
}; };
...@@ -235,7 +235,7 @@ NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void ...@@ -235,7 +235,7 @@ NPError NPN_GetURLNotify(NPP instance, const char* url, const char* window, void
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err; NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData); err = CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
...@@ -256,7 +256,7 @@ NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uin ...@@ -256,7 +256,7 @@ NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uin
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err; NPError err;
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url, err = CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url,
...@@ -283,7 +283,7 @@ NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStrea ...@@ -283,7 +283,7 @@ NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* window, NPStrea
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err; NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT ) if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{ {
err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream); err = CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream);
...@@ -299,7 +299,7 @@ int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer) ...@@ -299,7 +299,7 @@ int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err; NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT ) if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{ {
err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer); err = CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);
...@@ -315,7 +315,7 @@ NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason) ...@@ -315,7 +315,7 @@ NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
NPError err; NPError err;
if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT ) if( navMinorVers >= NPVERS_HAS_STREAMOUTPUT )
{ {
err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason); err = CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);
...@@ -398,7 +398,7 @@ NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name) ...@@ -398,7 +398,7 @@ NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_GetStringIdentifierProc( gNetscapeFuncs.getstringidentifier, name); return CallNPN_GetStringIdentifierProc( gNetscapeFuncs.getstringidentifier, name);
} }
return NULL; return NULL;
...@@ -408,7 +408,7 @@ void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentif ...@@ -408,7 +408,7 @@ void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentif
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
CallNPN_GetStringIdentifiersProc( gNetscapeFuncs.getstringidentifiers, names, nameCount, identifiers); CallNPN_GetStringIdentifiersProc( gNetscapeFuncs.getstringidentifiers, names, nameCount, identifiers);
} }
} }
...@@ -417,7 +417,7 @@ NPIdentifier NPN_GetIntIdentifier(int32_t intid) ...@@ -417,7 +417,7 @@ NPIdentifier NPN_GetIntIdentifier(int32_t intid)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_GetIntIdentifierProc( gNetscapeFuncs.getintidentifier, intid); return CallNPN_GetIntIdentifierProc( gNetscapeFuncs.getintidentifier, intid);
} }
return NULL; return NULL;
...@@ -427,7 +427,7 @@ bool NPN_IdentifierIsString(NPIdentifier identifier) ...@@ -427,7 +427,7 @@ bool NPN_IdentifierIsString(NPIdentifier identifier)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_IdentifierIsStringProc( gNetscapeFuncs.identifierisstring, identifier); return CallNPN_IdentifierIsStringProc( gNetscapeFuncs.identifierisstring, identifier);
} }
return false; return false;
...@@ -437,7 +437,7 @@ NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier) ...@@ -437,7 +437,7 @@ NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_UTF8FromIdentifierProc( gNetscapeFuncs.utf8fromidentifier, identifier); return CallNPN_UTF8FromIdentifierProc( gNetscapeFuncs.utf8fromidentifier, identifier);
} }
return NULL; return NULL;
...@@ -447,7 +447,7 @@ int32_t NPN_IntFromIdentifier(NPIdentifier identifier) ...@@ -447,7 +447,7 @@ int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_IntFromIdentifierProc( gNetscapeFuncs.intfromidentifier, identifier); return CallNPN_IntFromIdentifierProc( gNetscapeFuncs.intfromidentifier, identifier);
} }
return 0; return 0;
...@@ -457,7 +457,7 @@ NPObject *NPN_CreateObject(NPP instance, NPClass *aClass) ...@@ -457,7 +457,7 @@ NPObject *NPN_CreateObject(NPP instance, NPClass *aClass)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_CreateObjectProc( gNetscapeFuncs.createobject, instance, aClass); return CallNPN_CreateObjectProc( gNetscapeFuncs.createobject, instance, aClass);
} }
return NULL; return NULL;
...@@ -467,7 +467,7 @@ NPObject *NPN_RetainObject(NPObject *npobj) ...@@ -467,7 +467,7 @@ NPObject *NPN_RetainObject(NPObject *npobj)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_RetainObjectProc( gNetscapeFuncs.retainobject, npobj); return CallNPN_RetainObjectProc( gNetscapeFuncs.retainobject, npobj);
} }
return NULL; return NULL;
...@@ -477,7 +477,7 @@ void NPN_ReleaseObject(NPObject *npobj) ...@@ -477,7 +477,7 @@ void NPN_ReleaseObject(NPObject *npobj)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
CallNPN_ReleaseObjectProc( gNetscapeFuncs.releaseobject, npobj); CallNPN_ReleaseObjectProc( gNetscapeFuncs.releaseobject, npobj);
} }
} }
...@@ -486,7 +486,7 @@ bool NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName, const NP ...@@ -486,7 +486,7 @@ bool NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName, const NP
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_InvokeProc( gNetscapeFuncs.invoke, instance, npobj, methodName, args, argCount, result); return CallNPN_InvokeProc( gNetscapeFuncs.invoke, instance, npobj, methodName, args, argCount, result);
} }
return false; return false;
...@@ -496,7 +496,7 @@ bool NPN_InvokeDefault(NPP instance, NPObject *npobj, const NPVariant *args, uin ...@@ -496,7 +496,7 @@ bool NPN_InvokeDefault(NPP instance, NPObject *npobj, const NPVariant *args, uin
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_InvokeDefaultProc( gNetscapeFuncs.invokeDefault, instance, npobj, args, argCount, result); return CallNPN_InvokeDefaultProc( gNetscapeFuncs.invokeDefault, instance, npobj, args, argCount, result);
} }
return false; return false;
...@@ -506,7 +506,7 @@ bool NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *re ...@@ -506,7 +506,7 @@ bool NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *re
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_EvaluateProc( gNetscapeFuncs.evaluate, instance, npobj, script, result); return CallNPN_EvaluateProc( gNetscapeFuncs.evaluate, instance, npobj, script, result);
} }
return false; return false;
...@@ -516,7 +516,7 @@ bool NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, N ...@@ -516,7 +516,7 @@ bool NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, N
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_GetPropertyProc( gNetscapeFuncs.getproperty, instance, npobj, propertyName, result); return CallNPN_GetPropertyProc( gNetscapeFuncs.getproperty, instance, npobj, propertyName, result);
} }
return false; return false;
...@@ -526,7 +526,7 @@ bool NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, c ...@@ -526,7 +526,7 @@ bool NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, c
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_SetPropertyProc( gNetscapeFuncs.setproperty, instance, npobj, propertyName, value); return CallNPN_SetPropertyProc( gNetscapeFuncs.setproperty, instance, npobj, propertyName, value);
} }
return false; return false;
...@@ -536,7 +536,7 @@ bool NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName ...@@ -536,7 +536,7 @@ bool NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_RemovePropertyProc( gNetscapeFuncs.removeproperty, instance, npobj, propertyName); return CallNPN_RemovePropertyProc( gNetscapeFuncs.removeproperty, instance, npobj, propertyName);
} }
return false; return false;
...@@ -546,7 +546,7 @@ bool NPN_HasProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName) ...@@ -546,7 +546,7 @@ bool NPN_HasProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_HasPropertyProc( gNetscapeFuncs.hasproperty, instance, npobj, propertyName); return CallNPN_HasPropertyProc( gNetscapeFuncs.hasproperty, instance, npobj, propertyName);
} }
return false; return false;
...@@ -556,7 +556,7 @@ bool NPN_HasMethod(NPP instance, NPObject *npobj, NPIdentifier methodName) ...@@ -556,7 +556,7 @@ bool NPN_HasMethod(NPP instance, NPObject *npobj, NPIdentifier methodName)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
return CallNPN_HasMethodProc( gNetscapeFuncs.hasmethod, instance, npobj, methodName); return CallNPN_HasMethodProc( gNetscapeFuncs.hasmethod, instance, npobj, methodName);
} }
return false; return false;
...@@ -566,7 +566,7 @@ void NPN_ReleaseVariantValue(NPVariant *variant) ...@@ -566,7 +566,7 @@ void NPN_ReleaseVariantValue(NPVariant *variant)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
CallNPN_ReleaseVariantValueProc( gNetscapeFuncs.releasevariantvalue, variant); CallNPN_ReleaseVariantValueProc( gNetscapeFuncs.releasevariantvalue, variant);
} }
} }
...@@ -575,7 +575,7 @@ void NPN_SetException(NPObject *npobj, const NPUTF8 *message) ...@@ -575,7 +575,7 @@ void NPN_SetException(NPObject *npobj, const NPUTF8 *message)
{ {
int navMinorVers = gNetscapeFuncs.version & 0xFF; int navMinorVers = gNetscapeFuncs.version & 0xFF;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
CallNPN_SetExceptionProc( gNetscapeFuncs.setexception, npobj, message); CallNPN_SetExceptionProc( gNetscapeFuncs.setexception, npobj, message);
} }
} }
...@@ -633,7 +633,6 @@ void Private_Shutdown(void) ...@@ -633,7 +633,6 @@ void Private_Shutdown(void)
ExitCodeResource(); ExitCodeResource();
} }
NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved) NPError Private_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved)
{ {
EnterCodeResource(); EnterCodeResource();
...@@ -721,7 +720,6 @@ void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname) ...@@ -721,7 +720,6 @@ void Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
ExitCodeResource(); ExitCodeResource();
} }
NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason) NPError Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
{ {
NPError err; NPError err;
...@@ -786,14 +784,14 @@ void SetUpQD(void) ...@@ -786,14 +784,14 @@ void SetUpQD(void)
OSErr result = noErr; OSErr result = noErr;
CFragConnectionID connID; CFragConnectionID connID;
Str255 errName; Str255 errName;
#endif #endif
// //
// Memorize the plugin’s resource file // Memorize the plugin’s resource file
// refnum for later use. // refnum for later use.
// //
gResFile = CurResFile(); gResFile = CurResFile();
#if !TARGET_API_MAC_CARBON #if !TARGET_API_MAC_CARBON
// //
// Ask the system if CFM is available. // Ask the system if CFM is available.
...@@ -815,11 +813,11 @@ void SetUpQD(void) ...@@ -815,11 +813,11 @@ void SetUpQD(void)
infoRec.processInfoLength = sizeof(ProcessInfoRec); infoRec.processInfoLength = sizeof(ProcessInfoRec);
infoRec.processName = name; infoRec.processName = name;
infoRec.processAppSpec = &myFSSpec; infoRec.processAppSpec = &myFSSpec;
ProcessSerialNumber PSN; ProcessSerialNumber PSN;
PSN.highLongOfPSN = 0; PSN.highLongOfPSN = 0;
PSN.lowLongOfPSN = kCurrentProcess; PSN.lowLongOfPSN = kCurrentProcess;
result = GetProcessInformation(&PSN, &infoRec); result = GetProcessInformation(&PSN, &infoRec);
if (result != noErr) if (result != noErr)
PLUGINDEBUGSTR("\pFailed in GetProcessInformation"); PLUGINDEBUGSTR("\pFailed in GetProcessInformation");
...@@ -828,8 +826,8 @@ void SetUpQD(void) ...@@ -828,8 +826,8 @@ void SetUpQD(void)
// //
// If no CFM installed, assume it must be a 68K app. // If no CFM installed, assume it must be a 68K app.
// //
result = -1; result = -1;
CFragConnectionID connID; CFragConnectionID connID;
if (result == noErr) if (result == noErr)
{ {
...@@ -839,7 +837,7 @@ void SetUpQD(void) ...@@ -839,7 +837,7 @@ void SetUpQD(void)
// return the address of “main” in app, which we ignore). If GetDiskFragment // return the address of “main” in app, which we ignore). If GetDiskFragment
// returns an error, we assume the app must be 68K. // returns an error, we assume the app must be 68K.
// //
Ptr mainAddr; Ptr mainAddr;
Str255 errName; Str255 errName;
result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName, result = GetDiskFragment(infoRec.processAppSpec, 0L, 0L, infoRec.processName,
kLoadCFrag, &connID, (Ptr*)&mainAddr, errName); kLoadCFrag, &connID, (Ptr*)&mainAddr, errName);
...@@ -903,13 +901,13 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -903,13 +901,13 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
#endif #endif
NPError err = NPERR_NO_ERROR; NPError err = NPERR_NO_ERROR;
// //
// Ensure that everything Netscape passed us is valid! // Ensure that everything Netscape passed us is valid!
// //
if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL)) if ((nsTable == NULL) || (pluginFuncs == NULL) || (unloadUpp == NULL))
err = NPERR_INVALID_FUNCTABLE_ERROR; err = NPERR_INVALID_FUNCTABLE_ERROR;
// //
// Check the “major” version passed in Netscape’s function table. // Check the “major” version passed in Netscape’s function table.
// We won’t load if the major version is newer than what we expect. // We won’t load if the major version is newer than what we expect.
...@@ -922,8 +920,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -922,8 +920,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte if ((nsTable->version >> 8) > NP_VERSION_MAJOR) // Major version is in high byte
err = NPERR_INCOMPATIBLE_VERSION_ERROR; err = NPERR_INCOMPATIBLE_VERSION_ERROR;
} }
if (err == NPERR_NO_ERROR) if (err == NPERR_NO_ERROR)
{ {
// //
...@@ -933,7 +930,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -933,7 +930,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
// the whole structure, because the Netscape function table // the whole structure, because the Netscape function table
// could actually be bigger than what we expect. // could actually be bigger than what we expect.
// //
int navMinorVers = nsTable->version & 0xFF; int navMinorVers = nsTable->version & 0xFF;
gNetscapeFuncs.version = nsTable->version; gNetscapeFuncs.version = nsTable->version;
...@@ -956,7 +953,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -956,7 +953,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
gNetscapeFuncs.getJavaPeer = (NPN_GetJavaPeerUPP)HOST_TO_PLUGIN_GLUE(getJavaPeer, nsTable->getJavaPeer); gNetscapeFuncs.getJavaPeer = (NPN_GetJavaPeerUPP)HOST_TO_PLUGIN_GLUE(getJavaPeer, nsTable->getJavaPeer);
} }
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
gNetscapeFuncs.geturlnotify = (NPN_GetURLNotifyUPP)HOST_TO_PLUGIN_GLUE(geturlnotify, nsTable->geturlnotify); gNetscapeFuncs.geturlnotify = (NPN_GetURLNotifyUPP)HOST_TO_PLUGIN_GLUE(geturlnotify, nsTable->geturlnotify);
gNetscapeFuncs.posturlnotify = (NPN_PostURLNotifyUPP)HOST_TO_PLUGIN_GLUE(posturlnotify, nsTable->posturlnotify); gNetscapeFuncs.posturlnotify = (NPN_PostURLNotifyUPP)HOST_TO_PLUGIN_GLUE(posturlnotify, nsTable->posturlnotify);
} }
...@@ -966,7 +963,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -966,7 +963,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
gNetscapeFuncs.invalidateregion = (NPN_InvalidateRegionUPP)HOST_TO_PLUGIN_GLUE(invalidateregion, nsTable->invalidateregion); gNetscapeFuncs.invalidateregion = (NPN_InvalidateRegionUPP)HOST_TO_PLUGIN_GLUE(invalidateregion, nsTable->invalidateregion);
gNetscapeFuncs.forceredraw = (NPN_ForceRedrawUPP)HOST_TO_PLUGIN_GLUE(forceredraw, nsTable->forceredraw); gNetscapeFuncs.forceredraw = (NPN_ForceRedrawUPP)HOST_TO_PLUGIN_GLUE(forceredraw, nsTable->forceredraw);
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
// NPRuntime support // NPRuntime support
gNetscapeFuncs.getstringidentifier = (NPN_GetStringIdentifierUPP)HOST_TO_PLUGIN_GLUE(getstringidentifier, nsTable->getstringidentifier); gNetscapeFuncs.getstringidentifier = (NPN_GetStringIdentifierUPP)HOST_TO_PLUGIN_GLUE(getstringidentifier, nsTable->getstringidentifier);
gNetscapeFuncs.getstringidentifiers = (NPN_GetStringIdentifiersUPP)HOST_TO_PLUGIN_GLUE(getstringidentifiers, nsTable->getstringidentifiers); gNetscapeFuncs.getstringidentifiers = (NPN_GetStringIdentifiersUPP)HOST_TO_PLUGIN_GLUE(getstringidentifiers, nsTable->getstringidentifiers);
...@@ -1005,11 +1002,11 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -1005,11 +1002,11 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
pluginFuncs->writeready = NewNPP_WriteReadyProc(PLUGIN_TO_HOST_GLUE(writeready, Private_WriteReady)); pluginFuncs->writeready = NewNPP_WriteReadyProc(PLUGIN_TO_HOST_GLUE(writeready, Private_WriteReady));
pluginFuncs->write = NewNPP_WriteProc(PLUGIN_TO_HOST_GLUE(write, Private_Write)); pluginFuncs->write = NewNPP_WriteProc(PLUGIN_TO_HOST_GLUE(write, Private_Write));
pluginFuncs->print = NewNPP_PrintProc(PLUGIN_TO_HOST_GLUE(print, Private_Print)); pluginFuncs->print = NewNPP_PrintProc(PLUGIN_TO_HOST_GLUE(print, Private_Print));
pluginFuncs->event = NewNPP_HandleEventProc(PLUGIN_TO_HOST_GLUE(event, Private_HandleEvent)); pluginFuncs->event = NewNPP_HandleEventProc(PLUGIN_TO_HOST_GLUE(event, Private_HandleEvent));
pluginFuncs->getvalue = NewNPP_GetValueProc(PLUGIN_TO_HOST_GLUE(getvalue, Private_GetValue)); pluginFuncs->getvalue = NewNPP_GetValueProc(PLUGIN_TO_HOST_GLUE(getvalue, Private_GetValue));
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(PLUGIN_TO_HOST_GLUE(urlnotify, Private_URLNotify)); pluginFuncs->urlnotify = NewNPP_URLNotifyProc(PLUGIN_TO_HOST_GLUE(urlnotify, Private_URLNotify));
} }
#ifdef OJI #ifdef OJI
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
...@@ -1024,7 +1021,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs, ...@@ -1024,7 +1021,7 @@ DEFINE_API_C(NPError) main(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs,
SetUpQD(); SetUpQD();
err = Private_Initialize(); err = Private_Initialize();
} }
ExitCodeResource(); ExitCodeResource();
return err; return err;
} }
...@@ -1048,12 +1045,12 @@ extern "C" { ...@@ -1048,12 +1045,12 @@ extern "C" {
NPError NP_Initialize(NPNetscapeFuncs* nsTable) NPError NP_Initialize(NPNetscapeFuncs* nsTable)
{ {
PLUGINDEBUGSTR("\pNP_Initialize"); PLUGINDEBUGSTR("\pNP_Initialize");
/* validate input parameters */ /* validate input parameters */
if( NULL == nsTable ) if( NULL == nsTable )
return NPERR_INVALID_FUNCTABLE_ERROR; return NPERR_INVALID_FUNCTABLE_ERROR;
/* /*
* Check the major version passed in Netscape's function table. * Check the major version passed in Netscape's function table.
* We won't load if the major version is newer than what we expect. * We won't load if the major version is newer than what we expect.
...@@ -1068,8 +1065,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable) ...@@ -1068,8 +1065,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
if (nsTable->size < sizeof(NPNetscapeFuncs)) if (nsTable->size < sizeof(NPNetscapeFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR; return NPERR_INVALID_FUNCTABLE_ERROR;
int navMinorVers = nsTable->version & 0xFF; int navMinorVers = nsTable->version & 0xFF;
/* /*
...@@ -1099,7 +1095,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable) ...@@ -1099,7 +1095,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer; gNetscapeFuncs.getJavaPeer = nsTable->getJavaPeer;
} }
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
gNetscapeFuncs.geturlnotify = nsTable->geturlnotify; gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
gNetscapeFuncs.posturlnotify = nsTable->posturlnotify; gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
} }
...@@ -1110,7 +1106,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable) ...@@ -1110,7 +1106,7 @@ NPError NP_Initialize(NPNetscapeFuncs* nsTable)
gNetscapeFuncs.invalidateregion = nsTable->invalidateregion; gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
gNetscapeFuncs.forceredraw = nsTable->forceredraw; gNetscapeFuncs.forceredraw = nsTable->forceredraw;
if( navMinorVers >= 14 ) if( navMinorVers >= 14 )
{ {
// NPRuntime support // NPRuntime support
gNetscapeFuncs.getstringidentifier = nsTable->getstringidentifier; gNetscapeFuncs.getstringidentifier = nsTable->getstringidentifier;
gNetscapeFuncs.getstringidentifiers = nsTable->getstringidentifiers; gNetscapeFuncs.getstringidentifiers = nsTable->getstringidentifiers;
...@@ -1169,8 +1165,8 @@ NPError NP_GetEntryPoints(NPPluginFuncs* pluginFuncs) ...@@ -1169,8 +1165,8 @@ NPError NP_GetEntryPoints(NPPluginFuncs* pluginFuncs)
pluginFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue); pluginFuncs->getvalue = NewNPP_GetValueProc(Private_GetValue);
pluginFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue); pluginFuncs->setvalue = NewNPP_SetValueProc(Private_SetValue);
if( navMinorVers >= NPVERS_HAS_NOTIFICATION ) if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
{ {
pluginFuncs->urlnotify = Private_URLNotify; pluginFuncs->urlnotify = Private_URLNotify;
} }
#ifdef OJI #ifdef OJI
if( navMinorVers >= NPVERS_HAS_LIVECONNECT ) if( navMinorVers >= NPVERS_HAS_LIVECONNECT )
......
...@@ -13,7 +13,7 @@ data 'carb' (0) ...@@ -13,7 +13,7 @@ data 'carb' (0)
resource 'STR#' (126) 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>", "<BR><A HREF='http://www.videolan.org'>http://www.videolan.org</A>",
"VLC Multimedia Plugin" "VLC Multimedia Plugin"
}; };
...@@ -23,28 +23,43 @@ resource 'STR#' (126) ...@@ -23,28 +23,43 @@ resource 'STR#' (126)
resource 'STR#' (127) resource 'STR#' (127)
{ {
{ {
/* MPEG-1 and MPEG-2 */
"MPEG audio", "MPEG audio",
"MPEG audio", "MPEG audio",
"MPEG video", "MPEG video",
"MPEG video", "MPEG video",
"MPEG video", "MPEG video",
"MPEG video", "MPEG video",
/* MPEG-4 */
"MPEG-4 video", "MPEG-4 video",
"MPEG-4 audio", "MPEG-4 audio",
"MPEG-4 video", "MPEG-4 video",
"MPEG-4 video", "MPEG-4 video",
/* AVI */
"AVI video", "AVI video",
/* Quicktime */
/* "QuickTime video", */ /* "QuickTime video", */
/* OGG */
"Ogg stream", "Ogg stream",
"Ogg stream", "Ogg stream",
/* VLC */
"VLC plugin", "VLC plugin",
"ASF stream", /* Windows Media */
"ASF stream", "Windows Media video",
"", "Windows Media video",
"", "Windows Media plugin",
"Google VLC Plugin", "Windows Media video",
/* Google VLC */
"Google VLC plugin",
/* WAV audio */
"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) ...@@ -52,28 +67,43 @@ resource 'STR#' (127)
resource 'STR#' (128,"MIME Type") resource 'STR#' (128,"MIME Type")
{ {
{ {
/* MPEG-1 and MPEG-2 */
"audio/mpeg", "mp2,mp3,mpga,mpega", "audio/mpeg", "mp2,mp3,mpga,mpega",
"audio/x-mpeg", "mp2,mp3,mpga,mpega", "audio/x-mpeg", "mp2,mp3,mpga,mpega",
"video/mpeg", "mpg,mpeg,mpe", "video/mpeg", "mpg,mpeg,mpe",
"video/x-mpeg", "mpg,mpeg,mpe", "video/x-mpeg", "mpg,mpeg,mpe",
"video/mpeg-system", "mpg,mpeg,vob", "video/mpeg-system", "mpg,mpeg,vob",
"video/x-mpeg-system", "mpg,mpeg,vob", "video/x-mpeg-system", "mpg,mpeg,vob",
/* MPEG-4 */
"video/mpeg4", "mp4,mpg4", "video/mpeg4", "mp4,mpg4",
"audio/mpeg4", "mp4,mpg4", "audio/mpeg4", "mp4,mpg4",
"application/mpeg4-iod", "mp4,mpg4", "application/mpeg4-iod", "mp4,mpg4",
"application/mpeg4-muxcodetable", "mp4,mpg4", "application/mpeg4-muxcodetable", "mp4,mpg4",
/* AVI */
"video/x-msvideo", "avi", "video/x-msvideo", "avi",
/* "video/quicktime", "mov, qt", */ /* Quicktime */
/* "video/quicktime", "mov,qt", */
/* OGG */
"application/ogg", "ogg", "application/ogg", "ogg",
"application/x-ogg", "ogg", "application/x-ogg", "ogg",
/* VLC */
"application/x-vlc-plugin", "vlc", "application/x-vlc-plugin", "vlc",
"video/x-ms-asf-plugin", "", /* Windows Media */
"video/x-ms-asf", "", "video/x-ms-asf-plugin", "asf,asx",
"video/x-ms-asf", "asf,asx",
"application/x-mplayer2", "", "application/x-mplayer2", "",
"video/x-ms-wmv", "wmv", "video/x-ms-wmv", "wmv",
/* Google VLC */
"video/x-google-vlc-plugin", "", "video/x-google-vlc-plugin", "",
/* WAV audio */
"audio/wav", "wav", "audio/wav", "wav",
"audio/x-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 @@ ...@@ -35,16 +35,20 @@
#include "control/npovlc.h" #include "control/npovlc.h"
#include "control/npolibvlc.h" #include "control/npolibvlc.h"
#include <ctype.h>
/***************************************************************************** /*****************************************************************************
* VlcPlugin constructor and destructor * VlcPlugin constructor and destructor
*****************************************************************************/ *****************************************************************************/
VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
i_npmode(mode), i_npmode(mode),
b_stream(0), b_stream(0),
b_autoplay(0), b_autoplay(1),
psz_target(NULL), psz_target(NULL),
libvlc_instance(NULL), libvlc_instance(NULL),
scriptClass(NULL), libvlc_log(NULL),
p_scriptClass(NULL),
p_scriptObject(NULL),
p_browser(instance), p_browser(instance),
psz_baseURL(NULL) psz_baseURL(NULL)
#if XP_WIN #if XP_WIN
...@@ -58,7 +62,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) : ...@@ -58,7 +62,7 @@ VlcPlugin::VlcPlugin( NPP instance, uint16 mode ) :
memset(&npwindow, 0, sizeof(NPWindow)); memset(&npwindow, 0, sizeof(NPWindow));
} }
static int boolValue(const char *value) { static bool boolValue(const char *value) {
return ( !strcmp(value, "1") || return ( !strcmp(value, "1") ||
!strcasecmp(value, "true") || !strcasecmp(value, "true") ||
!strcasecmp(value, "yes") ); !strcasecmp(value, "yes") );
...@@ -123,7 +127,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) ...@@ -123,7 +127,7 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
ppsz_argv[ppsz_argc++] = "--intf"; ppsz_argv[ppsz_argc++] = "--intf";
ppsz_argv[ppsz_argc++] = "dummy"; ppsz_argv[ppsz_argc++] = "dummy";
const char *version = NULL; const char *progid = NULL;
/* parse plugin arguments */ /* parse plugin arguments */
for( int i = 0; i < argc ; i++ ) for( int i = 0; i < argc ; i++ )
...@@ -172,9 +176,10 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[]) ...@@ -172,9 +176,10 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
ppsz_argv[ppsz_argc++] = "--no-loop"; 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[]) ...@@ -224,19 +229,20 @@ NPError VlcPlugin::init(int argc, char* const argn[], char* const argv[])
if( psz_target ) if( psz_target )
{ {
// get absolute URL from src // 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 */ /* assign plugin script root class */
if( (NULL != version) && (!strcmp(version, "VideoLAN.VLCPlugin.2")) ) if( (NULL != progid) && (!strcmp(progid, "VideoLAN.VLCPlugin.2")) )
{ {
/* new APIs */ /* new APIs */
scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass(); p_scriptClass = RuntimeNPClass<LibvlcRootNPObject>::getClass();
} }
else else
{ {
/* legacy APIs */ /* legacy APIs */
scriptClass = RuntimeNPClass<VlcNPObject>::getClass(); p_scriptClass = RuntimeNPClass<VlcNPObject>::getClass();
} }
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
...@@ -279,6 +285,10 @@ VlcPlugin::~VlcPlugin() ...@@ -279,6 +285,10 @@ VlcPlugin::~VlcPlugin()
{ {
delete psz_baseURL; delete psz_baseURL;
delete psz_target; delete psz_target;
if( p_scriptObject )
NPN_ReleaseObject(p_scriptObject);
if( libvlc_log )
libvlc_log_close(libvlc_log, NULL);
if( libvlc_instance ) if( libvlc_instance )
libvlc_destroy(libvlc_instance, NULL ); libvlc_destroy(libvlc_instance, NULL );
} }
...@@ -298,20 +308,22 @@ char *VlcPlugin::getAbsoluteURL(const char *url) ...@@ -298,20 +308,22 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
// validate protocol header // validate protocol header
const char *start = url; const char *start = url;
while( start != end ) { while( start != end ) {
char c = *start | 0x20; char c = tolower(*start);
if( (c < 'a') || (c > 'z') ) if( (c < 'a') || (c > 'z') )
// not valid protocol header, assume relative URL // not valid protocol header, assume relative URL
break; goto relativeurl;
++start; ++start;
} }
/* we have a protocol header, therefore URL is absolute */ /* we have a protocol header, therefore URL is absolute */
return strdup(url); return strdup(url);
} }
relativeurl:
if( psz_baseURL ) if( psz_baseURL )
{ {
size_t baseLen = strlen(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 ) if( href )
{ {
/* prepend base URL */ /* prepend base URL */
...@@ -331,21 +343,35 @@ char *VlcPlugin::getAbsoluteURL(const char *url) ...@@ -331,21 +343,35 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
/* skip over protocol part */ /* skip over protocol part */
char *pathstart = strchr(href, ':'); char *pathstart = strchr(href, ':');
char *pathend; char *pathend;
if( '/' == *(++pathstart) ) if( pathstart )
{ {
if( '/' == *(++pathstart) ) if( '/' == *(++pathstart) )
{ {
++pathstart; if( '/' == *(++pathstart) )
{
++pathstart;
}
}
/* skip over host part */
pathstart = strchr(pathstart, '/');
pathend = href+baseLen;
if( ! pathstart )
{
// no path, add a / past end of url (over '\0')
pathstart = pathend;
*pathstart = '/';
} }
} }
/* skip over host part */ else
pathstart = strchr(pathstart, '/');
pathend = href+baseLen;
if( ! pathstart )
{ {
// no path, add a / past end of url (over '\0') /* baseURL is just a UNIX path */
pathstart = pathend; if( '/' != *href )
*pathstart = '/'; {
/* baseURL is not an absolute path */
return NULL;
}
pathstart = href;
pathend = href+baseLen;
} }
/* relative URL made of an absolute path ? */ /* relative URL made of an absolute path ? */
...@@ -357,7 +383,8 @@ char *VlcPlugin::getAbsoluteURL(const char *url) ...@@ -357,7 +383,8 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
} }
/* find last path component and replace it */ /* find last path component and replace it */
while( '/' != *pathend) --pathend; while( '/' != *pathend)
--pathend;
/* /*
** if relative url path starts with one or more '../', ** if relative url path starts with one or more '../',
...@@ -370,17 +397,43 @@ char *VlcPlugin::getAbsoluteURL(const char *url) ...@@ -370,17 +397,43 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
if( '.' != *p ) if( '.' != *p )
break; break;
++p; ++p;
if( '.' != *p ) if( '\0' == *p )
{
/* relative url is just '.' */
url = p;
break; break;
++p; }
if( '/' != *p ) if( '/' == *p )
{
/* relative url starts with './' */
url = ++p;
continue;
}
if( '.' != *p )
break; break;
++p; ++p;
if( '\0' == *p )
{
/* relative url is '..' */
}
else
{
if( '/' != *p )
break;
/* relative url starts with '../' */
++p;
}
url = p; url = p;
while( '/' != *pathend ) --pathend; do
{
--pathend;
}
while( '/' != *pathend );
} }
/* skip over '/' separator */
++pathend;
/* concatenate remaining base URL and relative URL */ /* concatenate remaining base URL and relative URL */
strcpy(pathend+1, url); strcpy(pathend, url);
} }
return href; return href;
} }
...@@ -388,6 +441,15 @@ char *VlcPlugin::getAbsoluteURL(const char *url) ...@@ -388,6 +441,15 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
return NULL; 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 #if XP_UNIX
int VlcPlugin::setSize(unsigned width, unsigned height) int VlcPlugin::setSize(unsigned width, unsigned height)
{ {
......
...@@ -71,9 +71,12 @@ public: ...@@ -71,9 +71,12 @@ public:
void setWindow(const NPWindow *window) void setWindow(const NPWindow *window)
{ npwindow = *window; }; { npwindow = *window; };
NPClass* getScriptClass() NPObject* getScriptObject();
{ return scriptClass; };
void setLog(libvlc_log_t *log)
{ libvlc_log = log; };
libvlc_log_t* getLog()
{ return libvlc_log; };
#if XP_WIN #if XP_WIN
WNDPROC getWindowProc() WNDPROC getWindowProc()
{ return pf_wndproc; }; { return pf_wndproc; };
...@@ -94,8 +97,10 @@ public: ...@@ -94,8 +97,10 @@ public:
private: private:
/* VLC reference */ /* VLC reference */
libvlc_instance_t *libvlc_instance; libvlc_instance_t *libvlc_instance;
NPClass *scriptClass; libvlc_log_t *libvlc_log;
NPClass *p_scriptClass;
NPObject *p_scriptObject;
/* browser reference */ /* browser reference */
NPP p_browser; NPP p_browser;
...@@ -114,12 +119,10 @@ private: ...@@ -114,12 +119,10 @@ private:
/******************************************************************************* /*******************************************************************************
* Plugin properties. * Plugin properties.
******************************************************************************/ ******************************************************************************/
#define PLUGIN_NAME "VLC multimedia plugin" #define PLUGIN_NAME "VLC Multimedia Plugin"
#define PLUGIN_DESCRIPTION \ #define PLUGIN_DESCRIPTION \
"VLC multimedia plugin <br>" \ "Version %s, copyright 1996-2006 The VideoLAN Team" \
" <br>" \ "<br><a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
"version %s <br>" \
"VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
#define PLUGIN_MIMETYPES \ #define PLUGIN_MIMETYPES \
/* MPEG-1 and MPEG-2 */ \ /* MPEG-1 and MPEG-2 */ \
...@@ -138,20 +141,26 @@ private: ...@@ -138,20 +141,26 @@ private:
"video/x-msvideo:avi:AVI video;" \ "video/x-msvideo:avi:AVI video;" \
/* QuickTime */ \ /* QuickTime */ \
"video/quicktime:mov,qt:QuickTime video;" \ "video/quicktime:mov,qt:QuickTime video;" \
/* Ogg */ \ /* OGG */ \
"application/x-ogg:ogg:Ogg stream;" \ "application/x-ogg:ogg:Ogg stream;" \
"application/ogg:ogg:Ogg stream;" \ "application/ogg:ogg:Ogg stream;" \
/* explicit plugin call */ \ /* VLC */ \
"application/x-vlc-plugin::VLC plugin;" \ "application/x-vlc-plugin:vlc:VLC plugin;" \
/* windows media */ \ /* Windows Media */ \
"video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \ "video/x-ms-asf-plugin:asf,asx:Windows Media Video;" \
"video/x-ms-asf:asf,asx:Windows Media Video;" \ "video/x-ms-asf:asf,asx:Windows Media Video;" \
"application/x-mplayer2::Windows Media;" \ "application/x-mplayer2::Windows Media;" \
"video/x-ms-wmv:wmv:Windows Media;" \ "video/x-ms-wmv:wmv:Windows Media;" \
/* Google VLC mime */ \ /* Google VLC */ \
"application/x-google-vlc-plugin::Google VLC plugin" \ "application/x-google-vlc-plugin::Google VLC plugin;" \
/* Misc */ \ /* WAV audio */ \
"audio/wav::WAV audio" \ "audio/wav:wav:WAV audio;" \
"audio/x-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 #endif
...@@ -120,7 +120,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value ) ...@@ -120,7 +120,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
{ {
case NPPVpluginScriptableNPObject: case NPPVpluginScriptableNPObject:
/* create an instance and return it */ /* create an instance and return it */
*(NPObject**)value = NPN_CreateObject(instance, p_plugin->getScriptClass()); *(NPObject**)value = p_plugin->getScriptObject();
if( NULL == *(NPObject**)value ) if( NULL == *(NPObject**)value )
{ {
return NPERR_OUT_OF_MEMORY_ERROR; return NPERR_OUT_OF_MEMORY_ERROR;
...@@ -139,6 +139,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value ) ...@@ -139,6 +139,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
#ifdef XP_MACOSX #ifdef XP_MACOSX
int16 NPP_HandleEvent( NPP instance, void * event ) int16 NPP_HandleEvent( NPP instance, void * event )
{ {
static UInt32 lastMouseUp = 0;
if( instance == NULL ) if( instance == NULL )
{ {
return false; return false;
...@@ -152,7 +154,29 @@ int16 NPP_HandleEvent( NPP instance, void * event ) ...@@ -152,7 +154,29 @@ int16 NPP_HandleEvent( NPP instance, void * event )
case nullEvent: case nullEvent:
break; break;
case mouseDown: 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: case mouseUp:
lastMouseUp = myEvent->when;
return true; return true;
case keyUp: case keyUp:
case keyDown: case keyDown:
...@@ -268,12 +292,14 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, ...@@ -268,12 +292,14 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
NPError NPP_Destroy( NPP instance, NPSavedData** save ) NPError NPP_Destroy( NPP instance, NPSavedData** save )
{ {
if( instance == NULL ) if( NULL == instance )
{
return NPERR_INVALID_INSTANCE_ERROR; return NPERR_INVALID_INSTANCE_ERROR;
}
VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata); VlcPlugin* p_plugin = reinterpret_cast<VlcPlugin*>(instance->pdata);
if( NULL == p_plugin )
return NPERR_NO_ERROR;
instance->pdata = NULL;
#if XP_WIN #if XP_WIN
HWND win = (HWND)p_plugin->getWindow()->window; HWND win = (HWND)p_plugin->getWindow()->window;
...@@ -288,8 +314,6 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save ) ...@@ -288,8 +314,6 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
if( p_plugin ) if( p_plugin )
delete p_plugin; delete p_plugin;
instance->pdata = NULL;
return NPERR_NO_ERROR; return NPERR_NO_ERROR;
} }
...@@ -433,14 +457,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window ) ...@@ -433,14 +457,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{ {
if( p_plugin->psz_target ) 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 ) if( p_plugin->b_autoplay )
{ {
libvlc_playlist_play(p_vlc, 0, 0, NULL, NULL); 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; return NPERR_NO_ERROR;
...@@ -506,7 +530,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname ) ...@@ -506,7 +530,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
VlcPlugin *p_plugin = reinterpret_cast<VlcPlugin *>(instance->pdata); 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 ) 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