Commit a593fa18 authored by Damien Fouilleul's avatar Damien Fouilleul

all: rewrite of mozilla plugin

- added a couple of support APIs in libvlc
- retired XPCOM interface, all scripting now goes through NPObject apis
- new APIs using libvlc (roughly similar to java bindings)
parent faef0357
......@@ -275,7 +275,8 @@ enum output_query_e
VOUT_REPARENT,
VOUT_SNAPSHOT,
VOUT_CLOSE,
VOUT_SET_FOCUS /* arg1= vlc_bool_t res= */
VOUT_SET_FOCUS, /* arg1= vlc_bool_t res= */
VOUT_SET_VIEWPORT /* arg1= view rect, arg2=clip rect, res= */
};
/**
......
......@@ -356,7 +356,7 @@ void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
typedef int libvlc_drawable_t;
/**
* Get current mute status
* change the video output parent
* \param p_instance libvlc instance
* \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
* \param p_exception an initialized exception
......@@ -364,6 +364,45 @@ typedef int libvlc_drawable_t;
*/
int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception_t * );
/**
* Set the video output parent
* \param p_instance libvlc instance
* \param drawable the new parent window (Drawable on X11, CGrafPort on MacOSX, HWND on Win32)
* \param p_exception an initialized exception
*/
void libvlc_video_set_parent( libvlc_instance_t *, libvlc_drawable_t, libvlc_exception_t * );
/**
* Set the video output size
* \param p_instance libvlc instance
* \param width new width for video drawable
* \param height new height for video drawable
* \param p_exception an initialized exception
*/
void libvlc_video_set_size( libvlc_instance_t *, int, int, libvlc_exception_t * );
/**
* Downcast to this general type as placeholder for a platform specific one, such as:
* Drawable on X11,
* CGrafPort on MacOSX,
* HWND on win32
*/
typedef struct
{
int top, left;
int bottom, right;
}
libvlc_rectangle_t;
/**
* Set the video output viewport for a windowless video ouput (MacOS X only)
* \param p_instance libvlc instance
* \param view coordinates within video drawable
* \param clip coordinates within video drawable
* \param p_exception an initialized exception
*/
void libvlc_video_set_viewport( libvlc_instance_t *, const libvlc_rectangle_t *, const libvlc_rectangle_t *, libvlc_exception_t * );
/** @} */
......@@ -380,6 +419,14 @@ int libvlc_video_reparent( libvlc_input_t *, libvlc_drawable_t, libvlc_exception
* @{
*/
/**
* Toggle mute status
* \param p_instance libvlc instance
* \param p_exception an initialized exception
* \return void
*/
void libvlc_audio_toggle_mute( libvlc_instance_t *, libvlc_exception_t * );
/**
* Get current mute status
* \param p_instance libvlc instance
......
......@@ -86,11 +86,9 @@ static void Unlock ( vout_thread_t * p_vout );
static int aglInit ( vout_thread_t * p_vout );
static void aglEnd ( vout_thread_t * p_vout );
static int aglManage ( vout_thread_t * p_vout );
static int aglControl( vout_thread_t *, int, va_list );
static void aglSwap ( vout_thread_t * p_vout );
static int DrawableRedraw( vlc_object_t *p_this, const char *psz_name,
vlc_value_t oval, vlc_value_t nval, void *param);
int E_(OpenVideoGL) ( vlc_object_t * p_this )
{
vout_thread_t * p_vout = (vout_thread_t *) p_this;
......@@ -131,19 +129,11 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
AGL_DEPTH_SIZE, 24,
AGL_NONE };
AGLDevice screen;
AGLPixelFormat pixFormat;
p_vout->p_sys->b_embedded = VLC_TRUE;
screen = GetGWorldDevice((CGrafPtr)value_drawable.i_int);
if( NULL == screen )
{
msg_Err( p_vout, "can't find screen device for drawable" );
return VLC_EGENERIC;
}
pixFormat = aglChoosePixelFormat(&screen, 1, ATTRIBUTES);
pixFormat = aglChoosePixelFormat(NULL, 0, ATTRIBUTES);
if( NULL == pixFormat )
{
msg_Err( p_vout, "no screen renderer available for required attributes." );
......@@ -158,8 +148,8 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
return VLC_EGENERIC;
}
else {
// tell opengl to sync buffer swap with vertical retrace
GLint param = 1;
// tell opengl not to sync buffer swap with vertical retrace
GLint param = 0;
aglSetInteger(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL, &param);
aglEnable(p_vout->p_sys->agl_ctx, AGL_SWAP_INTERVAL);
}
......@@ -167,7 +157,7 @@ int E_(OpenVideoGL) ( vlc_object_t * p_this )
p_vout->pf_init = aglInit;
p_vout->pf_end = aglEnd;
p_vout->pf_manage = aglManage;
p_vout->pf_control = NULL;
p_vout->pf_control = aglControl;
p_vout->pf_swap = aglSwap;
p_vout->pf_lock = Lock;
p_vout->pf_unlock = Unlock;
......@@ -207,7 +197,6 @@ void E_(CloseVideoGL) ( vlc_object_t * p_this )
vout_thread_t * p_vout = (vout_thread_t *) p_this;
if( p_vout->p_sys->b_embedded )
{
var_DelCallback(p_vout->p_vlc, "drawableredraw", DrawableRedraw, p_vout);
aglDestroyContext(p_vout->p_sys->agl_ctx);
}
else
......@@ -456,13 +445,38 @@ static void Unlock( vout_thread_t * p_vout )
* embedded AGL context implementation
*****************************************************************************/
static void UpdateEmbeddedGeometry( vout_thread_t *p_vout );
static void aglSetViewport( vout_thread_t *p_vout, Rect viewBounds, Rect clipBounds );
static void aglReshape( vout_thread_t * p_vout );
static int aglInit( vout_thread_t * p_vout )
{
UpdateEmbeddedGeometry(p_vout);
var_AddCallback(p_vout->p_vlc, "drawableredraw", DrawableRedraw, p_vout);
vlc_value_t val;
Rect viewBounds;
Rect clipBounds;
var_Get( p_vout->p_vlc, "drawable", &val );
p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
var_Get( p_vout->p_vlc, "drawable-view-top", &val );
viewBounds.top = val.i_int;
var_Get( p_vout->p_vlc, "drawable-view-left", &val );
viewBounds.left = val.i_int;
var_Get( p_vout->p_vlc, "drawable-view-bottom", &val );
viewBounds.bottom = val.i_int;
var_Get( p_vout->p_vlc, "drawable-view-right", &val );
viewBounds.right = val.i_int;
var_Get( p_vout->p_vlc, "drawable-clip-top", &val );
clipBounds.top = val.i_int;
var_Get( p_vout->p_vlc, "drawable-clip-left", &val );
clipBounds.left = val.i_int;
var_Get( p_vout->p_vlc, "drawable-clip-bottom", &val );
clipBounds.bottom = val.i_int;
var_Get( p_vout->p_vlc, "drawable-clip-right", &val );
clipBounds.right = val.i_int;
aglSetViewport(p_vout, viewBounds, clipBounds);
aglSetCurrentContext(p_vout->p_sys->agl_ctx);
return VLC_SUCCESS;
......@@ -547,84 +561,80 @@ static int aglManage( vout_thread_t * p_vout )
return VLC_SUCCESS;
}
static int aglControl( vout_thread_t *p_vout, int i_query, va_list args )
{
switch( i_query )
{
case VOUT_SET_VIEWPORT:
{
Rect viewBounds, clipBounds;
viewBounds.top = va_arg( args, int);
viewBounds.left = va_arg( args, int);
viewBounds.bottom = va_arg( args, int);
viewBounds.right = va_arg( args, int);
clipBounds.top = va_arg( args, int);
clipBounds.left = va_arg( args, int);
clipBounds.bottom = va_arg( args, int);
clipBounds.right = va_arg( args, int);
aglSetViewport(p_vout, viewBounds, clipBounds);
return VLC_SUCCESS;
}
case VOUT_REPARENT:
{
AGLDrawable drawable = (AGLDrawable)va_arg( args, int);
if( drawable != p_vout->p_sys->agl_drawable )
{
p_vout->p_sys->agl_drawable = drawable;
aglSetDrawable(p_vout->p_sys->agl_ctx, drawable);
}
return VLC_SUCCESS;
}
default:
return vout_vaControlDefault( p_vout, i_query, args );
}
}
static void aglSwap( vout_thread_t * p_vout )
{
p_vout->p_sys->b_got_frame = VLC_TRUE;
aglSwapBuffers(p_vout->p_sys->agl_ctx);
}
static void UpdateEmbeddedGeometry( vout_thread_t *p_vout )
static void aglSetViewport( vout_thread_t *p_vout, Rect viewBounds, Rect clipBounds )
{
vlc_value_t val;
vlc_value_t valt, vall, valb, valr, valx, valy, valw, valh,
valportx, valporty;
Rect winBounds;
Rect clientBounds;
GLint rect[4];
var_Get( p_vout->p_vlc, "drawable", &val );
var_Get( p_vout->p_vlc, "drawablet", &valt );
var_Get( p_vout->p_vlc, "drawablel", &vall );
var_Get( p_vout->p_vlc, "drawableb", &valb );
var_Get( p_vout->p_vlc, "drawabler", &valr );
var_Get( p_vout->p_vlc, "drawablex", &valx );
var_Get( p_vout->p_vlc, "drawabley", &valy );
var_Get( p_vout->p_vlc, "drawablew", &valw );
var_Get( p_vout->p_vlc, "drawableh", &valh );
var_Get( p_vout->p_vlc, "drawableportx", &valportx );
var_Get( p_vout->p_vlc, "drawableporty", &valporty );
// mozilla plugin provides coordinates based on port bounds
// however AGL coordinates are based on window structure region
// and are vertically flipped
GLint rect[4];
CGrafPtr port = (CGrafPtr)p_vout->p_sys->agl_drawable;
Rect winBounds, clientBounds;
GetWindowBounds(GetWindowFromPort((CGrafPtr)val.i_int),
GetWindowBounds(GetWindowFromPort(port),
kWindowStructureRgn, &winBounds);
GetWindowBounds(GetWindowFromPort((CGrafPtr)val.i_int),
GetWindowBounds(GetWindowFromPort(port),
kWindowContentRgn, &clientBounds);
/* update video clipping bounds in drawable */
rect[0] = (clientBounds.left-winBounds.left)
+ vall.i_int; // from window left edge
+ clipBounds.left; // from window left edge
rect[1] = (winBounds.bottom-winBounds.top)
- (clientBounds.top-winBounds.top)
- valb.i_int; // from window bottom edge
rect[2] = valr.i_int-vall.i_int; // width
rect[3] = valb.i_int-valt.i_int; // height
- clipBounds.bottom; // from window bottom edge
rect[2] = clipBounds.right-clipBounds.left; // width
rect[3] = clipBounds.bottom-clipBounds.top; // height
aglSetInteger(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT, rect);
aglEnable(p_vout->p_sys->agl_ctx, AGL_BUFFER_RECT);
/* update video internal bounds in drawable */
p_vout->p_sys->i_offx = -vall.i_int - valportx.i_int;
p_vout->p_sys->i_offy = valb.i_int + valporty.i_int - valh.i_int;
p_vout->p_sys->i_width = valw.i_int;
p_vout->p_sys->i_height = valh.i_int;
p_vout->p_sys->i_width = viewBounds.right-viewBounds.left;
p_vout->p_sys->i_height = viewBounds.bottom-viewBounds.top;
p_vout->p_sys->i_offx = -clipBounds.left - viewBounds.left;
p_vout->p_sys->i_offy = clipBounds.bottom + viewBounds.top
- p_vout->p_sys->i_height;
if( p_vout->p_sys->agl_drawable == (AGLDrawable)val.i_int )
{
aglUpdateContext(p_vout->p_sys->agl_ctx);
}
else
{
p_vout->p_sys->agl_drawable = (AGLDrawable)val.i_int;
aglSetDrawable(p_vout->p_sys->agl_ctx, p_vout->p_sys->agl_drawable);
}
aglUpdateContext(p_vout->p_sys->agl_ctx);
aglReshape( p_vout );
}
/* If we're embedded, the application is expected to indicate a
* window change (move/resize/etc) via the "drawableredraw" value.
*/
static int DrawableRedraw( vlc_object_t *p_this, const char *psz_name,
vlc_value_t oval, vlc_value_t nval, void *param)
{
vout_thread_t *p_vout = (vout_thread_t *)param;
UpdateEmbeddedGeometry( p_vout );
return VLC_SUCCESS;
}
......@@ -4,18 +4,20 @@
noinst_LIBRARIES = $(noinst_LIBRARIES_mozilla)
MOSTLYCLEANFILES = $(npvlc_DATA) $(vlcintf_xpt_DATA)
MOSTLYCLEANFILES = $(npvlc_DATA)
CLEANFILES = stamp-pic $(BUILT_SOURCES)
EXTRA_DIST = $(DIST_sources) vlcintf.idl npvlc_rc.rc vlc.r
EXTRA_DIST = $(DIST_sources) npvlc_rc.rc vlc.r
SOURCES_mozilla_common = \
vlcshell.cpp \
vlcplugin.cpp \
vlcplugin.h \
vlcpeer.cpp \
vlcpeer.h \
vlcruntime.cpp \
vlcruntime.h \
control/npolibvlc.cpp \
control/npolibvlc.h \
control/npovlc.cpp \
control/npovlc.h \
control/nporuntime.cpp \
control/nporuntime.h \
support/classinfo.h
DIST_sources = $(SOURCES_mozilla_common) \
......@@ -141,11 +143,6 @@ endif
noinst_LIBRARIES_mozilla = libnpvlc.a
$(SOURCES_mozilla): vlcintf.h
BUILT_SOURCES = vlcintf.h
vlcintf_xpt_DATA = vlcintf.xpt
if USE_LIBTOOL
# FIXME: name is incorrect on Win32 & Darwin
npvlc_LTLIBRARIES = libvlcplugin.la
......@@ -175,15 +172,6 @@ $(npvlc): $(libnpvlc_a_OBJECTS) $(libnpvlc_a_DEPENDENCIES) stamp-pic
# Cygwin work-around
@if test -f "$@.exe"; then mv -f "$@.exe" "$@"; fi
vlcintf_xptdir = $(libdir)/mozilla/components
vlcintf.xpt: vlcintf.idl
$(XPIDL) $(XPIDL_INCL) \
-m typelib -o vlcintf $(srcdir)/vlcintf.idl
vlcintf.h: vlcintf.idl
$(XPIDL) $(XPIDL_INCL) \
-m header -o vlcintf $(srcdir)/vlcintf.idl
###############################################################################
# Stamp rules
###############################################################################
......
This diff is collapsed.
/*****************************************************************************
* vlc.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* $Id: vlcruntime.h 14466 2006-02-22 23:34:54Z dionoea $
*
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
** defined runtime script objects
*/
#include "nporuntime.h"
class LibvlcRootNPObject: public RuntimeNPObject
{
public:
LibvlcRootNPObject(NPP instance, const NPClass *aClass);
virtual ~LibvlcRootNPObject();
protected:
friend class RuntimeNPClass<LibvlcRootNPObject>;
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant *result);
static const int methodCount;
static const NPUTF8 * const methodNames[];
NPObject *audioObj;
NPObject *inputObj;
NPObject *playlistObj;
NPObject *videoObj;
};
class LibvlcAudioNPObject: public RuntimeNPObject
{
public:
LibvlcAudioNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcAudioNPObject() {};
protected:
friend class RuntimeNPClass<LibvlcAudioNPObject>;
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant *result);
InvokeResult setProperty(int index, const NPVariant *value);
static const int methodCount;
static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result);
};
class LibvlcInputNPObject: public RuntimeNPObject
{
public:
LibvlcInputNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcInputNPObject() {};
protected:
friend class RuntimeNPClass<LibvlcInputNPObject>;
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant *result);
InvokeResult setProperty(int index, const NPVariant *value);
static const int methodCount;
static const NPUTF8 * const methodNames[];
};
class LibvlcPlaylistNPObject: public RuntimeNPObject
{
public:
LibvlcPlaylistNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcPlaylistNPObject() {};
protected:
friend class RuntimeNPClass<LibvlcPlaylistNPObject>;
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 LibvlcVideoNPObject: public RuntimeNPObject
{
public:
LibvlcVideoNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcVideoNPObject() {};
protected:
friend class RuntimeNPClass<LibvlcVideoNPObject>;
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant *result);
InvokeResult setProperty(int index, const NPVariant *value);
static const int methodCount;
static const NPUTF8 * const methodNames[];
InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result);
};
/*****************************************************************************
* runtime.cpp: support for NPRuntime API for Netscape Script-able plugins
* FYI: http://www.mozilla.org/projects/plugins/npruntime.html
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* Mozilla stuff */
#ifdef HAVE_MOZILLA_CONFIG_H
# include <mozilla-config.h>
#endif
#include "nporuntime.h"
#include "vlcplugin.h"
RuntimeNPObject::InvokeResult RuntimeNPObject::getProperty(int index, NPVariant *result)
{
/* default behaviour */
return INVOKERESULT_GENERIC_ERROR;
}
RuntimeNPObject::InvokeResult RuntimeNPObject::setProperty(int index, const NPVariant *value)
{
/* default behaviour */
return INVOKERESULT_GENERIC_ERROR;
}
RuntimeNPObject::InvokeResult RuntimeNPObject::removeProperty(int index)
{
/* default behaviour */
return INVOKERESULT_GENERIC_ERROR;
}
RuntimeNPObject::InvokeResult RuntimeNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result)
{
/* default beahviour */
return INVOKERESULT_GENERIC_ERROR;
}
RuntimeNPObject::InvokeResult RuntimeNPObject::invokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result)
{
/* return void */
VOID_TO_NPVARIANT(*result);
return INVOKERESULT_NO_ERROR;
}
bool RuntimeNPObject::returnInvokeResult(RuntimeNPObject::InvokeResult result)
{
switch( result )
{
case INVOKERESULT_NO_ERROR:
return true;
case INVOKERESULT_GENERIC_ERROR:
break;
case INVOKERESULT_NO_SUCH_METHOD:
NPN_SetException(this, "No such method or arguments mismatch");
break;
case INVOKERESULT_INVALID_ARGS:
NPN_SetException(this, "Invalid arguments");
break;
case INVOKERESULT_INVALID_VALUE:
NPN_SetException(this, "Invalid value in assignment");
break;
case INVOKERESULT_OUT_OF_MEMORY:
NPN_SetException(this, "Out of memory");
break;
}
return false;
}
This diff is collapsed.
/*****************************************************************************
* vlcpeer.h: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef __VLCPEER_H__
#define __VLCPEER_H__
#include "vlcintf.h"
#include "support/classinfo.h"
class VlcPlugin;
class VlcPeer : public VlcIntf, public ClassInfo
{
public:
NS_DECL_ISUPPORTS
NS_DECL_VLCINTF
// These flags are used by the DOM and security systems to signal that
// JavaScript callers are allowed to call this object's scriptable 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;
}
VlcPeer();
VlcPeer( VlcPlugin * );
virtual ~VlcPeer();
void Disable();
private:
VlcPlugin * p_plugin;
};
#endif
/*****************************************************************************
* vlc.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* $Id: vlcruntime.h 14466 2006-02-22 23:34:54Z dionoea $
*
* Authors: Damien Fouilleul <damien.fouilleul@laposte.net>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*
** defined runtime script objects
*/
#include "nporuntime.h"
class VlcNPObject: public RuntimeNPObject
{
public:
VlcNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~VlcNPObject() {};
protected:
friend class RuntimeNPClass<VlcNPObject>;
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
static const int methodCount;
static const NPUTF8 * const methodNames[];
virtual InvokeResult invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result);
};
#include "nsISupports.idl"
[scriptable, uuid(ea92ef52-afe4-4212-bacb-dfe9fca94cd6)]
interface VlcIntf : nsISupports
{
/* Basic playback control */
void play();
void pause();
void stop();
/* Audio/Video control */
void fullscreen();
void set_volume( in PRInt64 i_volume );
PRInt64 get_volume();
void mute();
/* Get/Set variable */
void set_int_variable( in string psz_var, in PRInt64 i_value );
void set_bool_variable( in string psz_var, in PRBool b_value );
void set_str_variable( in string psz_var, in string psz_value );
PRInt64 get_int_variable( in string psz_var );
PRBool get_bool_variable( in string psz_var );
string get_str_variable( in string psz_var );
/* Playlist management */
void clear_playlist();
void add_item( in string psz_name);
void next();
void previous();
/* Status accessors */
PRBool isplaying();
PRInt64 get_length();
PRInt64 get_position();
PRInt64 get_time();
void seek( in PRInt64 i_secs, in PRInt64 b_relative);
};
/*****************************************************************************
* vlcpeer.cpp: scriptable peer descriptor
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* $Id$
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include "config.h"
#include <vlc/vlc.h>
#ifdef DEBUG
/* We do not want to use nsDebug.h */
# undef DEBUG
#endif
#ifdef HAVE_MOZILLA_CONFIG_H
# include <mozilla-config.h>
#endif
#include <nsISupports.h>
#include <nsMemory.h>
#include <npapi.h>
#if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
#define XP_UNIX 1
#elif defined(XP_MACOSX)
#undef XP_UNIX
#endif
#include "vlcpeer.h"
#include "vlcplugin.h"
NS_IMPL_ISUPPORTS2( VlcPeer, VlcIntf, nsIClassInfo )
/*****************************************************************************
* Scriptable peer constructor and destructor
*****************************************************************************/
VlcPeer::VlcPeer()
{
NS_INIT_ISUPPORTS();
}
VlcPeer::VlcPeer( VlcPlugin * plugin )
{
NS_INIT_ISUPPORTS();
p_plugin = plugin;
}
VlcPeer::~VlcPeer()
{
;
}
/*****************************************************************************
* Scriptable peer methods
*****************************************************************************/
void VlcPeer::Disable()
{
p_plugin = NULL;
}
/*****************************************************************************
* Scriptable peer plugin methods
*****************************************************************************/
NS_IMETHODIMP VlcPeer::Play()
{
if( p_plugin )
{
if( !p_plugin->b_stream && p_plugin->psz_target )
{
VLC_AddTarget( p_plugin->i_vlc, p_plugin->psz_target, 0, 0,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
p_plugin->b_stream = 1;
}
VLC_Play( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Pause()
{
if( p_plugin )
{
VLC_Pause( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Stop()
{
if( p_plugin )
{
VLC_Stop( p_plugin->i_vlc );
p_plugin->b_stream = 0;
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Fullscreen()
{
if( p_plugin )
{
#ifdef XP_MACOSX
#else
VLC_FullScreen( p_plugin->i_vlc );
#endif
}
return NS_OK;
}
/* Set/Get vlc variables */
NS_IMETHODIMP VlcPeer::Set_int_variable(const char *psz_var, PRInt64 value )
{
vlc_value_t val;
val.i_int = value;
if( p_plugin )
{
VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Set_str_variable(const char *psz_var, const char *value )
{
vlc_value_t val;
val.psz_string = strdup( value );
if( p_plugin )
{
VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Set_bool_variable(const char *psz_var, PRBool value )
{
vlc_value_t val;
val.b_bool = value >= 1 ? VLC_TRUE : VLC_FALSE;
if( p_plugin )
{
VLC_VariableSet( p_plugin->i_vlc, psz_var, val );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_int_variable( const char *psz_var, PRInt64 *result )
{
vlc_value_t val;
if( p_plugin )
{
VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
*result = (PRInt64)val.i_int;
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_bool_variable( const char *psz_var,PRBool *result )
{
vlc_value_t val;
if( p_plugin )
{
VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
*result = (PRBool)val.b_bool;
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_str_variable( const char *psz_var, char **result )
{
vlc_value_t val;
if( p_plugin )
{
VLC_VariableGet( p_plugin->i_vlc, psz_var, &val );
if( val.psz_string )
{
*result = strdup( val.psz_string );
}
else
{
*result = strdup( "" );
}
}
return NS_OK;
}
/* Playlist control */
NS_IMETHODIMP VlcPeer::Clear_playlist()
{
if( p_plugin )
{
VLC_PlaylistClear( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Add_item( const char *psz_item )
{
if( p_plugin )
{
VLC_AddTarget( p_plugin->i_vlc, psz_item, NULL, 0,
PLAYLIST_APPEND, PLAYLIST_END);
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Isplaying( PRBool *b_playing )
{
if( p_plugin->i_vlc )
{
*b_playing = VLC_IsPlaying( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_position( PRInt64 *i_position )
{
if( p_plugin->i_vlc )
{
*i_position = (PRInt64)VLC_PositionGet( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_time( PRInt64 *i_time )
{
if( p_plugin->i_vlc )
{
*i_time = VLC_TimeGet( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_length( PRInt64 *i_length )
{
if( p_plugin->i_vlc )
{
*i_length = VLC_LengthGet( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Seek( PRInt64 i_secs, PRInt64 b_relative )
{
if( p_plugin->i_vlc )
{
VLC_TimeSet( p_plugin->i_vlc, i_secs, b_relative );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Next()
{
if( p_plugin->i_vlc )
{
VLC_PlaylistNext( p_plugin->i_vlc);
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Previous()
{
if( p_plugin->i_vlc )
{
VLC_PlaylistPrev( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Set_volume( PRInt64 i_volume )
{
if( p_plugin->i_vlc )
{
VLC_VolumeSet( p_plugin->i_vlc, i_volume );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Get_volume( PRInt64 *i_volume )
{
if( p_plugin->i_vlc )
{
*i_volume = VLC_VolumeGet( p_plugin->i_vlc );
}
return NS_OK;
}
NS_IMETHODIMP VlcPeer::Mute()
{
if( p_plugin->i_vlc )
{
VLC_VolumeMute( p_plugin->i_vlc );
}
return NS_OK;
}
This diff is collapsed.
/*****************************************************************************
* vlcplugin.h: a VLC plugin for Mozilla
*****************************************************************************
* Copyright (C) 2002-2005 the VideoLAN team
* Copyright (C) 2002-2006 the VideoLAN team
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
Damien Fouilleul <damienf@videolan.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
......@@ -27,7 +28,9 @@
#ifndef __VLCPLUGIN_H__
#define __VLCPLUGIN_H__
#include "vlcpeer.h"
#include <vlc/libvlc.h>
#include <npapi.h>
#include "control/nporuntime.h"
#if !defined(XP_MACOSX) && !defined(XP_UNIX) && !defined(XP_WIN)
#define XP_UNIX 1
......@@ -35,6 +38,7 @@
#undef XP_UNIX
#endif
#if 0
#ifdef XP_WIN
/* Windows stuff */
#endif
......@@ -50,49 +54,63 @@
# include <X11/Intrinsic.h>
# include <X11/StringDefs.h>
#endif
#endif
class VlcPlugin
{
public:
VlcPlugin( NPP );
VlcPlugin( NPP, uint16 );
virtual ~VlcPlugin();
void SetInstance( NPP );
NPP GetInstance();
VlcIntf* GetPeer();
/* Window settings */
NPWindow* p_npwin;
uint16 i_npmode;
uint32 i_width, i_height;
#ifdef XP_WIN
/* Windows data members */
HWND p_hwnd;
WNDPROC pf_wndproc;
#endif
#ifdef XP_UNIX
/* UNIX data members */
Window window;
Display *p_display;
NPError init(int argc, char* const argn[], char* const argv[]);
libvlc_instance_t* getVLC()
{ return libvlc_instance; };
NPP getBrowser()
{ return p_browser; };
char* getAbsoluteURL(const char *url);
const NPWindow* getWindow()
{ return &npwindow; };
void setWindow(const NPWindow *window)
{ npwindow = *window; };
NPClass* getScriptClass()
{ return scriptClass; };
#if XP_WIN
WNDPROC getWindowProc()
{ return pf_wndproc; };
void setWindowProc(WNDPROC wndproc)
{ pf_wndproc = wndproc; };
#endif
#ifdef XP_MACOSX
/* MACOS data members */
NPWindow *window;
#if XP_UNIX
int setSize(unsigned width, unsigned height);
#endif
uint16 i_npmode; /* either NP_EMBED or NP_FULL */
/* vlc data members */
int i_vlc;
/* plugin properties */
int b_stream;
int b_autoplay;
char * psz_target;
private:
NPP p_instance;
VlcPeer* p_peer;
/* VLC reference */
libvlc_instance_t *libvlc_instance;
NPClass *scriptClass;
/* browser reference */
NPP p_browser;
char* psz_baseURL;
/* display settings */
NPWindow npwindow;
#if XP_WIN
WNDPROC pf_wndproc;
#endif
#if XP_UNIX
unsigned int i_width, i_height;
#endif
};
/*******************************************************************************
......
/*****************************************************************************
* vlcruntime.cpp: support for NPRuntime API for Netscape Script-able plugins
* FYI: http://www.mozilla.org/projects/plugins/npruntime.html
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/* vlc stuff */
#ifdef USE_LIBVLC
# include <vlc/vlc.h>
#endif
/* Mozilla stuff */
#ifdef HAVE_MOZILLA_CONFIG_H
# include <mozilla-config.h>
#endif
#include <nsISupports.h>
#include <nsMemory.h>
#include <npapi.h>
#include <npruntime.h>
#include "vlcplugin.h"
#include "vlcruntime.h"
/*
** utility functions
*/
static PRInt64 NPVariantToPRInt64(const NPVariant &v)
{
switch( v.type ) {
case NPVariantType_Bool:
return static_cast<PRInt64>(NPVARIANT_TO_BOOLEAN(v));
case NPVariantType_Int32:
return static_cast<PRInt64>(NPVARIANT_TO_INT32(v));
case NPVariantType_Double:
return static_cast<PRInt64>(NPVARIANT_TO_DOUBLE(v));
default:
return 0;
}
}
/*
** implementation root object
*/
const NPUTF8 * const VlcRuntimeRootObject::propertyNames[] = { };
const NPUTF8 * const VlcRuntimeRootObject::methodNames[] =
{
"play",
"pause",
"stop",
"fullscreen",
"set_volume",
"get_volume",
"mute",
"get_int_variable",
"set_int_variable",
"get_bool_variable",
"set_bool_variable",
"get_str_variable",
"set_str_variable",
"clear_playlist",
"add_item",
"next",
"previous",
"isplaying",
"get_length",
"get_position",
"get_time",
"seek",
};
enum VlcRuntimeRootObjectMethodIds
{
ID_play = 0,
ID_pause,
ID_stop,
ID_fullscreen,
ID_set_volume,
ID_get_volume,
ID_mute,
ID_get_int_variable,
ID_set_int_variable,
ID_get_bool_variable,
ID_set_bool_variable,
ID_get_str_variable,
ID_set_str_variable,
ID_clear_playlist,
ID_add_item,
ID_next,
ID_previous,
ID_isplaying,
ID_get_length,
ID_get_position,
ID_get_time,
ID_seek,
};
const int VlcRuntimeRootObject::propertyCount = sizeof(VlcRuntimeRootObject::propertyNames)/sizeof(NPUTF8 *);
const int VlcRuntimeRootObject::methodCount = sizeof(VlcRuntimeRootObject::methodNames)/sizeof(NPUTF8 *);
bool VlcRuntimeRootObject::getProperty(int index, NPVariant *result)
{
return false;
}
bool VlcRuntimeRootObject::setProperty(int index, const NPVariant *value)
{
return false;
}
bool VlcRuntimeRootObject::removeProperty(int index)
{
return false;
}
bool VlcRuntimeRootObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant *result)
{
VlcPlugin *plugin = (VlcPlugin *)(_instance->pdata);
if( plugin )
{
VlcIntf *peer = plugin->GetPeer();
switch( index )
{
case ID_play:
peer->Play();
VOID_TO_NPVARIANT(*result);
return true;
case ID_pause:
peer->Pause();
VOID_TO_NPVARIANT(*result);
return true;
case ID_stop:
peer->Stop();
VOID_TO_NPVARIANT(*result);
return true;
case ID_fullscreen:
peer->Fullscreen();
VOID_TO_NPVARIANT(*result);
return true;
case ID_set_volume:
if( argCount == 1 )
{
peer->Set_volume(NPVariantToPRInt64(args[0]));
VOID_TO_NPVARIANT(*result);
return true;
}
return false;
case ID_get_volume:
{
PRInt64 val;
peer->Get_volume(&val);
INT32_TO_NPVARIANT(val, *result);
return true;
}
case ID_mute:
peer->Mute();
VOID_TO_NPVARIANT(*result);
return true;
case ID_get_int_variable:
if( (argCount == 1)
&& NPVARIANT_IS_STRING(args[0]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
PRInt64 val;
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Get_int_variable(s, &val);
INT32_TO_NPVARIANT(val, *result);
delete s;
return true;
}
}
return false;
case ID_set_int_variable:
if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Set_int_variable(s, NPVariantToPRInt64(args[1]));
delete s;
VOID_TO_NPVARIANT(*result);
return true;
}
}
return false;
case ID_get_bool_variable:
if( (argCount == 1)
&& NPVARIANT_IS_STRING(args[0]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
PRBool val;
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Get_bool_variable(s, &val);
BOOLEAN_TO_NPVARIANT(val, *result);
delete s;
return true;
}
}
return false;
case ID_set_bool_variable:
if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0])
&& NPVARIANT_IS_BOOLEAN(args[1]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Set_bool_variable(s, NPVARIANT_TO_BOOLEAN(args[1]));
delete s;
VOID_TO_NPVARIANT(*result);
return true;
}
}
return false;
case ID_get_str_variable:
if( (argCount == 1)
&& NPVARIANT_IS_STRING(args[0]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
char *val;
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Get_str_variable(s, &val);
delete s;
int len = strlen(val);
NPUTF8 *retval = (NPUTF8 *)NPN_MemAlloc(len);
if( retval )
{
memcpy(retval, val, len);
STRINGN_TO_NPVARIANT(retval, len, *result);
free(val);
return true;
}
free(val);
}
}
return false;
case ID_set_str_variable:
if( (argCount == 2)
&& NPVARIANT_IS_STRING(args[0])
&& NPVARIANT_IS_STRING(args[1]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
const NPString &val = NPVARIANT_TO_STRING(args[1]);
NPUTF8 *v = new NPUTF8[val.utf8length+1];
if( v )
{
strncpy(v, val.utf8characters, val.utf8length);
v[val.utf8length] = '\0';
peer->Set_str_variable(s, v);
delete s;
delete v;
VOID_TO_NPVARIANT(*result);
return true;
}
delete s;
}
}
return false;
case ID_clear_playlist:
peer->Clear_playlist();
VOID_TO_NPVARIANT(*result);
return true;
case ID_add_item:
if( (argCount == 1)
&& NPVARIANT_IS_STRING(args[0]) )
{
const NPString &name = NPVARIANT_TO_STRING(args[0]);
NPUTF8 *s = new NPUTF8[name.utf8length+1];
if( s )
{
strncpy(s, name.utf8characters, name.utf8length);
s[name.utf8length] = '\0';
peer->Add_item(s);
delete s;
return true;
}
}
return false;
case ID_next:
peer->Next();
VOID_TO_NPVARIANT(*result);
return true;
case ID_previous:
peer->Previous();
VOID_TO_NPVARIANT(*result);
return true;
case ID_isplaying:
{
PRBool val;
peer->Isplaying(&val);
BOOLEAN_TO_NPVARIANT(val, *result);
return true;
}
case ID_get_length:
{
PRInt64 val;
peer->Get_length(&val);
DOUBLE_TO_NPVARIANT(val, *result);
return true;
}
case ID_get_position:
{
PRInt64 val;
peer->Get_position(&val);
INT32_TO_NPVARIANT(val, *result);
return true;
}
case ID_get_time:
{
PRInt64 val;
peer->Get_time(&val);
INT32_TO_NPVARIANT(val, *result);
return true;
}
case ID_seek:
if( argCount == 2 )
{
peer->Seek(NPVariantToPRInt64(args[0]), NPVariantToPRInt64(args[1]));
VOID_TO_NPVARIANT(*result);
return true;
}
return false;
}
NS_RELEASE(peer);
}
return false;
}
bool VlcRuntimeRootObject::invokeDefault(const NPVariant *args, uint32_t argCount, NPVariant *result)
{
return false;
}
This diff is collapsed.
......@@ -234,6 +234,96 @@ void libvlc_video_resize( libvlc_input_t *p_input, int width, int height, libvlc
vlc_object_release( p_vout );
}
/* global video settings */
void libvlc_video_set_parent( libvlc_instance_t *p_instance, libvlc_drawable_t d,
libvlc_exception_t *p_e )
{
/* set as default for future vout instances */
var_SetInteger(p_instance->p_vlc, "drawable", (int)d);
if( libvlc_playlist_isplaying(p_instance, p_e) )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
if( p_input )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
if( p_vout )
{
/* tell running vout to re-parent */
vout_Control( p_vout , VOUT_REPARENT, d);
vlc_object_release( p_vout );
}
libvlc_input_free(p_input);
}
}
}
void libvlc_video_set_size( libvlc_instance_t *p_instance, int width, int height,
libvlc_exception_t *p_e )
{
/* set as default for future vout instances */
config_PutInt(p_instance->p_vlc, "width", width);
config_PutInt(p_instance->p_vlc, "height", height);
if( libvlc_playlist_isplaying(p_instance, p_e) )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
if( p_input )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
if( p_vout )
{
/* tell running vout to re-size */
vout_Control( p_vout , VOUT_SET_SIZE, width, height);
vlc_object_release( p_vout );
}
libvlc_input_free(p_input);
}
}
}
void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
const libvlc_rectangle_t *view, const libvlc_rectangle_t *clip,
libvlc_exception_t *p_e )
{
if( NULL == view )
{
libvlc_exception_raise( p_e, "viewport is NULL" );
}
/* if clip is NULL, then use view rectangle as clip */
if( NULL == clip )
clip = view;
/* set as default for future vout instances */
var_SetInteger( p_instance->p_vlc, "drawable-view-top", view->top );
var_SetInteger( p_instance->p_vlc, "drawable-view-left", view->left );
var_SetInteger( p_instance->p_vlc, "drawable-view-bottom", view->bottom );
var_SetInteger( p_instance->p_vlc, "drawable-view-right", view->right );
var_SetInteger( p_instance->p_vlc, "drawable-clip-top", clip->top );
var_SetInteger( p_instance->p_vlc, "drawable-clip-left", clip->left );
var_SetInteger( p_instance->p_vlc, "drawable-clip-bottom", clip->bottom );
var_SetInteger( p_instance->p_vlc, "drawable-clip-right", clip->right );
if( libvlc_playlist_isplaying(p_instance, p_e) )
{
libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
if( p_input )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
if( p_vout )
{
/* change viewport for running vout */
vout_Control( p_vout , VOUT_SET_VIEWPORT,
view->top, view->left, view->bottom, view->right,
clip->top, clip->left, clip->bottom, clip->right );
vlc_object_release( p_vout );
}
libvlc_input_free(p_input);
}
}
}
int libvlc_video_destroy( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
......
......@@ -833,17 +833,14 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
* FIXME: kludge to use a p_vlc-local variable for the Mozilla plugin
*/
var_Create( p_vlc, "drawable", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawableredraw", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawablet", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawablel", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawableb", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawabler", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawablex", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawabley", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawablew", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawableh", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawableportx", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawableporty", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-view-top", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-view-left", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-view-bottom", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-view-right", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-clip-top", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-clip-left", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-clip-bottom", VLC_VAR_INTEGER );
var_Create( p_vlc, "drawable-clip-right", VLC_VAR_INTEGER );
/* Create volume callback system. */
var_Create( p_vlc, "volume-change", VLC_VAR_BOOL );
......
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