Commit eb22c298 authored by Clément Stenac's avatar Clément Stenac

Cancel

parent 86e5f20a
dnl Autoconf settings for vlc
dnl $Id$
AC_INIT(vlc,0.7.2-cvs)
CONFIGURE_LINE="$0 $*"
......@@ -892,7 +892,7 @@ AX_ADD_PLUGINS([trivial_channel_mixer headphone_channel_mixer])
AX_ADD_PLUGINS([trivial_mixer spdif_mixer float32_mixer])
AX_ADD_PLUGINS([aout_file])
AX_ADD_PLUGINS([i420_rgb i420_yuy2 i422_yuy2 i420_ymga])
AX_ADD_PLUGINS([id3 m3u sgimb])
AX_ADD_PLUGINS([id3 m3u playlist export sgimb])
AX_ADD_PLUGINS([rawvideo])
AX_ADD_PLUGINS([wav araw demuxdump demuxsub adpcm a52sys dtssys au])
AX_ADD_PLUGINS([access_file access_udp access_tcp access_http ipv4 access_mms])
......@@ -2903,48 +2903,6 @@ if test "${enable_skins}" != "no"; then
fi fi
fi
dnl
dnl libxml2
dnl
XML2_PATH="${PATH}"
AC_ARG_WITH(xml2-config-path,
[ --with-xml2-config-path=PATH xml2-config path (default search in \$PATH)],
[ if test "${with_xml2_config_path}" != "no"; then
XML2_PATH="${with_xml2_config_path}:${PATH}"
fi ])
AC_PATH_PROG(XML2_CONFIG, xml2-config, no, ${XML2_PATH})
AC_MSG_WARN([trucmuche0])
if test "${XML2_CONFIG}" != "no"; then
AC_MSG_WARN([trucmuche2])
AX_ADD_CPPFLAGS([skins2],[`${XML2_CONFIG} --cflags`])
AX_ADD_CFLAGS([playlist export],[`${XML2_CONFIG} --cflags`])
AX_ADD_LDFLAGS([skins2 playlist export],[`${XML2_CONFIG} --libs`])
AC_MSG_WARN([trucmuche3])
dnl skins2 and playlist depend on the xmlTextReader extension
AC_CHECK_LIB(xml2,xmlTextReaderConstName,
[ AC_MSG_WARN([trucmuche4])
AX_ADD_PLUGINS([playlist export])],
[
skins2_missing_lib="yes"
AC_MSG_WARN([trucmuche5])
AC_MSG_WARN([libxml2 missing the xmlTextReader extension, you should update your version])
AC_MSG_WARN([You will not be able to import/export playlists])
if test "${enable_skins2}" = "yes"; then
AC_MSG_WARN([trucmuche6])
AC_MSG_ERROR([libxml2 missing the xmlTextReader extension (required for skins2)])
fi])
else
skins2_missing_lib="yes"
AC_MSG_ERROR([Could not find libxml2. You will not be able to import/export playlists])
if test "${enable_skins2}" = "yes"; then
AC_MSG_ERROR([Could not find libxml2 (required for skins2)])
fi
fi
dnl
dnl Skins2 module
dnl
......@@ -2977,7 +2935,32 @@ if test "${enable_skins2}" = "yes" || (test "${SYS}" != "darwin" && test "${SYS}
fi
fi
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_skins2}"
dnl libxml2
XML2_PATH="${PATH}"
AC_ARG_WITH(xml2-config-path,
[ --with-xml2-config-path=PATH xml2-config path (default search in \$PATH)],
[ if test "${with_xml2_config_path}" != "no"; then
XML2_PATH="${with_xml2_config_path}:${PATH}"
fi ])
AC_PATH_PROG(XML2_CONFIG, xml2-config, no, ${XML2_PATH})
if test "${XML2_CONFIG}" != "no"; then
AX_ADD_CPPFLAGS([skins2],[`${XML2_CONFIG} --cflags`])
AX_ADD_LDFLAGS([skins2],[`${XML2_CONFIG} --libs`])
dnl skins2 depends on the xmlTextReader extension
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_skins2}"
AC_CHECK_LIB(xml2,xmlTextReaderConstName,[],[
skins2_missing_lib="yes"
AC_MSG_WARN([libxml2 missing the xmlTextReader extension, you should update your version])
if test "${enable_skins2}" = "yes"; then
AC_MSG_ERROR([libxml2 missing the xmlTextReader extension (required for skins2)])
fi])
LDFLAGS="${LDFLAGS_save}"
else
skins2_missing_lib="yes"
if test "${enable_skins2}" = "yes"; then
AC_MSG_ERROR([Could not find libxml2 (required for skins2)])
fi
fi
if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"); then
AX_ADD_PLUGINS([skins2])
......
......@@ -2,5 +2,4 @@ SOURCES_playlist = playlist.c \
playlist.h \
old.c \
m3u.c \
native.c \
pls.c
/*****************************************************************************
* native.c : Native playlist format import
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: old.c 6961 2004-03-05 17:34:23Z sam $
*
* Authors: Clment Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include <libxml/xmlreader.h>
#include <libxml/encoding.h>
#define HEADER "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<playlist"
#define CHUNK_SIZE 256
typedef struct attribute_s {
xmlChar *pxsz_attrname;
xmlChar *pxsz_attrvalue;
} attribute_t;
struct demux_sys_t
{
/* Playlist elements */
playlist_t *p_playlist;
playlist_item_t *p_item;
char *psz_category;
/* XML Parsing elements */
xmlChar *pxsz_elemname;
xmlChar *pxsz_attrname;
xmlChar *pxsz_attrvalue;
int i_attributes;
attribute_t **pp_attributes;
};
/*****************************************************************************
* Local prototypes
*****************************************************************************/
int Import_Native ( vlc_object_t * );
int HandleBeginningElement( demux_t *p_demux );
int HandleEndingElement( demux_t *p_demux );
char *SearchAttribute( int i_attribute,attribute_t **pp_attributes,
char *psz_name );
static int Demux( demux_t *p_demux);
static int Control( demux_t *p_demux, int i_query, va_list args );
/*****************************************************************************
* Import_Native : main import function
*****************************************************************************/
int Import_Native(vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys = (demux_sys_t *)malloc( sizeof( demux_sys_t ) );
p_demux->p_sys = p_sys;
uint8_t *p_peek;
if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
{
msg_Err( p_demux, "cannot peek" );
return VLC_EGENERIC;
}
if( strncmp( p_peek, HEADER , 40 ) )
{
msg_Warn(p_demux, "native import module discarded: invalid file");
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "found valid native playlist file");
p_sys->p_playlist = (playlist_t*)vlc_object_find( p_demux,
VLC_OBJECT_PLAYLIST, FIND_PARENT );
if( !p_sys->p_playlist )
{
msg_Err( p_demux, "cannot attach playlist" );
return VLC_EGENERIC;
}
p_sys->p_playlist->pp_items[p_sys->p_playlist->i_index]->b_autodeletion =
VLC_TRUE;
p_sys->p_item = NULL;
p_sys->psz_category = NULL;
p_sys->pp_attributes = NULL;
p_sys->i_attributes = 0;
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
return VLC_SUCCESS;
}
void Close_Native( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
if( p_sys )
{
if( p_sys->psz_category != NULL ) free( p_sys->psz_category );
if( p_sys->pxsz_elemname != NULL) free( p_sys->pxsz_elemname );
if( p_sys->p_playlist )
{
vlc_object_release( p_sys->p_playlist );
}
free( p_sys );
}
}
static int Demux( demux_t *p_demux)
{
char *psz_file=(char *)malloc( sizeof( char ) );
int i_size = 0;
int i_ret, i;
xmlTextReaderPtr p_reader;
uint8_t p_peek[CHUNK_SIZE];
demux_sys_t *p_sys = p_demux->p_sys;
msg_Dbg( p_demux, "building playlist string" );
/* Build the string containing the playlist */
while( 1 )
{
i_ret = stream_Read( p_demux->s, p_peek, CHUNK_SIZE );
i_size+= i_ret;
psz_file = (char *)realloc( psz_file, i_size + 1242 );
memcpy( psz_file + i_size - i_ret, p_peek, CHUNK_SIZE );
if( i_ret < CHUNK_SIZE )
{
break;
}
}
psz_file[i_size]=0;
msg_Dbg( p_demux, "parsing playlist");
/* Create the XML parser */
p_reader = xmlReaderForMemory( psz_file, i_size, NULL, "UTF-8", 0 );
if( !p_reader )
{
msg_Warn( p_demux, "Unable to parse");
return VLC_EGENERIC;
}
i_ret = xmlTextReaderRead( p_reader );
/* Start the main parsing loop */
while( i_ret == 1)
{
int i_type = xmlTextReaderNodeType( p_reader );
switch( i_type )
{
/* -1 = error */
case -1:
return VLC_EGENERIC;
break;
/* 1 = Beginning of an element */
case 1:
{
/* Clean attributes of previous element */
for(i = 0 ; i < p_sys->i_attributes ; i++ )
{
if( p_sys->pp_attributes[i]->pxsz_attrname )
{
free( p_sys->pp_attributes[i]->pxsz_attrname );
}
if( p_sys->pp_attributes[i]->pxsz_attrvalue )
{
free( p_sys->pp_attributes[i]->pxsz_attrvalue );
}
free( p_sys->pp_attributes[i] );
}
p_sys->i_attributes = 0;
p_sys->pp_attributes = NULL;
p_sys->pxsz_elemname = xmlTextReaderName( p_reader );
if( !p_sys->pxsz_elemname )
{
return VLC_EGENERIC;
}
/* Get all attributes */
while( xmlTextReaderMoveToNextAttribute( p_reader ) == 1 )
{
attribute_t *p_attribute =
(attribute_t *)malloc( sizeof(attribute_t) );
p_attribute->pxsz_attrname = xmlTextReaderName( p_reader );
p_attribute->pxsz_attrvalue = xmlTextReaderValue( p_reader );
if( !p_attribute->pxsz_attrname ||
!p_attribute->pxsz_attrvalue )
{
return VLC_EGENERIC;
}
INSERT_ELEM( p_sys->pp_attributes,
p_sys->i_attributes,
p_sys->i_attributes,
p_attribute );
}
HandleBeginningElement( p_demux );
break;
}
/* 15 = End of an element */
case 15:
p_sys->pxsz_elemname = xmlTextReaderName( p_reader );
if( !p_sys->pxsz_elemname )
{
return VLC_EGENERIC;
}
HandleEndingElement( p_demux );
break;
}
i_ret= xmlTextReaderRead( p_reader );
}
if( p_sys->p_item )
{
/* We still have an item. Add it */
playlist_AddItem( p_sys->p_playlist, p_sys->p_item,
PLAYLIST_APPEND, PLAYLIST_END );
p_sys->p_item = NULL;
}
p_demux->b_die = VLC_TRUE;
return VLC_SUCCESS;
}
static int Control( demux_t *p_demux, int i_query, va_list args )
{
return VLC_EGENERIC;
}
int HandleBeginningElement( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
if( !strcmp( p_sys->pxsz_elemname, "item" ) )
{
char *psz_uri,*psz_name,*psz_duration;
if( p_sys->p_item )
{
/* We already have an item. Assume that it is because
* we have <item name="" uri="" /> */
playlist_AddItem( p_sys->p_playlist, p_sys->p_item,
PLAYLIST_APPEND, PLAYLIST_END );
p_sys->p_item = NULL;
}
psz_uri = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes, "uri" );
psz_name = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes, "name" );
psz_duration = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes, "duration");
if( !psz_uri )
{
return VLC_EGENERIC;
}
p_sys->p_item = playlist_ItemNew( p_sys->p_playlist ,
psz_uri, psz_name );
}
else if( !strcmp( p_sys->pxsz_elemname, "category" ) )
{
if( !p_sys->p_item)
{
msg_Warn( p_demux, "trying to set category without item" );
return VLC_EGENERIC;
}
p_sys->psz_category = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes,
"name" );
}
else if( !strcmp( p_sys->pxsz_elemname, "info" ) )
{
char *psz_name, *psz_value;
if( !p_sys->psz_category || !p_sys->p_item )
{
msg_Warn( p_demux, "trying to set info without item or category" );
}
psz_name = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes,
"name" );
psz_value = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes,
"value" );
playlist_ItemAddInfo( p_sys->p_item, p_sys->psz_category,
psz_name, psz_value );
}
else if( !strcmp( p_sys->pxsz_elemname, "option" ) )
{
char *psz_name;
if( !p_sys->p_item )
{
msg_Warn( p_demux, "trying to set category without item" );
return VLC_EGENERIC;
}
psz_name = SearchAttribute( p_sys->i_attributes,
p_sys->pp_attributes,
"name" );
if( psz_name )
{
playlist_ItemAddOption( p_sys->p_item, psz_name );
}
}
return VLC_SUCCESS;
}
int HandleEndingElement( demux_t *p_demux )
{
int i;
demux_sys_t *p_sys = p_demux->p_sys;
if( !strcmp( p_sys->pxsz_elemname, "item" ) )
{
/* Add the item to the playlist */
if( p_sys->p_item )
{
playlist_AddItem( p_sys->p_playlist, p_sys->p_item,
PLAYLIST_APPEND, PLAYLIST_END );
p_sys->p_item = NULL;
}
}
else if (!strcmp( p_sys->pxsz_elemname, "category" ) )
{
p_sys->psz_category = NULL;
}
/* Clear attribute list */
for(i = 0 ; i < p_sys->i_attributes ; i++ )
{
if( p_sys->pp_attributes[i]->pxsz_attrname )
{
free( p_sys->pp_attributes[i]->pxsz_attrname );
}
if( p_sys->pp_attributes[i]->pxsz_attrvalue )
{
free( p_sys->pp_attributes[i]->pxsz_attrvalue );
}
free( p_sys->pp_attributes[i] );
}
p_sys->i_attributes = 0;
return VLC_SUCCESS;
}
char *SearchAttribute( int i_attribute,attribute_t **pp_attributes, char *psz_name )
{
int i, i_size, i_iso_size, i_read;
char *psz_iso, *psz_value;
for( i = 0 ; i < i_attribute ; i++ )
{
if( !strcmp( (char *)pp_attributes[i]->pxsz_attrname , psz_name ) )
{
psz_value = (char *)pp_attributes[i]->pxsz_attrvalue;
i_size = sizeof( char ) * strlen(psz_value);
i_iso_size = 2*i_size + 1;
psz_iso = (char *)malloc( sizeof(char) * i_iso_size );
i_read = UTF8Toisolat1( psz_iso, &i_iso_size, psz_value, &i_size) ;
psz_iso[i_iso_size ]=0;
return psz_iso;
}
}
return NULL;
}
......@@ -40,12 +40,6 @@ vlc_module_begin();
set_capability( "demux2" , 10 );
set_callbacks( Import_Old , NULL );
add_submodule();
set_description( _("Native playlist import") );
add_shortcut( "playlist" );
add_shortcut( "native-open" );
set_capability( "demux2" , 10 );
set_callbacks( Import_Native , Close_Native );
add_submodule();
set_description( _("M3U playlist import") );
add_shortcut( "m3u-open" );
......
......@@ -26,8 +26,6 @@ char *FindPrefix( demux_t * );
int Import_Old ( vlc_object_t * );
int Import_M3U ( vlc_object_t * );
int Import_Native ( vlc_object_t * );
int Close_Native ( vlc_object_t * );
void Close_M3U ( vlc_object_t * );
int Import_PLS ( vlc_object_t * );
......
......@@ -591,8 +591,7 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
char *psz_desc;
char *psz_filter;
char *psz_module;
} formats[] = {{ _("Native VLC playlist"), "*.vlp", "export-native" },
{ _("M3U file"), "*.m3u", "export-m3u" },
} formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
{ _("PLS file"), "*.pls", "export-pls" }};
wxString filter = wxT("");
......
SOURCES_export = export.c \
native.c \
m3u.c \
old.c
......@@ -2,7 +2,7 @@
* export.c : Playlist export module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: export.c,v 1.2 2004/02/22 15:52:33 zorglub Exp $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -29,7 +29,6 @@
/***************************************************************************
* Prototypes
***************************************************************************/
int Export_Native ( vlc_object_t *p_intf );
int Export_M3U ( vlc_object_t *p_intf );
int Export_Old ( vlc_object_t *p_intf );
......@@ -39,12 +38,6 @@ int Export_Old ( vlc_object_t *p_intf );
*****************************************************************************/
vlc_module_begin();
add_submodule();
set_description( _("Native playlist exporter") );
add_shortcut( "export-native" );
set_capability( "playlist export" , 0 );
set_callbacks( Export_Native , NULL );
add_submodule();
set_description( _("M3U playlist exporter") );
add_shortcut( "export-m3u" );
......
/*****************************************************************************
* native.c : Native playlist export module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id$
*
* Authors: Clment Stenac <zorglub@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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include <libxml/xmlwriter.h>
#include <libxml/encoding.h>
#define ENCODING "UTF-8"
/*****************************************************************************
* Local prototypes
*****************************************************************************/
int Export_Native ( vlc_object_t * );
char *ToUTF8( char *);
/*****************************************************************************
* Native: main export function
*****************************************************************************/
int Export_Native( vlc_object_t *p_this )
{
playlist_t *p_playlist = (playlist_t*)p_this;
playlist_export_t *p_export = (playlist_export_t *)p_playlist->p_private;
int i,j,k;
char *psz_name="VLC Playlist";
int i_version = 1;
int i_ret;
xmlTextWriterPtr p_writer;
xmlBufferPtr p_buf;
xmlChar *tmp;
msg_Dbg(p_playlist, "Saving using native format");
/* Create a new XmlWriter */
p_buf = xmlBufferCreate();
if ( !p_buf )
{
msg_Warn( p_playlist, "Unable to create XML buffer" );
return VLC_EGENERIC;
}
/* Create a new XmlWriter */
p_writer = xmlNewTextWriterMemory( p_buf, 0);
if ( !p_writer)
{
msg_Dbg( p_playlist, "Unable to create XML writer" );
return VLC_EGENERIC;
}
/* Make a beautiful output */
i_ret = xmlTextWriterSetIndent( p_writer, 1 );