mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-02 16:52:42 +00:00
sdpdemux: Port to GIO and the new udpsrc/sink properties
This commit is contained in:
parent
49d1e59f0a
commit
f6427af9f9
4 changed files with 48 additions and 61 deletions
22
configure.ac
22
configure.ac
|
@ -194,7 +194,22 @@ AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
|
||||||
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
|
AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
|
||||||
|
|
||||||
dnl GLib is required
|
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 checks for gstreamer
|
||||||
dnl uninstalled is selected preferentially -- see pkg-config(1)
|
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)
|
AG_GST_DISABLE_PLUGIN(real)
|
||||||
fi
|
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 disable gst plugins we might not be able to build on this
|
||||||
dnl platform: librfb (ugly but minimally invasive)
|
dnl platform: librfb (ugly but minimally invasive)
|
||||||
dnl FIXME: maybe move to sys, or make work with winsock2
|
dnl FIXME: maybe move to sys, or make work with winsock2
|
||||||
|
|
|
@ -2,8 +2,8 @@ plugin_LTLIBRARIES = libgstsdpelem.la
|
||||||
|
|
||||||
libgstsdpelem_la_SOURCES = gstsdpelem.c gstsdpdemux.h gstsdpdemux.c
|
libgstsdpelem_la_SOURCES = gstsdpelem.c gstsdpdemux.h gstsdpdemux.c
|
||||||
|
|
||||||
libgstsdpelem_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
|
libgstsdpelem_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS)
|
||||||
libgstsdpelem_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) \
|
libgstsdpelem_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GIO_LIBS) \
|
||||||
-lgstinterfaces-@GST_MAJORMINOR@ \
|
-lgstinterfaces-@GST_MAJORMINOR@ \
|
||||||
-lgstrtp-@GST_MAJORMINOR@ -lgstsdp-@GST_MAJORMINOR@ \
|
-lgstrtp-@GST_MAJORMINOR@ -lgstsdp-@GST_MAJORMINOR@ \
|
||||||
$(GST_LIBS) $(WIN32_LIBS)
|
$(GST_LIBS) $(WIN32_LIBS)
|
||||||
|
|
|
@ -47,39 +47,14 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_UNISTD_H
|
#include "gstsdpdemux.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 <gst/rtp/gstrtppayloads.h>
|
#include <gst/rtp/gstrtppayloads.h>
|
||||||
#include <gst/sdp/gstsdpmessage.h>
|
#include <gst/sdp/gstsdpmessage.h>
|
||||||
|
|
||||||
#include "gstsdpdemux.h"
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (sdpdemux_debug);
|
GST_DEBUG_CATEGORY_STATIC (sdpdemux_debug);
|
||||||
#define GST_CAT_DEFAULT (sdpdemux_debug)
|
#define GST_CAT_DEFAULT (sdpdemux_debug)
|
||||||
|
@ -372,32 +347,31 @@ gst_sdp_demux_stream_free (GstSDPDemux * demux, GstSDPStream * stream)
|
||||||
static gboolean
|
static gboolean
|
||||||
is_multicast_address (const gchar * host_name)
|
is_multicast_address (const gchar * host_name)
|
||||||
{
|
{
|
||||||
struct addrinfo hints;
|
GInetAddress *addr;
|
||||||
struct addrinfo *ai;
|
GResolver *resolver = NULL;
|
||||||
struct addrinfo *res;
|
|
||||||
gboolean ret = FALSE;
|
gboolean ret = FALSE;
|
||||||
|
|
||||||
memset (&hints, 0, sizeof (hints));
|
addr = g_inet_address_new_from_string (host_name);
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
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)
|
g_resolver_free_addresses (results);
|
||||||
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_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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1073,7 +1047,8 @@ gst_sdp_demux_stream_configure_udp_sink (GstSDPDemux * demux,
|
||||||
GstSDPStream * stream)
|
GstSDPStream * stream)
|
||||||
{
|
{
|
||||||
GstPad *pad, *sinkpad;
|
GstPad *pad, *sinkpad;
|
||||||
gint port, sockfd = -1;
|
gint port;
|
||||||
|
GSocket *socket;
|
||||||
gchar *destination, *uri, *name;
|
gchar *destination, *uri, *name;
|
||||||
|
|
||||||
/* get destination and port */
|
/* 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
|
/* 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
|
* because some servers check the port number of where it sends RTCP to identify
|
||||||
* the RTCP packets it receives */
|
* the RTCP packets it receives */
|
||||||
g_object_get (G_OBJECT (stream->udpsrc[1]), "sock", &sockfd, NULL);
|
g_object_get (G_OBJECT (stream->udpsrc[1]), "used_socket", &socket, NULL);
|
||||||
GST_DEBUG_OBJECT (demux, "UDP src has sock %d", sockfd);
|
GST_DEBUG_OBJECT (demux, "UDP src has socket %p", socket);
|
||||||
/* configure socket and make sure udpsink does not close it when shutting
|
/* configure socket and make sure udpsink does not close it when shutting
|
||||||
* down, it belongs to udpsrc after all. */
|
* down, it belongs to udpsrc after all. */
|
||||||
g_object_set (G_OBJECT (stream->udpsink), "sockfd", sockfd, NULL);
|
g_object_set (G_OBJECT (stream->udpsink), "socket", socket, NULL);
|
||||||
g_object_set (G_OBJECT (stream->udpsink), "closefd", FALSE, NULL);
|
g_object_set (G_OBJECT (stream->udpsink), "close-socket", FALSE, NULL);
|
||||||
|
g_object_unref (socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* we keep this playing always */
|
/* we keep this playing always */
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstadapter.h>
|
#include <gst/base/gstadapter.h>
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue