]> git.sesse.net Git - vlc/blobdiff - src/stream_output/sap.c
Basic unit test for URI decoding
[vlc] / src / stream_output / sap.c
index e8a748461925adbbc1ef4efac18af64a63a59af7..4a63b198bd44e892b22c093367ff4f7d25f57518 100644 (file)
@@ -123,7 +123,7 @@ sap_handler_t *announce_SAPHandlerCreate( announce_handler_t *p_announce )
     if( vlc_thread_create( p_sap, "sap handler", RunThread,
                        VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
     {
-        msg_Dbg( p_announce, "Unable to spawn SAP handler thread");
+        msg_Dbg( p_announce, "unable to spawn SAP handler thread");
         free( p_sap );
         return NULL;
     };
@@ -246,7 +246,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
     if( p_session->psz_uri == NULL )
     {
         vlc_mutex_unlock( &p_sap->object_lock );
-        msg_Err( p_sap, "*FIXME* Unexpected NULL URI for SAP announce" );
+        msg_Err( p_sap, "*FIXME* unexpected NULL URI for SAP announce" );
         msg_Err( p_sap, "This should not happen. VLC needs fixing." );
         return VLC_EGENERIC;
     }
@@ -317,9 +317,21 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
             if ((ipv4 & 0xfffc0000) == 0xefc00000)
                 ipv4 =  0xefc3ffff;
             else
+            if ((ipv4 & 0xff000000) == 0xef000000)
+                ipv4 = 0;
+            else
             /* other addresses => 224.2.127.254 */
                 ipv4 = 0xe0027ffe;
 
+            if( ipv4 == 0 )
+            {
+                msg_Err( p_sap, "Out-of-scope multicast address "
+                        "not supported by SAP: %s", p_session->psz_uri );
+                vlc_mutex_unlock( &p_sap->object_lock );
+                vlc_freeaddrinfo( res );
+                return VLC_EGENERIC;
+            }
+
             ((struct sockaddr_in *)&addr)->sin_addr.s_addr = htonl( ipv4 );
             break;
         }
@@ -485,7 +497,7 @@ static int announce_SAPAnnounceAdd( sap_handler_t *p_sap,
                  p_sap->i_sessions,
                  p_sap->i_sessions,
                  p_sap_session );
-    msg_Dbg( p_sap,"Addresses: %i  Sessions: %i",
+    msg_Dbg( p_sap,"%i addresses, %i sessions",
                    p_sap->i_addresses,p_sap->i_sessions);
 
     /* Remember the SAP session for later deletion */
@@ -548,7 +560,7 @@ static int announce_SendSAPAnnounce( sap_handler_t *p_sap,
     if( p_session->i_next < mdate() )
     {
 #ifdef EXTRA_DEBUG
-        msg_Dbg( p_sap, "Sending announce");
+        msg_Dbg( p_sap, "sending announce");
 #endif
         i_ret = net_Write( p_sap, p_session->p_address->i_wfd, NULL,
                            p_session->psz_data,
@@ -616,7 +628,9 @@ static char *SDPGenerate( sap_handler_t *p_sap,
                             "%s%s%s",
                             i_sdp_id, i_sdp_version,
                             ipv, p_addr->psz_machine,
-                            psz_name, ipv, psz_uri, p_session->i_ttl,
+                            psz_name, ipv, psz_uri,
+                            /* FIXME: 1 is IPv4 default TTL, not that of IPv6 */
+                            p_session->i_ttl ?: (config_GetInt( p_sap, "ttl" ) ?: 1),
                             p_session->i_port, 
                             p_session->b_rtp ? "RTP/AVP" : "udp",
                             p_session->i_payload,
@@ -673,7 +687,7 @@ static int CalculateRate( sap_handler_t *p_sap, sap_address_t *p_address )
         p_address->i_interval = MAX_INTERVAL;
     }
 #ifdef EXTRA_DEBUG
-    msg_Dbg( p_sap,"%s:%i : Rate=%i, Interval = %i s",
+    msg_Dbg( p_sap,"%s:%i: rate=%i, interval = %i s",
              p_address->psz_address,SAP_PORT, i_rate, p_address->i_interval );
 #endif