Commit 73a3acb7 authored by trax's avatar trax
Browse files

* modules/access_output/shout.c: removed protocol selection and set it to...

* modules/access_output/shout.c: removed protocol selection and set it to automaticly try shoutcast protocol if icecast fails. added options for stream info settings, genre, url and public (yellow pages).
parent ac16a947
......@@ -69,11 +69,38 @@ static void Close( vlc_object_t * );
"MP3 instead, so you can forward MP3 streams to " \
"the shoutcast/icecast server." )
#define PROTOCOL_TEXT N_("Shoutcast protocol")
#define PROTOCOL_LONGTEXT N_("Shoutcast header protocol to use when communicating " \
"with the server. Shoutcast servers need 'icy', " \
"icecast 1.x needs 'xaudiocast', and icecast 2.x " \
"needs 'http'. " )
/* To be listed properly as a public stream on the Yellow Pages of shoutcast/icecast
the genres should match those used on the corresponding sites. Several examples
are Alternative, Classical, Comedy, Country etc. */
#define GENRE_TEXT N_("Genre description")
#define GENRE_LONGTEXT N_("Genre of the content. " )
#define URL_TEXT N_("URL description")
#define URL_LONGTEXT N_("URL with information about the stream or your channel. " )
/* The shout module only "transmits" data. It does not have direct access to
"codec level" information. Stream information such as bitrate, samplerate,
channel numbers and quality (in case of Ogg streaming) need to be set manually */
#define BITRATE_TEXT N_("Bitrate")
#define BITRATE_LONGTEXT N_("Bitrate information of the transcoded stream. " )
#define SAMPLERATE_TEXT N_("Samplerate")
#define SAMPLERATE_LONGTEXT N_("Samplerate information of the transcoded stream. " )
#define CHANNELS_TEXT N_("Number of channels")
#define CHANNELS_LONGTEXT N_("Number of channels information of the transcoded stream. " )
#define QUALITY_TEXT N_("Ogg Vorbis Quality")
#define QUALITY_LONGTEXT N_("Ogg Vorbis Quality information of the transcoded stream. " )
#define PUBLIC_TEXT N_("Stream Public")
#define PUBLIC_LONGTEXT N_("Make the server publicly available on the 'Yellow Pages' " \
"of icecast/shoutcast (directory listing of broadcast " \
"streams). Requires the bitrate information to be " \
"specified for shoutcast. Requires Ogg streaming " \
"for icecast." )
vlc_module_begin();
set_description( _("IceCAST output") );
......@@ -85,13 +112,24 @@ vlc_module_begin();
add_string( SOUT_CFG_PREFIX "name", "VLC media player - Live stream", NULL,
NAME_TEXT, NAME_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "description",
"Live stream from VLC media player. " \
"http://www.videolan.org/vlc", NULL,
"Live stream from VLC media player", NULL,
DESCRIPTION_TEXT, DESCRIPTION_LONGTEXT, VLC_FALSE );
add_bool( SOUT_CFG_PREFIX "mp3", VLC_FALSE, NULL,
MP3_TEXT, MP3_LONGTEXT, VLC_TRUE );
add_string( SOUT_CFG_PREFIX "protocol", "http", NULL,
PROTOCOL_TEXT, PROTOCOL_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "genre", "Alternative", NULL,
GENRE_TEXT, GENRE_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "url", "http://www.videolan.org/vlc", NULL,
URL_TEXT, URL_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "bitrate", "0", NULL,
BITRATE_TEXT, BITRATE_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "samplerate", "", NULL,
SAMPLERATE_TEXT, SAMPLERATE_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "channels", "", NULL,
CHANNELS_TEXT, CHANNELS_LONGTEXT, VLC_FALSE );
add_string( SOUT_CFG_PREFIX "quality", "", NULL,
QUALITY_TEXT, QUALITY_LONGTEXT, VLC_FALSE );
add_bool( SOUT_CFG_PREFIX "public", VLC_FALSE, NULL,
PUBLIC_TEXT, PUBLIC_LONGTEXT, VLC_TRUE );
set_callbacks( Open, Close );
vlc_module_end();
......@@ -99,7 +137,8 @@ vlc_module_end();
* Exported prototypes
*****************************************************************************/
static const char *ppsz_sout_options[] = {
"name", "description", "mp3", "protocol", NULL
"name", "description", "mp3", "genre", "url", "bitrate", "samplerate",
"channels", "quality", "public", NULL
};
......@@ -135,9 +174,11 @@ static int Open( vlc_object_t *p_this )
char *psz_mount = NULL;
char *psz_name = NULL;
char *psz_description = NULL;
char *psz_protocol = NULL;
char *tmp_port = NULL;
char *psz_genre = NULL;
char *psz_url = NULL;
char *psz_bitrate = NULL;
sout_CfgParse( p_access, SOUT_CFG_PREFIX, ppsz_sout_options, p_access->p_cfg );
psz_accessname = psz_parser = strdup( p_access->psz_name );
......@@ -186,16 +227,38 @@ static int Open( vlc_object_t *p_this )
else
free( val.psz_string );
var_Get( p_access, SOUT_CFG_PREFIX "genre", &val );
if( *val.psz_string )
psz_genre = val.psz_string;
else
free( val.psz_string );
var_Get( p_access, SOUT_CFG_PREFIX "url", &val );
if( *val.psz_string )
psz_url = val.psz_string;
else
free( val.psz_string );
var_Get( p_access, SOUT_CFG_PREFIX "bitrate", &val );
if( *val.psz_string )
psz_bitrate = val.psz_string;
else
free( val.psz_string );
p_shout = p_sys->p_shout = shout_new();
if( !p_shout
|| shout_set_host( p_shout, psz_host ) != SHOUTERR_SUCCESS
|| shout_set_protocol( p_shout, SHOUT_PROTOCOL_HTTP ) != SHOUTERR_SUCCESS
|| shout_set_port( p_shout, i_port ) != SHOUTERR_SUCCESS
|| shout_set_password( p_shout, psz_pass ) != SHOUTERR_SUCCESS
|| shout_set_mount( p_shout, psz_mount ) != SHOUTERR_SUCCESS
|| shout_set_user( p_shout, psz_user ) != SHOUTERR_SUCCESS
|| shout_set_agent( p_shout, "VLC media player " VERSION ) != SHOUTERR_SUCCESS
|| shout_set_name( p_shout, psz_name ) != SHOUTERR_SUCCESS
|| shout_set_description( p_shout, psz_description ) != SHOUTERR_SUCCESS
|| shout_set_description( p_shout, psz_description ) != SHOUTERR_SUCCESS
|| shout_set_genre( p_shout, psz_genre ) != SHOUTERR_SUCCESS
|| shout_set_url( p_shout, psz_url ) != SHOUTERR_SUCCESS
|| shout_set_audio_info( p_shout, SHOUT_AI_BITRATE, psz_bitrate ) != SHOUTERR_SUCCESS
// || shout_set_nonblocking( p_shout, 1 ) != SHOUTERR_SUCCESS
)
{
......@@ -208,6 +271,9 @@ static int Open( vlc_object_t *p_this )
if( psz_name ) free( psz_name );
if( psz_description ) free( psz_description );
if( psz_genre ) free( psz_genre );
if( psz_url ) free( psz_url );
if( psz_bitrate ) free( psz_bitrate );
var_Get( p_access, SOUT_CFG_PREFIX "mp3", &val );
if( val.b_bool == VLC_TRUE )
......@@ -223,25 +289,57 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC;
}
var_Get( p_access, SOUT_CFG_PREFIX "protocol", &val );
if( !strcmp( val.psz_string, "icy" ) )
var_Get( p_access, SOUT_CFG_PREFIX "samplerate", &val );
if( *val.psz_string )
i_ret = shout_set_audio_info( p_shout, SHOUT_AI_SAMPLERATE, val.psz_string );
else
free( val.psz_string );
if( i_ret != SHOUTERR_SUCCESS )
{
i_ret = shout_set_protocol( p_shout, SHOUT_PROTOCOL_ICY );
msg_Err( p_access, "failed to set the information about the samplerate" );
free( p_access->p_sys );
free( psz_accessname );
return VLC_EGENERIC;
}
else if( !strcmp( val.psz_string, "xaudiocast" ) )
var_Get( p_access, SOUT_CFG_PREFIX "channels", &val );
if( *val.psz_string )
i_ret = shout_set_audio_info( p_shout, SHOUT_AI_CHANNELS, val.psz_string );
else
free( val.psz_string );
if( i_ret != SHOUTERR_SUCCESS )
{
i_ret = shout_set_protocol( p_shout, SHOUT_PROTOCOL_XAUDIOCAST );
msg_Err( p_access, "failed to set the information about the number of channels" );
free( p_access->p_sys );
free( psz_accessname );
return VLC_EGENERIC;
}
else if( !strcmp( val.psz_string, "http" ) )
var_Get( p_access, SOUT_CFG_PREFIX "quality", &val );
if( *val.psz_string )
i_ret = shout_set_audio_info( p_shout, SHOUT_AI_QUALITY, val.psz_string );
else
free( val.psz_string );
if( i_ret != SHOUTERR_SUCCESS )
{
i_ret = shout_set_protocol( p_shout, SHOUT_PROTOCOL_HTTP );
msg_Err( p_access, "failed to set the information about Ogg Vorbis quality" );
free( p_access->p_sys );
free( psz_accessname );
return VLC_EGENERIC;
}
var_Get( p_access, SOUT_CFG_PREFIX "public", &val );
if( val.b_bool == VLC_TRUE )
i_ret = shout_set_public( p_shout, 1 );
if( i_ret != SHOUTERR_SUCCESS )
{
msg_Err( p_access, "failed to set the shoutcast header protocol" );
msg_Err( p_access, "failed to set the server status setting to public" );
free( p_access->p_sys );
free( psz_protocol );
free( psz_accessname );
return VLC_EGENERIC;
}
......@@ -250,6 +348,58 @@ static int Open( vlc_object_t *p_this )
{
i_ret = SHOUTERR_CONNECTED;
}
else
{
/* If default 'http' protocol for icecast 2.x fails, fall back to 'icy'
for shoutcast server */
msg_Warn( p_access, "failed to connect using 'http' (icecast 2.x) protocol, "
"switching to 'icy' (shoutcast)" );
i_ret = shout_get_format( p_shout );
if( i_ret != SHOUT_FORMAT_MP3 )
{
msg_Err( p_access, "failed to use 'icy' protocol: only MP3 " \
"streaming to shoutcast is supported" );
free( p_access->p_sys );
free( psz_accessname );
return VLC_EGENERIC;
}
/* Shout parameters cannot be changed on an open connection */
i_ret = shout_close( p_shout );
if( i_ret == SHOUTERR_SUCCESS )
{
i_ret = SHOUTERR_UNCONNECTED;
}
i_ret = shout_set_protocol( p_shout, SHOUT_PROTOCOL_ICY );
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;
}
/* Server status public requires the shout bitrate to be specified */
if( shout_get_audio_info ( p_shout, SHOUT_AI_BITRATE ) == "0" )
{
if ( shout_get_public ( p_shout ))
{
msg_Warn( p_access, "server status public for shoutcast not supported: " \
"no bitrate specified" );
free( p_access->p_sys );
free( psz_accessname );
return VLC_EGENERIC;
}
}
i_ret = shout_open( p_shout );
if( i_ret == SHOUTERR_SUCCESS )
{
i_ret = SHOUTERR_CONNECTED;
}
}
/*
for non-blocking, use:
......
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