gst/udp/: Use NetBuffer and small cleanups.

Original commit message from CVS:
* gst/udp/Makefile.am:
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_get_type),
(gst_multiudpsink_base_init), (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_finalize),
(gst_multiudpsink_get_times), (gst_multiudpsink_render),
(gst_multiudpsink_set_property), (gst_multiudpsink_init_send),
(gst_multiudpsink_add), (client_compare), (free_client),
(gst_multiudpsink_remove), (gst_multiudpsink_clear),
(gst_multiudpsink_get_stats):
* gst/udp/gstudpsrc.c: (gst_udpsrc_get_type),
(gst_udpsrc_base_init), (gst_udpsrc_class_init),
(gst_udpsrc_create), (gst_udpsrc_set_uri), (gst_udpsrc_start),
(gst_udpsrc_unlock), (gst_udpsrc_stop):
Use NetBuffer and small cleanups.
Implement client removal in multiudpsink.
This commit is contained in:
Wim Taymans 2005-06-02 13:28:46 +00:00
parent ca1f865eaa
commit 8e61fd9230
4 changed files with 69 additions and 5 deletions

View file

@ -1,3 +1,21 @@
2005-06-02 Wim Taymans <wim@fluendo.com>
* gst/udp/Makefile.am:
* gst/udp/gstmultiudpsink.c: (gst_multiudpsink_get_type),
(gst_multiudpsink_base_init), (gst_multiudpsink_class_init),
(gst_multiudpsink_init), (gst_multiudpsink_finalize),
(gst_multiudpsink_get_times), (gst_multiudpsink_render),
(gst_multiudpsink_set_property), (gst_multiudpsink_init_send),
(gst_multiudpsink_add), (client_compare), (free_client),
(gst_multiudpsink_remove), (gst_multiudpsink_clear),
(gst_multiudpsink_get_stats):
* gst/udp/gstudpsrc.c: (gst_udpsrc_get_type),
(gst_udpsrc_base_init), (gst_udpsrc_class_init),
(gst_udpsrc_create), (gst_udpsrc_set_uri), (gst_udpsrc_start),
(gst_udpsrc_unlock), (gst_udpsrc_stop):
Use NetBuffer and small cleanups.
Implement client removal in multiudpsink.
2005-06-02 Wim Taymans <wim@fluendo.com> 2005-06-02 Wim Taymans <wim@fluendo.com>
* gst/rtsp/README: * gst/rtsp/README:

View file

@ -13,9 +13,9 @@ built_headers = gstudp-enumtypes.h gstudp-marshal.h
BUILT_SOURCES = $(built_sources) $(built_headers) BUILT_SOURCES = $(built_sources) $(built_headers)
libgstudp_la_SOURCES = gstudp.c gstudpsrc.c gstudpsink.c gstmultiudpsink.c libgstudp_la_SOURCES = gstudp.c gstudpsrc.c gstudpsink.c gstmultiudpsink.c
libgstudp_la_CFLAGS = $(GST_CFLAGS) libgstudp_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_LIBS_CFLAGS)
libgstudp_la_LIBADD = libgstudp_la_LIBADD =
libgstudp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS) libgstudp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS) ../../../gst-plugins-base/gst-libs/gst/net/libgstnet.la
nodist_libgstudp_la_SOURCES = \ nodist_libgstudp_la_SOURCES = \
$(built_sources) $(built_sources)

View file

@ -382,14 +382,54 @@ host_error:
} }
} }
static gint
client_compare (GstUDPClient * a, GstUDPClient * b)
{
if ((a->port == b->port) && (strcmp (a->host, b->host) == 0))
return 0;
return 1;
}
static void
free_client (GstUDPClient * client)
{
g_free (client->host);
g_free (client);
}
void void
gst_multiudpsink_remove (GstMultiUDPSink * sink, const gchar * host, gint port) gst_multiudpsink_remove (GstMultiUDPSink * sink, const gchar * host, gint port)
{ {
GList *find;
GstUDPClient udpclient;
udpclient.host = (gchar *) host;
udpclient.port = port;
g_mutex_lock (sink->client_lock);
find = g_list_find_custom (sink->clients, &udpclient,
(GCompareFunc) client_compare);
if (find) {
GstUDPClient *client;
client = (GstUDPClient *) find->data;
sink->clients = g_list_delete_link (sink->clients, find);
free_client (client);
}
g_mutex_unlock (sink->client_lock);
} }
void void
gst_multiudpsink_clear (GstMultiUDPSink * sink) gst_multiudpsink_clear (GstMultiUDPSink * sink)
{ {
g_mutex_lock (sink->client_lock);
g_list_foreach (sink->clients, (GFunc) free_client, sink);
g_list_free (sink->clients);
sink->clients = NULL;
g_mutex_unlock (sink->client_lock);
} }
GValueArray * GValueArray *

View file

@ -25,6 +25,7 @@
#include "gstudpsrc.h" #include "gstudpsrc.h"
#include <unistd.h> #include <unistd.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <gst/net/gstnetbuffer.h>
#ifdef HAVE_FIONREAD_IN_SYS_FILIO #ifdef HAVE_FIONREAD_IN_SYS_FILIO
#include <sys/filio.h> #include <sys/filio.h>
@ -201,7 +202,7 @@ static GstFlowReturn
gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf) gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
{ {
GstUDPSrc *udpsrc; GstUDPSrc *udpsrc;
GstBuffer *outbuf; GstNetBuffer *outbuf;
struct sockaddr_in tmpaddr; struct sockaddr_in tmpaddr;
socklen_t len; socklen_t len;
fd_set read_fds; fd_set read_fds;
@ -286,11 +287,16 @@ gst_udpsrc_create (GstPushSrc * psrc, GstBuffer ** buf)
break; break;
} }
outbuf = gst_buffer_new (); outbuf = gst_netbuffer_new ();
GST_BUFFER_DATA (outbuf) = pktdata; GST_BUFFER_DATA (outbuf) = pktdata;
GST_BUFFER_SIZE (outbuf) = ret; GST_BUFFER_SIZE (outbuf) = ret;
*buf = outbuf; gst_netaddress_set_ip4_address (&outbuf->from, tmpaddr.sin_addr.s_addr,
tmpaddr.sin_port);
GST_LOG_OBJECT (udpsrc, "read %d bytes", readsize);
*buf = GST_BUFFER (outbuf);
return GST_FLOW_OK; return GST_FLOW_OK;