diff options
author | Zeeshan Ali <zeenix@gmail.com> | 2003-06-09 23:13:40 +0000 |
---|---|---|
committer | Zeeshan Ali <zeenix@gmail.com> | 2003-06-09 23:13:40 +0000 |
commit | 8d3275ce496233345e6b49cec205f55f6a5c7436 (patch) | |
tree | d595e2793f27e2114a227b874b65bbdd37de2d59 /gst/udp/gstudpsink.c | |
parent | 5f9547b0567d384797949031cc9b7f4fd8be4edb (diff) |
Congrats everyone! udp plugins are now multicast-enabled
Original commit message from CVS:
Congrats everyone! udp plugins are now multicast-enabled
Diffstat (limited to 'gst/udp/gstudpsink.c')
-rw-r--r-- | gst/udp/gstudpsink.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/gst/udp/gstudpsink.c b/gst/udp/gstudpsink.c index f4b97de2..3d2580c3 100644 --- a/gst/udp/gstudpsink.c +++ b/gst/udp/gstudpsink.c @@ -120,7 +120,8 @@ gst_udpsink_class_init (GstUDPSink *klass) parent_class = g_type_class_ref (GST_TYPE_ELEMENT); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST, - g_param_spec_string ("host", "host", "The host/IP to send the packets to", + g_param_spec_string ("host", "host", + "The host/IP/Multicast group to send the packets to", UDP_DEFAULT_HOST, G_PARAM_READWRITE)); g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT, g_param_spec_int ("port", "port", "The port to send the packets to", @@ -377,15 +378,28 @@ gst_udpsink_init_send (GstUDPSink *sink) /* if its an IP address */ if (inet_aton (sink->host, &addr)) { - sink->theiraddr.sin_addr = - *((struct in_addr *) g_memdup (&addr, sizeof (addr))); + /* check if its a multicast address */ + if ((ntohl (addr.s_addr) & 0xe0000000) == 0xe0000000) { + sink->multi_addr.imr_multiaddr.s_addr = addr.s_addr; + sink->multi_addr.imr_interface.s_addr = INADDR_ANY; + + sink->theiraddr.sin_addr = sink->multi_addr.imr_multiaddr; + + /* Joining the multicast group */ + setsockopt (sink->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &sink->multi_addr, sizeof(sink->multi_addr)); + } + + else { + sink->theiraddr.sin_addr = + *((struct in_addr *) &addr); + } } /* we dont need to lookup for localhost */ else if (strcmp (sink->host, UDP_DEFAULT_HOST) == 0 && inet_aton ("127.0.0.1", &addr)) { sink->theiraddr.sin_addr = - *((struct in_addr *) g_memdup (&addr, sizeof (addr))); + *((struct in_addr *) &addr); } /* if its a hostname */ |