RTP sout: pick truly random ISN and SSRC
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 3 Dec 2008 19:53:12 +0000 (21:53 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Wed, 3 Dec 2008 19:53:12 +0000 (21:53 +0200)
We were always picking the same values. This is pretty bad as it breaks
fast resynchronization (and is totally lame anyway).

modules/stream_out/rtp.c

index 119d153..30b34aa 100644 (file)
@@ -39,6 +39,7 @@
 #include <vlc_network.h>
 #include <vlc_charset.h>
 #include <vlc_strings.h>
+#include <vlc_rand.h>
 #include <srtp.h>
 
 #include "rtp.h"
@@ -890,17 +891,14 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 
     id->p_stream   = p_stream;
 
-    id->i_sequence = rand()&0xffff;
     /* Look for free dymanic payload type */
     id->i_payload_type = 96;
     while (p_sys->payload_bitmap & (1 << (id->i_payload_type - 96)))
         id->i_payload_type++;
     assert (id->i_payload_type < 128);
 
-    id->ssrc[0] = rand()&0xff;
-    id->ssrc[1] = rand()&0xff;
-    id->ssrc[2] = rand()&0xff;
-    id->ssrc[3] = rand()&0xff;
+    vlc_rand_bytes (&id->i_sequence, sizeof (id->i_sequence));
+    vlc_rand_bytes (id->ssrc, sizeof (id->ssrc));
 
     id->psz_enc    = NULL;
     id->psz_fmtp   = NULL;