* announce.h : Session announcement
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: announce.h,v 1.2 2003/05/26 13:45:51 zorglub Exp $
+ * $Id: announce.h,v 1.3 2003/06/12 11:37:48 zorglub Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Laurent Aimar <fenrir@via.ecp.fr>
*****************************************************************************/
VLC_EXPORT( sap_session_t *, sout_SAPNew, ( sout_instance_t *,char * , char * , char * ) );
VLC_EXPORT( void, sout_SAPSend, ( sout_instance_t *,sap_session_t * ) );
-VLC_EXPORT( void, sout_SAPDelete, ( sap_session_t * ) );
+VLC_EXPORT( void, sout_SAPDelete, ( sout_instance_t *,sap_session_t * ) );
* standard.c
*****************************************************************************
* Copyright (C) 2001, 2002 VideoLAN
- * $Id: standard.c,v 1.3 2003/05/26 13:45:52 zorglub Exp $
+ * $Id: standard.c,v 1.4 2003/06/12 11:37:48 zorglub Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
{
msg_Dbg( p_sout , "Creating SAP" );
p_sap = sout_SAPNew( p_sout , psz_url , psz_port , psz_sap );
+ if(!p_sap)
+ {
+ msg_Err( p_sout,"Unable to initialize SAP. SAP disabled");
+ p_sys->b_sap=0;
+ }
}
/* XXX beurk */
sout_access_out_t *p_access = p_sys->p_mux->p_access;
if(p_sys -> b_sap)
- sout_SAPDelete( p_sys->p_sap );
+ sout_SAPDelete( p_this ,p_sys->p_sap );
sout_MuxDelete( p_sys->p_mux );
sout_AccessOutDelete( p_access );
struct sockaddr_in addr;
p_new = (sap_session_t *)malloc( sizeof ( sap_session_t ) ) ;
+
+ if ( !p_new )
+ return NULL;
sprintf ( p_new->psz_url , "%s" , psz_url_arg );
sprintf ( p_new->psz_name , "%s" , psz_name_arg );
/*****************************************************************************
* sout_SAPDelete: Deletes a SAP Session
*****************************************************************************/
-void sout_SAPDelete( sap_session_t * p_this )
+void sout_SAPDelete( sout_instance_t *p_sout , sap_session_t * p_this )
{
- shutdown(p_this->socket,0);
- free(p_this);
+ if( close(p_this->socket) )
+ msg_Err ( p_sout, "Unable to close SAP socket");
+ if( p_this ) free(p_this);
}
/*****************************************************************************
int i_msg_size;
int i_size;
- if( p_this->sendnow == 1 )
+ if( p_this->sendnow == 24 )
{
- i_header_size = 9 + strlen( payload_type );
- sap_head = ( char * )malloc( i_header_size * sizeof( char ) );
-
+ i_header_size = 9 + strlen( payload_type );
+ sap_head = ( char * )malloc( i_header_size * sizeof( char ) );
+
+ if( ! sap_head )
+ {
+ msg_Err( p_sout , "No memory left");
+ return;
+ }
+
sap_head[0]=0x20; /* Means IPv4, not encrypted, not compressed */
sap_head[1]=0x00; /* No authentification */
sap_head[2]=0x42; /* Version */
strncpy( sap_head+8 , payload_type , 15 );
sap_head[ i_header_size-1 ] = '\0';
- /* Do not add spaces at beginning of the lines ! */
+ /* Do not add spaces at beginning of the lines ! */
sprintf(sap_msg,"v=0\n\
o=VideoLAN 3247692199 3247895918 IN IP4 VideoLAN\n\
s=%s\n\
i_size = i_msg_size + i_header_size;
sap_send = ( char* )malloc( i_size*sizeof(char) );
-
+
+ if(! sap_send)
+ {
+ msg_Err( p_sout , "No memory left") ;
+ return;
+ }
+
for(i=0 ; i<i_header_size ; i++)
{
sap_send[i] = sap_head[i];