Commit b9df3870 authored by Damien Fouilleul's avatar Damien Fouilleul

- some backporting, some changes and some new stuff. in brief, a holy mess

parent dd73ed45
......@@ -586,6 +586,108 @@ void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * )
/** @} */
/** @} */
/*****************************************************************************
* Message log handling
*****************************************************************************/
/** defgroup libvlc_log Log
* \ingroup libvlc
* LibVLC Message Logging
* @{
*/
/** This structure is opaque. It represents a libvlc log instance */
typedef struct libvlc_log_t libvlc_log_t;
/** This structure is opaque. It represents a libvlc log iterator */
typedef struct libvlc_log_iterator_t libvlc_log_iterator_t;
typedef struct libvlc_log_message_t
{
unsigned sizeof_msg; /* sizeof() of message structure, must be filled in by user */
int i_severity; /* 0=INFO, 1=ERR, 2=WARN, 3=DBG */
const char *psz_type; /* module type */
const char *psz_name; /* module name */
const char *psz_header; /* optional header */
const char *psz_message; /* message */
} libvlc_log_message_t;
/**
* Returns the VLC messaging verbosity level
* \param p_instance libvlc instance
* \param exception an initialized exception pointer
*/
unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e );
/**
* Set the VLC messaging verbosity level
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e );
/**
* Open an instance to VLC message log
* \param p_instance libvlc instance
* \param exception an initialized exception pointer
*/
libvlc_log_t *libvlc_log_open( const libvlc_instance_t *, libvlc_exception_t *);
/**
* Close an instance of VLC message log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
void libvlc_log_close( libvlc_log_t *, libvlc_exception_t *);
/**
* Returns the number of messages in log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
unsigned libvlc_log_count( const libvlc_log_t *, libvlc_exception_t *);
/**
* Clear all messages in log
* the log should be cleared on a regular basis to avoid clogging
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
void libvlc_log_clear( libvlc_log_t *, libvlc_exception_t *);
/**
* Allocate and returns a new iterator to messages in log
* \param p_log libvlc log instance
* \param exception an initialized exception pointer
*/
libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *, libvlc_exception_t *);
/**
* Releases a previoulsy allocated iterator
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
/**
* Returns whether log iterator has more messages
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e );
/**
* Returns next log message
* the content of message must not be freed
* \param p_log libvlc log iterator
* \param exception an initialized exception pointer
*/
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
struct libvlc_log_message_t *buffer,
libvlc_exception_t *p_e );
/** @} */
# ifdef __cplusplus
}
# endif
......
......@@ -196,6 +196,7 @@ void __msg_Destroy ( vlc_object_t * );
VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
extern const char *msg_GetObjectTypeName(int i_object_type );
/**
* @}
......
This diff is collapsed.
......@@ -23,6 +23,7 @@
/*
** defined runtime script objects
*/
#include <vlc/libvlc.h>
#include "nporuntime.h"
......@@ -46,6 +47,7 @@ protected:
NPObject *audioObj;
NPObject *inputObj;
NPObject *logObj;
NPObject *playlistObj;
NPObject *videoObj;
};
......@@ -78,7 +80,7 @@ protected:
LibvlcInputNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcInputNPObject() {};
static const int propertyCount;
......@@ -91,6 +93,130 @@ protected:
static const NPUTF8 * const methodNames[];
};
class LibvlcMessageNPObject: public RuntimeNPObject
{
public:
void setMessage(struct libvlc_log_message_t &msg)
{
_msg = msg;
};
protected:
friend class RuntimeNPClass<LibvlcMessageNPObject>;
LibvlcMessageNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessageNPObject() {};
static const int propertyCount;
static const NPUTF8 * const propertyNames[];
InvokeResult getProperty(int index, NPVariant &result);
static const int methodCount;
static const NPUTF8 * const methodNames[];
private:
struct libvlc_log_message_t _msg;
};
class LibvlcLogNPObject;
class LibvlcMessageIteratorNPObject: public RuntimeNPObject
{
public:
void setLog(LibvlcLogNPObject* p_vlclog);
protected:
friend class RuntimeNPClass<LibvlcMessageIteratorNPObject>;
LibvlcMessageIteratorNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass) {};
virtual ~LibvlcMessageIteratorNPObject() {};
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);
private:
LibvlcLogNPObject* _p_vlclog;
libvlc_log_iterator_t* _p_iter;
};
class LibvlcMessagesNPObject: public RuntimeNPObject
{
public:
void setLog(LibvlcLogNPObject *p_log)
{
_p_vlclog = p_log;
}
protected:
friend class RuntimeNPClass<LibvlcMessagesNPObject>;
LibvlcMessagesNPObject(NPP instance, const NPClass *aClass) :
RuntimeNPObject(instance, aClass),
_p_vlclog(NULL) {};
virtual ~LibvlcMessagesNPObject() {};
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);
private:
LibvlcLogNPObject* _p_vlclog;
};
class LibvlcLogNPObject: public RuntimeNPObject
{
protected:
friend class RuntimeNPClass<LibvlcLogNPObject>;
friend class LibvlcMessagesNPObject;
friend class LibvlcMessageIteratorNPObject;
libvlc_log_t *_p_log;
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 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[];
private:
LibvlcMessagesNPObject* _p_vlcmessages;
};
class LibvlcPlaylistNPObject: public RuntimeNPObject
{
protected:
......
/*****************************************************************************
* 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;
}
/*****************************************************************************
* 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
......@@ -330,22 +330,31 @@ char *VlcPlugin::getAbsoluteURL(const char *url)
/* skip over protocol part */
char *pathstart = strchr(href, ':');
char *pathend;
if( '/' == *(++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 = '/';
}
if( pathstart )
{
if( '/' == *(++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 = '/';
}
}
else
{
/* baseURL is just a path */
pathstart = href;
pathend = href+baseLen;
}
/* relative URL made of an absolute path ? */
if( '/' == *url )
......
......@@ -93,8 +93,7 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
return NPERR_NO_ERROR;
case NPPVpluginDescriptionString:
snprintf( psz_desc, sizeof(psz_desc)-1, PLUGIN_DESCRIPTION, VLC_Version() );
psz_desc[sizeof(psz_desc)-1] = 0;
snprintf( psz_desc, sizeof(psz_desc), PLUGIN_DESCRIPTION, VLC_Version() );
*((char **)value) = psz_desc;
return NPERR_NO_ERROR;
......@@ -140,6 +139,8 @@ NPError NPP_GetValue( NPP instance, NPPVariable variable, void *value )
#ifdef XP_MACOSX
int16 NPP_HandleEvent( NPP instance, void * event )
{
static UInt32 lastMouseUp = 0;
if( instance == NULL )
{
return false;
......@@ -153,7 +154,29 @@ int16 NPP_HandleEvent( NPP instance, void * event )
case nullEvent:
break;
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:
lastMouseUp = myEvent->when;
return true;
case keyUp:
case keyDown:
......@@ -178,7 +201,7 @@ int16 NPP_HandleEvent( NPP instance, void * event )
}
const NPWindow *npwindow = p_plugin->getWindow();
if( needsDisplay && npwindow->window )
{
/* draw the beautiful "No Picture" */
......@@ -434,14 +457,14 @@ NPError NPP_SetWindow( NPP instance, NPWindow* window )
{
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 )
{
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;
......@@ -507,7 +530,7 @@ void NPP_StreamAsFile( NPP instance, NPStream *stream, const char* fname )
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 )
{
......
......@@ -320,6 +320,7 @@ SOURCES_libvlc_common = \
misc/hashtables.c \
extras/libc.c \
control/core.c \
control/log.c \
control/playlist.c \
control/vlm.c \
control/input.c \
......
/*****************************************************************************
* log.c: libvlc new API log functions
*****************************************************************************
* Copyright (C) 2005 the VideoLAN team
*
* $Id: core.c 14187 2006-02-07 16:37:40Z courmisch $
*
* Authors: 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
* 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 <libvlc_internal.h>
#include <vlc/libvlc.h>
struct libvlc_log_t
{
const libvlc_instance_t *p_instance;
msg_subscription_t *p_messages;
};
struct libvlc_log_iterator_t
{
msg_subscription_t *p_messages;
int i_start;
int i_pos;
int i_end;
};
unsigned libvlc_get_log_verbosity( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
{
if( p_instance )
{
return p_instance->p_vlc->p_libvlc->i_verbose;
}
RAISEZERO("Invalid VLC instance!");
}
void libvlc_set_log_verbosity( libvlc_instance_t *p_instance, unsigned level, libvlc_exception_t *p_e )
{
if( p_instance )
{
p_instance->p_vlc->p_libvlc->i_verbose = level;
}
else
RAISEVOID("Invalid VLC instance!");
}
libvlc_log_t *libvlc_log_open( const libvlc_instance_t *p_instance, libvlc_exception_t *p_e )
{
struct libvlc_log_t *p_log =
(struct libvlc_log_t *)malloc(sizeof(struct libvlc_log_t));
if( !p_log ) RAISENULL( "Out of memory" );
p_log->p_instance = p_instance;
p_log->p_messages = msg_Subscribe(p_instance->p_vlc, MSG_QUEUE_NORMAL);
if( !p_log->p_messages ) RAISENULL( "Out of memory" );
return p_log;
}
void libvlc_log_close( libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
if( p_log && p_log->p_messages )
{
msg_Unsubscribe(p_log->p_instance->p_vlc, p_log->p_messages);
free(p_log);
}
else
RAISEVOID("Invalid log object!");
}
unsigned libvlc_log_count( const libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
if( p_log && p_log->p_messages )
{
int i_start = p_log->p_messages->i_start;
int i_stop = *(p_log->p_messages->pi_stop);
return (i_stop - i_start) % VLC_MSG_QSIZE;
}
RAISEZERO("Invalid log object!");
}
void libvlc_log_clear( libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
if( p_log && p_log->p_messages )
{
vlc_mutex_lock(p_log->p_messages->p_lock);
p_log->p_messages->i_start = *(p_log->p_messages->pi_stop);
vlc_mutex_unlock(p_log->p_messages->p_lock);
}
else
RAISEVOID("Invalid log object!");
}
libvlc_log_iterator_t *libvlc_log_get_iterator( const libvlc_log_t *p_log, libvlc_exception_t *p_e )
{
if( p_log && p_log->p_messages )
{
struct libvlc_log_iterator_t *p_iter =
(struct libvlc_log_iterator_t *)malloc(sizeof(struct libvlc_log_iterator_t));
if( !p_iter ) RAISENULL( "Out of memory" );
vlc_mutex_lock(p_log->p_messages->p_lock);
p_iter->p_messages = p_log->p_messages;
p_iter->i_start = p_log->p_messages->i_start;
p_iter->i_pos = p_log->p_messages->i_start;
p_iter->i_end = *(p_log->p_messages->pi_stop);
vlc_mutex_unlock(p_log->p_messages->p_lock);
return p_iter;
}
RAISENULL("Invalid log object!");
}
void libvlc_log_iterator_free( libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e )
{
if( p_iter )
{
free(p_iter);
}
else
RAISEVOID("Invalid log iterator!");
}
int libvlc_log_iterator_has_next( const libvlc_log_iterator_t *p_iter, libvlc_exception_t *p_e )
{
if( p_iter )
{
return p_iter->i_pos != p_iter->i_end;
}
RAISEZERO("Invalid log iterator!");
}
libvlc_log_message_t *libvlc_log_iterator_next( libvlc_log_iterator_t *p_iter,
struct libvlc_log_message_t *buffer,
libvlc_exception_t *p_e )
{
if( p_iter )
{
if( buffer && (sizeof(struct libvlc_log_message_t) == buffer->sizeof_msg) )
{
int i_pos = p_iter->i_pos;
if( i_pos != p_iter->i_end )
{
msg_item_t *msg;
vlc_mutex_lock(p_iter->p_messages->p_lock);
msg = p_iter->p_messages->p_msg+i_pos;
buffer->i_severity = msg->i_type;
buffer->psz_type = msg_GetObjectTypeName(msg->i_object_type);
buffer->psz_name = msg->psz_module;
buffer->psz_header = msg->psz_header;
buffer->psz_message = msg->psz_msg;
p_iter->i_pos = ++i_pos % VLC_MSG_QSIZE;
vlc_mutex_unlock(p_iter->p_messages->p_lock);
return buffer;
}
RAISENULL("No more messages");
}
RAISENULL("Invalid message buffer!");
}
RAISENULL("Invalid log iterator!");
}
......@@ -231,6 +231,33 @@ void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub )
vlc_mutex_unlock( &p_bank->lock );
}
const char *msg_GetObjectTypeName(int i_object_type )
{
switch( i_object_type )
{
case VLC_OBJECT_ROOT: return "root";
case VLC_OBJECT_MODULE: return "module";
case VLC_OBJECT_INTF: return "interface";
case VLC_OBJECT_PLAYLIST: return "playlist";
case VLC_OBJECT_ITEM: return "item";
case VLC_OBJECT_INPUT: return "input";
case VLC_OBJECT_DECODER: return "decoder";
case VLC_OBJECT_PACKETIZER: return "packetizer";
case VLC_OBJECT_ENCODER: return "encoder";
case VLC_OBJECT_VOUT: return "video output";
case VLC_OBJECT_AOUT: return "audio output";
case VLC_OBJECT_SOUT: return "stream output";
case VLC_OBJECT_HTTPD: return "http server";
case VLC_OBJECT_HTTPD_HOST: return "http server";
case VLC_OBJECT_DIALOGS: return "dialogs provider";
case VLC_OBJECT_VLM: return "vlm";
case VLC_OBJECT_ANNOUNCE: return "announce handler";
case VLC_OBJECT_DEMUX: return "demuxer";
case VLC_OBJECT_ACCESS: return "access";
default: return "private";
}
}
/*****************************************************************************
* __msg_*: print a message
*****************************************************************************
......@@ -558,29 +585,7 @@ static void PrintMsg ( vlc_object_t * p_this, msg_item_t * p_item )
break;
}
switch( p_item->i_object_type )
{
case VLC_OBJECT_ROOT: psz_object = "root"; break;
case VLC_OBJECT_VLC: psz_object = "vlc"; break;
case VLC_OBJECT_MODULE: psz_object = "module"; break;
case VLC_OBJECT_INTF: psz_object = "interface"; break;
case VLC_OBJECT_PLAYLIST: psz_object = "playlist"; break;
case VLC_OBJECT_ITEM: psz_object = "item"; break;
case VLC_OBJECT_INPUT: psz_object = "input"; break;
case VLC_OBJECT_DECODER: psz_object = "decoder"; break;
case VLC_OBJECT_PACKETIZER: psz_object = "packetizer"; break;
case VLC_OBJECT_ENCODER: psz_object = "encoder"; break;
case VLC_OBJECT_VOUT: psz_object = "video output"; break;
case VLC_OBJECT_AOUT: psz_object = "audio output"; break;
case VLC_OBJECT_SOUT: psz_object = "stream output"; break;
case VLC_OBJECT_HTTPD: psz_object = "http server"; break;
case VLC_OBJECT_HTTPD_HOST: psz_object = "http server"; break;
case VLC_OBJECT_DIALOGS: psz_object = "dialogs provider"; break;
case VLC_OBJECT_VLM: psz_object = "vlm"; break;
case VLC_OBJECT_ANNOUNCE: psz_object = "announce handler"; break;
case VLC_OBJECT_DEMUX: psz_object = "demuxer"; break;
case VLC_OBJECT_ACCESS: psz_object = "access"; break;
}
psz_object = msg_GetObjectTypeName(p_item->i_object_type);
#ifdef UNDER_CE
# define CE_WRITE(str) WriteFile( p_this->p_libvlc->msg_bank.pp_queues[MSG_QUEUE_NORMAL]->logfile, \
......
......@@ -206,6 +206,8 @@ while test $# -gt 0; do
;;
mozilla)
;;
pic)
;;
external)
echo_external=yes
ldflags="${ldflags} -lvlc"
......
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