mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
sdp: Port to GIO for multicast address detection
This commit is contained in:
parent
6cb38409d1
commit
cfa7083e94
5 changed files with 10 additions and 54 deletions
|
@ -7,8 +7,8 @@ lib_LTLIBRARIES = libgstsdp-@GST_MAJORMINOR@.la
|
||||||
|
|
||||||
libgstsdp_@GST_MAJORMINOR@_la_SOURCES = gstsdpmessage.c
|
libgstsdp_@GST_MAJORMINOR@_la_SOURCES = gstsdpmessage.c
|
||||||
|
|
||||||
libgstsdp_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
libgstsdp_@GST_MAJORMINOR@_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS)
|
||||||
libgstsdp_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS) $(WIN32_LIBS)
|
libgstsdp_@GST_MAJORMINOR@_la_LIBADD = $(GST_LIBS) $(GIO_LIBS)
|
||||||
libgstsdp_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
|
libgstsdp_@GST_MAJORMINOR@_la_LDFLAGS = $(GST_LIB_LDFLAGS) $(GST_ALL_LDFLAGS) $(GST_LT_LDFLAGS)
|
||||||
|
|
||||||
if HAVE_INTROSPECTION
|
if HAVE_INTROSPECTION
|
||||||
|
|
|
@ -61,28 +61,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#include <gio/gio.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <glib.h> /* for G_OS_WIN32 */
|
|
||||||
#include <gst/gstinfo.h> /* For GST_STR_NULL */
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
|
||||||
/* ws2_32.dll has getaddrinfo and freeaddrinfo on Windows XP and later.
|
|
||||||
* minwg32 headers check WINVER before allowing the use of these */
|
|
||||||
#ifndef WINVER
|
|
||||||
#define WINVER 0x0501
|
|
||||||
#endif
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#include <Winsock2.h>
|
|
||||||
#endif
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#else
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netdb.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "gstsdpmessage.h"
|
#include "gstsdpmessage.h"
|
||||||
|
|
||||||
|
@ -338,10 +317,8 @@ gboolean
|
||||||
gst_sdp_address_is_multicast (const gchar * nettype, const gchar * addrtype,
|
gst_sdp_address_is_multicast (const gchar * nettype, const gchar * addrtype,
|
||||||
const gchar * addr)
|
const gchar * addr)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
|
||||||
struct addrinfo *ai;
|
|
||||||
struct addrinfo *res;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
GInetAddress *iaddr;
|
||||||
|
|
||||||
g_return_val_if_fail (addr, FALSE);
|
g_return_val_if_fail (addr, FALSE);
|
||||||
|
|
||||||
|
@ -349,32 +326,9 @@ gst_sdp_address_is_multicast (const gchar * nettype, const gchar * addrtype,
|
||||||
if (nettype && strcmp (nettype, "IN") != 0)
|
if (nettype && strcmp (nettype, "IN") != 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
memset (&hints, 0, sizeof (hints));
|
iaddr = g_inet_address_new_from_string (addr);
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
ret = g_inet_address_get_is_multicast (iaddr);
|
||||||
|
g_object_unref (iaddr);
|
||||||
/* set the address type as a hint */
|
|
||||||
if (addrtype) {
|
|
||||||
if (!strcmp (addrtype, "IP4"))
|
|
||||||
hints.ai_family = AF_INET;
|
|
||||||
else if (!strcmp (addrtype, "IP6"))
|
|
||||||
hints.ai_family = AF_INET6;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getaddrinfo (addr, NULL, &hints, &res) < 0)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (ai = res; !ret && ai; ai = ai->ai_next) {
|
|
||||||
if (ai->ai_family == AF_INET)
|
|
||||||
ret =
|
|
||||||
IN_MULTICAST (ntohl (((struct sockaddr_in *) ai->ai_addr)->
|
|
||||||
sin_addr.s_addr));
|
|
||||||
else
|
|
||||||
ret =
|
|
||||||
IN6_IS_ADDR_MULTICAST (&((struct sockaddr_in6 *) ai->
|
|
||||||
ai_addr)->sin6_addr);
|
|
||||||
}
|
|
||||||
|
|
||||||
freeaddrinfo (res);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#define __GST_SDP_MESSAGE_H__
|
#define __GST_SDP_MESSAGE_H__
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <gst/gst.h>
|
||||||
#include <gst/sdp/gstsdp.h>
|
#include <gst/sdp/gstsdp.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
|
@ -11,6 +11,7 @@ Name: GStreamer SDP Library, Uninstalled
|
||||||
Description: SDP helper functions, uninstalled
|
Description: SDP helper functions, uninstalled
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Requires: glib-2.0
|
Requires: glib-2.0
|
||||||
|
Requires.private: gio-2.0
|
||||||
Libs: @abs_top_builddir@/gst-libs/gst/sdp/libgstsdp-@GST_MAJORMINOR@.la
|
Libs: @abs_top_builddir@/gst-libs/gst/sdp/libgstsdp-@GST_MAJORMINOR@.la
|
||||||
Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
|
Cflags: -I@abs_top_srcdir@/gst-libs -I@abs_top_builddir@/gst-libs
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ typelibdir=${libdir}/girepository-1.0
|
||||||
Name: GStreamer SDP Library
|
Name: GStreamer SDP Library
|
||||||
Description: SDP helper functions
|
Description: SDP helper functions
|
||||||
Requires: glib-2.0
|
Requires: glib-2.0
|
||||||
|
Requires.private: gio-2.0
|
||||||
Version: @VERSION@
|
Version: @VERSION@
|
||||||
Libs: -L${libdir} -lgstsdp-@GST_MAJORMINOR@
|
Libs: -L${libdir} -lgstsdp-@GST_MAJORMINOR@
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
Loading…
Reference in a new issue