Commit da014eb8 authored by Arnaud Schauly's avatar Arnaud Schauly

fixed a segfault under windows.

parent 0c091c92
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sap.c : SAP interface module * sap.c : SAP interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: sap.c,v 1.4 2002/12/06 22:44:03 gitan Exp $ * $Id: sap.c,v 1.5 2002/12/10 00:02:29 gitan Exp $
* *
* Authors: Arnaud Schauly <gitan@via.ecp.fr> * Authors: Arnaud Schauly <gitan@via.ecp.fr>
* *
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
#define MAX_LINE_LENGTH 256 #define MAX_LINE_LENGTH 256
/* SAP is always on that port */ /* SAP is always on that port */
#define HELLO_PORT 9875 #define HELLO_PORT 9875
#define HELLO_GROUP "239.255.255.255" #define HELLO_GROUP "224.2.127.254"
#define ADD_SESSION 1 #define ADD_SESSION 1
/***************************************************************************** /*****************************************************************************
...@@ -81,7 +81,7 @@ typedef struct sess_descr_t sess_descr_t; ...@@ -81,7 +81,7 @@ typedef struct sess_descr_t sess_descr_t;
static int Activate ( vlc_object_t * ); static int Activate ( vlc_object_t * );
static void Run ( intf_thread_t *p_intf ); static void Run ( intf_thread_t *p_intf );
static int Kill ( intf_thread_t * ); static int Kill ( intf_thread_t * );
static ssize_t NetRead ( intf_thread_t*, int , byte_t *, size_t ); static ssize_t NetRead ( intf_thread_t*, int , byte_t *, size_t );
/* playlist related functions */ /* playlist related functions */
...@@ -95,7 +95,7 @@ static sess_descr_t * parse_sdp( char *,intf_thread_t * ) ; ...@@ -95,7 +95,7 @@ static sess_descr_t * parse_sdp( char *,intf_thread_t * ) ;
/* specific sdp fields parsing */ /* specific sdp fields parsing */
static void cfield_parse( char *, char ** ); static void cfield_parse( char *, char ** );
static void mfield_parse( char *psz_mfield, char **ppsz_proto, static void mfield_parse( char *psz_mfield, char **ppsz_proto,
char **ppsz_port ); char **ppsz_port );
static void free_sd( sess_descr_t * ); static void free_sd( sess_descr_t * );
...@@ -104,19 +104,19 @@ static int ismult( char * ); ...@@ -104,19 +104,19 @@ static int ismult( char * );
/* The struct that contains sdp informations */ /* The struct that contains sdp informations */
struct sess_descr_t { struct sess_descr_t {
char *psz_version; char *psz_version;
char *psz_origin; char *psz_origin;
char *psz_sessionname; char *psz_sessionname;
char *psz_information; char *psz_information;
char *psz_uri; char *psz_uri;
char *psz_emails; char *psz_emails;
char *psz_phone; char *psz_phone;
char *psz_time; char *psz_time;
char *psz_repeat; char *psz_repeat;
char *psz_attribute; char *psz_attribute;
char *psz_connection; char *psz_connection;
int i_media; int i_media;
media_descr_t ** pp_media; media_descr_t ** pp_media;
}; };
/* All this informations are not useful yet. */ /* All this informations are not useful yet. */
struct media_descr_t { struct media_descr_t {
...@@ -129,7 +129,7 @@ struct media_descr_t { ...@@ -129,7 +129,7 @@ struct media_descr_t {
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
add_category_hint( N_("SAP"), NULL ); add_category_hint( N_("SAP"), NULL );
add_string( "sap-addr", NULL, NULL, add_string( "sap-addr", NULL, NULL,
"SAP multicast address", "SAP multicast address" ); "SAP multicast address", "SAP multicast address" );
set_description( _("SAP interface module") ); set_description( _("SAP interface module") );
set_capability( "interface", 0 ); set_capability( "interface", 0 );
...@@ -164,14 +164,14 @@ static void Run( intf_thread_t *p_intf ) ...@@ -164,14 +164,14 @@ static void Run( intf_thread_t *p_intf )
module_t *p_network; module_t *p_network;
network_socket_t socket_desc; network_socket_t socket_desc;
psz_buf = NULL; psz_buf = NULL;
if( !(psz_addr = config_GetPsz( p_intf, "sap-addr" ) ) ) if( !(psz_addr = config_GetPsz( p_intf, "sap-addr" ) ) )
{ {
psz_addr = strdup( HELLO_GROUP ); psz_addr = strdup( HELLO_GROUP );
} }
/* Prepare the network_socket_t structure */ /* Prepare the network_socket_t structure */
socket_desc.i_type = NETWORK_UDP; socket_desc.i_type = NETWORK_UDP;
socket_desc.psz_bind_addr = psz_addr; socket_desc.psz_bind_addr = psz_addr;
...@@ -180,8 +180,8 @@ static void Run( intf_thread_t *p_intf ) ...@@ -180,8 +180,8 @@ static void Run( intf_thread_t *p_intf )
socket_desc.i_server_port = 0; socket_desc.i_server_port = 0;
p_intf->p_private = (void*) &socket_desc; p_intf->p_private = (void*) &socket_desc;
psz_network = "ipv4"; // FIXME psz_network = "ipv4"; // FIXME
/* Create, Bind the socket, ... with the appropriate module */ /* Create, Bind the socket, ... with the appropriate module */
if( !( p_network = module_Need( p_intf, "network", psz_network ) ) ) if( !( p_network = module_Need( p_intf, "network", psz_network ) ) )
...@@ -189,26 +189,25 @@ static void Run( intf_thread_t *p_intf ) ...@@ -189,26 +189,25 @@ static void Run( intf_thread_t *p_intf )
msg_Err( p_intf, "failed to open a connection (udp)" ); msg_Err( p_intf, "failed to open a connection (udp)" );
return; return;
} }
module_Unneed( p_intf, p_network ); module_Unneed( p_intf, p_network );
fd = socket_desc.i_handle; fd = socket_desc.i_handle;
/* read SAP packets */ /* read SAP packets */
psz_buf = malloc( 2000 ); psz_buf = malloc( 2000 );
while( !p_intf->b_die ) while( !p_intf->b_die )
{ {
int i_read; int i_read;
addrlen=sizeof(addr); addrlen=sizeof(addr);
memset(psz_buf, 0, 2000); memset(psz_buf, 0, 2000);
i_read = NetRead( p_intf, fd, psz_buf, 2000 ); i_read = NetRead( p_intf, fd, psz_buf, 2000 );
if( i_read < 0 ) if( i_read < 0 )
{ {
msg_Err( p_intf, "Cannot read in the socket" ); msg_Err( p_intf, "Cannot read in the socket" );
...@@ -220,12 +219,12 @@ static void Run( intf_thread_t *p_intf ) ...@@ -220,12 +219,12 @@ static void Run( intf_thread_t *p_intf )
packet_handle( p_intf, &psz_buf ); packet_handle( p_intf, &psz_buf );
} }
free( psz_buf ); free( psz_buf );
/* Closing socket */ /* Closing socket */
#ifdef UNDER_CE #ifdef UNDER_CE
CloseHandle( socket_desc.i_handle ); CloseHandle( socket_desc.i_handle );
#elif defined( WIN32 ) #elif defined( WIN32 )
...@@ -233,13 +232,13 @@ static void Run( intf_thread_t *p_intf ) ...@@ -233,13 +232,13 @@ static void Run( intf_thread_t *p_intf )
#else #else
close( socket_desc.i_handle ); close( socket_desc.i_handle );
#endif #endif
} }
/******************************************************************** /********************************************************************
* Kill * Kill
******************************************************************* *******************************************************************
* Kills the SAP interface. * Kills the SAP interface.
********************************************************************/ ********************************************************************/
static int Kill( intf_thread_t *p_intf ) static int Kill( intf_thread_t *p_intf )
{ {
...@@ -250,11 +249,11 @@ static int Kill( intf_thread_t *p_intf ) ...@@ -250,11 +249,11 @@ static int Kill( intf_thread_t *p_intf )
} }
/******************************************************************* /*******************************************************************
* sess_toitem : changes a sess_descr_t into a hurd of * sess_toitem : changes a sess_descr_t into a hurd of
* playlist_item_t, which are enqueued. * playlist_item_t, which are enqueued.
******************************************************************* *******************************************************************
* Note : does not support sessions that take place on consecutive * Note : does not support sessions that take place on consecutive
* port or adresses yet. * port or adresses yet.
*******************************************************************/ *******************************************************************/
static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
...@@ -266,11 +265,10 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -266,11 +265,10 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
int i_multicast; int i_multicast;
int i_count; int i_count;
playlist_t *p_playlist; playlist_t *p_playlist;
psz_uri_default = NULL;
psz_uri_default = NULL;
cfield_parse( p_sd->psz_connection, &psz_uri_default ); cfield_parse( p_sd->psz_connection, &psz_uri_default );
for( i_count=0 ; i_count <= p_sd->i_media ; i_count ++ ) for( i_count=0 ; i_count <= p_sd->i_media ; i_count ++ )
{ {
...@@ -278,22 +276,22 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -278,22 +276,22 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
p_item->psz_name = strdup( p_sd->psz_sessionname ); p_item->psz_name = strdup( p_sd->psz_sessionname );
p_item->i_type = 0; p_item->i_type = 0;
p_item->i_status = 0; p_item->i_status = 0;
p_item->b_autodeletion = VLC_FALSE; p_item->b_autodeletion = VLC_FALSE;
p_item->psz_uri = NULL; p_item->psz_uri = NULL;
psz_uri = NULL; psz_uri = NULL;
/* Build what we have to put in p_item->psz_uri, with the m and /* Build what we have to put in p_item->psz_uri, with the m and
* c fields */ * c fields */
if( !p_sd->pp_media[i_count] ) if( !p_sd->pp_media[i_count] )
{ {
return 0; return 0;
} }
mfield_parse( p_sd->pp_media[i_count]->psz_medianame, mfield_parse( p_sd->pp_media[i_count]->psz_medianame,
& psz_proto, & psz_port ); & psz_proto, & psz_port );
if( !psz_proto || !psz_port ) if( !psz_proto || !psz_port )
{ {
return 0; return 0;
...@@ -301,10 +299,10 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -301,10 +299,10 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
if( p_sd->pp_media[i_count]->psz_mediaconnection ) if( p_sd->pp_media[i_count]->psz_mediaconnection )
{ {
cfield_parse( p_sd->pp_media[i_count]->psz_mediaconnection, cfield_parse( p_sd->pp_media[i_count]->psz_mediaconnection,
& psz_uri ); & psz_uri );
} }
else else
{ {
psz_uri = NULL; psz_uri = NULL;
} }
...@@ -323,38 +321,39 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -323,38 +321,39 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
/* Filling p_item->psz_uri */ /* Filling p_item->psz_uri */
i_multicast = ismult( psz_uri ); i_multicast = ismult( psz_uri );
p_item->psz_uri = malloc( strlen( psz_proto ) + strlen( psz_uri ) +
p_item->psz_uri = malloc( strlen( psz_proto ) + strlen( psz_uri ) +
strlen( psz_port ) + 5 +i_multicast ); strlen( psz_port ) + 5 +i_multicast );
if( p_item->psz_uri == NULL ) if( p_item->psz_uri == NULL )
{ {
msg_Err( p_intf, "Not enough memory"); msg_Err( p_intf, "Not enough memory");
return 0; return 0;
} }
if( i_multicast == 1) if( i_multicast == 1)
{ {
sprintf( p_item->psz_uri, "%s://@%s:%s", psz_proto, sprintf( p_item->psz_uri, "%s://@%s:%s", psz_proto,
psz_uri, psz_port ); psz_uri, psz_port );
} }
else else
{ {
sprintf( p_item->psz_uri, "%s://%s:%s", psz_proto, sprintf( p_item->psz_uri, "%s://%s:%s", psz_proto,
psz_uri, psz_port ); psz_uri, psz_port );
} }
/* Enqueueing p_item in the playlist */ /* Enqueueing p_item in the playlist */
if( p_item ) if( p_item )
{ {
p_playlist = vlc_object_find( p_intf, p_playlist = vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_AddItem ( p_playlist, p_item, playlist_AddItem ( p_playlist, p_item,
PLAYLIST_CHECK_INSERT, PLAYLIST_END); PLAYLIST_CHECK_INSERT, PLAYLIST_END);
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
} }
} }
...@@ -366,29 +365,29 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd ) ...@@ -366,29 +365,29 @@ static int sess_toitem( intf_thread_t * p_intf, sess_descr_t * p_sd )
/********************************************************************** /**********************************************************************
* cfield_parse * cfield_parse
********************************************************************* *********************************************************************
* put into *ppsz_uri, the the uri in the cfield, psz_cfield. * put into *ppsz_uri, the the uri in the cfield, psz_cfield.
*********************************************************************/ *********************************************************************/
static void cfield_parse( char *psz_cfield, char **ppsz_uri ) static void cfield_parse( char *psz_cfield, char **ppsz_uri )
{ {
char *psz_pos; char *psz_pos;
if( psz_cfield ) if( psz_cfield )
{ {
psz_pos = psz_cfield; psz_pos = psz_cfield;
while( *psz_pos && *psz_pos != ' ' && *psz_pos !='\0' ) while( *psz_pos != ' ' && *psz_pos !='\0' )
{ {
psz_pos++; psz_pos++;
} }
psz_pos++; psz_pos++;
while( *psz_pos && *psz_pos != ' ' && *psz_pos !='\0' ) while( *psz_pos != ' ' && *psz_pos !='\0' )
{ {
psz_pos++; psz_pos++;
} }
psz_pos++; psz_pos++;
*ppsz_uri = psz_pos; *ppsz_uri = psz_pos;
while( *psz_pos && *psz_pos != ' ' && *psz_pos !='/' while( *psz_pos != ' ' && *psz_pos !='/'
&& *psz_pos != '\0' ) && *psz_pos != '\0' )
{ {
psz_pos++; psz_pos++;
...@@ -400,51 +399,52 @@ static void cfield_parse( char *psz_cfield, char **ppsz_uri ) ...@@ -400,51 +399,52 @@ static void cfield_parse( char *psz_cfield, char **ppsz_uri )
{ {
ppsz_uri = NULL; ppsz_uri = NULL;
} }
return; return;
} }
/********************************************************************** /**********************************************************************
* mcfield_parse * mfield_parse
********************************************************************* *********************************************************************
* put into *ppsz_proto, and *ppsz_port, the protocol and the port. * put into *ppsz_proto, and *ppsz_port, the protocol and the port.
*********************************************************************/ *********************************************************************/
static void mfield_parse( char *psz_mfield, char **ppsz_proto, static void mfield_parse( char *psz_mfield, char **ppsz_proto,
char **ppsz_port ) char **ppsz_port )
{ {
char *psz_pos; char *psz_pos;
if( psz_mfield ) if( psz_mfield )
{ {
psz_pos = psz_mfield; psz_pos = psz_mfield;
while( *psz_pos && *psz_pos != ' ' ) while( *psz_pos != '\0' && *psz_pos != ' ' )
{ {
psz_pos++; psz_pos++;
} }
psz_pos++; psz_pos++;
*ppsz_port = psz_pos; *ppsz_port = psz_pos;
while( *psz_pos && *psz_pos !=' ' && *psz_pos!='/' ) while( *psz_pos != '\0' && *psz_pos && *psz_pos !=' ' && *psz_pos!='/' )
{ {
psz_pos++; psz_pos++;
} }
if( *psz_pos == '/' ) // FIXME does not support multi-port if( *psz_pos == '/' ) // FIXME does not support multi-port
{ {
*psz_pos = '\0'; *psz_pos = '\0';
while( *psz_pos && *psz_pos !=' ' ) psz_pos++;
while( *psz_pos != '\0' && *psz_pos !=' ' )
{ {
psz_pos++; psz_pos++;
} }
} }
*psz_pos = '\0'; *psz_pos = '\0';
psz_pos++; psz_pos++;
*ppsz_proto = psz_pos; *ppsz_proto = psz_pos;
while( *psz_pos && *psz_pos !=' ' && *psz_pos!='\0' && while( *psz_pos!='\0' && *psz_pos !=' ' &&
*psz_pos!='/' ) *psz_pos!='/' )
{ {
*psz_pos = tolower( *psz_pos ); *psz_pos = tolower( *psz_pos );
psz_pos++; psz_pos++;
} }
*psz_pos = '\0'; *psz_pos = '\0';
} }
...@@ -459,7 +459,7 @@ static void mfield_parse( char *psz_mfield, char **ppsz_proto, ...@@ -459,7 +459,7 @@ static void mfield_parse( char *psz_mfield, char **ppsz_proto,
/*********************************************************************** /***********************************************************************
* parse_sap : Takes care of the SAP headers * parse_sap : Takes care of the SAP headers
*********************************************************************** ***********************************************************************
* checks if the packet has the true headers ; * checks if the packet has the true headers ;
***********************************************************************/ ***********************************************************************/
static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothing !*/ static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothing !*/
...@@ -468,30 +468,29 @@ static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothin ...@@ -468,30 +468,29 @@ static int parse_sap( char ** ppsz_sa_packet ) { /* Dummy Parser : does nothin
} }
/************************************************************************* /*************************************************************************
* packet_handle : handle the received packet and enques the * packet_handle : handle the received packet and enques the
* the understated session * the understated session
*************************************************************************/ *************************************************************************/
static int packet_handle( intf_thread_t * p_intf, char ** ppsz_packet ) { static int packet_handle( intf_thread_t * p_intf, char ** ppsz_packet ) {
int j=0; int j=0;
sess_descr_t * p_sd; sess_descr_t * p_sd;
/* playlist_t *p_playlist;
playlist_item_t *p_item; */
j=parse_sap( ppsz_packet ); j=parse_sap( ppsz_packet );
if(j != 0) { if(j != 0) {
p_sd = parse_sdp( *ppsz_packet, p_intf );
p_sd = parse_sdp( *ppsz_packet, p_intf );
sess_toitem ( p_intf, p_sd ); sess_toitem ( p_intf, p_sd );
free_sd ( p_sd ); free_sd ( p_sd );
return 1; return 1;
} }
return 0; // Invalid Packet return 0; // Invalid Packet
} }
...@@ -501,13 +500,13 @@ static int packet_handle( intf_thread_t * p_intf, char ** ppsz_packet ) { ...@@ -501,13 +500,13 @@ static int packet_handle( intf_thread_t * p_intf, char ** ppsz_packet ) {
* Make a sess_descr_t with a psz * Make a sess_descr_t with a psz
***********************************************************************/ ***********************************************************************/
static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
{ {
int j,k; int j,k;
char ** ppsz_fill=NULL; char ** ppsz_fill=NULL;
sess_descr_t * sd; sess_descr_t * sd;
sd = malloc( sizeof(sess_descr_t) ); sd = malloc( sizeof(sess_descr_t) );
if( sd == NULL ) if( sd == NULL )
...@@ -517,9 +516,9 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -517,9 +516,9 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
else else
{ {
sd->pp_media = NULL; sd->pp_media = NULL;
sd->psz_origin = NULL; sd->psz_origin = NULL;
sd->psz_sessionname = NULL; sd->psz_sessionname = NULL;
sd->psz_information = NULL; sd->psz_information = NULL;
sd->psz_uri = NULL; sd->psz_uri = NULL;
sd->psz_emails = NULL; sd->psz_emails = NULL;
sd->psz_phone = NULL; sd->psz_phone = NULL;
...@@ -529,17 +528,17 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -529,17 +528,17 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
sd->psz_connection = NULL; sd->psz_connection = NULL;
sd->i_media=-1; sd->i_media=-1;
j=0; j=0;
while( psz_pct[j]!=EOF ) while( psz_pct[j]!=EOF && psz_pct[j] != '\0' )
{ {
j++; j++;
if (psz_pct[j] == '=') if (psz_pct[j] == '=')
{ {
switch(psz_pct[(j-1)]) { switch(psz_pct[(j-1)]) {
case ('v') : { case ('v') : {
ppsz_fill = & sd->psz_version; ppsz_fill = & sd->psz_version;
break; break;
} }
case ('o') : { case ('o') : {
ppsz_fill = & sd->psz_origin; ppsz_fill = & sd->psz_origin;
break; break;
...@@ -579,16 +578,16 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -579,16 +578,16 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
case ('m') : { case ('m') : {
sd->i_media++; sd->i_media++;
if( sd->pp_media ) { if( sd->pp_media ) {
sd->pp_media = realloc( sd->pp_media, sd->pp_media = realloc( sd->pp_media,
( sizeof( void * ) * (sd->i_media + 1)) ); ( sizeof( void * ) * (sd->i_media + 1)) );
} }
else else
{ {
sd->pp_media = malloc( sizeof ( void * ) ); sd->pp_media = malloc( sizeof ( void * ) );
} }
sd->pp_media[sd->i_media] = sd->pp_media[sd->i_media] =
malloc( sizeof( media_descr_t ) ); malloc( sizeof( media_descr_t ) );
sd->pp_media[sd->i_media]->psz_medianame = NULL; sd->pp_media[sd->i_media]->psz_medianame = NULL;
sd->pp_media[sd->i_media]->psz_mediaconnection = NULL; sd->pp_media[sd->i_media]->psz_mediaconnection = NULL;
...@@ -596,11 +595,11 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -596,11 +595,11 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
break; break;
} }
case ('c') : { case ('c') : {
if( sd->i_media == -1 ) if( sd->i_media == -1 )
{ {
ppsz_fill = & sd->psz_connection; ppsz_fill = & sd->psz_connection;
} }
else else
{ {
ppsz_fill = & sd->pp_media[sd->i_media]-> ppsz_fill = & sd->pp_media[sd->i_media]->
psz_mediaconnection; psz_mediaconnection;
...@@ -608,19 +607,19 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -608,19 +607,19 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
break; break;
} }
default : { default : {
msg_Info( p_intf, "Warning : Ignored field \"%c\" ",
psz_pct[j-1] );
ppsz_fill = NULL; ppsz_fill = NULL;
} }
} }
k=0;j++; k=0;j++;
while (psz_pct[j] != '\n'&& psz_pct[j] != EOF) { while (psz_pct[j] != '\n'&& psz_pct[j] != EOF) {
k++; j++; k++; j++;
} }
j--; j--;
if( ppsz_fill != NULL ) if( ppsz_fill != NULL )
{ {
*ppsz_fill= malloc( sizeof(char) * (k+1) ); *ppsz_fill= malloc( sizeof(char) * (k+1) );
...@@ -637,11 +636,12 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf ) ...@@ -637,11 +636,12 @@ static sess_descr_t * parse_sdp( char * psz_pct, intf_thread_t * p_intf )
#define FREE( p ) \ #define FREE( p ) \
if( p ) { free( p ); (p) = NULL; } if( p ) { free( p ); (p) = NULL; }
static void free_sd( sess_descr_t * p_sd ) static void free_sd( sess_descr_t * p_sd )
{ {
int i; int i;
if( p_sd ) if( p_sd )
{ {
FREE( p_sd->psz_origin ); FREE( p_sd->psz_origin );
FREE( p_sd->psz_sessionname ); FREE( p_sd->psz_sessionname );
FREE( p_sd->psz_information ); FREE( p_sd->psz_information );
...@@ -661,7 +661,7 @@ static void free_sd( sess_descr_t * p_sd ) ...@@ -661,7 +661,7 @@ static void free_sd( sess_descr_t * p_sd )
FREE( p_sd->pp_media[i]->psz_mediaconnection ); FREE( p_sd->pp_media[i]->psz_mediaconnection );
} }
FREE( p_sd->pp_media ); FREE( p_sd->pp_media );
} }
free( p_sd ); free( p_sd );
} }
else else
...@@ -681,20 +681,21 @@ static int ismult( char *psz_uri ) ...@@ -681,20 +681,21 @@ static int ismult( char *psz_uri )
int i; int i;
psz_c = malloc( 3 ); psz_c = malloc( 3 );
memcpy( psz_c, psz_uri, 3 ); memcpy( psz_c, psz_uri, 3 );
if( psz_c[2] == '.' || psz_c[1] == '.' ) if( psz_c[2] == '.' || psz_c[1] == '.' )
{ {
free( psz_c ); free( psz_c );
return 0; return 0;
} }
i = atoi( psz_c ); i = atoi( psz_c );
if( i < 224 ) if( i < 224 )
{ {
free( psz_c ); free( psz_c );
return 0; return 0;
} }
free( psz_c ); free( psz_c );
return 1; return 1;
} }
...@@ -704,29 +705,29 @@ static int ismult( char *psz_uri ) ...@@ -704,29 +705,29 @@ static int ismult( char *psz_uri )
***************************************************************************** *****************************************************************************
* Taken from udp.c * Taken from udp.c
******************************************************************************/ ******************************************************************************/
static ssize_t NetRead( intf_thread_t *p_intf, static ssize_t NetRead( intf_thread_t *p_intf,
int i_handle, byte_t *p_buffer, size_t i_len) int i_handle, byte_t *p_buffer, size_t i_len)
{ {
#ifdef UNDER_CE #ifdef UNDER_CE
return -1; return -1;
#else #else
struct timeval timeout; struct timeval timeout;
fd_set fds; fd_set fds;
int i_ret; int i_ret;
/* Initialize file descriptor set */ /* Initialize file descriptor set */
FD_ZERO( &fds ); FD_ZERO( &fds );
FD_SET( i_handle, &fds ); FD_SET( i_handle, &fds );
/* We'll wait 0.5 second if nothing happens */ /* We'll wait 0.5 second if nothing happens */
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_usec = 500000; timeout.tv_usec = 500000;
/* Find if some data is available */ /* Find if some data is available */
i_ret = select( i_handle + 1, &fds, i_ret = select( i_handle + 1, &fds,
NULL, NULL, &timeout ); NULL, NULL, &timeout );
if( i_ret == -1 && errno != EINTR ) if( i_ret == -1 && errno != EINTR )
{ {
msg_Err( p_intf, "network select error (%s)", strerror(errno) ); msg_Err( p_intf, "network select error (%s)", strerror(errno) );
...@@ -734,15 +735,15 @@ static ssize_t NetRead( intf_thread_t *p_intf, ...@@ -734,15 +735,15 @@ static ssize_t NetRead( intf_thread_t *p_intf,
else if( i_ret > 0 ) else if( i_ret > 0 )
{ {
ssize_t i_recv = recv( i_handle, p_buffer, i_len, 0 ); ssize_t i_recv = recv( i_handle, p_buffer, i_len, 0 );
if( i_recv < 0 ) if( i_recv < 0 )
{ {
msg_Err( p_intf, "recv failed (%s)", strerror(errno) ); msg_Err( p_intf, "recv failed (%s)", strerror(errno) );
} }
return i_recv; return i_recv;
} }
return 0; return 0;
#endif #endif
......
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