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 \
......
This diff is collapsed.
...@@ -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"
......
This diff is collapsed.
...@@ -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