Commit 86e5f20a authored by Clément Stenac's avatar Clément Stenac

* modules/demux/playlist : native playlist import

* modules/misc/playlist : native playlist export
* configure.ac : playlist and export need libxml2
parent e94ac636
......@@ -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 playlist export sgimb])
AX_ADD_PLUGINS([id3 m3u 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,6 +2903,48 @@ 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
......@@ -2935,32 +2977,7 @@ if test "${enable_skins2}" = "yes" || (test "${SYS}" != "darwin" && test "${SYS}
fi
fi
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
LDFLAGS="${LDFLAGS_save} ${LDFLAGS_skins2}"
if test "${skins2_missing_lib}" = "no" && (test "${SYS}" = "mingw32" -o "${SYS}" = "cygwin"); then
AX_ADD_PLUGINS([skins2])
......
......@@ -2,7 +2,7 @@
* m3u.c: a meta demux to parse pls, m3u, asx et b4s playlists
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
* $Id: m3u.c,v 1.26 2004/01/25 20:05:28 hartman Exp $
* $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* Gildas Bazin <gbazin@netcourrier.com>
......@@ -155,10 +155,12 @@ static int Activate( vlc_object_t * p_this )
{
i_type2 = TYPE_ASX;
}
#if 0
else if ( !strncasecmp( p_peek, "<?xml", sizeof("<?xml") -1 ) )
{
i_type2 = TYPE_B4S;
}
#endif
}
}
if ( i_type == TYPE_UNKNOWN && i_type2 == TYPE_UNKNOWN)
......
......@@ -2,4 +2,5 @@ SOURCES_playlist = playlist.c \
playlist.h \
old.c \
m3u.c \
native.c \
pls.c
This diff is collapsed.
......@@ -2,7 +2,7 @@
* playlist.c : Playlist import module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: playlist.c,v 1.5 2004/02/13 23:54:42 gbazin Exp $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -40,6 +40,12 @@ 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" );
......
......@@ -2,7 +2,7 @@
* playlist.h: Playlist import module common functions
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: playlist.h,v 1.1 2004/01/11 17:46:58 sigmunau Exp $
* $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
......@@ -26,6 +26,9 @@ 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 * );
void Close_PLS ( vlc_object_t * );
......@@ -591,7 +591,8 @@ void Playlist::OnSave( wxCommandEvent& WXUNUSED(event) )
char *psz_desc;
char *psz_filter;
char *psz_module;
} formats[] = {{ _("M3U file"), "*.m3u", "export-m3u" },
} formats[] = {{ _("Native VLC playlist"), "*.vlp", "export-native" },
{ _("M3U file"), "*.m3u", "export-m3u" },
{ _("PLS file"), "*.pls", "export-pls" }};
wxString filter = wxT("");
......
......@@ -2,7 +2,7 @@
* native.c : Native playlist export module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* $Id: native.c,v 1.2 2004/02/22 15:52:33 zorglub Exp $
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
*
......@@ -31,10 +31,15 @@
#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
......@@ -42,7 +47,203 @@ int Export_Native ( vlc_object_t * );
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");
return VLC_SUCCESS;
/* 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 );
/* Start the document */
i_ret = xmlTextWriterStartDocument(p_writer, NULL, ENCODING, NULL);
if (i_ret < 0)
{
return VLC_EGENERIC;
}
i_ret = xmlTextWriterStartElement( p_writer, BAD_CAST "playlist");
if (i_ret < 0)
{
msg_Dbg( p_playlist, "Unable to write root node");
return VLC_EGENERIC;
}
for( i = 0; i< p_playlist->i_size ; i++)
{
playlist_item_t *p_item= p_playlist->pp_items[i];
char *psz_utf8 = NULL;
i_ret = xmlTextWriterStartElement( p_writer, BAD_CAST "item");
/* Write item attributes */
psz_utf8 = ToUTF8( p_item->input.psz_uri );
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer, "uri",
psz_utf8 );
free( psz_utf8 );
psz_utf8 = ToUTF8( p_item->input.psz_name );
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer, "name",
psz_utf8 );
free( psz_utf8 );
/* Write categories */
for( j = 0; j< p_item->input.i_categories ; j++ )
{
info_category_t *p_cat = p_item->input.pp_categories[j];
if( p_cat->i_infos > 0 )
{
i_ret = xmlTextWriterStartElement( p_writer,
"category" );
psz_utf8 = ToUTF8( p_cat->psz_name );
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer, "name",
psz_utf8 );
free( psz_utf8 );
for( k = 0; k< p_cat->i_infos; k++)
{
i_ret = xmlTextWriterStartElement( p_writer,"info" );
psz_utf8 = ToUTF8( p_cat->pp_infos[k]->psz_name);
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer,"name",
psz_utf8 );
free( psz_utf8 );
psz_utf8 = ToUTF8( p_cat->pp_infos[k]->psz_value);
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer,"value",
psz_utf8 );
free( psz_utf8 );
i_ret = xmlTextWriterEndElement( p_writer );
}
/* Finish category */
i_ret = xmlTextWriterEndElement( p_writer);
}
}
for( j = 0; j< p_item->input.i_options ; j++ )
{
i_ret = xmlTextWriterStartElement( p_writer,
"option" );
psz_utf8 = ToUTF8( p_item->input.ppsz_options[j] );
if( !psz_utf8 ) return VLC_EGENERIC;
i_ret = xmlTextWriterWriteAttribute( p_writer, "name",
psz_utf8 );
}
/* Finish item */
i_ret = xmlTextWriterEndElement( p_writer );
}
/* Finish playlist */
i_ret = xmlTextWriterEndElement( p_writer );
i_ret = xmlTextWriterEndDocument(p_writer);
xmlFreeTextWriter(p_writer);
fprintf( p_export->p_file, "%s", (const char *) p_buf->content);
#if 0
/* Write items */
for( i = 0; i< p_playlist->i_size ; i++)
{
playlist_item_t *p_item= p_playlist->pp_items[i];
ItemStripEntities( p_item );
fprintf( p_export->p_file," <item uri=\"%s\" name=\"%s\"",
p_item->psz_uri,
p_item->psz_name );
if( p_item->i_duration != -1 )
{
fprintf( p_export->p_file, "duration=\""I64Fi"\""
p_item->i_duration )
}
if( p_item->b_enabled != 1 )
{
fprintf( p_export->p_file," enabled=\"%i\"", p_item->b_enabled );
}
if( p_item->i_group != 1 )
{
fprintf( p_export->p_file,"group=\"%i\"", p_item->i_group );
}
if( p_item->i_played > 0 )
{
fprintf( p_export->p_file," played=\"%i\"",p_item->i_nb_played );
}
fprintf( p_export->p_file, ">\n" );
for( j = 0; j< p_item->i_categories ; j++ )
{
item_info_category_t *p_cat = p_item->pp_categories[j];
if( p_cat->i_infos > 0 )
{
fprintf( p_export->p_file," <category name=\"%s\">\n",
p_cat->psz_name);
for( k = 0; k< p_cat->i_infos; k++)
{
fprintf( p_export->p_file,
" <info name=\"%s\" value=\"%s\" />\n",
p_cat->pp_infos[k]->psz_name,
p_cat->pp_infos[k]->psz_value );
}
fprintf( p_export->p_file," </category>\n" );
}
}
for( j = 0; j< p_item->i_options ; j++ )
{
fprintf( p_export->p_file," <option name=\"%s\">\n",
p_item->ppsz_options[j]);
}
fprintf( p_export->p_file, " </item>\n");
}
/* Write groups */
for( i = 0; i< p_playlist->i_groups ; i++)
{
fprintf( p_export->p_file," <group name=\"%s\" id=\"%i\" />\n",
p_playlist->pp_groups[i]->psz_name,
p_playlist->pp_groups[i]->i_id );
}
/* Write footer */
fprintf( p_export->p_file,"</playlist>\n" );
#endif
return VLC_SUCCESS;
}
char *ToUTF8( char *psz_in )
{
int i_in = strlen( psz_in );
int i_out = 2*i_in + 1;
char *psz_out = (char *)malloc( sizeof(char) * i_out );
isolat1ToUTF8( psz_out, &i_out, psz_in, &i_in );
psz_out[ i_out ] = 0;
return psz_out;
}
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