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

sap: remove useless destination socket address

parent e5cadc53
...@@ -44,9 +44,6 @@ ...@@ -44,9 +44,6 @@
struct session_descriptor_t struct session_descriptor_t
{ {
struct sockaddr_storage addr;
socklen_t addrlen;
bool b_ssm; bool b_ssm;
}; };
...@@ -208,7 +205,7 @@ static void *RunThread (void *self) ...@@ -208,7 +205,7 @@ static void *RunThread (void *self)
* Add a SAP announce * Add a SAP announce
*/ */
static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session, static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session,
const char *sdp) const char *sdp, const char *dst)
{ {
int i; int i;
char psz_addr[NI_MAXNUMERICHOST]; char psz_addr[NI_MAXNUMERICHOST];
...@@ -220,18 +217,24 @@ static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session, ...@@ -220,18 +217,24 @@ static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session,
struct sockaddr_in in; struct sockaddr_in in;
struct sockaddr_in6 in6; struct sockaddr_in6 in6;
} addr; } addr;
socklen_t addrlen; socklen_t addrlen = 0;
struct addrinfo *res;
if (vlc_getaddrinfo (dst, 0, NULL, &res) == 0)
{
if (res->ai_addrlen <= sizeof (addr))
memcpy (&addr, res->ai_addr, res->ai_addrlen);
addrlen = res->ai_addrlen;
freeaddrinfo (res);
}
addrlen = p_session->addrlen; if (addrlen == 0 || addrlen > sizeof (addr))
if ((addrlen == 0) || (addrlen > sizeof (addr)))
{ {
msg_Err( p_sap, "No/invalid address specified for SAP announce" ); msg_Err( p_sap, "No/invalid address specified for SAP announce" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
/* Determine SAP multicast address automatically */ /* Determine SAP multicast address automatically */
memcpy (&addr, &p_session->addr, addrlen);
switch (addr.a.sa_family) switch (addr.a.sa_family)
{ {
#if defined (HAVE_INET_PTON) || defined (_WIN32) #if defined (HAVE_INET_PTON) || defined (_WIN32)
...@@ -483,16 +486,6 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp, ...@@ -483,16 +486,6 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
if( !p_session ) if( !p_session )
return NULL; return NULL;
/* GRUIK. We should not convert back-and-forth from string to numbers */
struct addrinfo *res;
if (vlc_getaddrinfo (psz_dst, 0, NULL, &res) == 0)
{
if (res->ai_addrlen <= sizeof (p_session->addr))
memcpy (&p_session->addr, res->ai_addr,
p_session->addrlen = res->ai_addrlen);
freeaddrinfo (res);
}
vlc_mutex_lock (&sap_mutex); vlc_mutex_lock (&sap_mutex);
sap_handler_t *p_sap = libvlc_priv (obj->p_libvlc)->p_sap; sap_handler_t *p_sap = libvlc_priv (obj->p_libvlc)->p_sap;
if (p_sap == NULL) if (p_sap == NULL)
...@@ -509,7 +502,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp, ...@@ -509,7 +502,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
goto error; goto error;
msg_Dbg (obj, "adding SAP session"); msg_Dbg (obj, "adding SAP session");
if (SAP_Add (p_sap, p_session, psz_sdp)) if (SAP_Add (p_sap, p_session, psz_sdp, psz_dst))
{ {
vlc_mutex_lock (&sap_mutex); vlc_mutex_lock (&sap_mutex);
vlc_object_release ((vlc_object_t *)p_sap); vlc_object_release ((vlc_object_t *)p_sap);
......
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