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

Add a bunch of helper functions/macros and start using them:

* malloc with NULL check
* file extension check
* check if a demux was forced
* try peeking, and check what we poke
* init standard demuxer fields
* create packetizers
parent 50a87715
......@@ -596,6 +596,20 @@ static int64_t GCD( int64_t a, int64_t b )
else return a;
}
/* Malloc with automatic error */
#define MALLOC_VOID( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return; }
#define MALLOC_NULL( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return NULL; }
#define MALLOC_ERR( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) return VLC_ENOMEM; }
#define MALLOC_GOTOERR( var, type ) { var = (type*)malloc( sizeof( type) ); \
if( !var ) goto error; }
#define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return;
#define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\
if( !var ) return NULL;
/* Dynamic array handling: realloc array, move data, increment position */
#if defined( _MSC_VER ) && _MSC_VER < 1300 && !defined( UNDER_CE )
# define VLCCVP (void**) /* Work-around for broken compiler */
......
......@@ -132,6 +132,97 @@ static inline int demux2_Control( demux_t *p_demux, int i_query, ... )
va_end( args );
return i_result;
}
/*************************************************************************
* Miscellaneous helpers for demuxers
*************************************************************************/
static inline vlc_bool_t isExtension( demux_t *p_demux, char *psz_requested )
{
char *psz_ext;
psz_ext = strrchr ( p_demux->psz_path, '.' );
if( !psz_ext || strcmp( psz_ext, psz_requested ) )
return VLC_FALSE;
return VLC_TRUE;
}
static inline vlc_bool_t isDemux( demux_t *p_demux, char *psz_requested )
{
if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, psz_requested ) )
return VLC_FALSE;
return VLC_TRUE;
}
#define STANDARD_DEMUX_INIT \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
MALLOC_ERR( p_demux->p_sys, demux_sys_t );
#define STANDARD_DEMUX_INIT_MSG( msg ) \
p_demux->pf_control = Control; \
p_demux->pf_demux = Demux; \
MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
msg_Dbg( p_demux, msg ); \
#define DEMUX_BY_EXTENSION( ext ) \
demux_t *p_demux = (demux_t *)p_this; \
if( !isExtension( p_demux, ext ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT;
#define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
demux_t *p_demux = (demux_t *)p_this; \
if( !isExtension( p_demux, ext ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT_MSG( msg );
#define DEMUX_BY_EXTENSION_OR_FORCED( ext, module ) \
demux_t *p_demux = (demux_t *)p_this; \
if( !isExtension( p_demux, ext ) && !isDemux( p_demux, module ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT;
#define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
demux_t *p_demux = (demux_t *)p_this; \
if( !isExtension( p_demux, ext ) && !isDemux( p_demux, module ) ) \
return VLC_EGENERIC; \
STANDARD_DEMUX_INIT_MSG( msg );
#define CHECK_PEEK( zepeek, size ) \
if( stream_Peek( p_demux->s , &zepeek, size ) < size ){ \
msg_Dbg( p_demux, "not enough data" ); return VLC_EGENERIC; }
#define CHECK_PEEK_GOTO( zepeek, size ) \
if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \
msg_Dbg( p_demux, "not enough data" ); goto error; }
#define CHECK_DISCARD_PEEK( size ) { uint8_t *p_peek; \
if( stream_Peek( p_demux->s , &p_peek, size ) < size ) return VLC_EGENERIC;}
#define POKE( peek, stuff, size ) (strncasecmp( (char *)peek, stuff, size )==0)
#define CREATE_PACKETIZER( a,b,c,d ) \
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER ); \
p_sys->p_packetizer->pf_decode_audio = 0; \
p_sys->p_packetizer->pf_decode_video = 0; \
p_sys->p_packetizer->pf_decode_sub = 0; \
p_sys->p_packetizer->pf_packetize = 0; \
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES, \
VLC_FOURCC( a, b, c, d ) );
/* BEWARE ! This can lead to memory leaks ! */
#define LOAD_PACKETIZER_OR_FAIL( msg ) \
p_sys->p_packetizer->p_module = \
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 ); \
\
if( p_sys->p_packetizer->p_module == NULL ) \
{ \
vlc_object_destroy( p_sys->p_packetizer ); \
msg_Err( p_demux, "cannot find packetizer for " # msg ); \
free( p_sys ); \
return VLC_EGENERIC; \
}
/**
* @}
*/
......
......@@ -125,13 +125,7 @@ static int Open( vlc_object_t * p_this )
}
/* Have a peep at the show. */
if( stream_Peek( p_demux->s, &p_peek, i_peek + A52_MAX_HEADER_SIZE * 2 ) <
i_peek + A52_MAX_HEADER_SIZE * 2 )
{
/* Stream too short */
msg_Warn( p_demux, "cannot peek()" );
return VLC_EGENERIC;
}
CHECK_PEEK( p_peek, i_peek + A52_MAX_HEADER_SIZE * 2 );
if( CheckSync( p_peek + i_peek, &b_big_endian ) != VLC_SUCCESS )
{
......@@ -146,16 +140,12 @@ static int Open( vlc_object_t * p_this )
}
/* Fill p_demux fields */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
p_sys->b_start = VLC_TRUE;
p_sys->i_mux_rate = 0;
p_sys->b_big_endian = b_big_endian;
/*
* Load the A52 packetizer
*/
/* Load the A52 packetizer */
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER );
p_sys->p_packetizer->pf_decode_audio = 0;
p_sys->p_packetizer->pf_decode_video = 0;
......
......@@ -113,10 +113,7 @@ static int Open( vlc_object_t *p_this )
stream_Read( p_demux->s, NULL, 12 );
/* Fill p_demux field */
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
es_format_Init( &p_sys->fmt, UNKNOWN_ES, 0 );
p_sys->i_time = 1;
p_sys->i_ssnd_pos = -1;
......@@ -125,22 +122,14 @@ static int Open( vlc_object_t *p_this )
{
uint32_t i_size;
if( stream_Peek( p_demux->s, &p_peek, 8 ) < 8 )
{
msg_Dbg( p_demux, "cannot peek()" );
goto error;
}
CHECK_PEEK_GOTO( p_peek, 8 );
i_size = GetDWBE( &p_peek[4] );
msg_Dbg( p_demux, "chunk fcc=%4.4s size=%d", p_peek, i_size );
if( !strncmp( (char *)&p_peek[0], "COMM", 4 ) )
{
if( stream_Peek( p_demux->s, &p_peek, 18 + 8 ) < 18 + 8 )
{
msg_Dbg( p_demux, "cannot peek()" );
goto error;
}
CHECK_PEEK_GOTO( p_peek, 18+8 );
es_format_Init( &p_sys->fmt, AUDIO_ES, VLC_FOURCC( 't', 'w', 'o', 's' ) );
p_sys->fmt.audio.i_channels = GetWBE( &p_peek[8] );
p_sys->fmt.audio.i_bitspersample = GetWBE( &p_peek[14] );
......@@ -151,12 +140,7 @@ static int Open( vlc_object_t *p_this )
}
else if( !strncmp( (char *)&p_peek[0], "SSND", 4 ) )
{
if( stream_Peek( p_demux->s, &p_peek, 8 + 8 ) < 8 + 8 )
{
msg_Dbg( p_demux, "cannot peek()" );
goto error;
}
CHECK_PEEK_GOTO( p_peek, 8+8 );
p_sys->i_ssnd_pos = stream_Tell( p_demux->s );
p_sys->i_ssnd_size = i_size;
p_sys->i_ssnd_offset = GetDWBE( &p_peek[8] );
......
......@@ -89,7 +89,7 @@ struct demux_sys_t
int i_header_size;
};
static int DemuxPCM( demux_t * );
static int Demux( demux_t * );
static int Control ( demux_t *, int i_query, va_list args );
/*****************************************************************************
......@@ -105,7 +105,7 @@ static int Open( vlc_object_t *p_this )
int i_cat;
int i_samples, i_modulo;
if( stream_Peek( p_demux->s, &p_peek, 4 ) < 4 ) return VLC_EGENERIC;
CHECK_PEEK( p_peek, 4 );
if( memcmp( p_peek, ".snd", 4 ) )
{
......@@ -128,7 +128,7 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
p_sys = p_demux->p_sys = malloc( sizeof( demux_sys_t ) );
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
p_sys->i_time = 1;
p_sys->i_header_size = GetDWBE( &hdr[0] );
......@@ -276,19 +276,15 @@ static int Open( vlc_object_t *p_this )
(mtime_t)i_samples /
(mtime_t)p_sys->fmt.audio.i_rate;
/* finish to set up p_demux */
p_demux->pf_demux = DemuxPCM;
p_demux->pf_control = Control;
return VLC_SUCCESS;
}
/*****************************************************************************
* DemuxPCM: read packet and send them to decoders
* Demux: read packet and send them to decoders
*****************************************************************************
* Returns -1 in case of error, 0 in case of EOF, 1 otherwise
*****************************************************************************/
static int DemuxPCM( demux_t *p_demux )
static int Demux( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
block_t *p_block;
......
......@@ -136,13 +136,7 @@ static int Open( vlc_object_t * p_this )
}
/* Have a peep at the show. */
if( stream_Peek( p_demux->s, &p_peek, i_peek + DTS_MAX_HEADER_SIZE * 2 ) <
i_peek + DTS_MAX_HEADER_SIZE * 2 )
{
/* Stream too short */
msg_Warn( p_demux, "cannot peek()" );
return VLC_EGENERIC;
}
CHECK_PEEK( p_peek, i_peek + DTS_MAX_HEADER_SIZE * 2 );
if( CheckSync( p_peek + i_peek ) != VLC_SUCCESS )
{
......@@ -155,32 +149,10 @@ static int Open( vlc_object_t * p_this )
"continuing anyway" );
}
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->b_start = VLC_TRUE;
p_sys->i_mux_rate = 0;
/*
* Load the DTS packetizer
*/
p_sys->p_packetizer = vlc_object_create( p_demux, VLC_OBJECT_DECODER );
p_sys->p_packetizer->pf_decode_audio = 0;
p_sys->p_packetizer->pf_decode_video = 0;
p_sys->p_packetizer->pf_decode_sub = 0;
p_sys->p_packetizer->pf_packetize = 0;
/* Initialization of decoder structure */
es_format_Init( &p_sys->p_packetizer->fmt_in, AUDIO_ES,
VLC_FOURCC( 'd', 't', 's', ' ' ) );
p_sys->p_packetizer->p_module =
module_Need( p_sys->p_packetizer, "packetizer", NULL, 0 );
if( !p_sys->p_packetizer->p_module )
{
msg_Err( p_demux, "cannot find DTS packetizer" );
return VLC_EGENERIC;
}
STANDARD_DEMUX_INIT; p_sys = p_demux->p_sys;
INIT_PACKETIZER( 'd','t','s',' ' );
LOAD_PACKETIZER_OR_FAIL( "DTS" );
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->p_packetizer->fmt_in );
......
......@@ -86,7 +86,6 @@ static int StoreString( demux_t *p_demux, char **ppsz_string, char *psz_source_s
int E_(Import_ASX)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
char *psz_ext;
......@@ -95,7 +94,7 @@ int E_(Import_ASX)( vlc_object_t *p_this )
if( ( psz_ext && !strcasecmp( psz_ext, ".asx") ) ||
( psz_ext && !strcasecmp( psz_ext, ".wax") ) ||
( psz_ext && !strcasecmp( psz_ext, ".wvx") ) ||
( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "asx-open") ) )
isDemux( p_demux, "asx-open" ) )
{
;
}
......@@ -103,20 +102,11 @@ int E_(Import_ASX)( vlc_object_t *p_this )
{
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using asx playlist import");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_sys->psz_data = NULL;
p_sys->i_data_len = -1;
p_sys->b_utf8 = VLC_FALSE;
STANDARD_DEMUX_INIT_MSG( "using ASX playlist reader" );
p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_demux->p_sys->psz_data = NULL;
p_demux->p_sys->i_data_len = -1;
p_demux->p_sys->b_utf8 = VLC_FALSE;
return VLC_SUCCESS;
}
......
......@@ -24,14 +24,12 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isspace() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include "playlist.h"
#include "vlc_xml.h"
......@@ -55,36 +53,11 @@ static int IsWhitespace( char *psz_string );
*****************************************************************************/
int E_(Import_B4S)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
char *psz_ext;
psz_ext = strrchr ( p_demux->psz_path, '.' );
if( ( psz_ext && !strcasecmp( psz_ext, ".b4s") ) ||
( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "b4s-open") ) )
{
;
}
else
{
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using b4s playlist import");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_sys->p_xml = NULL;
p_sys->p_xml_reader = NULL;
DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".b4s", "b4s-open",
"using B4S playlist reader" );
p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_demux->p_sys->p_xml = NULL;
p_demux->p_sys->p_xml_reader = NULL;
return VLC_SUCCESS;
}
......
......@@ -24,8 +24,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
......@@ -54,13 +52,10 @@ int E_(Import_DVB)( vlc_object_t *p_this )
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( !isExtension( 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 )
......@@ -81,7 +76,6 @@ int E_(Import_DVB)( vlc_object_t *p_this )
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;
......
......@@ -37,8 +37,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
......@@ -68,7 +66,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_GVP)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
int i_size;
byte_t *p_peek;
......@@ -79,18 +76,11 @@ int E_(Import_GVP)( vlc_object_t *p_this )
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using Google Video Playlist (gvp) import");
STANDARD_DEMUX_INIT_MSG( "using Google Video Playlist (gvp) import" )
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_playlist = NULL;
MALLOC_ERR( p_demux->p_sys, demux_sys_t );
p_demux->p_sys->p_playlist = NULL;
return VLC_SUCCESS;
}
......
......@@ -72,7 +72,7 @@ int E_(Import_M3U)( vlc_object_t *p_this )
( psz_ext && !strcasecmp( psz_ext, ".rm") ) ||
( psz_ext && !strcasecmp( psz_ext, ".vlc") ) ||
/* A .ram file can contain a single rtsp link */
( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "m3u") ) )
isDemux( p_demux, "m3u" ) )
{
;
}
......@@ -80,16 +80,7 @@ int E_(Import_M3U)( vlc_object_t *p_this )
{
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "found valid M3U playlist file");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = malloc( sizeof(demux_sys_t) );
if( p_demux->p_sys == NULL )
{
msg_Err( p_demux, "Out of memory" );
return VLC_ENOMEM;
}
STANDARD_DEMUX_INIT_MSG( "found valid M3U playlist" );
p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
return VLC_SUCCESS;
......
......@@ -24,15 +24,11 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include "charset.h"
#include <errno.h> /* ENOMEM */
#define PLAYLIST_FILE_HEADER "# vlc playlist file version 0.5"
/*****************************************************************************
......@@ -54,7 +50,6 @@ int E_(Import_Old)( vlc_object_t *p_this )
if( strncmp( (char *)p_peek, PLAYLIST_FILE_HEADER , 31 ) ) return VLC_EGENERIC;
msg_Dbg( p_demux, "found valid old playlist file");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
......
......@@ -25,13 +25,10 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include "playlist.h"
struct demux_sys_t
......@@ -51,34 +48,17 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_PLS)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
uint8_t *p_peek;
char *psz_ext;
if( stream_Peek( p_demux->s , &p_peek, 7 ) < 7 ) return VLC_EGENERIC;
psz_ext = strrchr ( p_demux->psz_path, '.' );
CHECK_PEEK( p_peek, 7 );
if( !strncasecmp( (char *)p_peek, "[playlist]", 10 ) )
{
;
}
else if( ( psz_ext && !strcasecmp( psz_ext, ".pls") ) ||
( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "pls") ) )
if( POKE( p_peek, "[playlist]", 10 ) ||
isExtension( p_demux, ".pls" ) || isDemux( p_demux, "pls" ) )
{
;
}
else return VLC_EGENERIC;
msg_Dbg( p_demux, "found valid PLS playlist file");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = malloc( sizeof(demux_sys_t) );
if( p_demux->p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
STANDARD_DEMUX_INIT_MSG( "found valid PLS playlist file");
p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
return VLC_SUCCESS;
......
......@@ -24,14 +24,12 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isspace() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include "playlist.h"
#include "vlc_xml.h"
......@@ -55,34 +53,15 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_podcast)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
char *psz_ext;
psz_ext = strrchr ( p_demux->psz_path, '.' );
if( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "podcast") )
{
;
}
else
{
if( !isDemux( p_demux, "podcast" ) )
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using podcast playlist import");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_sys->p_playlist = NULL;
p_sys->p_xml = NULL;
p_sys->p_xml_reader = NULL;
STANDARD_DEMUX_INIT_MSG( "using podcast reader" );
p_demux->p_sys->psz_prefix = E_(FindPrefix)( p_demux );
p_demux->p_sys->p_playlist = NULL;
p_demux->p_sys->p_xml = NULL;
p_demux->p_sys->p_xml_reader = NULL;
return VLC_SUCCESS;
}
......
......@@ -47,14 +47,12 @@ volume - 0 (mute) - 100 (max)
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isspace() */
#include <vlc/vlc.h>
#include <vlc/input.h>
#include <vlc/intf.h>
#include <errno.h> /* ENOMEM */
#include "playlist.h"
#include "vlc_xml.h"
......@@ -91,32 +89,10 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
*****************************************************************************/
int E_(Import_QTL)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
char *psz_ext;
psz_ext = strrchr ( p_demux->psz_path, '.' );
if( strcmp( psz_ext, ".qtl" ) )
{
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using QuickTime Media Link playlist import");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_playlist = NULL;
p_sys->p_xml = NULL;
p_sys->p_xml_reader = NULL;
DEMUX_BY_EXTENSION_MSG( ".qtl", "using QuickTime Media Link reader" );
p_demux->p_sys->p_playlist = NULL;
p_demux->p_sys->p_xml = NULL;
p_demux->p_sys->p_xml_reader = NULL;
return VLC_SUCCESS;
}
......
......@@ -135,7 +135,6 @@ static int Control( demux_t *p_demux, int i_query, va_list args );
int E_(Import_SGIMB)( vlc_object_t * p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
byte_t *p_peek;
int i_size;
......@@ -152,26 +151,21 @@ int E_(Import_SGIMB)( vlc_object_t * p_this )
}
if ( !strncasecmp( (char *)p_peek, "sgiNameServerHost=", i_len ) )
{
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->psz_uri = NULL;
p_sys->psz_server = NULL;
p_sys->psz_location = NULL;
p_sys->psz_name = NULL;
p_sys->psz_user = NULL;
p_sys->psz_password = NULL;
p_sys->psz_mcast_ip = NULL;
p_sys->i_mcast_port = 0;
p_sys->i_packet_size = 0;
p_sys->i_duration = 0;
p_sys->i_port = 0;
p_sys->i_sid = 0;
p_sys->b_rtsp_kasenna = VLC_FALSE;
p_sys->b_concert = VLC_FALSE;
msg_Dbg( p_demux, "using sgimb playlist import");
STANDARD_DEMUX_INIT_MSG( "using SGIMB playlist reader" );
p_demux->p_sys->psz_uri = NULL;
p_demux->p_sys->psz_server = NULL;
p_demux->p_sys->psz_location = NULL;
p_demux->p_sys->psz_name = NULL;
p_demux->p_sys->psz_user = NULL;
p_demux->p_sys->psz_password = NULL;
p_demux->p_sys->psz_mcast_ip = NULL;
p_demux->p_sys->i_mcast_port = 0;
p_demux->p_sys->i_packet_size = 0;
p_demux->p_sys->i_duration = 0;
p_demux->p_sys->i_port = 0;
p_demux->p_sys->i_sid = 0;
p_demux->p_sys->b_rtsp_kasenna = VLC_FALSE;
p_demux->p_sys->b_concert = VLC_FALSE;
return VLC_SUCCESS;
}
......
......@@ -25,7 +25,6 @@
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <stdlib.h> /* malloc(), free() */
#include <ctype.h> /* isspace() */
#include <vlc/vlc.h>
......@@ -69,35 +68,19 @@ static int DemuxStation( demux_t *p_demux );
int E_(Import_Shoutcast)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
demux_sys_t *p_sys;
char *psz_ext;
psz_ext = strrchr ( p_demux->psz_path, '.' );
if( !p_demux->psz_demux || strcmp(p_demux->psz_demux, "shout-winamp") )
{
if( !isDemux( p_demux, "shout-winamp" ) )
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using shoutcast playlist import");
p_demux->pf_control = Control;
p_demux->pf_demux = Demux;
p_demux->p_sys = p_sys = malloc( sizeof(demux_sys_t) );
if( p_sys == NULL )
{
msg_Err( p_demux, "out of memory" );
return VLC_ENOMEM;
}
p_sys->p_playlist = NULL;
p_sys->p_xml = NULL;
p_sys->p_xml_reader = NULL;
STANDARD_DEMUX_INIT_MSG( "using shoutcast playlist reader" );
p_demux->p_sys->p_playlist = NULL;
p_demux->p_sys->p_xml = NULL;
p_demux->p_sys->p_xml_reader = NULL;
/* Do we want to list adult content ? */
var_Create( p_demux, "shoutcast-show-adult",
VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
p_sys->b_adult = var_GetBool( p_demux, "shoutcast-show-adult" );
p_demux->p_sys->b_adult = var_GetBool( p_demux, "shoutcast-show-adult" );
return VLC_SUCCESS;
}
......
......@@ -44,39 +44,23 @@ struct demux_sys_t
int i_identifier;
};
static int Control( demux_t *, int, va_list );
static int Demux( demux_t * );
/**
* \brief XSPF submodule initialization function
*/
int E_(xspf_import_Activate)( vlc_object_t *p_this )
{
demux_t *p_demux = (demux_t *)p_this;
char *psz_ext;
psz_ext = strrchr( p_demux->psz_path, '.' );
if( ( psz_ext && !strcasecmp( psz_ext, ".xspf") ) ||
( p_demux->psz_demux && !strcmp(p_demux->psz_demux, "xspf-open") ) )
{
;
}
else
{
return VLC_EGENERIC;
}
msg_Dbg( p_demux, "using xspf playlist import");
p_demux->p_sys = (demux_sys_t*)malloc(sizeof(demux_sys_t ) );
p_demux->pf_control = xspf_import_Control;
p_demux->pf_demux = xspf_import_Demux;
DEMUX_BY_EXTENSION_OR_FORCED_MSG( ".xspf", "xspf-open",
"using XSPF playlist reader" );
return VLC_SUCCESS;
}
/**
* \brief demuxer function for XSPF parsing
*/
int xspf_import_Demux( demux_t *p_demux )
int Demux( demux_t *p_demux )
{
int i_ret = VLC_SUCCESS;
xml_t *p_xml = NULL;
......@@ -138,7 +122,7 @@ int xspf_import_Demux( demux_t *p_demux )
}
/** \brief dummy function for demux callback interface */
int xspf_import_Control( demux_t *p_demux, int i_query, va_list args )
static int Control( demux_t *p_demux, int i_query, va_list args )
{
return VLC_EGENERIC;
}
......
......@@ -41,9 +41,6 @@
const char *psz_element)
/* prototypes */
int xspf_import_Demux( demux_t *);
int xspf_import_Control( demux_t *, int, va_list );
static vlc_bool_t parse_playlist_node COMPLEX_INTERFACE;
static vlc_bool_t parse_tracklist_node COMPLEX_INTERFACE;
static vlc_bool_t parse_track_node COMPLEX_INTERFACE;
......
......@@ -76,9 +76,7 @@ playlist_item_t *__playlist_ItemNewFromInput( vlc_object_t *p_obj,
{
/** FIXME !!!!! don't find playlist each time */
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_obj, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_item_t * p_item;
p_item = malloc( sizeof( playlist_item_t ) );
if( p_item == NULL ) return NULL;
DECMALLOC_NULL( p_item, playlist_item_t );
p_item->p_input = p_input;
vlc_gc_incref( p_item->p_input );
......
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