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