Commit 97a8984f authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Patch to reenable sap-timeout functionality (Bug 2007) By Dermot McGahon,...

* Patch to reenable sap-timeout functionality (Bug 2007) By Dermot McGahon, dermot at lincor dot com
  Modified by me.
* also restored some indentation of this file.
parent 7a5f6a89
/*****************************************************************************
* sap.c : SAP interface module
*****************************************************************************
* Copyright (C) 2004 VideoLAN
* Copyright (C) 2004-2005 VideoLAN
* $Id$
*
* Authors: Clment Stenac <zorglub@videolan.org>
......@@ -272,7 +272,7 @@ static int Open( vlc_object_t *p_this )
char *psz_addr, *psz_charset;
vlc_value_t val;
p_sys->i_timeout = config_GetInt( p_sd,"sap-timeout" );
p_sys->i_timeout = var_CreateGetInteger( p_sd, "sap-timeout" );
vlc_current_charset( &psz_charset );
p_sys->iconvHandle = vlc_iconv_open( psz_charset, "UTF-8" );
......@@ -288,24 +288,24 @@ static int Open( vlc_object_t *p_this )
p_sys->pi_fd = NULL;
p_sys->i_fd = 0;
p_sys->b_strict = config_GetInt( p_sd, "sap-strict");
p_sys->b_parse = config_GetInt( p_sd, "sap-parse" );
p_sys->b_strict = var_CreateGetInteger( p_sd, "sap-strict");
p_sys->b_parse = var_CreateGetInteger( p_sd, "sap-parse" );
if( config_GetInt( p_sd, "sap-cache" ) )
if( var_CreateGetInteger( p_sd, "sap-cache" ) )
{
CacheLoad( p_sd );
}
if( config_GetInt( p_sd, "sap-ipv4" ) )
if( var_CreateGetInteger( p_sd, "sap-ipv4" ) )
{
InitSocket( p_sd, SAP_V4_ADDRESS, SAP_PORT );
}
if( config_GetInt( p_sd, "sap-ipv6" ) )
if( var_CreateGetInteger( p_sd, "sap-ipv6" ) )
{
/* [ + 8x4+7*':' + ] */
char psz_address[42];
char c_scope;
char *psz_scope = config_GetPsz( p_sd, "sap-ipv6-scope" );
char *psz_scope = var_CreateGetString( p_sd, "sap-ipv6-scope" );
if( psz_scope == NULL || *psz_scope == '\0')
{
......@@ -320,7 +320,7 @@ static int Open( vlc_object_t *p_this )
InitSocket( p_sd, psz_address, SAP_PORT );
}
psz_addr = config_GetPsz( p_sd, "sap-addr" );
psz_addr = var_CreateGetString( p_sd, "sap-addr" );
if( psz_addr && *psz_addr )
{
InitSocket( p_sd, psz_addr, SAP_PORT );
......@@ -328,7 +328,7 @@ static int Open( vlc_object_t *p_this )
if( p_sys->i_fd == 0 )
{
msg_Err( p_sd, "unable to read on any address");
msg_Err( p_sd, "unable to read on any address" );
return VLC_EGENERIC;
}
......@@ -504,10 +504,9 @@ static void CloseDemux( vlc_object_t *p_this )
static void Run( services_discovery_t *p_sd )
{
int i;
uint8_t *p_buffer;
/* Dirty hack to slow down the startup of the sap interface */
/* Unneeded now : our node is in no_select mode */
// msleep( 500000 );
playlist_t *p_playlist;
/* read SAP packets */
while( !p_sd->b_die )
......@@ -525,16 +524,19 @@ static void Run( services_discovery_t *p_sd )
i_read = net_Select( p_sd, p_sd->p_sys->pi_fd, NULL,
p_sd->p_sys->i_fd, p_buffer,
MAX_SAP_BUFFER, 500000 );
#if 0
/* Check for items that need deletion */
for( i = 0 ; i< p_sd->p_sys->i_announces ; i++ )
for( i = 0; i < p_sd->p_sys->i_announces; i++ )
{
struct sap_announce_t *p_announce;
mtime_t i_timeout = ( mtime_t ) 1000000*p_sys->i_timeout;
mtime_t i_timeout = ( mtime_t ) 1000000 * p_sd->p_sys->i_timeout;
if( mdate() - p_sd->p_sys->pp_announces[i]->i_last > i_timeout )
{
msg_Dbg( p_sd,"Time out for %s, deleting (%i/%i)",
p_sd->p_sys->pp_announces[i]->psz_name,
struct sap_announce_t *p_announce;
p_announce = p_sd->p_sys->pp_announces[i];
msg_Dbg( p_sd, "Time out for %s, deleting (%i/%i)",
p_announce->p_item->input.psz_name,
i , p_sd->p_sys->i_announces );
/* Remove the playlist item */
......@@ -542,28 +544,17 @@ static void Run( services_discovery_t *p_sd )
FIND_ANYWHERE );
if( p_playlist )
{
int i_pos = playlist_GetPositionById( p_playlist,
p_sd->p_sys->pp_announces[i]->i_id );
playlist_Delete( p_playlist, i_pos );
playlist_Delete( p_playlist, p_announce->p_item->input.i_id );
vlc_object_release( p_playlist );
}
/* Free the p_announce */
p_announce = p_sd->p_sys->pp_announces[i];
if( p_announce->psz_name )
free( p_announce->psz_name );
if( p_announce->psz_uri )
free( p_announce->psz_uri );
/* Remove the sap_announce from the array */
REMOVE_ELEM( p_sd->p_sys->pp_announces,
p_sd->p_sys->i_announces, i );
free( p_announce );
}
}
#endif
/* Minimum length is > 6 */
if( i_read <= 6 )
......@@ -677,7 +668,7 @@ static int ParseSAP( services_discovery_t *p_sd, uint8_t *p_buffer, int i_read )
psz_sdp += 4;
if( i_read <= 9 )
{
msg_Warn( p_sd,"too short SAP packet\n" );
msg_Warn( p_sd, "too short SAP packet\n" );
return VLC_EGENERIC;
}
}
......@@ -686,7 +677,7 @@ static int ParseSAP( services_discovery_t *p_sd, uint8_t *p_buffer, int i_read )
psz_sdp += 16;
if( i_read <= 21 )
{
msg_Warn( p_sd,"too short SAP packet\n" );
msg_Warn( p_sd, "too short SAP packet\n" );
return VLC_EGENERIC;
}
}
......@@ -873,11 +864,13 @@ sap_announce_t *CreateAnnounce( services_discovery_t *p_sd, uint16_t i_hash,
p_child = playlist_NodeCreate( p_playlist, VIEW_CATEGORY,
psz_grp, p_sd->p_sys->p_node );
free( psz_grp );
free( psz_value );
}
else
{
vlc_object_release( p_playlist );
msg_Err( p_sd, "out of memory");
free( psz_value );
free( p_sap );
return NULL;
}
......@@ -1060,7 +1053,7 @@ static int ParseConnection( vlc_object_t *p_obj, sdp_t *p_sdp )
free( psz_proto );
psz_proto = strdup( "rtp" );
}
if( psz_proto && !strncmp( psz_proto, "UDP", 3 ) )
if( psz_proto && !strncasecmp( psz_proto, "UDP", 3 ) )
{
free( psz_proto );
psz_proto = strdup( "udp" );
......
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