+ else
+ free( val.psz_string );
+
+ 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 );
+ if( i_ret != SHOUTERR_SUCCESS )
+ {
+ msg_Err( p_access, "failed to set the information about Ogg Vorbis quality" );
+ free( p_access->p_sys );
+ free( psz_accessname );
+ return VLC_EGENERIC;
+ }
+ }
+ else
+ free( val.psz_string );
+
+ var_Get( p_access, SOUT_CFG_PREFIX "public", &val );
+ if( val.b_bool == true )
+ {
+ 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;
+ }
+ }
+
+ /* Connect at startup. Cycle through the possible protocols. */
+ i_ret = shout_get_connected( p_shout );
+ while ( i_ret != SHOUTERR_CONNECTED )
+ {
+ /* Shout parameters cannot be changed on an open connection */
+ i_ret = shout_close( p_shout );
+ if( i_ret == SHOUTERR_SUCCESS )
+ {
+ i_ret = SHOUTERR_UNCONNECTED;
+ }
+
+ /* Re-initialize for Shoutcast using ICY protocol. Not needed for initial connection
+ but it is when we are reconnecting after other protocol was tried. */
+ 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;
+ }
+ i_ret = shout_open( p_shout );
+ if( i_ret == SHOUTERR_SUCCESS )
+ {
+ i_ret = SHOUTERR_CONNECTED;
+ msg_Dbg( p_access, "connected using 'icy' (shoutcast) protocol" );
+ }
+ else
+ {
+ msg_Warn( p_access, "failed to connect using 'icy' (shoutcast) protocol" );
+
+ /* Shout parameters cannot be changed on an open connection */
+ i_ret = shout_close( p_shout );
+ if( i_ret == SHOUTERR_SUCCESS )
+ {
+ i_ret = SHOUTERR_UNCONNECTED;
+ }
+
+ /* IceCAST using HTTP protocol */
+ i_ret = shout_set_protocol( p_shout, SHOUT_PROTOCOL_HTTP );
+ 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;
+ }
+ i_ret = shout_open( p_shout );
+ if( i_ret == SHOUTERR_SUCCESS )
+ {
+ i_ret = SHOUTERR_CONNECTED;
+ msg_Dbg( p_access, "connected using 'http' (icecast 2.x) protocol" );
+ }
+ else
+ msg_Warn( p_access, "failed to connect using 'http' (icecast 2.x) protocol " );
+ }
+/*
+ for non-blocking, use:
+ while( i_ret == SHOUTERR_BUSY )
+ {
+ sleep( 1 );
+ i_ret = shout_get_connected( p_shout );
+ }