sdpdemux: Port to GIO and the new udpsrc/sink properties

This commit is contained in:
Sebastian Dröge 2012-01-18 16:35:04 +01:00
parent 49d1e59f0a
commit f6427af9f9
4 changed files with 48 additions and 61 deletions

View file

@ -194,7 +194,22 @@ AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
dnl GLib is required
AG_GST_GLIB_CHECK([2.24])
GLIB_REQ=2.31.10
AG_GST_GLIB_CHECK([$GLIB_REQ])
dnl Check for GIO
PKG_CHECK_MODULES(GIO, gio-2.0 >= $GLIB_REQ)
GIO_MODULE_DIR="`$PKG_CONFIG --variable=giomoduledir gio-2.0`"
AC_DEFINE_UNQUOTED(GIO_MODULE_DIR, "$GIO_MODULE_DIR",
[The GIO modules directory.])
GIO_LIBDIR="`$PKG_CONFIG --variable=libdir gio-2.0`"
AC_DEFINE_UNQUOTED(GIO_LIBDIR, "$GIO_LIBDIR",
[The GIO library directory.])
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
AC_SUBST(GIO_LDFLAGS)
dnl checks for gstreamer
dnl uninstalled is selected preferentially -- see pkg-config(1)
@ -407,11 +422,6 @@ if test "x$HAVE_CPU_I386" != "xyes" && test "x$HAVE_CPU_X86_64" != "xyes"; then
AG_GST_DISABLE_PLUGIN(real)
fi
# This will always succeed because we depend on GLib >= 2.16
PKG_CHECK_MODULES(GIO, gio-2.0 >= 2.16, HAVE_GIO=yes, HAVE_GIO=no)
AC_SUBST(GIO_CFLAGS)
AC_SUBST(GIO_LIBS)
dnl disable gst plugins we might not be able to build on this
dnl platform: librfb (ugly but minimally invasive)
dnl FIXME: maybe move to sys, or make work with winsock2

View file

@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstsdpelem.la
libgstsdpelem_la_SOURCES = gstsdpelem.c gstsdpdemux.h gstsdpdemux.c
libgstsdpelem_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
libgstsdpelem_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
libgstsdpelem_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS)
libgstsdpelem_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GIO_LIBS) \
-lgstinterfaces-@GST_MAJORMINOR@ \
-lgstrtp-@GST_MAJORMINOR@ -lgstsdp-@GST_MAJORMINOR@ \
$(GST_LIBS) $(WIN32_LIBS)

View file

@ -47,39 +47,14 @@
#include "config.h"
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
/* include GLIB for G_OS_WIN32 */
#include <glib.h>
#ifdef G_OS_WIN32
#ifdef _MSC_VER
#include <Winsock2.h>
#endif
/* 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
#include <ws2tcpip.h>
#else
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include <stdio.h>
#include <stdarg.h>
#include "gstsdpdemux.h"
#include <gst/rtp/gstrtppayloads.h>
#include <gst/sdp/gstsdpmessage.h>
#include "gstsdpdemux.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
GST_DEBUG_CATEGORY_STATIC (sdpdemux_debug);
#define GST_CAT_DEFAULT (sdpdemux_debug)
@ -372,32 +347,31 @@ gst_sdp_demux_stream_free (GstSDPDemux * demux, GstSDPStream * stream)
static gboolean
is_multicast_address (const gchar * host_name)
{
struct addrinfo hints;
struct addrinfo *ai;
struct addrinfo *res;
GInetAddress *addr;
GResolver *resolver = NULL;
gboolean ret = FALSE;
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_DGRAM;
addr = g_inet_address_new_from_string (host_name);
if (!addr) {
GList *results;
g_return_val_if_fail (host_name, FALSE);
resolver = g_resolver_get_default ();
results = g_resolver_lookup_by_name (resolver, host_name, NULL, NULL);
if (!results)
goto out;
addr = G_INET_ADDRESS (g_object_ref (results->data));
if (getaddrinfo (host_name, 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);
g_resolver_free_addresses (results);
}
g_assert (addr != NULL);
freeaddrinfo (res);
ret = g_inet_address_get_is_multicast (addr);
out:
if (resolver)
g_object_unref (resolver);
if (addr)
g_object_unref (addr);
return ret;
}
@ -1073,7 +1047,8 @@ gst_sdp_demux_stream_configure_udp_sink (GstSDPDemux * demux,
GstSDPStream * stream)
{
GstPad *pad, *sinkpad;
gint port, sockfd = -1;
gint port;
GSocket *socket;
gchar *destination, *uri, *name;
/* get destination and port */
@ -1106,12 +1081,13 @@ gst_sdp_demux_stream_configure_udp_sink (GstSDPDemux * demux,
/* configure socket, we give it the same UDP socket as the udpsrc for RTCP
* because some servers check the port number of where it sends RTCP to identify
* the RTCP packets it receives */
g_object_get (G_OBJECT (stream->udpsrc[1]), "sock", &sockfd, NULL);
GST_DEBUG_OBJECT (demux, "UDP src has sock %d", sockfd);
g_object_get (G_OBJECT (stream->udpsrc[1]), "used_socket", &socket, NULL);
GST_DEBUG_OBJECT (demux, "UDP src has socket %p", socket);
/* configure socket and make sure udpsink does not close it when shutting
* down, it belongs to udpsrc after all. */
g_object_set (G_OBJECT (stream->udpsink), "sockfd", sockfd, NULL);
g_object_set (G_OBJECT (stream->udpsink), "closefd", FALSE, NULL);
g_object_set (G_OBJECT (stream->udpsink), "socket", socket, NULL);
g_object_set (G_OBJECT (stream->udpsink), "close-socket", FALSE, NULL);
g_object_unref (socket);
}
/* we keep this playing always */

View file

@ -22,6 +22,7 @@
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include <gio/gio.h>
G_BEGIN_DECLS