From: <wt...@ke...> - 2007-09-04 22:42:34
|
CVS Root: /cvs/gstreamer Module: gst-plugins-good Changes by: wtay Date: Tue Sep 04 2007 22:42:35 UTC Log message: * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), (gst_multiudpsink_set_clients_string), (gst_multiudpsink_get_clients_string), (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal), (gst_multiudpsink_add), (gst_multiudpsink_clear_internal), (gst_multiudpsink_clear): Add property do configure destination address/port pairs API:GstMultiUDPSink::clients Modified files: . : ChangeLog gst/udp : gstmultiudpsink.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/ChangeLog.diff?r1=1.3073&r2=1.3074 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c.diff?r1=1.22&r2=1.23 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-good/ChangeLog,v retrieving revision 1.3073 retrieving revision 1.3074 diff -u -d -r1.3073 -r1.3074 --- ChangeLog 4 Sep 2007 18:30:15 -0000 1.3073 +++ ChangeLog 4 Sep 2007 22:42:20 -0000 1.3074 @@ -1,5 +1,17 @@ 2007-09-04 Wim Taymans <wim...@gm...> + * gst/udp/gstmultiudpsink.c: (gst_multiudpsink_class_init), + (gst_multiudpsink_set_clients_string), + (gst_multiudpsink_get_clients_string), + (gst_multiudpsink_set_property), (gst_multiudpsink_get_property), + (gst_multiudpsink_init_send), (gst_multiudpsink_add_internal), + (gst_multiudpsink_add), (gst_multiudpsink_clear_internal), + (gst_multiudpsink_clear): + Add property do configure destination address/port pairs + API:GstMultiUDPSink::clients + +2007-09-04 Wim Taymans <wim...@gm...> * tests/examples/Makefile.am: * tests/examples/rtp/Makefile.am: * tests/examples/rtp/client-H263p-AMR.sh: Index: gstmultiudpsink.c RCS file: /cvs/gstreamer/gst-plugins-good/gst/udp/gstmultiudpsink.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- gstmultiudpsink.c 17 Aug 2007 13:59:15 -0000 1.22 +++ gstmultiudpsink.c 4 Sep 2007 22:42:21 -0000 1.23 @@ -71,6 +71,7 @@ #define DEFAULT_SOCKFD -1 #define DEFAULT_CLOSEFD TRUE #define DEFAULT_SOCK -1 +#define DEFAULT_CLIENTS NULL enum { @@ -79,7 +80,8 @@ PROP_BYTES_SERVED, PROP_SOCKFD, PROP_CLOSEFD, - PROP_SOCK + PROP_SOCK, + PROP_CLIENTS /* FILL ME */ }; @@ -103,6 +105,11 @@ static void gst_multiudpsink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); +static void gst_multiudpsink_add_internal (GstMultiUDPSink * sink, + const gchar * host, gint port, gboolean lock); +static void gst_multiudpsink_clear_internal (GstMultiUDPSink * sink, + gboolean lock); static void free_client (GstUDPClient * client); static GstElementClass *parent_class = NULL; @@ -266,6 +273,10 @@ g_param_spec_int ("sock", "Socket Handle", "Socket currently in use for UDP sending. (-1 == no socket)", -1, G_MAXINT, DEFAULT_SOCK, G_PARAM_READABLE)); + g_object_class_install_property (gobject_class, PROP_CLIENTS, + g_param_spec_string ("clients", "Clients", + "A comma separated list of host:port pairs with destinations", + DEFAULT_CLIENTS, G_PARAM_READWRITE)); gstelement_class->change_state = gst_multiudpsink_change_state; @@ -370,6 +381,61 @@ } static void +gst_multiudpsink_set_clients_string (GstMultiUDPSink * sink, + const gchar * string) +{ + gchar **clients; + gint i; + clients = g_strsplit (string, ",", 0); + g_mutex_lock (sink->client_lock); + /* clear all existing clients */ + gst_multiudpsink_clear_internal (sink, FALSE); + for (i = 0; clients[i]; i++) { + gchar *host, *p; + gint port = 0; + host = clients[i]; + p = strstr (clients[i], ":"); + if (p != NULL) { + *p = '\0'; + port = atoi (p + 1); + } + if (port != 0) + gst_multiudpsink_add_internal (sink, host, port, FALSE); + } + g_mutex_unlock (sink->client_lock); + g_strfreev (clients); +} +static gchar * +gst_multiudpsink_get_clients_string (GstMultiUDPSink * sink) + GString *str; + GList *clients; + str = g_string_new (""); + clients = sink->clients; + while (clients) { + GstUDPClient *client; + client = (GstUDPClient *) clients->data; + clients = g_list_next (clients); + g_string_append_printf (str, "%s:%d%s", client->host, client->port, + (clients ? "," : "")); + return g_string_free (str, FALSE); +static void gst_multiudpsink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) @@ -385,6 +451,9 @@ case PROP_CLOSEFD: udpsink->closefd = g_value_get_boolean (value); break; + case PROP_CLIENTS: + gst_multiudpsink_set_clients_string (udpsink, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -415,6 +484,10 @@ case PROP_SOCK: g_value_set_int (value, udpsink->sock); + g_value_take_string (value, + gst_multiudpsink_get_clients_string (udpsink)); @@ -512,8 +585,9 @@ CLOSE_IF_REQUESTED (sink); -void -gst_multiudpsink_add (GstMultiUDPSink * sink, const gchar * host, gint port) +gst_multiudpsink_add_internal (GstMultiUDPSink * sink, const gchar * host, + gint port, gboolean lock) struct hostent *he; struct in_addr addr; @@ -563,9 +637,11 @@ goto host_error; } - g_mutex_lock (sink->client_lock); + if (lock) + g_mutex_lock (sink->client_lock); sink->clients = g_list_prepend (sink->clients, client); - g_mutex_unlock (sink->client_lock); + g_mutex_unlock (sink->client_lock); g_signal_emit (G_OBJECT (sink), gst_multiudpsink_signals[SIGNAL_CLIENT_ADDED], 0, host, port); @@ -582,6 +658,12 @@ +void +gst_multiudpsink_add (GstMultiUDPSink * sink, const gchar * host, gint port) + gst_multiudpsink_add_internal (sink, host, port, TRUE); static gint client_compare (GstUDPClient * a, GstUDPClient * b) @@ -648,17 +730,25 @@ -gst_multiudpsink_clear (GstMultiUDPSink * sink) +gst_multiudpsink_clear_internal (GstMultiUDPSink * sink, gboolean lock) GST_DEBUG_OBJECT (sink, "clearing"); /* we only need to remove the client structure, there is no additional * socket or anything to free for UDP */ g_list_foreach (sink->clients, (GFunc) free_client, sink); g_list_free (sink->clients); sink->clients = NULL; +gst_multiudpsink_clear (GstMultiUDPSink * sink) + gst_multiudpsink_clear_internal (sink, TRUE); GValueArray * |