*
* 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.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <stdlib.h> /* malloc(), free() */
-
#include <vlc/vlc.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
+#include <vlc_demux.h>
+#include <vlc_interface.h>
+#include <vlc_charset.h>
#include "playlist.h"
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
int i_peek;
- char *psz_ext;
vlc_bool_t b_valid = VLC_FALSE;
- psz_ext = strrchr ( p_demux->psz_path, '.' );
-
- if( !( psz_ext && !strncasecmp( psz_ext, ".conf", 5 ) ) &&
- !p_demux->b_force ) return VLC_EGENERIC;
+ if( !demux2_IsPathExtension( p_demux, ".conf" ) && !p_demux->b_force )
+ return VLC_EGENERIC;
/* Check if this really is a channels file */
if( (i_peek = stream_Peek( p_demux->s, &p_peek, 1024 )) > 0 )
if( !b_valid ) return VLC_EGENERIC;
msg_Dbg( p_demux, "found valid DVB conf playlist file");
-
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
*****************************************************************************/
static int Demux( demux_t *p_demux )
{
- playlist_t *p_playlist;
char *psz_line;
- playlist_item_t *p_current;
- vlc_bool_t b_play;
-
- p_playlist = (playlist_t *) vlc_object_find( p_demux, VLC_OBJECT_PLAYLIST,
- FIND_PARENT );
- if( !p_playlist )
- {
- msg_Err( p_demux, "can't find playlist" );
- return -1;
- }
-
- b_play = E_(FindItem)( p_demux, p_playlist, &p_current );
-
- playlist_ItemToNode( p_playlist, p_current );
- p_current->input.i_type = ITEM_TYPE_PLAYLIST;
+ input_item_t *p_input;
+ INIT_PLAYLIST_STUFF;
while( (psz_line = stream_ReadLine( p_demux->s )) )
{
- playlist_item_t *p_item;
char **ppsz_options = NULL;
int i, i_options = 0;
char *psz_name = NULL;
EnsureUTF8( psz_name );
- p_item = playlist_ItemNew( p_playlist, "dvb:", psz_name );
+ p_input = input_ItemNewExt( p_playlist, "dvb:", psz_name, 0, NULL, -1 );
for( i = 0; i< i_options; i++ )
{
EnsureUTF8( ppsz_options[i] );
- playlist_ItemAddOption( p_item, ppsz_options[i] );
+ input_ItemAddOption( p_input, ppsz_options[i] );
}
- playlist_NodeAddItem( p_playlist, p_item,
- p_current->pp_parents[0]->i_view,
- p_current, PLAYLIST_APPEND, PLAYLIST_END );
-
- /* We need to declare the parents of the node as the
- * * same of the parent's ones */
- playlist_CopyParents( p_current, p_item );
- vlc_input_item_CopyOptions( &p_current->input, &p_item->input );
+ input_ItemAddSubItem( p_current_input, p_input );
while( i_options-- ) free( ppsz_options[i_options] );
if( ppsz_options ) free( ppsz_options );
free( psz_line );
}
- /* Go back and play the playlist */
- if( b_play && p_playlist->status.p_item &&
- p_playlist->status.p_item->i_children > 0 )
- {
- playlist_Control( p_playlist, PLAYLIST_VIEWPLAY,
- p_playlist->status.i_view,
- p_playlist->status.p_item,
- p_playlist->status.p_item->pp_children[0] );
- }
-
- vlc_object_release( p_playlist );
- return VLC_SUCCESS;
+ HANDLE_PLAY_AND_RELEASE;
+ return -1; /* Needed for correct operation of go back */
}
static struct
{
- char *psz_name;
- char *psz_option;
+ const char *psz_name;
+ const char *psz_option;
} dvb_options[] =
{
while( psz_parse )
{
- char *psz_option = 0;
+ const char *psz_option = 0;
char *psz_end = strchr( psz_parse, ':' );
if( psz_end ) { *psz_end = 0; psz_end++; }
if( psz_option && pppsz_options && pi_options )
{
- psz_option = strdup( psz_option );
- INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options),
- psz_option );
+ char *psz_dup = strdup( psz_option );
+ if (psz_dup != NULL)
+ INSERT_ELEM( *pppsz_options, (*pi_options), (*pi_options),
+ psz_dup );
}
psz_parse = psz_end;