]> git.sesse.net Git - vlc/commitdiff
Use hostname as SDP origin, as the spec says.
authorRémi Denis-Courmont <rem@videolan.org>
Tue, 21 Aug 2007 17:15:51 +0000 (17:15 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Tue, 21 Aug 2007 17:15:51 +0000 (17:15 +0000)
(Oh, I am well aware that this is often not correctly set, but then again,
 why the heck would someone wants to parse the SDP origin in real life?)

src/stream_output/sap.c
src/stream_output/sdp.c
src/stream_output/stream_output.h

index b2782c7030e8a3c362aba396e1da04841415d078..9dee242f40f93cca092f137259f842a04e54726b 100644 (file)
@@ -598,7 +598,7 @@ static char *SDPGenerate( sap_handler_t *p_sap,
     char *psz_group, *psz_name, *psz_sdp;
 
      char *head = StartSDP (p_session->psz_name, p_session->description,
-        p_session->url, p_session->email, p_session->phone, b_ssm,
+        p_session->url, p_session->email, p_session->phone,
         (const struct sockaddr *)&p_session->orig, p_session->origlen,
         (const struct sockaddr *)&p_session->addr, p_session->addrlen);
     if (head == NULL)
index 13d8396af297043b93283b307c7749f63a4920ae..d88a81a43480f6f7851cfe5ed3169948270066e6 100644 (file)
@@ -87,15 +87,18 @@ static vlc_bool_t IsSDPString (const char *str)
 
 
 char *StartSDP (const char *name, const char *description, const char *url,
-                const char *email, const char *phone, vlc_bool_t ssm,
-                const struct sockaddr *orig, socklen_t origlen,
+                const char *email, const char *phone,
+                const struct sockaddr *src, socklen_t srclen,
                 const struct sockaddr *addr, socklen_t addrlen)
 {
-    uint64_t t = NTPtime64 ();
-    char *sdp, machine[MAXSDPADDRESS], conn[MAXSDPADDRESS],
+    uint64_t now = NTPtime64 ();
+    char *sdp;
+    char connection[MAXSDPADDRESS], hostname[256],
          sfilter[MAXSDPADDRESS + sizeof ("\r\na=source-filter: incl * ")];
     const char *preurl = "\r\nu=", *premail = "\r\ne=", *prephone = "\r\np=";
 
+    gethostname (hostname, sizeof (hostname));
+
     if (name == NULL)
         name = "Unnamed";
     if (description == NULL)
@@ -109,18 +112,21 @@ char *StartSDP (const char *name, const char *description, const char *url,
 
     if (!IsSDPString (name) || !IsSDPString (description)
      || !IsSDPString (url) || !IsSDPString (email) || !IsSDPString (phone)
-     || (AddressToSDP (orig, origlen, machine) == NULL)
-     || (AddressToSDP (addr, addrlen, conn) == NULL))
+     || (AddressToSDP (addr, addrlen, connection) == NULL))
         return NULL;
 
-    if (ssm)
-        sprintf (sfilter, "\r\na=source-filter: incl IN IP%c * %s",
-                 machine[5], machine + 7);
-    else
-        *sfilter = '\0';
+    strcpy (sfilter, "");
+    if (srclen > 0)
+    {
+        char machine[MAXSDPADDRESS];
+
+        if (AddressToSDP (src, srclen, machine) != NULL)
+            sprintf (sfilter, "\r\na=source-filter: incl IN IP%c * %s",
+                     machine[5], machine + 7);
+    }
 
     if (asprintf (&sdp, "v=0"
-                    "\r\no=- "I64Fu" "I64Fu" %s"
+                    "\r\no=- "I64Fu" "I64Fu" IN IP%c %s"
                     "\r\ns=%s"
                     "\r\ni=%s"
                     "%s%s" // optional URL
@@ -138,13 +144,13 @@ char *StartSDP (const char *name, const char *description, const char *url,
                     "\r\na=charset:UTF-8"
                     "%s" // optional source filter
                     "\r\n",
-               /* o= */ t, t, machine,
+               /* o= */ now, now, connection[5], hostname,
                /* s= */ name,
                /* i= */ description,
                /* u= */ preurl, url,
                /* e= */ premail, email,
                /* p= */ prephone, phone,
-               /* c= */ conn,
+               /* c= */ connection,
     /* source-filter */ sfilter) == -1)
         return NULL;
     return sdp;
index 9daebe300629f4fa4f7f07e988b405d933aa6c55..6181d2933d1b6c6b619ffbc6ceb19ee59f11ec30 100644 (file)
@@ -118,7 +118,7 @@ void announce_SAPHandlerDestroy( sap_handler_t *p_sap );
 #include <stdarg.h>
 
 char *StartSDP (const char *name, const char *description, const char *url,
-                const char *email, const char *phone, vlc_bool_t ssm,
+                const char *email, const char *phone,
                 const struct sockaddr *orig, socklen_t origlen,
                 const struct sockaddr *addr, socklen_t addrlen);