Commit 5555c82c authored by Sam Hocevar's avatar Sam Hocevar

* ./mozilla/*: added hooks so that the vlc plugin is scriptable from

    javascript. It's also in C++, but we didn't have the choice.
parent cf891bad
...@@ -2028,9 +2028,9 @@ then ...@@ -2028,9 +2028,9 @@ then
LDFLAGS="${save_LDFLAGS}" LDFLAGS="${save_LDFLAGS}"
fi fi
MOZILLA=1 MOZILLA=1
mozilla_CFLAGS="${mozilla_CFLAGS} `${MOZILLA_CONFIG} --cflags plugin java --defines | xargs`"
dnl Workaround for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=150490 dnl Workaround for http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=150490
mozilla_LDFLAGS="${mozilla_LDFLAGS} `${MOZILLA_CONFIG} --libs | sed 's#-I\(.*\)/mozilla/\([^ ]*\)#-I\1/\2 -I\1/mozilla/\2#g'`" [mozilla_CFLAGS="${CPPFLAGS_mozilla} `${MOZILLA_CONFIG} --cflags plugin xpcom java | sed 's,-I\([^ ]*\)/mozilla/\([^ ]*\),-I\1/\2 -I\1/mozilla/\2,g' | xargs`"]
mozilla_LDFLAGS="${mozilla_LDFLAGS} `${MOZILLA_CONFIG} --libs plugin xpcom`"
fi fi
fi fi
......
vlcintf.h
vlcintf.xpt
...@@ -6,10 +6,13 @@ ...@@ -6,10 +6,13 @@
# #
# Source objects # Source objects
# #
C_SRC = vlcplugin.c npunix.c CPP_SRC = vlcplugin.cpp vlcpeer.cpp vlcshell.cpp
C_SRC = npunix.c
CPP_OBJ = $(CPP_SRC:%.cpp=%.o)
C_OBJ = $(C_SRC:%.c=%.o) C_OBJ = $(C_SRC:%.c=%.o)
PLUGIN_OBJ = libvlcplugin.so PLUGIN_OBJ = libvlcplugin.so
COMPONENT = vlcintf.xpt
# #
# Virtual targets # Virtual targets
...@@ -25,20 +28,35 @@ clean: ...@@ -25,20 +28,35 @@ clean:
install: install:
mkdir -p $(DESTDIR)$(libdir)/mozilla/plugins mkdir -p $(DESTDIR)$(libdir)/mozilla/plugins
$(INSTALL) -m 644 $(PLUGIN_OBJ) $(DESTDIR)$(libdir)/mozilla/plugins $(INSTALL) -m 644 $(PLUGIN_OBJ) $(DESTDIR)$(libdir)/mozilla/plugins
mkdir -p $(DESTDIR)$(libdir)/mozilla/components
$(INSTALL) -m 644 $(COMPONENT) $(DESTDIR)$(libdir)/mozilla/components
uninstall: uninstall:
rm -f $(DESTDIR)$(libdir)/mozilla/plugins/$(PLUGIN_OBJ) rm -f $(DESTDIR)$(libdir)/mozilla/plugins/$(PLUGIN_OBJ)
-rmdir $(DESTDIR)$(libdir)/mozilla/plugins -rmdir $(DESTDIR)$(libdir)/mozilla/plugins
rm -f $(DESTDIR)$(libdir)/mozilla/components/$(COMPONENT)
-rmdir $(DESTDIR)$(libdir)/mozilla/components
-rmdir $(DESTDIR)$(libdir)/mozilla -rmdir $(DESTDIR)$(libdir)/mozilla
FORCE: FORCE:
$(PLUGIN_OBJ): Makefile ../lib/libvlc.a $(BUILTIN_OBJ:%=../%) $(C_OBJ) $(PLUGIN_OBJ): Makefile ../lib/libvlc.a $(BUILTIN_OBJ:%=../%) $(C_OBJ) $(CPP_OBJ) $(COMPONENT)
$(CC) -shared $(LDFLAGS) -L../lib $(mozilla_LDFLAGS) $(C_OBJ) -lvlc $(BUILTIN_OBJ:%=../%) $(builtins_LDFLAGS) -o $@ $(CC) -shared $(LDFLAGS) -L../lib $(mozilla_LDFLAGS) $(C_OBJ) $(CPP_OBJ) -lvlc $(BUILTIN_OBJ:%=../%) $(builtins_LDFLAGS) -o $@
$(C_OBJ): %.o: %.c vlcplugin.h $(CPP_OBJ): %.o: %.cpp vlcplugin.h vlcpeer.h vlcintf.h classinfo.h
$(CC) $(CFLAGS) -I.. -I../include $(mozilla_CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -I.. -I../include $(mozilla_CFLAGS) -c $< -o $@
$(C_OBJ): %.o: %.c vlcplugin.h vlcpeer.h vlcintf.h classinfo.h
$(CC) $(CFLAGS) -I.. -I../include $(mozilla_CFLAGS) -c $< -o $@
vlcintf.xpt: vlcintf.idl
/usr/lib/mozilla/xpidl -I/usr/share/idl/mozilla -m typelib \
-o vlcintf vlcintf.idl
vlcintf.h: vlcintf.idl
/usr/lib/mozilla/xpidl -I/usr/share/idl/mozilla -m header \
-o vlcintf vlcintf.idl
../%: ../%:
@cd .. && $(MAKE) $(@:../%=%) @cd .. && $(MAKE) $(@:../%=%)
#include "nsIClassInfo.h"
// helper class to implement all necessary nsIClassInfo method stubs
// and to set flags used by the security system
class ClassInfo : public nsIClassInfo
{
// These flags are used by the DOM and security systems to signal that
// JavaScript callers are allowed to call this object's scritable methods.
NS_IMETHOD GetFlags(PRUint32 *aFlags)
{*aFlags = nsIClassInfo::PLUGIN_OBJECT | nsIClassInfo::DOM_OBJECT;
return NS_OK;}
NS_IMETHOD GetImplementationLanguage(PRUint32 *aImplementationLanguage)
{*aImplementationLanguage = nsIProgrammingLanguage::CPLUSPLUS;
return NS_OK;}
// The rest of the methods can safely return error codes...
NS_IMETHOD GetInterfaces(PRUint32 *count, nsIID * **array)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetHelperForLanguage(PRUint32 language, nsISupports **_retval)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetContractID(char * *aContractID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassDescription(char * *aClassDescription)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassID(nsCID * *aClassID)
{return NS_ERROR_NOT_IMPLEMENTED;}
NS_IMETHOD GetClassIDNoAlloc(nsCID *aClassIDNoAlloc)
{return NS_ERROR_NOT_IMPLEMENTED;}
};
This diff is collapsed.
#include "nsISupports.idl"
[scriptable, uuid(ea92ef52-afe4-4212-bacb-dfe9fca94cd6)]
interface VlcIntf : nsISupports
{
void play();
void pause();
void stop();
};
/*****************************************************************************
* vlcpeer.cpp: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcpeer.cpp,v 1.1 2002/09/17 08:18:24 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include "npapi.h"
#include "vlcpeer.h"
#include "vlcplugin.h"
#include "nsMemory.h"
NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
VlcPeer::VlcPeer()
{
NS_INIT_ISUPPORTS();
}
VlcPeer::VlcPeer( VlcPlugin * plugin )
{
NS_INIT_ISUPPORTS();
p_plugin = plugin;
}
VlcPeer::~VlcPeer()
{
;
}
NS_IMETHODIMP VlcPeer::Play()
{
if( p_plugin )
{
p_plugin->Play();
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Pause()
{
if( p_plugin )
{
p_plugin->Pause();
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Stop()
{
if( p_plugin )
{
p_plugin->Stop();
}
return NS_OK;
}
/*****************************************************************************
* vlcpeer.h: a VideoLAN plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcpeer.h,v 1.1 2002/09/17 08:18:24 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include "vlcintf.h"
#include "classinfo.h"
#include "nsMemory.h"
class VlcPlugin;
class VlcPeer : public VlcIntf, public ClassInfo
{
public:
NS_DECL_ISUPPORTS
NS_DECL_VLCINTF
VlcPeer();
VlcPeer( VlcPlugin * );
void Disable() { p_plugin = NULL; }
virtual ~VlcPeer();
/* additional members */
private:
VlcPlugin * p_plugin;
};
/*****************************************************************************
* vlcplugin.cpp: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcplugin.cpp,v 1.1 2002/09/17 08:18:24 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <npapi.h>
#include <vlc/vlc.h>
#include "vlcpeer.h"
#include "vlcplugin.h"
/*****************************************************************************
* VlcPlugin methods
*****************************************************************************/
VlcPlugin::VlcPlugin( NPP instance )
{
p_instance = instance;
p_peer = NULL;
}
VlcPlugin::~VlcPlugin()
{
if( p_peer )
{
p_peer->Disable();
p_peer->Release();
}
}
void VlcPlugin::SetInstance( NPP instance )
{
p_instance = instance;
}
NPP VlcPlugin::GetInstance()
{
return p_instance;
}
void VlcPlugin::SetFileName(const char * filename)
{
fprintf(stderr, "VlcPlugin::SetFilename %s\n", filename);
#if 0
FILE * fh;
fh = fopen(filename, "rb");
if(!fh)
{
fprintf(stderr, "Error while opening %s.\n", filename);
return;
}
fseek(fh, 0, SEEK_END);
m_lSize = ftell(fh);
m_szSound = (char*) malloc(m_lSize);
if(!m_szSound)
{
fprintf(stderr, "Error while allocating memory.\n");
fclose(fh);
return;
}
rewind(fh);
long pos = 0;
do
{
pos += fread(m_szSound + pos, 1, m_lSize - pos, fh);
fprintf(stderr, "pos = %d\n", pos);
}
while (pos < m_lSize -1);
fclose (fh);
fprintf(stderr, "File loaded\n");
#endif
return;
}
void VlcPlugin::Play()
{
fprintf(stderr, "VlcPlugin::Play\n");
}
void VlcPlugin::Pause()
{
fprintf(stderr, "VlcPlugin::Pause\n");
}
void VlcPlugin::Stop()
{
fprintf(stderr, "VlcPlugin::Stop\n");
}
VlcIntf* VlcPlugin::getScriptable()
{
if( !p_peer )
{
p_peer = new VlcPeer( this );
if( p_peer == NULL )
{
return NULL;
}
NS_ADDREF( p_peer );
}
// a getter should addref for its caller.
NS_ADDREF( p_peer );
return p_peer;
}
/***************************************************************************** /*****************************************************************************
* videolan.c: a VideoLAN plugin for Mozilla * vlcplugin.h: a VideoLAN plugin for Mozilla
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: vlcplugin.h,v 1.2 2002/07/23 20:12:55 sam Exp $ * $Id: vlcplugin.h,v 1.3 2002/09/17 08:18:24 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -24,8 +24,23 @@ ...@@ -24,8 +24,23 @@
/******************************************************************************* /*******************************************************************************
* Instance state information about the plugin. * Instance state information about the plugin.
******************************************************************************/ ******************************************************************************/
typedef struct _PluginInstance class VlcPlugin
{ {
public:
VlcPlugin( NPP );
virtual ~VlcPlugin();
void SetInstance( NPP );
NPP GetInstance();
void SetFileName( const char* );
void Play();
void Pause();
void Stop();
VlcIntf* getScriptable();
/* Window settings */
NPWindow* fWindow; NPWindow* fWindow;
uint16 fMode; uint16 fMode;
...@@ -36,11 +51,14 @@ typedef struct _PluginInstance ...@@ -36,11 +51,14 @@ typedef struct _PluginInstance
uint32 width, height; uint32 width, height;
/* vlc data members */ /* vlc data members */
vlc_t *p_vlc; vlc_t * p_vlc;
int b_stream; int b_stream;
char *psz_target; char * psz_target;
} PluginInstance; private:
NPP p_instance;
VlcPeer* p_peer;
};
/******************************************************************************* /*******************************************************************************
* Plugin properties. * Plugin properties.
...@@ -49,7 +67,7 @@ typedef struct _PluginInstance ...@@ -49,7 +67,7 @@ typedef struct _PluginInstance
#define PLUGIN_DESCRIPTION \ #define PLUGIN_DESCRIPTION \
"VideoLAN Client Multimedia Player Plugin <br>" \ "VideoLAN Client Multimedia Player Plugin <br>" \
" <br>" \ " <br>" \
COPYRIGHT_MESSAGE " <br>" \ /*COPYRIGHT_MESSAGE*/ " <br>" \
"VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>" "VideoLAN WWW: <a href=\"http://www.videolan.org/\">http://www.videolan.org/</a>"
#define PLUGIN_MIMETYPES \ #define PLUGIN_MIMETYPES \
......
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