[vlc-devel] [PATCH 1/2] rtp sout: randomize initial timestamp value

Pierre Ynard linkfanel at yahoo.fr
Sat Dec 12 03:55:01 CET 2009


RFC 3550 recommends this.


diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index 0e65085..9fff5e0 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -311,6 +311,7 @@ struct sout_stream_id_t
 
     sout_stream_t *p_stream;
     /* rtp field */
+    uint32_t    i_ts_offset;
     uint16_t    i_sequence;
     uint8_t     i_payload_type;
     uint8_t     ssrc[4];
@@ -929,6 +930,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     assert (id->i_payload_type < 128);
 
     vlc_rand_bytes (&id->i_sequence, sizeof (id->i_sequence));
+    vlc_rand_bytes (&id->i_ts_offset, sizeof (id->i_ts_offset));
     vlc_rand_bytes (id->ssrc, sizeof (id->ssrc));
 
     id->i_seq_sent_next = id->i_sequence;
@@ -1713,6 +1715,8 @@ void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
 {
     uint32_t i_timestamp = i_pts * (int64_t)id->i_clock_rate / CLOCK_FREQ;
 
+    i_timestamp += id->i_ts_offset;
+
     out->p_buffer[0] = 0x80;
     out->p_buffer[1] = (b_marker?0x80:0x00)|id->i_payload_type;
     out->p_buffer[2] = ( id->i_sequence >> 8)&0xff;


-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list