Commit 1df637dd authored by Sam Hocevar's avatar Sam Hocevar

* src/stream_output/announce.c:

    + Fixed a multiline string.
    + Coding style fixes.
parent 209f2eaf
......@@ -52,7 +52,6 @@ sap_session_t * sout_SAPNew ( sout_instance_t *p_sout ,
char * psz_name_arg, int ip_version,
char * psz_v6_scope )
{
sap_session_t *p_new; /* The SAP structure */
module_t *p_network; /* Network module */
network_socket_t socket_desc; /* Socket descriptor */
......@@ -76,7 +75,7 @@ sap_session_t * sout_SAPNew ( sout_instance_t *p_sout ,
p_new->i_ip_version = ip_version;
/* Only "6" triggers IPv6. IPv4 is default */
if(ip_version != 6)
if( ip_version != 6 )
{
msg_Dbg( p_sout , "Creating IPv4 SAP socket" );
......@@ -104,7 +103,6 @@ sap_session_t * sout_SAPNew ( sout_instance_t *p_sout ,
msg_Warn( p_sout, "Unable to initialize SAP" );
return NULL;
}
}
else
{
......@@ -150,7 +148,6 @@ sap_session_t * sout_SAPNew ( sout_instance_t *p_sout ,
return NULL;
}
/* Free what we allocated */
if( sap_ipv6_addr ) free(sap_ipv6_addr);
}
......@@ -166,7 +163,9 @@ sap_session_t * sout_SAPNew ( sout_instance_t *p_sout ,
void sout_SAPDelete( sout_instance_t *p_sout , sap_session_t * p_this )
{
if( close(p_this->socket) )
{
msg_Err ( p_sout, "Unable to close SAP socket");
}
if( p_this ) free( p_this );
}
......@@ -176,7 +175,6 @@ void sout_SAPDelete( sout_instance_t *p_sout , sap_session_t * p_this )
*****************************************************************************/
void sout_SAPSend( sout_instance_t *p_sout, sap_session_t * p_this)
{
char *sap_head; /* SAP header */
char sap_msg[1000]; /* SDP content */
char *sap_send; /* What we send */
......@@ -215,54 +213,52 @@ void sout_SAPSend( sout_instance_t *p_sout, sap_session_t * p_this)
/* Create the SDP content */
/* 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\
u=VideoLAN\n\
t=0 0\n\
m=audio %s udp 14\n\
c=IN IP4 %s/15\n\
a=type:test\n", p_this->psz_name , p_this->psz_port , p_this->psz_url );
sprintf( sap_msg, "v=0\n"
"o=VideoLAN 3247692199 3247895918 IN IP4 VideoLAN\n"
"s=%s\n"
"u=VideoLAN\n"
"t=0 0\n"
"m=audio %s udp 14\n"
"c=IN IP4 %s/15\n"
"a=type:test\n",
p_this->psz_name , p_this->psz_port , p_this->psz_url );
i_msg_size = strlen( sap_msg );
i_size = i_msg_size + i_header_size;
/* Create the message */
sap_send = ( char* )malloc( i_size*sizeof(char) );
if(! sap_send)
if( !sap_send )
{
msg_Err( p_sout , "No memory left") ;
return;
}
for(i=0 ; i<i_header_size ; i++)
for( i = 0 ; i < i_header_size ; i++ )
{
sap_send[i] = sap_head[i];
}
for( ; i<i_size; i++)
for( ; i < i_size ; i++ )
{
sap_send[i] = sap_msg[i-i_header_size];
}
if(i_size<1024) /* We mustn't send packets larger than 1024B */
if( i_size < 1024 ) /* We mustn't send packets larger than 1024B */
{
if( p_this->i_ip_version == 6)
{
i_send_result = send( p_this->socket , sap_send ,
i_size , 0 );
i_send_result = send( p_this->socket, sap_send, i_size, 0 );
}
else
{
i_send_result = send( p_this->socket , sap_send ,
i_size , 0 );
i_send_result = send( p_this->socket, sap_send, i_size, 0 );
}
}
if(i_send_result == -1)
if( i_send_result == -1 )
{
msg_Warn(p_sout , "SAP Send failed on socket %i. " ,
p_this->socket );
msg_Warn(p_sout, "SAP send failed on socket %i", p_this->socket );
perror("sendto");
}
......
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