Add multicast support to dynudpsink.
Requires multicast support in netbuffer in gst-plugins-base.

Index: gst-plugins-good0.10-0.10.4/gst/udp/gstdynudpsink.c
===================================================================
--- gst-plugins-good0.10-0.10.4.orig/gst/udp/gstdynudpsink.c	2006-08-08 06:27:29.000000000 -0400
+++ gst-plugins-good0.10-0.10.4/gst/udp/gstdynudpsink.c	2006-10-15 20:21:54.000000000 -0400
@@ -183,6 +183,9 @@
   struct sockaddr_in theiraddr;
   guint16 destport;
   guint32 destaddr;
+  struct ip_mreq multi_addr;
+  gboolean loopback;
+  guint8 ttl;
 
   memset (&theiraddr, 0, sizeof (theiraddr));
 
@@ -203,7 +206,62 @@
   // let's get the address from the netbuffer
   gst_netaddress_get_ip4_address (&netbuf->to, &destaddr, &destport);
 
-  GST_DEBUG ("sending %d bytes to client %d port %d", size, destaddr, destport);
+  GST_DEBUG ("checking multicast parameters");
+
+  /* Set Multicast interface if it's changed */
+  if (gst_netaddress_get_net_type (&netbuf->to) == GST_NET_TYPE_IP6) {
+    /* IPv6 code, multicast not supported yet */
+
+  } else { /* GST_NET_TYPE_IP4 */
+    GST_DEBUG ("IPV4 address");
+    /* IPv4 code, check for multicast address*/
+    if ((ntohl (destaddr) & 0xe0000000) == 0xe0000000) {
+      GST_DEBUG ("multicast address");
+      /* Get multicast address */
+      multi_addr.imr_multiaddr.s_addr = destaddr;
+
+      /* Get multicast interface */
+      if (!gst_netaddress_get_ip4_interface (&netbuf->to, &multi_addr.imr_interface.s_addr)) {
+        multi_addr.imr_interface.s_addr = INADDR_ANY;
+      }
+
+      /* Join Multicast group if it's changed from last time */
+      if (sink->multi_addr.imr_multiaddr.s_addr != multi_addr.imr_multiaddr.s_addr
+       || sink->multi_addr.imr_interface.s_addr != multi_addr.imr_interface.s_addr) {
+        GST_DEBUG ("setting multicast address to 0x%08X on interface 0x%08X",
+            ntohl(multi_addr.imr_multiaddr.s_addr), ntohl(multi_addr.imr_interface.s_addr));
+
+        /* Join multicast group */
+        if (setsockopt (sink->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &multi_addr, sizeof (multi_addr)) < 0)
+          goto send_error;
+
+        /* So we don't have to set it for the next packet */
+        sink->multi_addr = multi_addr;
+      }
+
+      /* Set Multicast loopback if it's changed */
+      if (gst_netaddress_get_loopback (&netbuf->to, &loopback) && sink->loopback != loopback) {
+        GST_DEBUG ("setting multicast loopback to %d", loopback);
+
+        if (setsockopt(sink->sock, IPPROTO_IP, IP_MULTICAST_LOOP, &loopback, sizeof(loopback)) < 0)
+          goto send_error;
+        /* So we don't have to set it for the next packet */
+        sink->loopback = loopback;
+      }
+
+      /* Set Multicast time-to-live if it's changed */
+      if (gst_netaddress_get_ttl (&netbuf->to, &ttl) && sink->ttl != ttl) {
+        GST_DEBUG ("setting multicast ttl to %d", ttl);
+
+        if (setsockopt(sink->sock, IPPROTO_IP, IP_MULTICAST_TTL, &ttl, sizeof(ttl)) < 0)
+          goto send_error;
+        /* So we don't have to set it for the next packet */
+        sink->ttl = ttl;
+      }
+    }
+  }
+
+  GST_DEBUG ("sending %d bytes to client 0x%08X port %d", size, ntohl(destaddr), ntohs(destport));
 
   theiraddr.sin_family = AF_INET;
   theiraddr.sin_addr.s_addr = destaddr;
Index: gst-plugins-good0.10-0.10.4/gst/udp/gstdynudpsink.h
===================================================================
--- gst-plugins-good0.10-0.10.4.orig/gst/udp/gstdynudpsink.h	2006-08-08 06:27:29.000000000 -0400
+++ gst-plugins-good0.10-0.10.4/gst/udp/gstdynudpsink.h	2006-10-15 11:39:49.000000000 -0400
@@ -53,6 +53,11 @@
   GstBaseSink parent;
 
   int sock;
+
+  /* Multicast values */
+  struct ip_mreq multi_addr;
+  gboolean	loopback;
+  guint8	ttl;
 };
 
 struct _GstDynUDPSinkClass {
