* sap.c : SAP interface module
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: sap.c,v 1.50 2004/01/22 01:14:50 sigmunau Exp $
+ * $Id$
*
* Authors: Arnaud Schauly <gitan@via.ecp.fr>
* Clément Stenac <zorglub@via.ecp.fr>
"Sets the scope for IPv6 announces (default is 8)")
#define SAP_TIMEOUT_TEXT N_("SAP timeout (seconds)")
#define SAP_TIMEOUT_LONGTEXT N_( \
- "Sets the time before SAP items get deleted if no new announce" \
- "is received")
+ "Sets the time before SAP items get deleted if no new announce " \
+ "is received.")
+#define SAP_PARSE_TEXT N_("Try to parse the SAP")
+#define SAP_PARSE_LONGTEXT N_( \
+ "When SAP can it will try to parse the SAP. Normal behaviour is" \
+ "to have livedotcom parse the announce." )
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin();
- add_category_hint( N_("SAP"), NULL, VLC_TRUE );
- add_string( "sap-addr", NULL, NULL,
- SAP_ADDR_TEXT, SAP_ADDR_LONGTEXT, VLC_TRUE );
-
- add_bool( "sap-ipv4", 1 , NULL,
- SAP_IPV4_TEXT,SAP_IPV4_LONGTEXT, VLC_TRUE);
-
- add_bool( "sap-ipv6", 0 , NULL,
- SAP_IPV6_TEXT, SAP_IPV6_LONGTEXT, VLC_TRUE);
-
- add_string( "sap-ipv6-scope", "8" , NULL,
- SAP_SCOPE_TEXT, SAP_SCOPE_LONGTEXT, VLC_TRUE);
+ set_description( _("SAP interface") );
- add_integer( "sap-timeout", 1800, NULL,
- SAP_TIMEOUT_TEXT, SAP_TIMEOUT_LONGTEXT, VLC_TRUE);
+ add_string( "sap-addr", NULL, NULL,
+ SAP_ADDR_TEXT, SAP_ADDR_LONGTEXT, VLC_TRUE );
+ add_bool( "sap-ipv4", 1 , NULL,
+ SAP_IPV4_TEXT,SAP_IPV4_LONGTEXT, VLC_TRUE);
+ add_bool( "sap-ipv6", 0 , NULL,
+ SAP_IPV6_TEXT, SAP_IPV6_LONGTEXT, VLC_TRUE);
+ add_string( "sap-ipv6-scope", "8" , NULL,
+ SAP_SCOPE_TEXT, SAP_SCOPE_LONGTEXT, VLC_TRUE);
+ add_integer( "sap-timeout", 1800, NULL,
+ SAP_TIMEOUT_TEXT, SAP_TIMEOUT_LONGTEXT, VLC_TRUE);
+ add_bool( "sap-parse", 1 , NULL,
+ SAP_PARSE_TEXT,SAP_PARSE_LONGTEXT, VLC_TRUE);
- set_description( _("SAP interface") );
set_capability( "interface", 0 );
set_callbacks( Open, Close );
vlc_module_end();
sock.i_ttl = 0;
p_intf->p_private = (void*) &sock;
- p_network = module_Need( p_intf, "network", "ipv4" );
+ p_network = module_Need( p_intf, "network", "ipv4", VLC_TRUE );
if( p_network )
{
p_sys->fd[0] = sock.i_handle;
sock.i_ttl = 0;
p_intf->p_private = (void*) &sock;
- p_network = module_Need( p_intf, "network", "ipv6" );
+ p_network = module_Need( p_intf, "network", "ipv6", VLC_TRUE );
if( p_network )
{
p_sys->fd[1] = sock.i_handle;
free( p_sys->pp_announces[i]->psz_uri );
free( p_sys->pp_announces[i] );
}
+ free( p_sys->pp_announces );
free( p_sys );
}
msg_Warn( p_intf, "ditching sap packet" );
}
+ memset( buffer, 0, MAX_SAP_BUFFER );
}
}
char *psz_uri, *psz_proto, *psz_item_uri;
char *psz_port;
char *psz_uri_default;
- int i_count , i , i_pos , i_id = 0;
+ int i_count, i, i_id = 0;
vlc_bool_t b_http = VLC_FALSE;
char *psz_http_path = NULL;
playlist_t *p_playlist = NULL;
+ playlist_item_t *p_item;
psz_uri_default = NULL;
- if( p_sd->i_media > 1 )
+ if( p_sd->i_media > 1 || !config_GetInt( p_intf, "sap-parse" ) )
{
asprintf( &psz_uri, "sdp://%s", p_sd->psz_sdp );
/* Check if we have already added the item */
PLAYLIST_CHECK_INSERT, PLAYLIST_END );
if( i_id != -1 )
{
- i_pos = playlist_GetPositionById( p_playlist, i_id );
- playlist_SetGroup( p_playlist, i_pos, p_intf->p_sys->i_group );
+ playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_id );
+ playlist_ItemSetGroup( p_item, p_intf->p_sys->i_group );
}
/* Remember it */
{
psz_http_path = strdup( "/" );
}
-
- psz_item_uri = malloc( strlen( psz_proto ) + strlen( psz_uri ) +
- strlen( psz_port ) + strlen(psz_http_path) +
- 5 );
- sprintf( psz_item_uri, "%s://%s:%s%s", psz_proto,
- psz_uri, psz_port,psz_http_path );
+ if( *psz_http_path == '/' )
+ {
+ asprintf( &psz_item_uri, "%s://%s:%s%s", psz_proto,
+ psz_uri, psz_port,psz_http_path );
+ }
+ else
+ {
+ asprintf( &psz_item_uri, "%s://%s:%s/%s", psz_proto, psz_uri,
+ psz_port, psz_http_path );
+ }
if( psz_http_path )
{
p_sd->psz_sessionname,
psz_item_uri );
- p_item = playlist_GetItemById( p_playlist,
+ p_item = playlist_ItemGetById( p_playlist,
p_intf->p_sys->pp_announces[i]->i_id );
/* Change the name in the item */
- if( p_item->psz_name )
- free( p_item->psz_name );
- p_item->psz_name = strdup( p_sd->psz_sessionname);
+ if( p_item->input.psz_name )
+ free( p_item->input.psz_name );
+ p_item->input.psz_name = strdup( p_sd->psz_sessionname);
/* Update the stored name */
if( p_intf->p_sys->pp_announces[i]->psz_name )
vlc_object_release( p_playlist );
}
+ free( psz_item_uri );
return;
}
}
i_id = playlist_Add ( p_playlist, psz_item_uri ,
p_sd->psz_sessionname,
PLAYLIST_CHECK_INSERT, PLAYLIST_END );
- i_pos = playlist_GetPositionById( p_playlist, i_id );
- playlist_SetGroup( p_playlist, i_pos, i_group );
+ p_item = playlist_ItemGetById( p_playlist, i_id );
+ if( p_item )
+ {
+ vlc_mutex_lock( &p_item->input.lock );
+ playlist_ItemSetGroup( p_item, i_group );
+ vlc_mutex_unlock( &p_item->input.lock );
+ }
/* Then remember it */
p_announce = (struct sap_announce_t *)malloc(
if( p_packet[1] != '=' )
{
- msg_Warn( p_intf, "packet invalid" );
+ msg_Warn( p_intf, "invalid packet") ;
free_sd( sd );
return NULL;
}