1 /*****************************************************************************
2 * profile_parser.c : VLC Streaming Profile parser
3 *****************************************************************************
4 * Copyright (C) 2003-2006 the VideoLAN team
7 * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8 * Gildas Bazin <gbazin@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_stream.h>
30 #include <vlc_streaming.h>
33 /*****************************************************************************
35 *****************************************************************************/
36 static int Open ( vlc_object_t * );
39 set_capability( "profile parser", 1 );
40 set_callbacks( Open, NULL );
43 static int Open( vlc_object_t *p_this )
45 profile_parser_t *p_parser = (profile_parser_t *)p_this->p_private;
46 stream_t *p_stream = stream_UrlNew( p_this, p_parser->psz_profile );
48 xml_reader_t *p_reader;
50 char *psz_elname = NULL;
52 /* Open the profile and get a XML reader from it */
55 msg_Err( p_this, "failed to parse profile %s", p_parser->psz_profile );
58 p_xml = xml_Create( p_this );
59 if( !p_xml ) return VLC_EGENERIC;
60 p_reader = xml_ReaderCreate( p_xml, p_stream );
62 if( xml_ReaderRead( p_reader ) != 1 ||
63 xml_ReaderNodeType( p_reader ) != XML_READER_STARTELEM )
65 msg_Err( p_this, "invalid file (invalid root)" );
69 /* Here goes the real parsing */
71 while( (i_ret = xml_ReaderRead( p_reader ) ) == 1 )
73 int i_type = xml_ReaderNodeType( p_reader );
77 /* ERROR : Bail out */
80 case XML_READER_STARTELEM:
82 psz_elname = xml_ReaderName( p_reader );
83 if( !psz_elname ) return VLC_EGENERIC;
84 printf( "<%s", psz_elname );
89 case XML_READER_ENDELEM:
91 psz_elname = xml_ReaderName( p_reader );
92 if( !psz_elname ) return VLC_EGENERIC;
100 msg_Err( p_this, "parse error" );
104 if( p_reader ) xml_ReaderDelete( p_xml, p_reader );
105 if( p_xml ) xml_Delete( p_xml );