1 /* GStreamer UDP network utility functions
2 * Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
3 * Copyright (C) 2006 Joni Valtanen <joni.valtanen@movial.fi>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_UDP_NET_UTILS_H__
22 #define __GST_UDP_NET_UTILS_H__
24 #include <sys/types.h>
26 /* Needed for G_OS_XXXX */
30 /* ws2_32.dll has getaddrinfo and freeaddrinfo on Windows XP and later.
31 * minwg32 headers check WINVER before allowing the use of these */
41 /* Needed for GstObject and GST_WARNING_OBJECT */
42 #include <gst/gstobject.h>
43 #include <gst/gstinfo.h>
47 #include <sys/socket.h>
48 #include <netinet/in.h>
52 #include <arpa/inet.h>
54 #include <sys/ioctl.h>
61 #define IOCTL_SOCKET ioctlsocket
62 #define CLOSE_SOCKET(sock) closesocket(sock)
63 #define setsockopt(sock,l,opt,val,len) setsockopt(sock,l,opt,(char *)(val),len)
64 #define WSA_STARTUP(obj) gst_udp_net_utils_win32_wsa_startup(GST_OBJECT(obj))
65 #define WSA_CLEANUP(obj) WSACleanup ()
69 #define IOCTL_SOCKET ioctl
70 #define CLOSE_SOCKET(sock) close(sock)
71 #define setsockopt(sock,l,opt,val,len) setsockopt(sock,l,opt,(void *)(val),len)
72 #define WSA_STARTUP(obj)
73 #define WSA_CLEANUP(obj)
79 gboolean gst_udp_net_utils_win32_wsa_startup (GstObject * obj);
89 int gst_udp_get_sockaddr_length (struct sockaddr_storage *addr);
91 int gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr);
92 int gst_udp_is_multicast (struct sockaddr_storage *addr);
94 int gst_udp_set_loop (int sockfd, guint16 ss_family, gboolean loop);
95 int gst_udp_set_ttl (int sockfd, guint16 ss_family, int ttl, gboolean is_multicast);
97 /* multicast groups */
98 int gst_udp_join_group (int sockfd, struct sockaddr_storage *addr,
100 int gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr);
103 void gst_udp_uri_init (GstUDPUri *uri, const gchar *host, gint port);
104 int gst_udp_uri_update (GstUDPUri *uri, const gchar *host, gint port);
105 int gst_udp_parse_uri (const gchar *uristr, GstUDPUri *uri);
106 gchar * gst_udp_uri_string (GstUDPUri *uri);
107 void gst_udp_uri_free (GstUDPUri *uri);
109 #endif /* __GST_UDP_NET_UTILS_H__*/