gst/udp/gstmultiudpsink.c: Add property do configure destination address/port pairs
Original commit message from CVS: * 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
This commit is contained in:
parent
ec68d41d69
commit
93e1176891
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2007-09-04 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
|
* 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.taymans@gmail.com>
|
2007-09-04 Wim Taymans <wim.taymans@gmail.com>
|
||||||
|
|
||||||
* tests/examples/Makefile.am:
|
* tests/examples/Makefile.am:
|
||||||
|
@ -71,6 +71,7 @@ enum
|
|||||||
#define DEFAULT_SOCKFD -1
|
#define DEFAULT_SOCKFD -1
|
||||||
#define DEFAULT_CLOSEFD TRUE
|
#define DEFAULT_CLOSEFD TRUE
|
||||||
#define DEFAULT_SOCK -1
|
#define DEFAULT_SOCK -1
|
||||||
|
#define DEFAULT_CLIENTS NULL
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -79,7 +80,8 @@ enum
|
|||||||
PROP_BYTES_SERVED,
|
PROP_BYTES_SERVED,
|
||||||
PROP_SOCKFD,
|
PROP_SOCKFD,
|
||||||
PROP_CLOSEFD,
|
PROP_CLOSEFD,
|
||||||
PROP_SOCK
|
PROP_SOCK,
|
||||||
|
PROP_CLIENTS
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -103,6 +105,11 @@ static void gst_multiudpsink_set_property (GObject * object, guint prop_id,
|
|||||||
static void gst_multiudpsink_get_property (GObject * object, guint prop_id,
|
static void gst_multiudpsink_get_property (GObject * object, guint prop_id,
|
||||||
GValue * value, GParamSpec * pspec);
|
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 void free_client (GstUDPClient * client);
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
@ -266,6 +273,10 @@ gst_multiudpsink_class_init (GstMultiUDPSinkClass * klass)
|
|||||||
g_param_spec_int ("sock", "Socket Handle",
|
g_param_spec_int ("sock", "Socket Handle",
|
||||||
"Socket currently in use for UDP sending. (-1 == no socket)",
|
"Socket currently in use for UDP sending. (-1 == no socket)",
|
||||||
-1, G_MAXINT, DEFAULT_SOCK, G_PARAM_READABLE));
|
-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;
|
gstelement_class->change_state = gst_multiudpsink_change_state;
|
||||||
|
|
||||||
@ -369,6 +380,61 @@ send_error:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 ("");
|
||||||
|
|
||||||
|
g_mutex_lock (sink->client_lock);
|
||||||
|
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 ? "," : ""));
|
||||||
|
}
|
||||||
|
g_mutex_unlock (sink->client_lock);
|
||||||
|
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_multiudpsink_set_property (GObject * object, guint prop_id,
|
gst_multiudpsink_set_property (GObject * object, guint prop_id,
|
||||||
const GValue * value, GParamSpec * pspec)
|
const GValue * value, GParamSpec * pspec)
|
||||||
@ -385,6 +451,9 @@ gst_multiudpsink_set_property (GObject * object, guint prop_id,
|
|||||||
case PROP_CLOSEFD:
|
case PROP_CLOSEFD:
|
||||||
udpsink->closefd = g_value_get_boolean (value);
|
udpsink->closefd = g_value_get_boolean (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CLIENTS:
|
||||||
|
gst_multiudpsink_set_clients_string (udpsink, g_value_get_string (value));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -415,6 +484,10 @@ gst_multiudpsink_get_property (GObject * object, guint prop_id, GValue * value,
|
|||||||
case PROP_SOCK:
|
case PROP_SOCK:
|
||||||
g_value_set_int (value, udpsink->sock);
|
g_value_set_int (value, udpsink->sock);
|
||||||
break;
|
break;
|
||||||
|
case PROP_CLIENTS:
|
||||||
|
g_value_take_string (value,
|
||||||
|
gst_multiudpsink_get_clients_string (udpsink));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
@ -512,8 +585,9 @@ gst_multiudpsink_close (GstMultiUDPSink * sink)
|
|||||||
CLOSE_IF_REQUESTED (sink);
|
CLOSE_IF_REQUESTED (sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static 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 hostent *he;
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
@ -563,8 +637,10 @@ gst_multiudpsink_add (GstMultiUDPSink * sink, const gchar * host, gint port)
|
|||||||
goto host_error;
|
goto host_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lock)
|
||||||
g_mutex_lock (sink->client_lock);
|
g_mutex_lock (sink->client_lock);
|
||||||
sink->clients = g_list_prepend (sink->clients, client);
|
sink->clients = g_list_prepend (sink->clients, client);
|
||||||
|
if (lock)
|
||||||
g_mutex_unlock (sink->client_lock);
|
g_mutex_unlock (sink->client_lock);
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (sink),
|
g_signal_emit (G_OBJECT (sink),
|
||||||
@ -582,6 +658,12 @@ host_error:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_multiudpsink_add (GstMultiUDPSink * sink, const gchar * host, gint port)
|
||||||
|
{
|
||||||
|
gst_multiudpsink_add_internal (sink, host, port, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
client_compare (GstUDPClient * a, GstUDPClient * b)
|
client_compare (GstUDPClient * a, GstUDPClient * b)
|
||||||
{
|
{
|
||||||
@ -648,19 +730,27 @@ not_found:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
gst_multiudpsink_clear (GstMultiUDPSink * sink)
|
gst_multiudpsink_clear_internal (GstMultiUDPSink * sink, gboolean lock)
|
||||||
{
|
{
|
||||||
GST_DEBUG_OBJECT (sink, "clearing");
|
GST_DEBUG_OBJECT (sink, "clearing");
|
||||||
/* we only need to remove the client structure, there is no additional
|
/* we only need to remove the client structure, there is no additional
|
||||||
* socket or anything to free for UDP */
|
* socket or anything to free for UDP */
|
||||||
|
if (lock)
|
||||||
g_mutex_lock (sink->client_lock);
|
g_mutex_lock (sink->client_lock);
|
||||||
g_list_foreach (sink->clients, (GFunc) free_client, sink);
|
g_list_foreach (sink->clients, (GFunc) free_client, sink);
|
||||||
g_list_free (sink->clients);
|
g_list_free (sink->clients);
|
||||||
sink->clients = NULL;
|
sink->clients = NULL;
|
||||||
|
if (lock)
|
||||||
g_mutex_unlock (sink->client_lock);
|
g_mutex_unlock (sink->client_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_multiudpsink_clear (GstMultiUDPSink * sink)
|
||||||
|
{
|
||||||
|
gst_multiudpsink_clear_internal (sink, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
GValueArray *
|
GValueArray *
|
||||||
gst_multiudpsink_get_stats (GstMultiUDPSink * sink, const gchar * host,
|
gst_multiudpsink_get_stats (GstMultiUDPSink * sink, const gchar * host,
|
||||||
gint port)
|
gint port)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user