Commit f1595993 authored by Sam Hocevar's avatar Sam Hocevar

* ALL: the build mechanism now uses automake. See HACKING for more details.

  * ./mozilla/vlcplugin.cpp: javascript support for the Mozilla plugin.
  * debian/rules: the A52 module is now in a separate package.
parent 9810b0ab
###############################################################################
# vlc (VideoLAN Client) Mozilla plugin Makefile
# (c)2002 VideoLAN
###############################################################################
#
# Source objects
#
CPP_SRC = vlcplugin.cpp vlcpeer.cpp vlcshell.cpp
C_SRC = npunix.c
CPP_OBJ = $(CPP_SRC:%.cpp=%.o)
C_OBJ = $(C_SRC:%.c=%.o)
PLUGIN_OBJ = libvlcplugin.so
COMPONENT = vlcintf.xpt
#
# Virtual targets
#
all: $(PLUGIN_OBJ)
distclean: clean
clean:
rm -f *.o *.so
rm -Rf .dep
install:
mkdir -p $(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:
rm -f $(DESTDIR)$(libdir)/mozilla/plugins/$(PLUGIN_OBJ)
-rmdir $(DESTDIR)$(libdir)/mozilla/plugins
rm -f $(DESTDIR)$(libdir)/mozilla/components/$(COMPONENT)
-rmdir $(DESTDIR)$(libdir)/mozilla/components
-rmdir $(DESTDIR)$(libdir)/mozilla
FORCE:
$(PLUGIN_OBJ): Makefile ../lib/libvlc.a $(BUILTIN_OBJ:%=../%) $(C_OBJ) $(CPP_OBJ) $(COMPONENT)
$(CC) -shared $(LDFLAGS) -L../lib $(mozilla_LDFLAGS) $(C_OBJ) $(CPP_OBJ) -lvlc $(BUILTIN_OBJ:%=../%) $(builtins_LDFLAGS) -o $@
$(CPP_OBJ): %.o: %.cpp vlcplugin.h vlcpeer.h vlcintf.h classinfo.h
$(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) $(@:../%=%)
......@@ -8,5 +8,7 @@ interface VlcIntf : nsISupports
void play();
void pause();
void stop();
void fullscreen();
};
/*****************************************************************************
* vlcpeer.cpp: a VideoLAN Client plugin for Mozilla
* vlcpeer.cpp: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcpeer.cpp,v 1.1 2002/09/17 08:18:24 sam Exp $
* $Id: vlcpeer.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -32,9 +32,11 @@
#include "nsMemory.h"
NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
/*****************************************************************************
* Scriptable peer constructor and destructor
*****************************************************************************/
VlcPeer::VlcPeer()
{
NS_INIT_ISUPPORTS();
......@@ -51,11 +53,29 @@ VlcPeer::~VlcPeer()
;
}
/*****************************************************************************
* Scriptable peer methods
*****************************************************************************/
void VlcPeer::Disable()
{
p_plugin = NULL;
}
/*****************************************************************************
* Scriptable peer plugin methods
*****************************************************************************/
NS_IMETHODIMP VlcPeer::Play()
{
if( p_plugin )
{
p_plugin->Play();
if( !p_plugin->b_stream && p_plugin->psz_target )
{
vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
p_plugin->b_stream = 1;
}
vlc_play_r( p_plugin->p_vlc );
}
return NS_OK;
}
......@@ -64,7 +84,7 @@ NS_IMETHODIMP VlcPeer::Pause()
{
if( p_plugin )
{
p_plugin->Pause();
vlc_pause_r( p_plugin->p_vlc );
}
return NS_OK;
}
......@@ -73,7 +93,17 @@ NS_IMETHODIMP VlcPeer::Stop()
{
if( p_plugin )
{
p_plugin->Stop();
vlc_stop_r( p_plugin->p_vlc );
p_plugin->b_stream = 0;
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Fullscreen()
{
if( p_plugin )
{
vlc_fullscreen_r( p_plugin->p_vlc );
}
return NS_OK;
}
......
/*****************************************************************************
* vlcpeer.h: a VideoLAN plugin for Mozilla
* vlcpeer.h: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcpeer.h,v 1.1 2002/09/17 08:18:24 sam Exp $
* $Id: vlcpeer.h,v 1.2 2002/09/30 11:05:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -24,8 +24,6 @@
#include "vlcintf.h"
#include "classinfo.h"
#include "nsMemory.h"
class VlcPlugin;
class VlcPeer : public VlcIntf, public ClassInfo
......@@ -34,13 +32,11 @@ public:
NS_DECL_ISUPPORTS
NS_DECL_VLCINTF
VlcPeer();
VlcPeer( VlcPlugin * );
void Disable() { p_plugin = NULL; }
VlcPeer();
VlcPeer( VlcPlugin * );
virtual ~VlcPeer();
/* additional members */
void Disable();
private:
VlcPlugin * p_plugin;
......
......@@ -2,7 +2,7 @@
* 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 $
* $Id: vlcplugin.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -24,15 +24,15 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <npapi.h>
#include <vlc/vlc.h>
#include <npapi.h>
#include "vlcpeer.h"
#include "vlcplugin.h"
/*****************************************************************************
* VlcPlugin methods
* VlcPlugin constructor and destructor
*****************************************************************************/
VlcPlugin::VlcPlugin( NPP instance )
{
......@@ -51,6 +51,9 @@ VlcPlugin::~VlcPlugin()
}
/*****************************************************************************
* VlcPlugin methods
*****************************************************************************/
void VlcPlugin::SetInstance( NPP instance )
{
p_instance = instance;
......@@ -63,9 +66,25 @@ NPP VlcPlugin::GetInstance()
}
VlcIntf* VlcPlugin::GetPeer()
{
if( !p_peer )
{
p_peer = new VlcPeer( this );
if( p_peer == NULL )
{
return NULL;
}
NS_ADDREF( p_peer );
}
NS_ADDREF( p_peer );
return p_peer;
}
void VlcPlugin::SetFileName(const char * filename)
{
fprintf(stderr, "VlcPlugin::SetFilename %s\n", filename);
#if 0
FILE * fh;
fh = fopen(filename, "rb");
......@@ -97,35 +116,3 @@ fprintf(stderr, "VlcPlugin::SetFilename %s\n", filename);
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;
}
......@@ -2,7 +2,7 @@
* vlcplugin.h: a VideoLAN plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcplugin.h,v 1.3 2002/09/17 08:18:24 sam Exp $
* $Id: vlcplugin.h,v 1.4 2002/09/30 11:05:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -32,13 +32,9 @@ public:
void SetInstance( NPP );
NPP GetInstance();
VlcIntf* GetPeer();
void SetFileName( const char* );
void Play();
void Pause();
void Stop();
VlcIntf* getScriptable();
/* Window settings */
NPWindow* fWindow;
......@@ -53,6 +49,7 @@ public:
/* vlc data members */
vlc_t * p_vlc;
int b_stream;
int b_autoplay;
char * psz_target;
private:
......
......@@ -2,7 +2,7 @@
* vlcshell.c: a VideoLAN Client plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlcshell.cpp,v 1.1 2002/09/17 08:18:24 sam Exp $
* $Id: vlcshell.cpp,v 1.2 2002/09/30 11:05:41 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -27,29 +27,33 @@
#include <stdio.h>
#include <string.h>
/* Mozilla stuff */
#include <plugin/npapi.h>
/* X11 stuff */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
/* vlc stuff */
#include <vlc/vlc.h>
#include "config.h"
/* Mozilla stuff */
#include <npapi.h>
#ifdef WIN32
#else
/* X11 stuff */
# include <X11/Xlib.h>
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
#endif
#include "vlcpeer.h"
#include "vlcplugin.h"
/******************************************************************************
/*****************************************************************************
* Unix-only declarations
******************************************************************************/
******************************************************************************/
#ifndef WIN32
static void Redraw( Widget w, XtPointer closure, XEvent *event );
#endif
/******************************************************************************
/*****************************************************************************
* Windows-only declarations
*****************************************************************************/
#ifdef WIN32
......@@ -106,7 +110,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
switch( variable )
{
case NPPVpluginScriptableInstance:
*(nsISupports**)value = p_plugin->getScriptable();
*(nsISupports**)value = p_plugin->GetPeer();
if( *(nsISupports**)value == NULL )
{
return NPERR_OUT_OF_MEMORY_ERROR;
......@@ -158,11 +162,11 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
"vlc"
/*, "--plugin-path", "/home/sam/videolan/vlc_MAIN/plugins"*/
, "--vout", "xvideo,x11,dummy"
/*, "--aout", "none"*/
, "--aout", "dsp"
, "--intf", "dummy"
/*, "--noaudio"*/
, "-q"
/*, "-v"*/
/*, "-q"*/
, "-v"
};
if( instance == NULL )
......@@ -203,35 +207,38 @@ NPError NPP_New( NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc,
vlc_set_r( p_plugin->p_vlc, "vout", "xvideo,x11,dummy" );
vlc_set_r( p_plugin->p_vlc, "intf", "dummy" );
vlc_set_r( p_plugin->p_vlc, "audio", "0" );
i_ret = vlc_run_r( p_plugin->p_vlc );
if( i_ret )
{
vlc_destroy_r( p_plugin->p_vlc );
p_plugin->p_vlc = NULL;
delete p_plugin;
p_plugin = NULL;
return NPERR_GENERIC_ERROR;
}
p_plugin->b_stream = 0;
p_plugin->b_autoplay = 0;
p_plugin->psz_target = NULL;
for( i = 0; i < argc ; i++ )
{
fprintf(stderr, "arg %i: '%s' = '%s'\n", i, argn[i], argv[i]);
if( !strcmp(argn[i],"target") )
if( !strcmp( argn[i], "target" ) )
{
fprintf(stderr, "target specified: %s\n", argv[i]);
p_plugin->psz_target = strdup( argv[i] );
p_plugin->psz_target = argv[i];
}
else
else if( !strcmp( argn[i], "autoplay" ) )
{
/*vlc_set_r( p_plugin->psz_target, argn[i], argv[i] );*/
if( !strcmp( argv[i], "yes" ) )
{
p_plugin->b_autoplay = 1;
}
}
else if( !strcmp( argn[i], "loop" ) )
{
if( !strcmp( argv[i], "yes" ) )
{
vlc_set_r( p_plugin->p_vlc, "loop", "1" );
}
}
}
if( p_plugin->psz_target )
{
p_plugin->psz_target = strdup( p_plugin->psz_target );
}
return NPERR_NO_ERROR;
}
......@@ -248,6 +255,7 @@ NPError NPP_Destroy( NPP instance, NPSavedData** save )
{
if( p_plugin->p_vlc != NULL )
{
vlc_stop_r( p_plugin->p_vlc );
vlc_destroy_r( p_plugin->p_vlc );
p_plugin->p_vlc = NULL;
}
......@@ -308,13 +316,18 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
#if 1
if( !p_plugin->b_stream )
{
p_plugin->b_stream = 1;
int i_mode = PLAYLIST_APPEND;
if( p_plugin->b_autoplay )
{
i_mode |= PLAYLIST_GO;
}
if( p_plugin->psz_target )
{
vlc_add_target_r( p_plugin->p_vlc, p_plugin->psz_target,
PLAYLIST_APPEND, PLAYLIST_END );
vlc_add_target_r( p_plugin->p_vlc, "vlc:loop",
PLAYLIST_APPEND, PLAYLIST_END );
i_mode, PLAYLIST_END );
p_plugin->b_stream = 1;
}
}
#endif
......@@ -330,7 +343,9 @@ NPError NPP_NewStream( NPP instance, NPMIMEType type, NPStream *stream,
return NPERR_INVALID_INSTANCE_ERROR;
}
#if 0
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
#endif
fprintf(stderr, "NPP_NewStream - FILE mode !!\n");
......@@ -379,7 +394,7 @@ int32 NPP_Write( NPP instance, NPStream *stream, int32 offset,
{
fprintf(stderr, "NPP_Write %i\n", len);
if (instance != NULL)
if( instance != NULL )
{
/*VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;*/
}
......@@ -395,8 +410,6 @@ NPError NPP_DestroyStream( NPP instance, NPStream *stream, NPError reason )
return NPERR_INVALID_INSTANCE_ERROR;
}
VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;
return NPERR_NO_ERROR;
}
......@@ -411,9 +424,8 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
fprintf(stderr, "NPP_StreamAsFile\n");
vlc_add_target_r( p_plugin->p_vlc, fname, PLAYLIST_APPEND, PLAYLIST_END );
vlc_add_target_r( p_plugin->p_vlc, "vlc:loop",
PLAYLIST_APPEND, PLAYLIST_END );
vlc_add_target_r( p_plugin->p_vlc, fname,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
#if 0
......@@ -440,15 +452,19 @@ void NPP_URLNotify( NPP instance, const char* url,
void NPP_Print( NPP instance, NPPrint* printInfo )
{
if(printInfo == NULL)
if( printInfo == NULL )
{
return;
}
if (instance != NULL) {
/***** Insert NPP_Print code here *****\
if( instance != NULL )
{
/***** Insert NPP_Print code here *****\
PluginInstance* p_plugin = (PluginInstance*) instance->pdata;
\**************************************/
\**************************************/
if (printInfo->mode == NP_FULL) {
if( printInfo->mode == NP_FULL )
{
/*
* PLUGIN DEVELOPERS:
* If your plugin would like to take over
......@@ -466,17 +482,19 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
* etc.
*/
/***** Insert NPP_Print code here *****\
/***** Insert NPP_Print code here *****\
void* platformPrint =
printInfo->print.fullPrint.platformPrint;
NPBool printOne =
printInfo->print.fullPrint.printOne;
\**************************************/
\**************************************/
/* Do the default*/
printInfo->print.fullPrint.pluginPrinted = FALSE;
}
else { /* If not fullscreen, we must be embedded */
else
{
/* If not fullscreen, we must be embedded */
/*
* PLUGIN DEVELOPERS:
* If your plugin is embedded, or is full-screen
......@@ -489,12 +507,12 @@ void NPP_Print( NPP instance, NPPrint* printInfo )
* device context.
*/
/***** Insert NPP_Print code here *****\
/***** Insert NPP_Print code here *****\
NPWindow* printWindow =
&(printInfo->print.embedPrint.window);
void* platformPrint =
printInfo->print.embedPrint.platformPrint;
\**************************************/
\**************************************/
}
}
}
......@@ -508,18 +526,22 @@ static void Redraw( Widget w, XtPointer closure, XEvent *event )
VlcPlugin* p_plugin = (VlcPlugin*)closure;
GC gc;
XGCValues gcv;
const char* text = "hello d00dZ, I'm in void Redraw()";
XtVaGetValues(w, XtNbackground, &gcv.background,
XtNforeground, &gcv.foreground, 0);
gc = XCreateGC(p_plugin->display, p_plugin->window,
GCForeground|GCBackground, &gcv);
XDrawRectangle(p_plugin->display, p_plugin->window, gc,
0, 0, p_plugin->width-1, p_plugin->height-1);
XDrawString(p_plugin->display, p_plugin->window, gc,
p_plugin->width/2 - 100, p_plugin->height/2,
text, strlen(text));
return;
const char * psz_text = "(no picture)";
gcv.foreground = BlackPixel( p_plugin->display, 0 );
gc = XCreateGC( p_plugin->display, p_plugin->window, GCForeground, &gcv );
XFillRectangle( p_plugin->display, p_plugin->window, gc,
0, 0, p_plugin->width, p_plugin->height );
gcv.foreground = WhitePixel( p_plugin->display, 0 );
XChangeGC( p_plugin->display, gc, GCForeground, &gcv );
XDrawString( p_plugin->display, p_plugin->window, gc,
p_plugin->width / 2 - 40, p_plugin->height / 2,
psz_text, strlen(psz_text) );
XFreeGC( p_plugin->display, gc );
}
#endif
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