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 */
39 /* Needed for GstObject and GST_WARNING_OBJECT */
40 #include <gst/gstobject.h>
41 #include <gst/gstinfo.h>
45 #include <sys/socket.h>
46 #include <netinet/in.h>
50 #include <arpa/inet.h>
52 #include <sys/ioctl.h>
59 #define IOCTL_SOCKET ioctlsocket
60 #define CLOSE_SOCKET(sock) closesocket(sock)
61 #define setsockopt(sock,l,opt,val,len) setsockopt(sock,l,opt,(char *)(val),len)
62 #define WSA_STARTUP(obj) gst_udp_net_utils_win32_wsa_startup(GST_OBJECT(obj))
63 #define WSA_CLEANUP(obj) WSACleanup ()
67 #define IOCTL_SOCKET ioctl
68 #define CLOSE_SOCKET(sock) close(sock)
69 #define setsockopt(sock,l,opt,val,len) setsockopt(sock,l,opt,(void *)(val),len)
70 #define WSA_STARTUP(obj)
71 #define WSA_CLEANUP(obj)
77 gboolean gst_udp_net_utils_win32_wsa_startup (GstObject * obj);
87 int gst_udp_get_sockaddr_length (struct sockaddr_storage *addr);
89 int gst_udp_get_addr (const char *hostname, int port, struct sockaddr_storage *addr);
90 int gst_udp_is_multicast (struct sockaddr_storage *addr);
92 int gst_udp_set_loop (int sockfd, guint16 ss_family, gboolean loop);
93 int gst_udp_set_ttl (int sockfd, guint16 ss_family, int ttl, gboolean is_multicast);
95 /* multicast groups */
96 int gst_udp_join_group (int sockfd, struct sockaddr_storage *addr,
98 int gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr);
101 void gst_udp_uri_init (GstUDPUri *uri, const gchar *host, gint port);
102 int gst_udp_uri_update (GstUDPUri *uri, const gchar *host, gint port);
103 int gst_udp_parse_uri (const gchar *uristr, GstUDPUri *uri);
104 gchar * gst_udp_uri_string (GstUDPUri *uri);
105 void gst_udp_uri_free (GstUDPUri *uri);
107 #endif /* __GST_UDP_NET_UTILS_H__*/