* 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>
*
#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
switch( variable )
{
case NPPVpluginScriptableInstance:
- *(nsISupports**)value = p_plugin->getScriptable();
+ *(nsISupports**)value = p_plugin->GetPeer();
if( *(nsISupports**)value == NULL )
{
return NPERR_OUT_OF_MEMORY_ERROR;
"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 )
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;
}
{
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;
}
#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
return NPERR_INVALID_INSTANCE_ERROR;
}
+#if 0
VlcPlugin* p_plugin = (VlcPlugin*)instance->pdata;
+#endif
fprintf(stderr, "NPP_NewStream - FILE mode !!\n");
{
fprintf(stderr, "NPP_Write %i\n", len);
- if (instance != NULL)
+ if( instance != NULL )
{
/*VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;*/
}
return NPERR_INVALID_INSTANCE_ERROR;
}
- VlcPlugin* p_plugin = (VlcPlugin*) instance->pdata;
-
return NPERR_NO_ERROR;
}
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
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
* 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
* device context.
*/
- /***** Insert NPP_Print code here *****\
+ /***** Insert NPP_Print code here *****\
NPWindow* printWindow =
&(printInfo->print.embedPrint.window);
void* platformPrint =
printInfo->print.embedPrint.platformPrint;
- \**************************************/
+ \**************************************/
}
}
}
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