vlc_module_begin ()
set_description( N_("IceCAST output") )
set_shortname( "Shoutcast" )
- set_capability( "sout access", 50 )
+ set_capability( "sout access", 0 )
set_category( CAT_SOUT )
set_subcategory( SUBCAT_SOUT_ACO )
add_shortcut( "shout" )
shout_t *p_shout;
long i_ret;
unsigned int i_port;
- vlc_value_t val;
-
- char *psz_accessname = NULL;
- char *psz_parser = NULL;
- char *psz_user = NULL;
- char *psz_pass = NULL;
- char *psz_host = NULL;
- char *psz_mount = NULL;
- char *psz_name = NULL;
- char *psz_description = NULL;
- char *tmp_port = NULL;
- char *psz_genre = NULL;
- char *psz_url = NULL;
+ char *psz_val;
+
+ char *psz_accessname;
+ char *psz_parser;
+ const char *psz_user;
+ char *psz_pass;
+ char *psz_host;
+ char *psz_mount;
+ char *psz_port;
+ char *psz_name;
+ char *psz_description;
+ char *psz_genre;
+ char *psz_url;
config_ChainParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
return VLC_ENOMEM;
/* Parse connection data user:pwd@host:port/mountpoint */
- psz_user = psz_parser;
- while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++;
- if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; }
- psz_pass = psz_parser;
- while( psz_parser[0] && psz_parser[0] != '@' ) psz_parser++;
- if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; }
- psz_host = psz_parser;
- while( psz_parser[0] && psz_parser[0] != ':' ) psz_parser++;
- if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; }
- tmp_port = psz_parser;
- while( psz_parser[0] && psz_parser[0] != '/' ) psz_parser++;
- if( psz_parser[0] ) { psz_parser[0] = 0; psz_parser++; }
- psz_mount = psz_parser;
-
- i_port = atoi( tmp_port );
-
- p_sys = p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) );
- if( !p_sys )
+ psz_host = strchr( psz_parser, '@' );
+ if( psz_host )
{
- free( psz_accessname );
- return VLC_ENOMEM;
+ psz_user = psz_parser;
+ *(psz_host++) = '\0';
}
-
- var_Get( p_access, SOUT_CFG_PREFIX "name", &val );
- if( *val.psz_string )
- psz_name = val.psz_string;
else
- free( val.psz_string );
+ psz_user = "";
- var_Get( p_access, SOUT_CFG_PREFIX "description", &val );
- if( *val.psz_string )
- psz_description = val.psz_string;
+ psz_pass = strchr( psz_user, ':' );
+ if( psz_pass )
+ *(psz_pass++) = '\0';
else
- free( val.psz_string );
+ psz_pass = "";
- var_Get( p_access, SOUT_CFG_PREFIX "genre", &val );
- if( *val.psz_string )
- psz_genre = val.psz_string;
+ psz_mount = strchr( psz_host, '/' );
+ if( psz_mount )
+ *(psz_mount++) = '\0';
else
- free( val.psz_string );
+ psz_mount = "";
- var_Get( p_access, SOUT_CFG_PREFIX "url", &val );
- if( *val.psz_string )
- psz_url = val.psz_string;
+ if( psz_host[0] == '[' )
+ {
+ psz_port = strstr( psz_host, "]:" );
+ if( psz_port )
+ {
+ *psz_port = '\0';
+ psz_port += 2;
+ }
+ }
else
- free( val.psz_string );
+ {
+ psz_port = strchr( psz_host, ':' );
+ if( psz_port )
+ *(psz_port++) = '\0';
+ }
+ i_port = psz_port ? atoi( psz_port ) : 8000;
+
+ p_sys = p_access->p_sys = malloc( sizeof( sout_access_out_sys_t ) );
+ if( !p_sys )
+ {
+ free( psz_accessname );
+ return VLC_ENOMEM;
+ }
+
+ psz_name = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "name" );
+ psz_description = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "description" );
+ psz_genre = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "genre" );
+ psz_url = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "url" );
p_shout = p_sys->p_shout = shout_new();
if( !p_shout
free( psz_genre );
free( psz_url );
- var_Get( p_access, SOUT_CFG_PREFIX "mp3", &val );
- if( val.b_bool == true )
+ if( var_GetBool( p_access, SOUT_CFG_PREFIX "mp3" ) )
i_ret = shout_set_format( p_shout, SHOUT_FORMAT_MP3 );
else
i_ret = shout_set_format( p_shout, SHOUT_FORMAT_OGG );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the shoutcast streaming format" );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
/* Don't force bitrate to 0 but only use when specified. This will otherwise
show an empty field on icecast directory listing instead of NA */
- var_Get( p_access, SOUT_CFG_PREFIX "bitrate", &val );
- if( *val.psz_string )
+ psz_val = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "bitrate" );
+ if( psz_val )
{
- i_ret = shout_set_audio_info( p_shout, SHOUT_AI_BITRATE, val.psz_string );
+ i_ret = shout_set_audio_info( p_shout, SHOUT_AI_BITRATE, psz_val );
+ free( psz_val );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the information about the bitrate" );
- free( val.psz_string );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
}
else
listings (sorting, stream info etc.) */
msg_Warn( p_access, "no bitrate information specified (required for listing " \
"the server as public on the shoutcast website)" );
- free( val.psz_string );
}
/* Information about samplerate, channels and quality will not be propagated
through the YP protocol for icecast to the public directory listing when
the icecast server is operating in shoutcast compatibility mode */
- var_Get( p_access, SOUT_CFG_PREFIX "samplerate", &val );
- if( *val.psz_string )
+ psz_val = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "samplerate" );
+ if( psz_val )
{
- i_ret = shout_set_audio_info( p_shout, SHOUT_AI_SAMPLERATE, val.psz_string );
+ i_ret = shout_set_audio_info( p_shout, SHOUT_AI_SAMPLERATE, psz_val );
+ free( psz_val );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the information about the samplerate" );
- free( val.psz_string );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
}
- else
- free( val.psz_string );
- var_Get( p_access, SOUT_CFG_PREFIX "channels", &val );
- if( *val.psz_string )
+ psz_val = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "channels" );
+ if( psz_val )
{
- i_ret = shout_set_audio_info( p_shout, SHOUT_AI_CHANNELS, val.psz_string );
+ i_ret = shout_set_audio_info( p_shout, SHOUT_AI_CHANNELS, psz_val );
+ free( psz_val );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the information about the number of channels" );
- free( val.psz_string );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
}
- else
- free( val.psz_string );
- var_Get( p_access, SOUT_CFG_PREFIX "quality", &val );
- if( *val.psz_string )
+ psz_val = var_GetNonEmptyString( p_access, SOUT_CFG_PREFIX "quality" );
+ if( psz_val )
{
- i_ret = shout_set_audio_info( p_shout, SHOUT_AI_QUALITY, val.psz_string );
+ i_ret = shout_set_audio_info( p_shout, SHOUT_AI_QUALITY, psz_val );
+ free( psz_val );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the information about Ogg Vorbis quality" );
- free( val.psz_string );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
}
- else
- free( val.psz_string );
- var_Get( p_access, SOUT_CFG_PREFIX "public", &val );
- if( val.b_bool == true )
+ if( var_GetBool( p_access, SOUT_CFG_PREFIX "public" ) )
{
i_ret = shout_set_public( p_shout, 1 );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the server status setting to public" );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
}
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the protocol to 'icy'" );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
i_ret = shout_open( p_shout );
if( i_ret == SHOUTERR_SUCCESS )
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the protocol to 'http'" );
- free( p_access->p_sys );
- free( psz_accessname );
- return VLC_EGENERIC;
+ goto error;
}
i_ret = shout_open( p_shout );
if( i_ret == SHOUTERR_SUCCESS )
free( psz_accessname );
return VLC_SUCCESS;
+
+error:
+ free( psz_accessname );
+ free( p_sys );
+ return VLC_EGENERIC;
}
/*****************************************************************************
*****************************************************************************/
static int Seek( sout_access_out_t *p_access, off_t i_pos )
{
+ VLC_UNUSED(i_pos);
msg_Err( p_access, "cannot seek on shout" );
return VLC_EGENERIC;
}