Commit ad1fb879 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Further factoring out osdmenu parser functionality from osdmenu handling....

Further factoring out osdmenu parser functionality from osdmenu handling. Started a dummy modules/misc/osd/xml.c osdmenu parser.
parent e467dc83
...@@ -397,7 +397,7 @@ struct osd_menu_t ...@@ -397,7 +397,7 @@ struct osd_menu_t
osd_button_t *p_last_button; /*< pointer to last button in the list */ osd_button_t *p_last_button; /*< pointer to last button in the list */
/* misc parser */ /* misc parser */
module_t *p_module; /*< pointer to parser module */ module_t *p_parser; /*< pointer to parser module */
char *psz_file; /*< Config file name */ char *psz_file; /*< Config file name */
image_handler_t *p_image; /*< handler to image loading and conversion libraries */ image_handler_t *p_image; /*< handler to image loading and conversion libraries */
}; };
...@@ -598,15 +598,6 @@ VLC_EXPORT( void,osd_Message, ( spu_t *, int, char *, ... ) ATTRIBUTE_FORMAT( 3, ...@@ -598,15 +598,6 @@ VLC_EXPORT( void,osd_Message, ( spu_t *, int, char *, ... ) ATTRIBUTE_FORMAT( 3,
VLC_EXPORT( int, osd_Slider, ( vlc_object_t *, spu_t *, int, int, int, int, int, int, short ) ); VLC_EXPORT( int, osd_Slider, ( vlc_object_t *, spu_t *, int, int, int, int, int, int, short ) );
VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, int, int, short ) ); VLC_EXPORT( int, osd_Icon, ( vlc_object_t *, spu_t *, int, int, int, int, int, short ) );
/**
* Loading and parse the OSD Configuration file
*
* These functions load/unload the OSD menu configuration file and
* create/destroy the themable OSD menu structure on the OSD object.
*/
VLC_EXPORT( int, osd_ConfigLoader, ( vlc_object_t *, const char *, osd_menu_t ** ) );
VLC_EXPORT( void, osd_ConfigUnload, ( vlc_object_t *, osd_menu_t ** ) );
/** @} */ /** @} */
/********************************************************************** /**********************************************************************
......
SOURCES_osd_parser = \ SOURCES_osd_parser = \
parser.c \ parser.c \
simple.c \
osd_menu.c \ osd_menu.c \
osd_menu.h \ osd_menu.h \
simple.c \
xml.c \ xml.c \
$(NULL) $(NULL)
...@@ -38,11 +38,10 @@ ...@@ -38,11 +38,10 @@
/*************************************************************************** /***************************************************************************
* Prototypes * Prototypes
***************************************************************************/ ***************************************************************************/
int osd_parser_simpleOpen ( vlc_object_t *p_this ); int E_(osd_parser_simpleOpen) ( vlc_object_t *p_this );
void osd_parser_simpleClose( vlc_object_t *p_this ); int E_(osd_parser_xmlOpen) ( vlc_object_t *p_this );
int osd_parser_xmlOpen ( vlc_object_t *p_this ); static void osd_parser_Close( vlc_object_t *p_this );
void osd_parser_xmlClose ( vlc_object_t *p_this );
/***************************************************************************** /*****************************************************************************
* Module descriptor * Module descriptor
...@@ -56,12 +55,23 @@ vlc_module_begin(); ...@@ -56,12 +55,23 @@ vlc_module_begin();
set_description( _("OSD configuration importer") ); set_description( _("OSD configuration importer") );
add_shortcut( "import-osd" ); add_shortcut( "import-osd" );
set_capability( "osd parser" , 0); set_capability( "osd parser" , 0);
set_callbacks( osd_parser_simpleOpen, osd_parser_simpleClose ); set_callbacks( E_(osd_parser_simpleOpen), osd_parser_Close );
add_submodule(); add_submodule();
set_description( _("XML OSD configuration importer") ); set_description( _("XML OSD configuration importer") );
add_shortcut( "import-osd-xml" ); add_shortcut( "import-osd-xml" );
set_capability( "osd parser" , 0); set_capability( "osd parser" , 0);
set_callbacks( osd_parser_xmlOpen, osd_parser_xmlClose ); set_callbacks( E_(osd_parser_xmlOpen), osd_parser_Close );
vlc_module_end(); vlc_module_end();
/*****************************************************************************
* osd_parser_Close: Free all osd menu structure resources
*****************************************************************************/
void osd_parser_Close ( vlc_object_t *p_this )
{
osd_menu_t *p_menu = (osd_menu_t *) p_this;
if( p_menu )
osd_MenuFree( p_this, &p_menu );
}
...@@ -271,7 +271,6 @@ SOURCES_libvlc_common = \ ...@@ -271,7 +271,6 @@ SOURCES_libvlc_common = \
stream_output/sap.c \ stream_output/sap.c \
stream_output/sdp.c \ stream_output/sdp.c \
osd/osd.c \ osd/osd.c \
osd/osd_parser.c \
osd/osd_text.c \ osd/osd_text.c \
osd/osd_widgets.c \ osd/osd_widgets.c \
network/acl.c \ network/acl.c \
......
/***************************************************************************** /*****************************************************************************
* osd.c - The OSD Menu core code. * osd.c - The OSD Menu core code.
***************************************************************************** *****************************************************************************
* Copyright (C) 2005 M2X * Copyright (C) 2005-2007 M2X
* $Id$ * $Id$
* *
* Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl> * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
...@@ -41,6 +41,8 @@ static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * ...@@ -41,6 +41,8 @@ static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t *
static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int ); static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
static int osd_VolumeStep( vlc_object_t *, int, int ); static int osd_VolumeStep( vlc_object_t *, int, int );
static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ); static vlc_bool_t osd_isVisible( osd_menu_t *p_osd );
static int osd_ParserLoad( vlc_object_t *, const char *, osd_menu_t ** );
static void osd_ParserUnload( vlc_object_t *, osd_menu_t ** );
static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ) static vlc_bool_t osd_isVisible( osd_menu_t *p_osd )
{ {
...@@ -50,6 +52,72 @@ static vlc_bool_t osd_isVisible( osd_menu_t *p_osd ) ...@@ -50,6 +52,72 @@ static vlc_bool_t osd_isVisible( osd_menu_t *p_osd )
return val.b_bool; return val.b_bool;
} }
/*****************************************************************************
* Wrappers for loading and unloading osd parser modules.
*****************************************************************************/
static int osd_ParserLoad( vlc_object_t *p_this, const char *psz_file, osd_menu_t **pp_menu )
{
osd_menu_t *p_menu = *pp_menu;
if( pp_menu && p_menu ) return VLC_EGENERIC;
p_menu = vlc_object_create( p_this, VLC_OBJECT_OSDMENU );
if( !p_menu )
{
msg_Err( p_this, "out of memory" );
return VLC_ENOMEM;
}
vlc_object_attach( p_this, p_menu );
/* Stuff needed for Parser */
p_menu->psz_file = strdup( psz_file );
p_menu->p_image = image_HandlerCreate( p_this );
if( !p_menu->p_image || !p_menu->psz_file )
{
msg_Err( p_this, "unable to load images, aborting .." );
osd_ParserUnload( p_this, pp_menu );
return VLC_ENOMEM;
}
else
{
char *psz_type;
char *psz_ext = strrchr( p_menu->psz_file, '.' );
if( psz_ext && !strcmp( psz_ext, ".cfg") )
psz_type = "import-osd";
else
psz_type = "import-osd-xml";
p_menu->p_parser = module_Need( p_menu, "osd parser", psz_type, VLC_TRUE );
if( !p_menu->p_parser )
{
osd_ParserUnload( p_this, pp_menu );
return VLC_ENOOBJ;
}
}
return VLC_SUCCESS;
}
static void osd_ParserUnload( vlc_object_t *p_this, osd_menu_t **pp_menu )
{
osd_menu_t *p_menu = (osd_menu_t *) *pp_menu;
if( p_menu->p_parser )
{
module_Unneed( p_menu, p_menu->p_parser );
}
p_menu->p_parser = NULL;
if( p_menu->p_image )
image_HandlerDelete( p_menu->p_image );
if( p_menu->psz_file )
free( p_menu->psz_file );
vlc_object_detach( p_menu );
vlc_object_destroy( p_menu );
p_menu = NULL;
}
/***************************************************************************** /*****************************************************************************
* OSD menu Funtions * OSD menu Funtions
*****************************************************************************/ *****************************************************************************/
...@@ -70,22 +138,8 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file ) ...@@ -70,22 +138,8 @@ osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
{ {
vlc_value_t val; vlc_value_t val;
msg_Dbg( p_this, "creating OSD menu object" );
if( ( p_osd = vlc_object_create( p_this, VLC_OBJECT_OSDMENU ) ) == NULL )
{
msg_Err( p_this, "out of memory" );
vlc_mutex_unlock( lockval.p_address );
return NULL;
}
/* Stuff needed for Parser */
p_osd->p_image = image_HandlerCreate( p_this );
if( !p_osd->p_image )
msg_Err( p_this, "unable to load images" );
p_osd->psz_file = strdup( psz_file );
/* Parse configuration file */ /* Parse configuration file */
if( osd_ConfigLoader( p_this, psz_file, &p_osd ) ) if( osd_ParserLoad( p_this, psz_file, &p_osd ) )
goto error; goto error;
/* Setup default button (first button) */ /* Setup default button (first button) */
...@@ -154,16 +208,7 @@ void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd ) ...@@ -154,16 +208,7 @@ void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd )
var_Destroy( p_osd, "osd-menu-visible" ); var_Destroy( p_osd, "osd-menu-visible" );
var_Destroy( p_osd, "osd-menu-update" ); var_Destroy( p_osd, "osd-menu-update" );
osd_ConfigUnload( p_this, &p_osd ); osd_ParserUnload( p_this, &p_osd );
if( p_osd->p_image )
image_HandlerDelete( p_osd->p_image );
if( p_osd->psz_file )
free( p_osd->psz_file );
vlc_object_detach( p_osd );
vlc_object_destroy( p_osd );
p_osd = NULL;
vlc_mutex_unlock( lockval.p_address ); vlc_mutex_unlock( lockval.p_address );
} }
......
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