]> git.sesse.net Git - vlc/commitdiff
* ipv4.c: IGMPv3 support (IP_ADD_SOURCE_MEMBERSHIP) for Win32
authorAlexis de Lattre <alexis@videolan.org>
Sat, 31 Jan 2004 18:02:32 +0000 (18:02 +0000)
committerAlexis de Lattre <alexis@videolan.org>
Sat, 31 Jan 2004 18:02:32 +0000 (18:02 +0000)
 * udp.c: restored the old syntax udp:server_addr@destination_addr
 * libvlc.h: updated 'vlc --help'

 To do an IGMPv3 query under Windows XP do:
 vlc udp:<source_addr>@<multicast_addr>
 Note: under previous versions of Windows, it will fail to join the group.

NEWS
modules/access/udp.c
modules/misc/network/ipv4.c
src/libvlc.h

diff --git a/NEWS b/NEWS
index a31c59d5e1ed31a3c8e2e7343d0417ce0e1c0872..48382c49d03a562cb923509bf8cda878341d0c10 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,11 @@
-$Id: NEWS,v 1.80 2004/01/23 11:54:48 rocky Exp $
+$Id: NEWS,v 1.81 2004/01/31 18:02:31 alexis Exp $
 Changes between 0.7.0 and 0.7.1:
 ---------------------------------
 
 Core support:
  * Fixed a nasty bug that causes preferences not to be saved some times.
- * SVCD (Philips OGT) and CVD subtitles 
+ * SVCD (Philips OGT) and CVD subtitles
+ * IGMPv3 support for VLC under Windows XP
 
 Playlist:
  * Internal improvments
index b1507ad2df6c940d2678eaccd32da0e9e09e114b..6cc7da471f909a40e598823f521351dbf44e10ce 100644 (file)
@@ -2,7 +2,7 @@
  * udp.c: raw UDP & RTP input module
  *****************************************************************************
  * Copyright (C) 2001-2004 VideoLAN
- * $Id: udp.c,v 1.28 2004/01/25 17:31:22 gbazin Exp $
+ * $Id: udp.c,v 1.29 2004/01/31 18:02:32 alexis Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Tristan Leteurtre <tooney@via.ecp.fr>
@@ -193,19 +193,6 @@ static int Open( vlc_object_t *p_this )
         i_bind_port = config_GetInt( p_this, "server-port" );
     }
 
-    if( *psz_server_addr || i_server_port )
-    {
-        msg_Err( p_input, "this UDP syntax is deprecated; the server argument will be");
-        msg_Err( p_input, "ignored (%s:%d). If you wanted to enter a multicast address",
-                          psz_server_addr, i_server_port);
-        msg_Err( p_input, "or local port, type : %s:@%s:%d",
-                          *p_input->psz_access ? p_input->psz_access : "udp",
-                          psz_server_addr, i_server_port );
-
-        i_server_port = 0;
-        psz_server_addr = "";
-    }
-
     msg_Dbg( p_input, "opening server=%s:%d local=%s:%d",
              psz_server_addr, i_server_port, psz_bind_addr, i_bind_port );
 
index 54a8917319ae2ed27fe81924bc7e4f887b4cdc6a..55b43e1d94e0e3502b534804ef511011f6f81d52 100644 (file)
@@ -2,10 +2,11 @@
  * ipv4.c: IPv4 network abstraction layer
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: ipv4.c,v 1.22 2004/01/15 14:57:00 gbazin Exp $
+ * $Id: ipv4.c,v 1.23 2004/01/31 18:02:32 alexis Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *          Mathias Kretschmer <mathias@research.att.com>
+ *          Alexis de Lattre <alexis@via.ecp.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -281,7 +282,91 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
         }
     }
 
-#if !defined( UNDER_CE ) && !defined( SYS_BEOS )
+#if defined( WIN32 )
+/* Only Win32 has the support for IP_ADD_SOURCE_MEMBERSHIP
+   with the headers that are included */
+
+    /* Join the multicast group if the socket is a multicast address */
+    if( IN_MULTICAST( ntohl(sock.sin_addr.s_addr) ) )
+    {
+        /* Determine interface to be used for multicast */
+        char * psz_if_addr = config_GetPsz( p_this, "iface-addr" );
+
+        /* If we have a source address, we use IP_ADD_SOURCE_MEMBERSHIP
+           so that IGMPv3 aware OSes running on IGMPv3 aware networks
+           will do an IGMPv3 query on the network */
+        if( *psz_server_addr )
+        {
+            struct ip_mreq_source imr;
+
+            imr.imr_multiaddr.s_addr = sock.sin_addr.s_addr;
+            imr.imr_sourceaddr.s_addr = inet_addr(psz_server_addr);
+
+            if( psz_if_addr != NULL && *psz_if_addr
+                && inet_addr(psz_if_addr) != INADDR_NONE )
+            {
+                imr.imr_interface.s_addr = inet_addr(psz_if_addr);
+            }
+            else
+            {
+                imr.imr_interface.s_addr = INADDR_ANY;
+            }
+            if( psz_if_addr != NULL ) free( psz_if_addr );
+
+            msg_Dbg( p_this, "IP_ADD_SOURCE_MEMBERSHIP multicast request" );
+            /* Join Multicast group with source filter */
+            if( setsockopt( i_handle, IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP,
+                         (char*)&imr, sizeof(struct ip_mreq_source) ) == -1 )
+            {
+#ifdef HAVE_ERRNO_H
+                msg_Err( p_this, "failed to join IP multicast group (%s)",
+                                  strerror(errno) );
+#else
+                msg_Err( p_this, "failed to join IP multicast group" );
+#endif
+                close( i_handle );
+                return( -1 );
+            }
+         }
+         /* If there is no source address, we use IP_ADD_MEMBERSHIP */
+         else
+         {
+             struct ip_mreq imr;
+
+             imr.imr_multiaddr.s_addr = sock.sin_addr.s_addr;
+             if( psz_if_addr != NULL && *psz_if_addr
+                && inet_addr(psz_if_addr) != INADDR_NONE )
+            {
+                imr.imr_interface.s_addr = inet_addr(psz_if_addr);
+            }
+            else
+            {
+                imr.imr_interface.s_addr = INADDR_ANY;
+            }
+            if( psz_if_addr != NULL ) free( psz_if_addr );
+
+            msg_Dbg( p_this, "IP_ADD_MEMBERSHIP multicast request" );
+            /* Join Multicast group without source filter */
+            if( setsockopt( i_handle, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+                            (char*)&imr, sizeof(struct ip_mreq) ) == -1 )
+            {
+#ifdef HAVE_ERRNO_H
+                msg_Err( p_this, "failed to join IP multicast group (%s)",
+                                  strerror(errno) );
+#else
+                msg_Err( p_this, "failed to join IP multicast group" );
+#endif
+                close( i_handle );
+                return( -1 );
+            }
+         }
+    }
+#endif
+
+#if !defined( UNDER_CE ) && !defined( SYS_BEOS ) && !defined( WIN32 )
+/* This code is for the OSes that have multicast support but
+   don't have IP_ADD_SOURCE_MEMBERSHIP with the headers included */
+
     /* Join the multicast group if the socket is a multicast address */
     if( IN_MULTICAST( ntohl(sock.sin_addr.s_addr) ) )
     {
@@ -301,6 +386,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
         }
         if( psz_if_addr != NULL ) free( psz_if_addr );
 
+        msg_Dbg( p_this, "IP_ADD_MEMBERSHIP multicast request" );
         /* Join Multicast group */
         if( setsockopt( i_handle, IPPROTO_IP, IP_ADD_MEMBERSHIP,
                         (char*)&imr, sizeof(struct ip_mreq) ) == -1 )
@@ -315,7 +401,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
             return( -1 );
         }
     }
-#endif /* UNDER_CE, SYS_BEOS */
+#endif
 
     if( *psz_server_addr )
     {
@@ -363,7 +449,7 @@ static int OpenUDP( vlc_object_t * p_this, network_socket_t * p_socket )
                 return( -1 );
             }
         }
-#endif /* UNDER_CE, SYS_BEOS */
+#endif
     }
 
     p_socket->i_handle = i_handle;
index c0ced469b49524aabcab3dcb504381f912ad5cda..b19f3b76b2a2af55f3557eb57a30137a932267d6 100644 (file)
@@ -2,7 +2,7 @@
  * libvlc.h: main libvlc header
  *****************************************************************************
  * Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.h,v 1.131 2004/01/29 14:39:08 sigmunau Exp $
+ * $Id: libvlc.h,v 1.132 2004/01/31 18:02:32 alexis Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
@@ -646,7 +646,7 @@ static char *ppsz_align_descriptions[] = { N_("Center"),
     "\n                                 DVD device" \
     "\n  [vcd:][device][@[title][,[chapter]]" \
     "\n                                 VCD device" \
-    "\n  udpstream:[@[<bind address>][:<bind port>]]" \
+    "\n  udpstream:[[<source address>]@[<bind address>][:<bind port>]]" \
     "\n                                 UDP stream sent by a streaming server" \
     "\n  vlc:pause                      pause execution of " \
     "playlist items" \