[vlc-commits] commit: net_Listen: pass socket type parameter ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Wed May 5 18:34:13 CEST 2010


vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May  5 19:15:48 2010 +0300| [074c4a997dbc40a7bc28b7d79a5498e6fe250e8d] | committer: Rémi Denis-Courmont 

net_Listen: pass socket type parameter

We cannot use any random type semantic that we do not know of.
This also works around bugs in deficient getaddrinfo() implementations.
(cherry picked from commit bb7ae441f98c35ed5248c6cb2946a371d4a82c96)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=074c4a997dbc40a7bc28b7d79a5498e6fe250e8d
---

 include/vlc_network.h    |    5 +++--
 modules/stream_out/rtp.c |    9 ++++++++-
 src/network/io.c         |    3 ++-
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/include/vlc_network.h b/include/vlc_network.h
index a9603a2..0755625 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -92,9 +92,10 @@ int net_Socket (vlc_object_t *obj, int family, int socktype, int proto);
 VLC_EXPORT( int, net_Connect, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
 #define net_Connect(a, b, c, d, e) net_Connect(VLC_OBJECT(a), b, c, d, e)
 
-VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int protocol) );
+VLC_EXPORT( int *, net_Listen, (vlc_object_t *p_this, const char *psz_host, int i_port, int socktype, int protocol) );
 
-#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, IPPROTO_TCP)
+#define net_ListenTCP(a, b, c) net_Listen(VLC_OBJECT(a), b, c, \
+                                          SOCK_STREAM, IPPROTO_TCP)
 
 static inline int net_ConnectTCP (vlc_object_t *obj, const char *host, int port)
 {
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index ab3907b..2199469 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1023,8 +1023,12 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 #endif
 
     if( p_sys->psz_destination != NULL )
+    {
+        int type = SOCK_STREAM;
+
         switch( p_sys->proto )
         {
+#ifdef SOCK_DCCP
             case IPPROTO_DCCP:
             {
                 const char *code;
@@ -1036,11 +1040,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                     default:       code = "RTPORTPV"; break;
                 }
                 var_SetString (p_stream, "dccp-service", code);
+                type = SOCK_DCCP;
             }   /* fall through */
+#endif
             case IPPROTO_TCP:
                 id->listen.fd = net_Listen( VLC_OBJECT(p_stream),
                                             p_sys->psz_destination, i_port,
-                                            p_sys->proto );
+                                            type, p_sys->proto );
                 if( id->listen.fd == NULL )
                 {
                     msg_Err( p_stream, "passive COMEDIA RTP socket failed" );
@@ -1072,6 +1078,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                 rtp_add_sink( id, fd, p_sys->rtcp_mux, NULL );
             }
         }
+    }
 
     if( p_fmt == NULL )
     {
diff --git a/src/network/io.c b/src/network/io.c
index 664c867..107ca44 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -127,11 +127,12 @@ int net_Socket (vlc_object_t *p_this, int family, int socktype,
 
 
 int *net_Listen (vlc_object_t *p_this, const char *psz_host,
-                 int i_port, int protocol)
+                 int i_port, int type, int protocol)
 {
     struct addrinfo hints, *res;
 
     memset (&hints, 0, sizeof( hints ));
+    hints.ai_socktype = type;
     hints.ai_protocol = protocol;
 
 #ifdef WIN32



More information about the vlc-commits mailing list