mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
udpsrc: Port to GIO
This commit is contained in:
parent
d55f75f6f4
commit
7f74fc9ef6
7 changed files with 362 additions and 420 deletions
|
@ -15,10 +15,8 @@ BUILT_SOURCES = $(built_sources) $(built_headers)
|
|||
|
||||
libgstudp_la_SOURCES = gstudp.c gstudpsrc.c gstudpsink.c gstmultiudpsink.c gstdynudpsink.c gstudpnetutils.c
|
||||
|
||||
# adding -D_GNU_SOURCE to get non-POSIX extensions like EAI_ADDRFAMILY
|
||||
# with glibc >= 2.8 when including netdb.h (see glibc sources bug 6452)
|
||||
libgstudp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_NET_CFLAGS) $(GST_CFLAGS) -D_GNU_SOURCE
|
||||
libgstudp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_NET_LIBS) $(WIN32_LIBS)
|
||||
libgstudp_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_NET_CFLAGS) $(GST_CFLAGS) $(GIO_CFLAGS) -D_GNU_SOURCE
|
||||
libgstudp_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_NET_LIBS) $(GIO_LIBS)
|
||||
libgstudp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgstudp_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
|
|
|
@ -182,6 +182,7 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
|||
struct sockaddr_in theiraddr;
|
||||
guint16 destport;
|
||||
guint32 destaddr;
|
||||
const guint8 *destaddr_bytes;
|
||||
|
||||
memset (&theiraddr, 0, sizeof (theiraddr));
|
||||
|
||||
|
@ -199,7 +200,12 @@ gst_dynudpsink_render (GstBaseSink * bsink, GstBuffer * buffer)
|
|||
GST_DEBUG ("about to send %" G_GSIZE_FORMAT " bytes", size);
|
||||
|
||||
/* let's get the address from the metaata */
|
||||
gst_net_address_get_ip4_address (&meta->naddr, &destaddr, &destport);
|
||||
destaddr_bytes =
|
||||
g_inet_address_to_bytes (g_inet_socket_address_get_address
|
||||
(G_INET_SOCKET_ADDRESS (meta->addr)));
|
||||
destaddr = GST_READ_UINT32_BE (destaddr_bytes);
|
||||
destport =
|
||||
g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (meta->addr));
|
||||
|
||||
GST_DEBUG ("sending %" G_GSIZE_FORMAT " bytes to client %d port %d", size,
|
||||
destaddr, destport);
|
||||
|
|
|
@ -367,8 +367,8 @@ gst_udp_uri_update (GstUDPUri * uri, const gchar * host, gint port)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
gst_udp_parse_uri (const gchar * uristr, GstUDPUri * uri)
|
||||
gboolean
|
||||
gst_udp_parse_uri (const gchar * uristr, gchar ** host, guint16 * port)
|
||||
{
|
||||
gchar *protocol, *location_start;
|
||||
gchar *location, *location_end;
|
||||
|
@ -402,49 +402,45 @@ gst_udp_parse_uri (const gchar * uristr, GstUDPUri * uri)
|
|||
if (location_end == NULL)
|
||||
goto wrong_address;
|
||||
|
||||
uri->is_ipv6 = TRUE;
|
||||
g_free (uri->host);
|
||||
uri->host = g_strndup (location + 1, location_end - location - 1);
|
||||
*host = g_strndup (location + 1, location_end - location - 1);
|
||||
colptr = strrchr (location_end, ':');
|
||||
} else {
|
||||
GST_DEBUG ("parse IPV4 address '%s'", location);
|
||||
uri->is_ipv6 = FALSE;
|
||||
colptr = strrchr (location, ':');
|
||||
|
||||
g_free (uri->host);
|
||||
if (colptr != NULL) {
|
||||
uri->host = g_strndup (location, colptr - location);
|
||||
*host = g_strndup (location, colptr - location);
|
||||
} else {
|
||||
uri->host = g_strdup (location);
|
||||
*host = g_strdup (location);
|
||||
}
|
||||
}
|
||||
GST_DEBUG ("host set to '%s'", uri->host);
|
||||
GST_DEBUG ("host set to '%s'", *host);
|
||||
|
||||
if (colptr != NULL) {
|
||||
uri->port = atoi (colptr + 1);
|
||||
*port = atoi (colptr + 1);
|
||||
}
|
||||
g_free (location_start);
|
||||
|
||||
return 0;
|
||||
return TRUE;
|
||||
|
||||
/* ERRORS */
|
||||
no_protocol:
|
||||
{
|
||||
GST_ERROR ("error parsing uri %s: no protocol", uristr);
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
wrong_protocol:
|
||||
{
|
||||
GST_ERROR ("error parsing uri %s: wrong protocol (%s != udp)", uristr,
|
||||
protocol);
|
||||
g_free (protocol);
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
wrong_address:
|
||||
{
|
||||
GST_ERROR ("error parsing uri %s", uristr);
|
||||
g_free (location);
|
||||
return -1;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ gboolean gst_udp_net_utils_win32_wsa_startup (GstObject * obj);
|
|||
|
||||
typedef struct {
|
||||
gchar *host;
|
||||
gint port;
|
||||
guint16 port;
|
||||
gboolean is_ipv6;
|
||||
} GstUDPUri;
|
||||
|
||||
|
@ -102,9 +102,10 @@ int gst_udp_leave_group (int sockfd, struct sockaddr_storage *addr)
|
|||
/* uri handling */
|
||||
void gst_udp_uri_init (GstUDPUri *uri, const gchar *host, gint port);
|
||||
int gst_udp_uri_update (GstUDPUri *uri, const gchar *host, gint port);
|
||||
int gst_udp_parse_uri (const gchar *uristr, GstUDPUri *uri);
|
||||
gchar * gst_udp_uri_string (GstUDPUri *uri);
|
||||
void gst_udp_uri_free (GstUDPUri *uri);
|
||||
|
||||
gboolean gst_udp_parse_uri (const gchar *uristr, gchar **host, guint16 *port);
|
||||
|
||||
#endif /* __GST_UDP_NET_UTILS_H__*/
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ gst_udpsink_set_uri (GstUDPSink * sink, const gchar * uri, GError ** error)
|
|||
gst_multiudpsink_remove (GST_MULTIUDPSINK (sink), sink->uri.host,
|
||||
sink->uri.port);
|
||||
|
||||
if (gst_udp_parse_uri (uri, &sink->uri) < 0)
|
||||
if (gst_udp_parse_uri (uri, &sink->uri.host, &sink->uri.port) < 0)
|
||||
goto wrong_uri;
|
||||
|
||||
gst_multiudpsink_add (GST_MULTIUDPSINK (sink), sink->uri.host,
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,15 +23,11 @@
|
|||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstpushsrc.h>
|
||||
#include <gio/gio.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "gstudpnetutils.h"
|
||||
|
||||
#include "gstudp.h"
|
||||
|
||||
#define GST_TYPE_UDPSRC \
|
||||
|
@ -53,27 +49,26 @@ struct _GstUDPSrc {
|
|||
GstPushSrc parent;
|
||||
|
||||
/* properties */
|
||||
GstUDPUri uri;
|
||||
gchar *host;
|
||||
gint port;
|
||||
gchar *multi_iface;
|
||||
gint ttl;
|
||||
GstCaps *caps;
|
||||
gint buffer_size;
|
||||
guint64 timeout;
|
||||
gint skip_first_bytes;
|
||||
int sockfd;
|
||||
gboolean closefd;
|
||||
GSocket *socket;
|
||||
gboolean close_socket;
|
||||
gboolean auto_multicast;
|
||||
gboolean reuse;
|
||||
|
||||
/* our sockets */
|
||||
GstPollFD sock;
|
||||
GstPoll *fdset;
|
||||
gboolean externalfd;
|
||||
gboolean is_ipv6;
|
||||
GSocket *used_socket;
|
||||
GCancellable *cancellable;
|
||||
GInetSocketAddress *addr;
|
||||
gboolean external_socket;
|
||||
|
||||
struct sockaddr_storage myaddr;
|
||||
|
||||
gchar *uristr;
|
||||
gchar *uri;
|
||||
};
|
||||
|
||||
struct _GstUDPSrcClass {
|
||||
|
|
Loading…
Reference in a new issue