rtsp-client: Use a random session ID in the SDP
authorSebastian Dröge <sebastian@centricular.com>
Sun, 18 Jan 2015 18:08:36 +0000 (19:08 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Sun, 18 Jan 2015 18:08:36 +0000 (19:08 +0100)
RFC4566 Section 5.2 says that it should make the username, session id,
nettype, addrtype and unicast address tuple globally unique. Always using
1188340656180883 is not going to guarantee that: https://xkcd.com/221/

Instead let's create a 64 bit random number, which at least brings us
closer to the goal of global uniqueness.

https://tools.ietf.org/html/rfc4566#section-5.2

gst/rtsp-server/rtsp-client.c

index faff8b1..6fbb5ea 100644 (file)
@@ -2008,6 +2008,8 @@ create_sdp (GstRTSPClient * client, GstRTSPMedia * media)
   GstSDPMessage *sdp;
   GstSDPInfo info;
   const gchar *proto;
+  guint64 session_id_tmp;
+  gchar session_id[21];
 
   gst_sdp_message_new (&sdp);
 
@@ -2019,7 +2021,11 @@ create_sdp (GstRTSPClient * client, GstRTSPMedia * media)
   else
     proto = "IP4";
 
-  gst_sdp_message_set_origin (sdp, "-", "1188340656180883", "1", "IN", proto,
+  session_id_tmp = (((guint64) g_random_int ()) << 32) | g_random_int ();
+  g_snprintf (session_id, sizeof (session_id), "%" G_GUINT64_FORMAT,
+      session_id_tmp);
+
+  gst_sdp_message_set_origin (sdp, "-", session_id, "1", "IN", proto,
       priv->server_ip);
 
   gst_sdp_message_set_session_name (sdp, "Session streamed with GStreamer");