[Live-devel] A problem: receiving data from several multicast groups, while joined only one

Oleg Galbert oleg_g at mer.co.il
Thu Aug 24 02:28:03 PDT 2006


Hi,

I have two processes - one streaming UDP data to specific multicast group 
(streamer), the second - receiving data from the same group (receiver).
On the streamer side I create Groupsock object with specific multicast IP, and 
start to stream the data. 
On the recorder side - I'm receiving the data for the multicast group with 
this IP.  
But the problem is that the receiver gets the data for even it is joined to 
the different multicast group. It looks like I cannot differentiate the 
streams by group.    

After some hacking I found a way to solve it. When I set 
ReceivingInterfaceAddr to the same group IP address, the socket is binded to 
this IP. everythink works OK. In original code the socket was binded to 
INADDR_ANY.

My question is: Is it correct to bind the receiving side socket to the same 
address as multicast group address?

I  include my patch for related functions in GroupsockHelper.cpp.
==============================================
   
--- live.2006.08.07/groupsock/GroupsockHelper.cpp	2006-08-07 
09:12:26.000000000 +0300
+++ live/groupsock/GroupsockHelper.cpp	2006-08-24 11:27:19.000000000 +0300
@ -425,9 +417,9 @@ Boolean socketJoinGroup(UsageEnvironment
 
   struct ip_mreq imr;
   imr.imr_multiaddr.s_addr = groupAddress;
-  imr.imr_interface.s_addr = ReceivingInterfaceAddr;
+  imr.imr_interface.s_addr = htonl(INADDR_ANY);  
   if (setsockopt(socket, IPPROTO_IP, IP_ADD_MEMBERSHIP,
-		 (const char*)&imr, sizeof (struct ip_mreq)) < 0) {
+		 (const char*)&imr, sizeof (struct ip_mreq)) != 0) { 
 #if defined(__WIN32__) || defined(_WIN32)
     if (env.getErrno() != 0) {
       // That piece-of-shit toy operating system (Windows) sometimes lies
@@ -466,8 +458,8 @@ Boolean socketLeaveGroup(UsageEnvironmen
 #define IP_ADD_SOURCE_MEMBERSHIP   39
 #define IP_DROP_SOURCE_MEMBERSHIP 40
 #else
-#define IP_ADD_SOURCE_MEMBERSHIP   25
-#define IP_DROP_SOURCE_MEMBERSHIP 26
+#define IP_ADD_SOURCE_MEMBERSHIP   67 
+#define IP_DROP_SOURCE_MEMBERSHIP 68 
 #endif
 
 struct ip_mreq_source {
@@ -550,6 +542,7 @@ Boolean loopbackWorks = 1;
 
 netAddressBits ourSourceAddressForMulticast(UsageEnvironment& env) {
   static netAddressBits ourAddress = 0;
+  netAddressBits oldReceivingInterfaceAddr = ReceivingInterfaceAddr; 
   int sock = -1;
   struct in_addr testAddr;
   
@@ -566,6 +559,7 @@ netAddressBits ourSourceAddressForMultic
       loopbackWorks = 0; // until we learn otherwise
 
       testAddr.s_addr = our_inet_addr("228.67.43.91"); // arbitrary
+	  ReceivingInterfaceAddr =  testAddr.s_addr; 
       Port testPort(15947); // ditto
       
       sock = setupDatagramSocket(env, testPort);
@@ -656,6 +650,7 @@ netAddressBits ourSourceAddressForMultic
     
     if (sock >= 0) {
       socketLeaveGroup(env, sock, testAddr.s_addr);
+	  ReceivingInterfaceAddr == oldReceivingInterfaceAddr; 
       closeSocket(sock);
     }
     
=========================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: live_multicast.patch
Type: text/x-diff
Size: 1893 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20060824/a94efb2d/attachment.bin 


More information about the live-devel mailing list