Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
eb22c298
Commit
eb22c298
authored
Apr 01, 2004
by
Clément Stenac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cancel
parent
86e5f20a
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
30 additions
and
708 deletions
+30
-708
configure.ac
configure.ac
+28
-45
modules/demux/playlist/Modules.am
modules/demux/playlist/Modules.am
+0
-1
modules/demux/playlist/native.c
modules/demux/playlist/native.c
+0
-394
modules/demux/playlist/playlist.c
modules/demux/playlist/playlist.c
+0
-6
modules/demux/playlist/playlist.h
modules/demux/playlist/playlist.h
+0
-2
modules/gui/wxwindows/playlist.cpp
modules/gui/wxwindows/playlist.cpp
+1
-2
modules/misc/playlist/Modules.am
modules/misc/playlist/Modules.am
+0
-1
modules/misc/playlist/export.c
modules/misc/playlist/export.c
+1
-8
modules/misc/playlist/native.c
modules/misc/playlist/native.c
+0
-249
No files found.
configure.ac
View file @
eb22c298
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])
...
...
modules/demux/playlist/Modules.am
View file @
eb22c298
...
...
@@ -2,5 +2,4 @@ SOURCES_playlist = playlist.c \
playlist.h \
old.c \
m3u.c \
native.c \
pls.c
modules/demux/playlist/native.c
deleted
100644 → 0
View file @
86e5f20a
/*****************************************************************************
* 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
;
}
modules/demux/playlist/playlist.c
View file @
eb22c298
...
...
@@ -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"
);
...
...
modules/demux/playlist/playlist.h
View file @
eb22c298
...
...
@@ -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
*
);
...
...
modules/gui/wxwindows/playlist.cpp
View file @
eb22c298
...
...
@@ -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
(
""
);
...
...
modules/misc/playlist/Modules.am
View file @
eb22c298
SOURCES_export = export.c \
native.c \
m3u.c \
old.c
modules/misc/playlist/export.c
View file @
eb22c298
...
...
@@ -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"
);
...
...
modules/misc/playlist/native.c
deleted
100644 → 0
View file @
86e5f20a
/*****************************************************************************
* 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
);
/* 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
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment