[vlc-commits] sap: remove useless destination socket address
Rémi Denis-Courmont
git at videolan.org
Fri Jun 20 19:01:26 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jun 20 19:13:18 2014 +0300| [fba40f89ca8bf95dbb4ff7bfeebfabfdae6a2aa6] | committer: Rémi Denis-Courmont
sap: remove useless destination socket address
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fba40f89ca8bf95dbb4ff7bfeebfabfdae6a2aa6
---
src/stream_output/sap.c | 33 +++++++++++++--------------------
1 file changed, 13 insertions(+), 20 deletions(-)
diff --git a/src/stream_output/sap.c b/src/stream_output/sap.c
index 4f59b1e..3bf483b 100644
--- a/src/stream_output/sap.c
+++ b/src/stream_output/sap.c
@@ -44,9 +44,6 @@
struct session_descriptor_t
{
- struct sockaddr_storage addr;
- socklen_t addrlen;
-
bool b_ssm;
};
@@ -208,7 +205,7 @@ static void *RunThread (void *self)
* Add a SAP announce
*/
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;
char psz_addr[NI_MAXNUMERICHOST];
@@ -220,18 +217,24 @@ static int SAP_Add (sap_handler_t *p_sap, session_descriptor_t *p_session,
struct sockaddr_in in;
struct sockaddr_in6 in6;
} 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" );
return VLC_EGENERIC;
}
/* Determine SAP multicast address automatically */
- memcpy (&addr, &p_session->addr, addrlen);
-
switch (addr.a.sa_family)
{
#if defined (HAVE_INET_PTON) || defined (_WIN32)
@@ -483,16 +486,6 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
if( !p_session )
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);
sap_handler_t *p_sap = libvlc_priv (obj->p_libvlc)->p_sap;
if (p_sap == NULL)
@@ -509,7 +502,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
goto error;
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_object_release ((vlc_object_t *)p_sap);
More information about the vlc-commits
mailing list