[gst-devel] Multicast support in gstnetbuffer
Behan Webster
behanw+gstreamer at websterwood.com
Thu Sep 28 06:45:37 CEST 2006
I am proposing to add data important to supporting multicast traffic to
gstnetbuffer. The idea is to include such information as loopback, ttl,
and sending interface settings such that these parameters can be passed
between gst elements.
In my particular case, I need to add multicast support to dynudpsink,
and by adding these parameters to gstnetbuffer, dynudpsink will be able
to support sending multicast udp packets using different settings per
multicast address.
Patch at the end of the email.
--
Behan Webster
behanw at websterwood.com
Index: gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.h
===================================================================
--- gst-plugins-base.orig/gst-libs/gst/netbuffer/gstnetbuffer.h
2006-09-27 19:58:32.000000000 -0400
+++ gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.h
2006-09-27 22:27:17.000000000 -0400
@@ -61,7 +61,13 @@
guint8 ip6[16];
guint32 ip4;
} address;
+ union {
+ guint8 ip6[16];
+ guint32 ip4;
+ } interface;
guint16 port;
+ guint8 loopback;
+ guint8 ttl;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
Index: gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.c
===================================================================
--- gst-plugins-base.orig/gst-libs/gst/netbuffer/gstnetbuffer.c
2006-09-27 21:29:09.000000000 -0400
+++ gst-plugins-base/gst-libs/gst/netbuffer/gstnetbuffer.c
2006-09-28 00:12:14.000000000 -0400
@@ -140,6 +140,22 @@
}
/**
+ * gst_netaddress_set_ip4_interface:
+ * @naddr: a multicast network address
+ * @address: an IPv4 network interface for use with multicast
+ *
+ * Set @naddr with the IPv4 @interface to use for multicast
+ */
+void
+gst_netaddress_set_ip4_interface (GstNetAddress * naddr, guint32 interface)
+{
+ g_return_if_fail (naddr != NULL);
+ g_return_if_fail (naddr->type != GST_NET_TYPE_IP4);
+
+ naddr->interface.ip4 = interface;
+}
+
+/**
* gst_netaddress_set_ip6_address:
* @naddr: a network address
* @address: an IPv6 network address.
@@ -159,6 +175,52 @@
}
/**
+ * gst_netaddress_set_ip6_interface:
+ * @naddr: a multicast network address
+ * @address: an IPv6 network interface for use with multicast
+ *
+ * Set @naddr with the IPv6 @interface to use for multicast
+ */
+void
+gst_netaddress_set_ip6_interface (GstNetAddress * naddr, guint8
interface[16])
+{
+ g_return_if_fail (naddr != NULL);
+ g_return_if_fail (naddr->type != GST_NET_TYPE_IP6);
+
+ memcpy (&naddr->interface.ip6, interface, 16);
+}
+
+/**
+ * gst_netaddress_set_loopback;
+ * @naddr: a multicast network address
+ * @loopbak: set to 1 to enable loopback or 0 to disable it.
+ *
+ * Set @naddr loopback option for multicast address
+ */
+void
+gst_netaddress_set_loopback (GstNetAddress * naddr, guint8 loopback)
+{
+ g_return_if_fail (naddr != NULL);
+
+ naddr->loopback = loopback;
+}
+
+/**
+ * gst_netaddress_set_ttl;
+ * @naddr: a multicast network address
+ * @ttl: Set time-to-live for multicast packets (0 to 255)
+ *
+ * Set @naddr TTL for multicats packets. Defaults to 1 to stay on the
local network.
+ */
+void
+gst_netaddress_set_ttl (GstNetAddress * naddr, guint8 ttl)
+{
+ g_return_if_fail (naddr != NULL);
+
+ naddr->ttl = ttl;
+}
+
+/**
* gst_netaddress_get_net_type:
* @naddr: a network address
*
@@ -202,6 +264,29 @@
}
/**
+ * gst_netaddress_get_ip4_interface:
+ * @naddr: a multicast network address
+ * @interface: a location to store the interface address.
+ *
+ * Get the IPv4 interface stored in @naddr into @interface.
+ *
+ * Returns: TRUE if the interface could be retrieved.
+ */
+gboolean
+gst_netaddress_get_ip4_interface (GstNetAddress * naddr, guint32 *
interface)
+{
+ g_return_val_if_fail (naddr != NULL, FALSE);
+
+ if (naddr->type != GST_NET_TYPE_IP4)
+ return FALSE;
+
+ if (interface)
+ *interface = naddr->interface.ip4;
+
+ return TRUE;
+}
+
+/**
* gst_netaddress_get_ip6_address:
* @naddr: a network address
* @address: a location to store the result.
@@ -227,3 +312,66 @@
return TRUE;
}
+
+/**
+ * gst_netaddress_get_ip6_interface:
+ * @naddr: a multicast network address
+ * @interface: a location to store the interface address.
+ *
+ * Get the IPv6 interface stored in @naddr into @interface.
+ *
+ * Returns: TRUE if the interface could be retrieved.
+ */
+gboolean
+gst_netaddress_get_ip6_interface (GstNetAddress * naddr, guint8
interface[16])
+{
+ g_return_val_if_fail (naddr != NULL, FALSE);
+
+ if (naddr->type != GST_NET_TYPE_IP6)
+ return FALSE;
+
+ if (interface)
+ memcpy (interface, naddr->interface.ip6, 16);
+
+ return TRUE;
+}
+
+/**
+ * gst_netaddress_get_loopback:
+ * @naddr: a multicast network address
+ * @loopback: a location to store the value of loopback
+ *
+ * Get whether ot not multicast loopback is enabled
+ *
+ * Returns: TRUE if the interface could be retrieved.
+ */
+gboolean
+gst_netaddress_get_loopback (GstNetAddress * naddr, guint8 * loopback)
+{
+ g_return_val_if_fail (naddr != NULL, FALSE);
+
+ if (loopback)
+ *loopback = naddr->loopback;
+
+ return TRUE;
+}
+
+/**
+ * gst_netaddress_get_ttl:
+ * @naddr: a multicast network address
+ * @ttl: a location to store the value of ttl
+ *
+ * Get the time-to-live value for multicast packets
+ *
+ * Returns: TRUE if the interface could be retrieved.
+ */
+gboolean
+gst_netaddress_get_ttl (GstNetAddress * naddr, guint8 * ttl)
+{
+ g_return_val_if_fail (naddr != NULL, FALSE);
+
+ if (ttl)
+ *ttl = naddr->ttl;
+
+ return TRUE;
+}
More information about the gstreamer-devel
mailing list