Commit 6d479b50 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use hostname as SDP origin, as the spec says.

(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?)
parent 0ac8f78a
...@@ -598,7 +598,7 @@ static char *SDPGenerate( sap_handler_t *p_sap, ...@@ -598,7 +598,7 @@ static char *SDPGenerate( sap_handler_t *p_sap,
char *psz_group, *psz_name, *psz_sdp; char *psz_group, *psz_name, *psz_sdp;
char *head = StartSDP (p_session->psz_name, p_session->description, 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->orig, p_session->origlen,
(const struct sockaddr *)&p_session->addr, p_session->addrlen); (const struct sockaddr *)&p_session->addr, p_session->addrlen);
if (head == NULL) if (head == NULL)
......
...@@ -87,15 +87,18 @@ static vlc_bool_t IsSDPString (const char *str) ...@@ -87,15 +87,18 @@ static vlc_bool_t IsSDPString (const char *str)
char *StartSDP (const char *name, const char *description, const char *url, 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 *src, socklen_t srclen,
const struct sockaddr *addr, socklen_t addrlen) const struct sockaddr *addr, socklen_t addrlen)
{ {
uint64_t t = NTPtime64 (); uint64_t now = NTPtime64 ();
char *sdp, machine[MAXSDPADDRESS], conn[MAXSDPADDRESS], char *sdp;
char connection[MAXSDPADDRESS], hostname[256],
sfilter[MAXSDPADDRESS + sizeof ("\r\na=source-filter: incl * ")]; sfilter[MAXSDPADDRESS + sizeof ("\r\na=source-filter: incl * ")];
const char *preurl = "\r\nu=", *premail = "\r\ne=", *prephone = "\r\np="; const char *preurl = "\r\nu=", *premail = "\r\ne=", *prephone = "\r\np=";
gethostname (hostname, sizeof (hostname));
if (name == NULL) if (name == NULL)
name = "Unnamed"; name = "Unnamed";
if (description == NULL) if (description == NULL)
...@@ -109,18 +112,21 @@ char *StartSDP (const char *name, const char *description, const char *url, ...@@ -109,18 +112,21 @@ char *StartSDP (const char *name, const char *description, const char *url,
if (!IsSDPString (name) || !IsSDPString (description) if (!IsSDPString (name) || !IsSDPString (description)
|| !IsSDPString (url) || !IsSDPString (email) || !IsSDPString (phone) || !IsSDPString (url) || !IsSDPString (email) || !IsSDPString (phone)
|| (AddressToSDP (orig, origlen, machine) == NULL) || (AddressToSDP (addr, addrlen, connection) == NULL))
|| (AddressToSDP (addr, addrlen, conn) == NULL))
return NULL; return NULL;
if (ssm) 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", sprintf (sfilter, "\r\na=source-filter: incl IN IP%c * %s",
machine[5], machine + 7); machine[5], machine + 7);
else }
*sfilter = '\0';
if (asprintf (&sdp, "v=0" if (asprintf (&sdp, "v=0"
"\r\no=- "I64Fu" "I64Fu" %s" "\r\no=- "I64Fu" "I64Fu" IN IP%c %s"
"\r\ns=%s" "\r\ns=%s"
"\r\ni=%s" "\r\ni=%s"
"%s%s" // optional URL "%s%s" // optional URL
...@@ -138,13 +144,13 @@ char *StartSDP (const char *name, const char *description, const char *url, ...@@ -138,13 +144,13 @@ char *StartSDP (const char *name, const char *description, const char *url,
"\r\na=charset:UTF-8" "\r\na=charset:UTF-8"
"%s" // optional source filter "%s" // optional source filter
"\r\n", "\r\n",
/* o= */ t, t, machine, /* o= */ now, now, connection[5], hostname,
/* s= */ name, /* s= */ name,
/* i= */ description, /* i= */ description,
/* u= */ preurl, url, /* u= */ preurl, url,
/* e= */ premail, email, /* e= */ premail, email,
/* p= */ prephone, phone, /* p= */ prephone, phone,
/* c= */ conn, /* c= */ connection,
/* source-filter */ sfilter) == -1) /* source-filter */ sfilter) == -1)
return NULL; return NULL;
return sdp; return sdp;
......
...@@ -118,7 +118,7 @@ void announce_SAPHandlerDestroy( sap_handler_t *p_sap ); ...@@ -118,7 +118,7 @@ void announce_SAPHandlerDestroy( sap_handler_t *p_sap );
#include <stdarg.h> #include <stdarg.h>
char *StartSDP (const char *name, const char *description, const char *url, 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 *orig, socklen_t origlen,
const struct sockaddr *addr, socklen_t addrlen); const struct sockaddr *addr, socklen_t addrlen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment