more borgifying

Original commit message from CVS:
more borgifying
This commit is contained in:
Thomas Vander Stichele 2005-12-01 01:21:49 +00:00
parent f39b477379
commit 2d899d13f5
12 changed files with 425 additions and 366 deletions

View file

@ -1,3 +1,58 @@
2005-12-01 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/tcp/gstmultifdsink.c: (gst_multi_fd_sink_base_init),
(gst_multi_fd_sink_class_init), (gst_multi_fd_sink_init),
(gst_multi_fd_sink_finalize), (gst_multi_fd_sink_add),
(gst_multi_fd_sink_remove), (gst_multi_fd_sink_clear),
(gst_multi_fd_sink_get_stats),
(gst_multi_fd_sink_remove_client_link),
(gst_multi_fd_sink_handle_client_read),
(gst_multi_fd_sink_client_queue_data),
(gst_multi_fd_sink_client_queue_caps),
(gst_multi_fd_sink_client_queue_buffer),
(gst_multi_fd_sink_new_client),
(gst_multi_fd_sink_handle_client_write),
(gst_multi_fd_sink_recover_client),
(gst_multi_fd_sink_queue_buffer),
(gst_multi_fd_sink_handle_clients), (gst_multi_fd_sink_thread),
(gst_multi_fd_sink_render), (gst_multi_fd_sink_set_property),
(gst_multi_fd_sink_get_property), (gst_multi_fd_sink_start),
(gst_multi_fd_sink_stop), (gst_multi_fd_sink_change_state):
* gst/tcp/gstmultifdsink.h:
* gst/tcp/gsttcpclientsink.c: (gst_tcp_client_sink_get_type),
(gst_tcp_client_sink_base_init), (gst_tcp_client_sink_class_init),
(gst_tcp_client_sink_init), (gst_tcp_client_sink_finalize),
(gst_tcp_client_sink_setcaps), (gst_tcp_client_sink_render),
(gst_tcp_client_sink_set_property),
(gst_tcp_client_sink_get_property), (gst_tcp_client_sink_start),
(gst_tcp_client_sink_stop), (gst_tcp_client_sink_change_state):
* gst/tcp/gsttcpclientsink.h:
* gst/tcp/gsttcpclientsrc.c: (gst_tcp_client_src_base_init),
(gst_tcp_client_src_class_init), (gst_tcp_client_src_init),
(gst_tcp_client_src_finalize), (gst_tcp_client_src_getcaps),
(gst_tcp_client_src_create), (gst_tcp_client_src_set_property),
(gst_tcp_client_src_get_property), (gst_tcp_client_src_start),
(gst_tcp_client_src_stop), (gst_tcp_client_src_unlock):
* gst/tcp/gsttcpclientsrc.h:
* gst/tcp/gsttcpplugin.c: (plugin_init):
* gst/tcp/gsttcpserversink.c: (gst_tcp_server_sink_base_init),
(gst_tcp_server_sink_class_init), (gst_tcp_server_sink_init),
(gst_tcp_server_sink_finalize),
(gst_tcp_server_sink_handle_server_read),
(gst_tcp_server_sink_removed), (gst_tcp_server_sink_handle_wait),
(gst_tcp_server_sink_set_property),
(gst_tcp_server_sink_get_property),
(gst_tcp_server_sink_init_send), (gst_tcp_server_sink_close):
* gst/tcp/gsttcpserversink.h:
* gst/tcp/gsttcpserversrc.c: (gst_tcp_server_src_base_init),
(gst_tcp_server_src_class_init), (gst_tcp_server_src_init),
(gst_tcp_server_src_finalize), (gst_tcp_server_src_create),
(gst_tcp_server_src_set_property),
(gst_tcp_server_src_get_property), (gst_tcp_server_src_start),
(gst_tcp_server_src_stop), (gst_tcp_server_src_unlock):
* gst/tcp/gsttcpserversrc.h:
more borgifying
2005-12-01 Thomas Vander Stichele <thomas at apestaart dot org>
* docs/plugins/Makefile.am:

View file

@ -64,7 +64,7 @@ G_STMT_START { \
} G_STMT_END
/* elementfactory information */
static GstElementDetails gst_multifdsink_details =
static GstElementDetails gst_multi_fd_sink_details =
GST_ELEMENT_DETAILS ("MultiFd sink",
"Sink/Network",
"Send data to multiple filedescriptors",
@ -218,42 +218,42 @@ gst_client_status_get_type (void)
return client_status_type;
}
static void gst_multifdsink_finalize (GObject * object);
static void gst_multi_fd_sink_finalize (GObject * object);
static void gst_multifdsink_remove_client_link (GstMultiFdSink * sink,
static void gst_multi_fd_sink_remove_client_link (GstMultiFdSink * sink,
GList * link);
static GstFlowReturn gst_multifdsink_render (GstBaseSink * bsink,
static GstFlowReturn gst_multi_fd_sink_render (GstBaseSink * bsink,
GstBuffer * buf);
static GstStateChangeReturn gst_multifdsink_change_state (GstElement *
static GstStateChangeReturn gst_multi_fd_sink_change_state (GstElement *
element, GstStateChange transition);
static void gst_multifdsink_set_property (GObject * object, guint prop_id,
static void gst_multi_fd_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_multifdsink_get_property (GObject * object, guint prop_id,
static void gst_multi_fd_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
GST_BOILERPLATE (GstMultiFdSink, gst_multifdsink, GstBaseSink,
GST_BOILERPLATE (GstMultiFdSink, gst_multi_fd_sink, GstBaseSink,
GST_TYPE_BASE_SINK);
static guint gst_multifdsink_signals[LAST_SIGNAL] = { 0 };
static guint gst_multi_fd_sink_signals[LAST_SIGNAL] = { 0 };
static void
gst_multifdsink_base_init (gpointer g_class)
gst_multi_fd_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details (element_class, &gst_multifdsink_details);
gst_element_class_set_details (element_class, &gst_multi_fd_sink_details);
}
static void
gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
gst_multi_fd_sink_class_init (GstMultiFdSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -263,9 +263,9 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->set_property = gst_multifdsink_set_property;
gobject_class->get_property = gst_multifdsink_get_property;
gobject_class->finalize = gst_multifdsink_finalize;
gobject_class->set_property = gst_multi_fd_sink_set_property;
gobject_class->get_property = gst_multi_fd_sink_get_property;
gobject_class->finalize = gst_multi_fd_sink_finalize;
g_object_class_install_property (gobject_class, ARG_PROTOCOL,
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
@ -342,7 +342,7 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
*
* Hand the given open file descriptor to multifdsink to write to.
*/
gst_multifdsink_signals[SIGNAL_ADD] =
gst_multi_fd_sink_signals[SIGNAL_ADD] =
g_signal_new ("add", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMultiFdSinkClass, add),
NULL, NULL, g_cclosure_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
@ -353,7 +353,7 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
*
* Remove the given open file descriptor from multifdsink.
*/
gst_multifdsink_signals[SIGNAL_REMOVE] =
gst_multi_fd_sink_signals[SIGNAL_REMOVE] =
g_signal_new ("remove", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMultiFdSinkClass, remove),
NULL, NULL, gst_tcp_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
@ -363,11 +363,11 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
*
* Clear all file descriptors from multifdsink.
*/
gst_multifdsink_signals[SIGNAL_CLEAR] =
gst_multi_fd_sink_signals[SIGNAL_CLEAR] =
g_signal_new ("clear", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMultiFdSinkClass, clear),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
gst_multifdsink_signals[SIGNAL_GET_STATS] =
gst_multi_fd_sink_signals[SIGNAL_GET_STATS] =
g_signal_new ("get-stats", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GstMultiFdSinkClass, get_stats),
NULL, NULL, gst_tcp_marshal_BOXED__INT, G_TYPE_VALUE_ARRAY, 1,
@ -380,7 +380,7 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
*
* The given file descriptor was added to multifdsink.
*/
gst_multifdsink_signals[SIGNAL_CLIENT_ADDED] =
gst_multi_fd_sink_signals[SIGNAL_CLIENT_ADDED] =
g_signal_new ("client-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstMultiFdSinkClass, client_added),
NULL, NULL, gst_tcp_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
@ -391,29 +391,29 @@ gst_multifdsink_class_init (GstMultiFdSinkClass * klass)
*
* The given file descriptor was removed from multifdsink.
*/
gst_multifdsink_signals[SIGNAL_CLIENT_REMOVED] =
gst_multi_fd_sink_signals[SIGNAL_CLIENT_REMOVED] =
g_signal_new ("client-removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstMultiFdSinkClass,
client_removed), NULL, NULL, gst_tcp_marshal_VOID__INT_BOXED,
G_TYPE_NONE, 2, G_TYPE_INT, GST_TYPE_CLIENT_STATUS);
gstelement_class->change_state =
GST_DEBUG_FUNCPTR (gst_multifdsink_change_state);
GST_DEBUG_FUNCPTR (gst_multi_fd_sink_change_state);
gstbasesink_class->render = gst_multifdsink_render;
gstbasesink_class->render = gst_multi_fd_sink_render;
klass->add = gst_multifdsink_add;
klass->remove = gst_multifdsink_remove;
klass->clear = gst_multifdsink_clear;
klass->get_stats = gst_multifdsink_get_stats;
klass->add = gst_multi_fd_sink_add;
klass->remove = gst_multi_fd_sink_remove;
klass->clear = gst_multi_fd_sink_clear;
klass->get_stats = gst_multi_fd_sink_get_stats;
GST_DEBUG_CATEGORY_INIT (multifdsink_debug, "multifdsink", 0, "FD sink");
}
static void
gst_multifdsink_init (GstMultiFdSink * this, GstMultiFdSinkClass * klass)
gst_multi_fd_sink_init (GstMultiFdSink * this, GstMultiFdSinkClass * klass)
{
GST_OBJECT_FLAG_UNSET (this, GST_MULTIFDSINK_OPEN);
GST_OBJECT_FLAG_UNSET (this, GST_MULTI_FD_SINK_OPEN);
this->protocol = DEFAULT_PROTOCOL;
this->mode = DEFAULT_MODE;
@ -433,11 +433,11 @@ gst_multifdsink_init (GstMultiFdSink * this, GstMultiFdSinkClass * klass)
}
static void
gst_multifdsink_finalize (GObject * object)
gst_multi_fd_sink_finalize (GObject * object)
{
GstMultiFdSink *this;
this = GST_MULTIFDSINK (object);
this = GST_MULTI_FD_SINK (object);
CLIENTS_LOCK_FREE (this);
g_hash_table_destroy (this->fd_hash);
@ -447,7 +447,7 @@ gst_multifdsink_finalize (GObject * object)
}
void
gst_multifdsink_add (GstMultiFdSink * sink, int fd)
gst_multi_fd_sink_add (GstMultiFdSink * sink, int fd)
{
GstTCPClient *client;
GList *clink;
@ -485,7 +485,8 @@ gst_multifdsink_add (GstMultiFdSink * sink, int fd)
CLIENTS_UNLOCK (sink);
GST_WARNING_OBJECT (sink, "[fd %5d] duplicate client found, refusing", fd);
g_signal_emit (G_OBJECT (sink),
gst_multifdsink_signals[SIGNAL_CLIENT_REMOVED], 0, fd, client->status);
gst_multi_fd_sink_signals[SIGNAL_CLIENT_REMOVED], 0, fd,
client->status);
g_free (client);
return;
}
@ -515,11 +516,11 @@ gst_multifdsink_add (GstMultiFdSink * sink, int fd)
CLIENTS_UNLOCK (sink);
g_signal_emit (G_OBJECT (sink),
gst_multifdsink_signals[SIGNAL_CLIENT_ADDED], 0, fd);
gst_multi_fd_sink_signals[SIGNAL_CLIENT_ADDED], 0, fd);
}
void
gst_multifdsink_remove (GstMultiFdSink * sink, int fd)
gst_multi_fd_sink_remove (GstMultiFdSink * sink, int fd)
{
GList *clink;
@ -531,7 +532,7 @@ gst_multifdsink_remove (GstMultiFdSink * sink, int fd)
GstTCPClient *client = (GstTCPClient *) clink->data;
client->status = GST_CLIENT_STATUS_REMOVED;
gst_multifdsink_remove_client_link (sink, clink);
gst_multi_fd_sink_remove_client_link (sink, clink);
SEND_COMMAND (sink, CONTROL_RESTART);
} else {
GST_WARNING_OBJECT (sink, "[fd %5d] no client with this fd found!", fd);
@ -540,7 +541,7 @@ gst_multifdsink_remove (GstMultiFdSink * sink, int fd)
}
void
gst_multifdsink_clear (GstMultiFdSink * sink)
gst_multi_fd_sink_clear (GstMultiFdSink * sink)
{
GList *clients, *next;
@ -554,14 +555,14 @@ gst_multifdsink_clear (GstMultiFdSink * sink)
next = g_list_next (clients);
client->status = GST_CLIENT_STATUS_REMOVED;
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
}
SEND_COMMAND (sink, CONTROL_RESTART);
CLIENTS_UNLOCK (sink);
}
GValueArray *
gst_multifdsink_get_stats (GstMultiFdSink * sink, int fd)
gst_multi_fd_sink_get_stats (GstMultiFdSink * sink, int fd)
{
GstTCPClient *client;
GValueArray *result = NULL;
@ -622,14 +623,14 @@ gst_multifdsink_get_stats (GstMultiFdSink * sink, int fd)
* close the fd itself.
*/
static void
gst_multifdsink_remove_client_link (GstMultiFdSink * sink, GList * link)
gst_multi_fd_sink_remove_client_link (GstMultiFdSink * sink, GList * link)
{
int fd;
GTimeVal now;
GstTCPClient *client = (GstTCPClient *) link->data;
GstMultiFdSinkClass *fclass;
fclass = GST_MULTIFDSINK_GET_CLASS (sink);
fclass = GST_MULTI_FD_SINK_GET_CLASS (sink);
fd = client->fd.fd;
@ -676,7 +677,7 @@ gst_multifdsink_remove_client_link (GstMultiFdSink * sink, GList * link)
CLIENTS_UNLOCK (sink);
g_signal_emit (G_OBJECT (sink),
gst_multifdsink_signals[SIGNAL_CLIENT_REMOVED], 0, fd, client->status);
gst_multi_fd_sink_signals[SIGNAL_CLIENT_REMOVED], 0, fd, client->status);
/* lock again before we remove the client completely */
CLIENTS_LOCK (sink);
@ -702,7 +703,7 @@ gst_multifdsink_remove_client_link (GstMultiFdSink * sink, GList * link)
* which either indicates a close or should be ignored
* returns FALSE if some error occured or the client closed. */
static gboolean
gst_multifdsink_handle_client_read (GstMultiFdSink * sink,
gst_multi_fd_sink_handle_client_read (GstMultiFdSink * sink,
GstTCPClient * client)
{
int avail, fd;
@ -770,8 +771,8 @@ gst_multifdsink_handle_client_read (GstMultiFdSink * sink,
* setting it as GST_BUFFER_MALLOCDATA() on the created buffer
*/
static gboolean
gst_multifdsink_client_queue_data (GstMultiFdSink * sink, GstTCPClient * client,
gchar * data, gint len)
gst_multi_fd_sink_client_queue_data (GstMultiFdSink * sink,
GstTCPClient * client, gchar * data, gint len)
{
GstBuffer *buf;
@ -789,8 +790,8 @@ gst_multifdsink_client_queue_data (GstMultiFdSink * sink, GstTCPClient * client,
}
static gboolean
gst_multifdsink_client_queue_caps (GstMultiFdSink * sink, GstTCPClient * client,
const GstCaps * caps)
gst_multi_fd_sink_client_queue_caps (GstMultiFdSink * sink,
GstTCPClient * client, const GstCaps * caps)
{
guint8 *header;
guint8 *payload;
@ -808,10 +809,10 @@ gst_multifdsink_client_queue_caps (GstMultiFdSink * sink, GstTCPClient * client,
GST_DEBUG_OBJECT (sink, "Could not create GDP packet from caps");
return FALSE;
}
gst_multifdsink_client_queue_data (sink, client, (gchar *) header, length);
gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) header, length);
length = gst_dp_header_payload_length (header);
gst_multifdsink_client_queue_data (sink, client, (gchar *) payload, length);
gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) payload, length);
return TRUE;
}
@ -828,7 +829,7 @@ is_sync_frame (GstMultiFdSink * sink, GstBuffer * buffer)
}
static gboolean
gst_multifdsink_client_queue_buffer (GstMultiFdSink * sink,
gst_multi_fd_sink_client_queue_buffer (GstMultiFdSink * sink,
GstTCPClient * client, GstBuffer * buffer)
{
if (sink->protocol == GST_TCP_PROTOCOL_GDP) {
@ -840,7 +841,7 @@ gst_multifdsink_client_queue_buffer (GstMultiFdSink * sink,
"[fd %5d] could not create header, removing client", client->fd.fd);
return FALSE;
}
gst_multifdsink_client_queue_data (sink, client, (gchar *) header, len);
gst_multi_fd_sink_client_queue_data (sink, client, (gchar *) header, len);
}
GST_LOG_OBJECT (sink, "[fd %5d] queueing buffer of length %d",
@ -853,7 +854,7 @@ gst_multifdsink_client_queue_buffer (GstMultiFdSink * sink,
}
static gint
gst_multifdsink_new_client (GstMultiFdSink * sink, GstTCPClient * client)
gst_multi_fd_sink_new_client (GstMultiFdSink * sink, GstTCPClient * client)
{
gint result;
@ -961,7 +962,7 @@ done:
* This functions returns FALSE if some error occured.
*/
static gboolean
gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
GstTCPClient * client)
{
int fd = client->fd.fd;
@ -989,7 +990,7 @@ gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
gst_object_unref (peer);
/* queue caps for sending */
res = gst_multifdsink_client_queue_caps (sink, client, caps);
res = gst_multi_fd_sink_client_queue_caps (sink, client, caps);
gst_caps_unref (caps);
@ -1011,7 +1012,7 @@ gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
for (l = sink->streamheader; l; l = l->next) {
/* queue stream headers for sending */
res =
gst_multifdsink_client_queue_buffer (sink, client,
gst_multi_fd_sink_client_queue_buffer (sink, client,
GST_BUFFER (l->data));
if (!res) {
GST_DEBUG_OBJECT (sink,
@ -1041,7 +1042,7 @@ gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
/* for new connections, we need to find a good spot in the
* bufqueue to start streaming from */
if (client->new_connection) {
gint position = gst_multifdsink_new_client (sink, client);
gint position = gst_multi_fd_sink_new_client (sink, client);
if (position >= 0) {
/* we got a valid spot in the queue */
@ -1061,7 +1062,7 @@ gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
fd, client, client->bufpos);
/* queueing a buffer will ref it */
gst_multifdsink_client_queue_buffer (sink, client, buf);
gst_multi_fd_sink_client_queue_buffer (sink, client, buf);
/* need to start from the first byte for this new buffer */
client->bufoffset = 0;
@ -1138,7 +1139,7 @@ gst_multifdsink_handle_client_write (GstMultiFdSink * sink,
* position.
*/
static gint
gst_multifdsink_recover_client (GstMultiFdSink * sink, GstTCPClient * client)
gst_multi_fd_sink_recover_client (GstMultiFdSink * sink, GstTCPClient * client)
{
gint newbufpos;
@ -1204,7 +1205,7 @@ gst_multifdsink_recover_client (GstMultiFdSink * sink, GstTCPClient * client)
*
*/
static void
gst_multifdsink_queue_buffer (GstMultiFdSink * sink, GstBuffer * buf)
gst_multi_fd_sink_queue_buffer (GstMultiFdSink * sink, GstBuffer * buf)
{
GList *clients, *next;
gint queuelen;
@ -1237,7 +1238,7 @@ gst_multifdsink_queue_buffer (GstMultiFdSink * sink, GstBuffer * buf)
if (sink->units_soft_max > 0 && client->bufpos >= sink->units_soft_max) {
gint newpos;
newpos = gst_multifdsink_recover_client (sink, client);
newpos = gst_multi_fd_sink_recover_client (sink, client);
if (newpos != client->bufpos) {
client->bufpos = newpos;
client->discont = TRUE;
@ -1259,7 +1260,7 @@ gst_multifdsink_queue_buffer (GstMultiFdSink * sink, GstBuffer * buf)
/* remove the client, the fd set will be cleared and the select thread will
* be signaled */
client->status = GST_CLIENT_STATUS_SLOW;
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
/* set client to invalid position while being removed */
client->bufpos = -1;
need_signal = TRUE;
@ -1334,14 +1335,14 @@ gst_multifdsink_queue_buffer (GstMultiFdSink * sink, GstBuffer * buf)
* garbage list and removed.
*/
static void
gst_multifdsink_handle_clients (GstMultiFdSink * sink)
gst_multi_fd_sink_handle_clients (GstMultiFdSink * sink)
{
int result;
GList *clients, *next;
gboolean try_again;
GstMultiFdSinkClass *fclass;
fclass = GST_MULTIFDSINK_GET_CLASS (sink);
fclass = GST_MULTI_FD_SINK_GET_CLASS (sink);
do {
gboolean stop = FALSE;
@ -1380,7 +1381,7 @@ gst_multifdsink_handle_clients (GstMultiFdSink * sink)
fd, g_strerror (errno), errno);
if (errno == EBADF) {
client->status = GST_CLIENT_STATUS_ERROR;
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
}
}
}
@ -1454,32 +1455,32 @@ gst_multifdsink_handle_clients (GstMultiFdSink * sink)
next = g_list_next (clients);
if (client->status != GST_CLIENT_STATUS_OK) {
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
continue;
}
if (gst_fdset_fd_has_closed (sink->fdset, &client->fd)) {
client->status = GST_CLIENT_STATUS_CLOSED;
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
continue;
}
if (gst_fdset_fd_has_error (sink->fdset, &client->fd)) {
GST_WARNING_OBJECT (sink, "gst_fdset_fd_has_error for %d", client->fd);
client->status = GST_CLIENT_STATUS_ERROR;
gst_multifdsink_remove_client_link (sink, clients);
gst_multi_fd_sink_remove_client_link (sink, clients);
continue;
}
if (gst_fdset_fd_can_read (sink->fdset, &client->fd)) {
/* handle client read */
if (!gst_multifdsink_handle_client_read (sink, client)) {
gst_multifdsink_remove_client_link (sink, clients);
if (!gst_multi_fd_sink_handle_client_read (sink, client)) {
gst_multi_fd_sink_remove_client_link (sink, clients);
continue;
}
}
if (gst_fdset_fd_can_write (sink->fdset, &client->fd)) {
/* handle client write */
if (!gst_multifdsink_handle_client_write (sink, client)) {
gst_multifdsink_remove_client_link (sink, clients);
if (!gst_multi_fd_sink_handle_client_write (sink, client)) {
gst_multi_fd_sink_remove_client_link (sink, clients);
continue;
}
}
@ -1490,25 +1491,25 @@ gst_multifdsink_handle_clients (GstMultiFdSink * sink)
/* we handle the client communication in another thread so that we do not block
* the gstreamer thread while we select() on the client fds */
static gpointer
gst_multifdsink_thread (GstMultiFdSink * sink)
gst_multi_fd_sink_thread (GstMultiFdSink * sink)
{
while (sink->running) {
gst_multifdsink_handle_clients (sink);
gst_multi_fd_sink_handle_clients (sink);
}
return NULL;
}
static GstFlowReturn
gst_multifdsink_render (GstBaseSink * bsink, GstBuffer * buf)
gst_multi_fd_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstMultiFdSink *sink;
sink = GST_MULTIFDSINK (bsink);
sink = GST_MULTI_FD_SINK (bsink);
/* since we keep this buffer out of the scope of this method */
gst_buffer_ref (buf);
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_MULTIFDSINK_OPEN),
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_MULTI_FD_SINK_OPEN),
GST_FLOW_ERROR);
GST_LOG_OBJECT (sink, "received buffer %p", buf);
@ -1541,7 +1542,7 @@ gst_multifdsink_render (GstBaseSink * bsink, GstBuffer * buf)
sink->previous_buffer_in_caps = FALSE;
/* queue the buffer */
gst_multifdsink_queue_buffer (sink, buf);
gst_multi_fd_sink_queue_buffer (sink, buf);
sink->bytes_to_serve += GST_BUFFER_SIZE (buf);
@ -1549,13 +1550,13 @@ gst_multifdsink_render (GstBaseSink * bsink, GstBuffer * buf)
}
static void
gst_multifdsink_set_property (GObject * object, guint prop_id,
gst_multi_fd_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstMultiFdSink *multifdsink;
g_return_if_fail (GST_IS_MULTIFDSINK (object));
multifdsink = GST_MULTIFDSINK (object);
g_return_if_fail (GST_IS_MULTI_FD_SINK (object));
multifdsink = GST_MULTI_FD_SINK (object);
switch (prop_id) {
case ARG_PROTOCOL:
@ -1596,13 +1597,13 @@ gst_multifdsink_set_property (GObject * object, guint prop_id,
}
static void
gst_multifdsink_get_property (GObject * object, guint prop_id, GValue * value,
gst_multi_fd_sink_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstMultiFdSink *multifdsink;
g_return_if_fail (GST_IS_MULTIFDSINK (object));
multifdsink = GST_MULTIFDSINK (object);
g_return_if_fail (GST_IS_MULTI_FD_SINK (object));
multifdsink = GST_MULTI_FD_SINK (object);
switch (prop_id) {
case ARG_PROTOCOL:
@ -1660,17 +1661,17 @@ gst_multifdsink_get_property (GObject * object, guint prop_id, GValue * value,
/* create a socket for sending to remote machine */
static gboolean
gst_multifdsink_start (GstBaseSink * bsink)
gst_multi_fd_sink_start (GstBaseSink * bsink)
{
GstMultiFdSinkClass *fclass;
int control_socket[2];
GstMultiFdSink *this;
if (GST_OBJECT_FLAG_IS_SET (bsink, GST_MULTIFDSINK_OPEN))
if (GST_OBJECT_FLAG_IS_SET (bsink, GST_MULTI_FD_SINK_OPEN))
return TRUE;
this = GST_MULTIFDSINK (bsink);
fclass = GST_MULTIFDSINK_GET_CLASS (this);
this = GST_MULTI_FD_SINK (bsink);
fclass = GST_MULTI_FD_SINK_GET_CLASS (this);
GST_INFO_OBJECT (this, "starting in mode %d", this->mode);
this->fdset = gst_fdset_new (this->mode);
@ -1696,10 +1697,10 @@ gst_multifdsink_start (GstBaseSink * bsink)
}
this->running = TRUE;
this->thread = g_thread_create ((GThreadFunc) gst_multifdsink_thread,
this->thread = g_thread_create ((GThreadFunc) gst_multi_fd_sink_thread,
this, TRUE, NULL);
GST_OBJECT_FLAG_SET (this, GST_MULTIFDSINK_OPEN);
GST_OBJECT_FLAG_SET (this, GST_MULTI_FD_SINK_OPEN);
return TRUE;
@ -1719,15 +1720,15 @@ multifdsink_hash_remove (gpointer key, gpointer value, gpointer data)
}
static gboolean
gst_multifdsink_stop (GstBaseSink * bsink)
gst_multi_fd_sink_stop (GstBaseSink * bsink)
{
GstMultiFdSinkClass *fclass;
GstMultiFdSink *this;
this = GST_MULTIFDSINK (bsink);
fclass = GST_MULTIFDSINK_GET_CLASS (this);
this = GST_MULTI_FD_SINK (bsink);
fclass = GST_MULTI_FD_SINK_GET_CLASS (this);
if (!GST_OBJECT_FLAG_IS_SET (bsink, GST_MULTIFDSINK_OPEN))
if (!GST_OBJECT_FLAG_IS_SET (bsink, GST_MULTI_FD_SINK_OPEN))
return TRUE;
this->running = FALSE;
@ -1739,7 +1740,7 @@ gst_multifdsink_stop (GstBaseSink * bsink)
}
/* free the clients */
gst_multifdsink_clear (this);
gst_multi_fd_sink_clear (this);
close (READ_SOCKET (this).fd);
close (WRITE_SOCKET (this).fd);
@ -1759,18 +1760,18 @@ gst_multifdsink_stop (GstBaseSink * bsink)
this->fdset = NULL;
}
g_hash_table_foreach_remove (this->fd_hash, multifdsink_hash_remove, this);
GST_OBJECT_FLAG_UNSET (this, GST_MULTIFDSINK_OPEN);
GST_OBJECT_FLAG_UNSET (this, GST_MULTI_FD_SINK_OPEN);
return TRUE;
}
static GstStateChangeReturn
gst_multifdsink_change_state (GstElement * element, GstStateChange transition)
gst_multi_fd_sink_change_state (GstElement * element, GstStateChange transition)
{
GstMultiFdSink *sink;
GstStateChangeReturn ret;
sink = GST_MULTIFDSINK (element);
sink = GST_MULTI_FD_SINK (element);
/* we disallow changing the state from the streaming thread */
if (g_thread_self () == sink->thread)
@ -1779,7 +1780,7 @@ gst_multifdsink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!gst_multifdsink_start (GST_BASE_SINK (sink)))
if (!gst_multi_fd_sink_start (GST_BASE_SINK (sink)))
goto start_failed;
break;
case GST_STATE_CHANGE_READY_TO_PAUSED:
@ -1798,7 +1799,7 @@ gst_multifdsink_change_state (GstElement * element, GstStateChange transition)
case GST_STATE_CHANGE_PAUSED_TO_READY:
break;
case GST_STATE_CHANGE_READY_TO_NULL:
gst_multifdsink_stop (GST_BASE_SINK (sink));
gst_multi_fd_sink_stop (GST_BASE_SINK (sink));
break;
default:
break;

View file

@ -19,8 +19,8 @@
*/
#ifndef __GST_MULTIFDSINK_H__
#define __GST_MULTIFDSINK_H__
#ifndef __GST_MULTI_FD_SINK_H__
#define __GST_MULTI_FD_SINK_H__
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
@ -30,27 +30,27 @@ G_BEGIN_DECLS
#include "gsttcp.h"
#include "gstfdset.h"
#define GST_TYPE_MULTIFDSINK \
(gst_multifdsink_get_type())
#define GST_MULTIFDSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTIFDSINK,GstMultiFdSink))
#define GST_MULTIFDSINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTIFDSINK,GstMultiFdSink))
#define GST_IS_MULTIFDSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTIFDSINK))
#define GST_IS_MULTIFDSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTIFDSINK))
#define GST_MULTIFDSINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MULTIFDSINK, GstMultiFdSinkClass))
#define GST_TYPE_MULTI_FD_SINK \
(gst_multi_fd_sink_get_type())
#define GST_MULTI_FD_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTI_FD_SINK,GstMultiFdSink))
#define GST_MULTI_FD_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTI_FD_SINK,GstMultiFdSink))
#define GST_IS_MULTI_FD_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTI_FD_SINK))
#define GST_IS_MULTI_FD_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTI_FD_SINK))
#define GST_MULTI_FD_SINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MULTI_FD_SINK, GstMultiFdSinkClass))
typedef struct _GstMultiFdSink GstMultiFdSink;
typedef struct _GstMultiFdSinkClass GstMultiFdSinkClass;
typedef enum {
GST_MULTIFDSINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_MULTI_FD_SINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_MULTIFDSINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2),
GST_MULTI_FD_SINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2),
} GstMultiFdSinkFlags;
typedef enum
@ -180,13 +180,13 @@ struct _GstMultiFdSinkClass {
void (*client_removed) (GstElement *element, gchar *host, gint fd);
};
GType gst_multifdsink_get_type (void);
GType gst_multi_fd_sink_get_type (void);
void gst_multifdsink_add (GstMultiFdSink *sink, int fd);
void gst_multifdsink_remove (GstMultiFdSink *sink, int fd);
void gst_multifdsink_clear (GstMultiFdSink *sink);
GValueArray* gst_multifdsink_get_stats (GstMultiFdSink *sink, int fd);
void gst_multi_fd_sink_add (GstMultiFdSink *sink, int fd);
void gst_multi_fd_sink_remove (GstMultiFdSink *sink, int fd);
void gst_multi_fd_sink_clear (GstMultiFdSink *sink);
GValueArray* gst_multi_fd_sink_get_stats (GstMultiFdSink *sink, int fd);
G_END_DECLS
#endif /* __GST_MULTIFDSINK_H__ */
#endif /* __GST_MULTI_FD_SINK_H__ */

View file

@ -27,7 +27,7 @@
#include "gsttcpclientsink.h"
/* elementfactory information */
static GstElementDetails gst_tcpclientsink_details =
static GstElementDetails gst_tcp_client_sink_details =
GST_ELEMENT_DETAILS ("TCP Client sink",
"Sink/Network",
"Send data as a client over the network via TCP",
@ -58,29 +58,30 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
static void gst_tcpclientsink_base_init (gpointer g_class);
static void gst_tcpclientsink_class_init (GstTCPClientSink * klass);
static void gst_tcpclientsink_init (GstTCPClientSink * tcpclientsink);
static void gst_tcpclientsink_finalize (GObject * gobject);
static void gst_tcp_client_sink_base_init (gpointer g_class);
static void gst_tcp_client_sink_class_init (GstTCPClientSink * klass);
static void gst_tcp_client_sink_init (GstTCPClientSink * tcpclientsink);
static void gst_tcp_client_sink_finalize (GObject * gobject);
static gboolean gst_tcpclientsink_setcaps (GstBaseSink * bsink, GstCaps * caps);
static GstFlowReturn gst_tcpclientsink_render (GstBaseSink * bsink,
static gboolean gst_tcp_client_sink_setcaps (GstBaseSink * bsink,
GstCaps * caps);
static GstFlowReturn gst_tcp_client_sink_render (GstBaseSink * bsink,
GstBuffer * buf);
static GstStateChangeReturn gst_tcpclientsink_change_state (GstElement *
static GstStateChangeReturn gst_tcp_client_sink_change_state (GstElement *
element, GstStateChange transition);
static void gst_tcpclientsink_set_property (GObject * object, guint prop_id,
static void gst_tcp_client_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tcpclientsink_get_property (GObject * object, guint prop_id,
static void gst_tcp_client_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static GstElementClass *parent_class = NULL;
/*static guint gst_tcpclientsink_signals[LAST_SIGNAL] = { 0 }; */
/*static guint gst_tcp_client_sink_signals[LAST_SIGNAL] = { 0 }; */
GType
gst_tcpclientsink_get_type (void)
gst_tcp_client_sink_get_type (void)
{
static GType tcpclientsink_type = 0;
@ -88,14 +89,14 @@ gst_tcpclientsink_get_type (void)
if (!tcpclientsink_type) {
static const GTypeInfo tcpclientsink_info = {
sizeof (GstTCPClientSinkClass),
gst_tcpclientsink_base_init,
gst_tcp_client_sink_base_init,
NULL,
(GClassInitFunc) gst_tcpclientsink_class_init,
(GClassInitFunc) gst_tcp_client_sink_class_init,
NULL,
NULL,
sizeof (GstTCPClientSink),
0,
(GInstanceInitFunc) gst_tcpclientsink_init,
(GInstanceInitFunc) gst_tcp_client_sink_init,
NULL
};
@ -107,18 +108,18 @@ gst_tcpclientsink_get_type (void)
}
static void
gst_tcpclientsink_base_init (gpointer g_class)
gst_tcp_client_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details (element_class, &gst_tcpclientsink_details);
gst_element_class_set_details (element_class, &gst_tcp_client_sink_details);
}
static void
gst_tcpclientsink_class_init (GstTCPClientSink * klass)
gst_tcp_client_sink_class_init (GstTCPClientSink * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
@ -130,9 +131,9 @@ gst_tcpclientsink_class_init (GstTCPClientSink * klass)
parent_class = g_type_class_ref (GST_TYPE_BASE_SINK);
gobject_class->set_property = gst_tcpclientsink_set_property;
gobject_class->get_property = gst_tcpclientsink_get_property;
gobject_class->finalize = gst_tcpclientsink_finalize;
gobject_class->set_property = gst_tcp_client_sink_set_property;
gobject_class->get_property = gst_tcp_client_sink_get_property;
gobject_class->finalize = gst_tcp_client_sink_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST,
g_param_spec_string ("host", "Host", "The host/IP to send the packets to",
@ -144,39 +145,39 @@ gst_tcpclientsink_class_init (GstTCPClientSink * klass)
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE, G_PARAM_READWRITE));
gstelement_class->change_state = gst_tcpclientsink_change_state;
gstelement_class->change_state = gst_tcp_client_sink_change_state;
gstbasesink_class->set_caps = gst_tcpclientsink_setcaps;
gstbasesink_class->render = gst_tcpclientsink_render;
gstbasesink_class->set_caps = gst_tcp_client_sink_setcaps;
gstbasesink_class->render = gst_tcp_client_sink_render;
GST_DEBUG_CATEGORY_INIT (tcpclientsink_debug, "tcpclientsink", 0, "TCP sink");
}
static void
gst_tcpclientsink_init (GstTCPClientSink * this)
gst_tcp_client_sink_init (GstTCPClientSink * this)
{
this->host = g_strdup (TCP_DEFAULT_HOST);
this->port = TCP_DEFAULT_PORT;
this->sock_fd = -1;
this->protocol = GST_TCP_PROTOCOL_NONE;
GST_OBJECT_FLAG_UNSET (this, GST_TCPCLIENTSINK_OPEN);
GST_OBJECT_FLAG_UNSET (this, GST_TCP_CLIENT_SINK_OPEN);
}
static void
gst_tcpclientsink_finalize (GObject * gobject)
gst_tcp_client_sink_finalize (GObject * gobject)
{
GstTCPClientSink *this = GST_TCPCLIENTSINK (gobject);
GstTCPClientSink *this = GST_TCP_CLIENT_SINK (gobject);
g_free (this->host);
}
static gboolean
gst_tcpclientsink_setcaps (GstBaseSink * bsink, GstCaps * caps)
gst_tcp_client_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
{
GstTCPClientSink *sink;
sink = GST_TCPCLIENTSINK (bsink);
sink = GST_TCP_CLIENT_SINK (bsink);
/* write the buffer header if we have one */
switch (sink->protocol) {
@ -216,15 +217,15 @@ gdp_write_error:
}
static GstFlowReturn
gst_tcpclientsink_render (GstBaseSink * bsink, GstBuffer * buf)
gst_tcp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
size_t wrote = 0;
GstTCPClientSink *sink;
gint size;
sink = GST_TCPCLIENTSINK (bsink);
sink = GST_TCP_CLIENT_SINK (bsink);
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_TCPCLIENTSINK_OPEN),
g_return_val_if_fail (GST_OBJECT_FLAG_IS_SET (sink, GST_TCP_CLIENT_SINK_OPEN),
GST_FLOW_WRONG_STATE);
size = GST_BUFFER_SIZE (buf);
@ -271,13 +272,13 @@ write_error:
}
static void
gst_tcpclientsink_set_property (GObject * object, guint prop_id,
gst_tcp_client_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTCPClientSink *tcpclientsink;
g_return_if_fail (GST_IS_TCPCLIENTSINK (object));
tcpclientsink = GST_TCPCLIENTSINK (object);
g_return_if_fail (GST_IS_TCP_CLIENT_SINK (object));
tcpclientsink = GST_TCP_CLIENT_SINK (object);
switch (prop_id) {
case ARG_HOST:
@ -302,13 +303,13 @@ gst_tcpclientsink_set_property (GObject * object, guint prop_id,
}
static void
gst_tcpclientsink_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
gst_tcp_client_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstTCPClientSink *tcpclientsink;
g_return_if_fail (GST_IS_TCPCLIENTSINK (object));
tcpclientsink = GST_TCPCLIENTSINK (object);
g_return_if_fail (GST_IS_TCP_CLIENT_SINK (object));
tcpclientsink = GST_TCP_CLIENT_SINK (object);
switch (prop_id) {
case ARG_HOST:
@ -330,12 +331,12 @@ gst_tcpclientsink_get_property (GObject * object, guint prop_id, GValue * value,
/* create a socket for sending to remote machine */
static gboolean
gst_tcpclientsink_start (GstTCPClientSink * this)
gst_tcp_client_sink_start (GstTCPClientSink * this)
{
int ret;
gchar *ip;
if (GST_OBJECT_FLAG_IS_SET (this, GST_TCPCLIENTSINK_OPEN))
if (GST_OBJECT_FLAG_IS_SET (this, GST_TCP_CLIENT_SINK_OPEN))
return TRUE;
/* reset caps_sent flag */
@ -388,7 +389,7 @@ gst_tcpclientsink_start (GstTCPClientSink * this)
}
}
GST_OBJECT_FLAG_SET (this, GST_TCPCLIENTSINK_OPEN);
GST_OBJECT_FLAG_SET (this, GST_TCP_CLIENT_SINK_OPEN);
this->data_written = 0;
@ -396,9 +397,9 @@ gst_tcpclientsink_start (GstTCPClientSink * this)
}
static gboolean
gst_tcpclientsink_stop (GstTCPClientSink * this)
gst_tcp_client_sink_stop (GstTCPClientSink * this)
{
if (!GST_OBJECT_FLAG_IS_SET (this, GST_TCPCLIENTSINK_OPEN))
if (!GST_OBJECT_FLAG_IS_SET (this, GST_TCP_CLIENT_SINK_OPEN))
return TRUE;
if (this->sock_fd != -1) {
@ -406,23 +407,24 @@ gst_tcpclientsink_stop (GstTCPClientSink * this)
this->sock_fd = -1;
}
GST_OBJECT_FLAG_UNSET (this, GST_TCPCLIENTSINK_OPEN);
GST_OBJECT_FLAG_UNSET (this, GST_TCP_CLIENT_SINK_OPEN);
return TRUE;
}
static GstStateChangeReturn
gst_tcpclientsink_change_state (GstElement * element, GstStateChange transition)
gst_tcp_client_sink_change_state (GstElement * element,
GstStateChange transition)
{
GstTCPClientSink *sink;
GstStateChangeReturn res;
sink = GST_TCPCLIENTSINK (element);
sink = GST_TCP_CLIENT_SINK (element);
switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY:
case GST_STATE_CHANGE_READY_TO_PAUSED:
if (!gst_tcpclientsink_start (GST_TCPCLIENTSINK (element)))
if (!gst_tcp_client_sink_start (GST_TCP_CLIENT_SINK (element)))
goto start_failure;
break;
default:
@ -432,7 +434,7 @@ gst_tcpclientsink_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_READY_TO_NULL:
gst_tcpclientsink_stop (GST_TCPCLIENTSINK (element));
gst_tcp_client_sink_stop (GST_TCP_CLIENT_SINK (element));
default:
break;
}

View file

@ -18,8 +18,8 @@
*/
#ifndef __GST_TCPCLIENTSINK_H__
#define __GST_TCPCLIENTSINK_H__
#ifndef __GST_TCP_CLIENT_SINK_H__
#define __GST_TCP_CLIENT_SINK_H__
#include <gst/gst.h>
@ -44,24 +44,24 @@ G_BEGIN_DECLS
#include <arpa/inet.h>
#include "gsttcp.h"
#define GST_TYPE_TCPCLIENTSINK \
(gst_tcpclientsink_get_type())
#define GST_TCPCLIENTSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCPCLIENTSINK,GstTCPClientSink))
#define GST_TCPCLIENTSINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCPCLIENTSINK,GstTCPClientSink))
#define GST_IS_TCPCLIENTSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCPCLIENTSINK))
#define GST_IS_TCPCLIENTSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPCLIENTSINK))
#define GST_TYPE_TCP_CLIENT_SINK \
(gst_tcp_client_sink_get_type())
#define GST_TCP_CLIENT_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCP_CLIENT_SINK,GstTCPClientSink))
#define GST_TCP_CLIENT_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCP_CLIENT_SINK,GstTCPClientSink))
#define GST_IS_TCP_CLIENT_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCP_CLIENT_SINK))
#define GST_IS_TCP_CLIENT_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCP_CLIENT_SINK))
typedef struct _GstTCPClientSink GstTCPClientSink;
typedef struct _GstTCPClientSinkClass GstTCPClientSinkClass;
typedef enum {
GST_TCPCLIENTSINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCP_CLIENT_SINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCPCLIENTSINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2),
GST_TCP_CLIENT_SINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2),
} GstTCPClientSinkFlags;
struct _GstTCPClientSink {
@ -84,8 +84,8 @@ struct _GstTCPClientSinkClass {
GstBaseSinkClass parent_class;
};
GType gst_tcpclientsink_get_type(void);
GType gst_tcp_client_sink_get_type(void);
G_END_DECLS
#endif /* __GST_TCPCLIENTSINK_H__ */
#endif /* __GST_TCP_CLIENT_SINK_H__ */

View file

@ -56,7 +56,7 @@ GST_DEBUG_CATEGORY (tcpclientsrc_debug);
#define MAX_READ_SIZE 4 * 1024
static GstElementDetails gst_tcpclientsrc_details =
static GstElementDetails gst_tcp_client_src_details =
GST_ELEMENT_DETAILS ("TCP Client source",
"Source/Network",
"Receive data as a client over the network via TCP",
@ -77,39 +77,39 @@ enum
};
GST_BOILERPLATE (GstTCPClientSrc, gst_tcpclientsrc, GstPushSrc,
GST_BOILERPLATE (GstTCPClientSrc, gst_tcp_client_src, GstPushSrc,
GST_TYPE_PUSH_SRC);
static void gst_tcpclientsrc_finalize (GObject * gobject);
static void gst_tcp_client_src_finalize (GObject * gobject);
static GstCaps *gst_tcpclientsrc_getcaps (GstBaseSrc * psrc);
static GstCaps *gst_tcp_client_src_getcaps (GstBaseSrc * psrc);
static GstFlowReturn gst_tcpclientsrc_create (GstPushSrc * psrc,
static GstFlowReturn gst_tcp_client_src_create (GstPushSrc * psrc,
GstBuffer ** outbuf);
static gboolean gst_tcpclientsrc_stop (GstBaseSrc * bsrc);
static gboolean gst_tcpclientsrc_start (GstBaseSrc * bsrc);
static gboolean gst_tcpclientsrc_unlock (GstBaseSrc * bsrc);
static gboolean gst_tcp_client_src_stop (GstBaseSrc * bsrc);
static gboolean gst_tcp_client_src_start (GstBaseSrc * bsrc);
static gboolean gst_tcp_client_src_unlock (GstBaseSrc * bsrc);
static void gst_tcpclientsrc_set_property (GObject * object, guint prop_id,
static void gst_tcp_client_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tcpclientsrc_get_property (GObject * object, guint prop_id,
static void gst_tcp_client_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
gst_tcpclientsrc_base_init (gpointer g_class)
gst_tcp_client_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
gst_element_class_set_details (element_class, &gst_tcpclientsrc_details);
gst_element_class_set_details (element_class, &gst_tcp_client_src_details);
}
static void
gst_tcpclientsrc_class_init (GstTCPClientSrcClass * klass)
gst_tcp_client_src_class_init (GstTCPClientSrcClass * klass)
{
GObjectClass *gobject_class;
GstBaseSrcClass *gstbasesrc_class;
@ -119,9 +119,9 @@ gst_tcpclientsrc_class_init (GstTCPClientSrcClass * klass)
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstpush_src_class = (GstPushSrcClass *) klass;
gobject_class->set_property = gst_tcpclientsrc_set_property;
gobject_class->get_property = gst_tcpclientsrc_get_property;
gobject_class->finalize = gst_tcpclientsrc_finalize;
gobject_class->set_property = gst_tcp_client_src_set_property;
gobject_class->get_property = gst_tcp_client_src_get_property;
gobject_class->finalize = gst_tcp_client_src_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HOST,
g_param_spec_string ("host", "Host",
@ -134,19 +134,19 @@ gst_tcpclientsrc_class_init (GstTCPClientSrcClass * klass)
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE, G_PARAM_READWRITE));
gstbasesrc_class->get_caps = gst_tcpclientsrc_getcaps;
gstbasesrc_class->start = gst_tcpclientsrc_start;
gstbasesrc_class->stop = gst_tcpclientsrc_stop;
gstbasesrc_class->unlock = gst_tcpclientsrc_unlock;
gstbasesrc_class->get_caps = gst_tcp_client_src_getcaps;
gstbasesrc_class->start = gst_tcp_client_src_start;
gstbasesrc_class->stop = gst_tcp_client_src_stop;
gstbasesrc_class->unlock = gst_tcp_client_src_unlock;
gstpush_src_class->create = gst_tcpclientsrc_create;
gstpush_src_class->create = gst_tcp_client_src_create;
GST_DEBUG_CATEGORY_INIT (tcpclientsrc_debug, "tcpclientsrc", 0,
"TCP Client Source");
}
static void
gst_tcpclientsrc_init (GstTCPClientSrc * this, GstTCPClientSrcClass * g_class)
gst_tcp_client_src_init (GstTCPClientSrc * this, GstTCPClientSrcClass * g_class)
{
this->port = TCP_DEFAULT_PORT;
this->host = g_strdup (TCP_DEFAULT_HOST);
@ -159,26 +159,26 @@ gst_tcpclientsrc_init (GstTCPClientSrc * this, GstTCPClientSrcClass * g_class)
gst_base_src_set_live (GST_BASE_SRC (this), TRUE);
GST_OBJECT_FLAG_UNSET (this, GST_TCPCLIENTSRC_OPEN);
GST_OBJECT_FLAG_UNSET (this, GST_TCP_CLIENT_SRC_OPEN);
}
static void
gst_tcpclientsrc_finalize (GObject * gobject)
gst_tcp_client_src_finalize (GObject * gobject)
{
GstTCPClientSrc *this = GST_TCPCLIENTSRC (gobject);
GstTCPClientSrc *this = GST_TCP_CLIENT_SRC (gobject);
g_free (this->host);
}
static GstCaps *
gst_tcpclientsrc_getcaps (GstBaseSrc * bsrc)
gst_tcp_client_src_getcaps (GstBaseSrc * bsrc)
{
GstTCPClientSrc *src;
GstCaps *caps = NULL;
src = GST_TCPCLIENTSRC (bsrc);
src = GST_TCP_CLIENT_SRC (bsrc);
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCPCLIENTSRC_OPEN))
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCP_CLIENT_SRC_OPEN))
caps = gst_caps_new_any ();
else if (src->caps)
caps = gst_caps_copy (src->caps);
@ -190,14 +190,14 @@ gst_tcpclientsrc_getcaps (GstBaseSrc * bsrc)
}
static GstFlowReturn
gst_tcpclientsrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
gst_tcp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
GstTCPClientSrc *src;
GstFlowReturn ret = GST_FLOW_OK;
src = GST_TCPCLIENTSRC (psrc);
src = GST_TCP_CLIENT_SRC (psrc);
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCPCLIENTSRC_OPEN))
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCP_CLIENT_SRC_OPEN))
goto wrong_state;
GST_LOG_OBJECT (src, "asked for a buffer");
@ -263,10 +263,10 @@ no_caps:
}
static void
gst_tcpclientsrc_set_property (GObject * object, guint prop_id,
gst_tcp_client_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTCPClientSrc *tcpclientsrc = GST_TCPCLIENTSRC (object);
GstTCPClientSrc *tcpclientsrc = GST_TCP_CLIENT_SRC (object);
switch (prop_id) {
case PROP_HOST:
@ -291,10 +291,10 @@ gst_tcpclientsrc_set_property (GObject * object, guint prop_id,
}
static void
gst_tcpclientsrc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
gst_tcp_client_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstTCPClientSrc *tcpclientsrc = GST_TCPCLIENTSRC (object);
GstTCPClientSrc *tcpclientsrc = GST_TCP_CLIENT_SRC (object);
switch (prop_id) {
case PROP_HOST:
@ -315,11 +315,11 @@ gst_tcpclientsrc_get_property (GObject * object, guint prop_id, GValue * value,
/* create a socket for connecting to remote server */
static gboolean
gst_tcpclientsrc_start (GstBaseSrc * bsrc)
gst_tcp_client_src_start (GstBaseSrc * bsrc)
{
int ret;
gchar *ip;
GstTCPClientSrc *src = GST_TCPCLIENTSRC (bsrc);
GstTCPClientSrc *src = GST_TCP_CLIENT_SRC (bsrc);
/* create the control sockets before anything */
if (socketpair (PF_UNIX, SOCK_STREAM, 0, CONTROL_SOCKETS (src)) < 0)
@ -337,7 +337,7 @@ gst_tcpclientsrc_start (GstBaseSrc * bsrc)
GST_DEBUG_OBJECT (src, "opened receiving client socket with fd %d",
src->sock_fd);
GST_OBJECT_FLAG_SET (src, GST_TCPCLIENTSRC_OPEN);
GST_OBJECT_FLAG_SET (src, GST_TCP_CLIENT_SRC_OPEN);
/* look up name if we need to */
if (!(ip = gst_tcp_host_to_ip (GST_ELEMENT (src), src->host)))
@ -357,7 +357,7 @@ gst_tcpclientsrc_start (GstBaseSrc * bsrc)
sizeof (src->server_sin));
if (ret) {
gst_tcpclientsrc_stop (GST_BASE_SRC (src));
gst_tcp_client_src_stop (GST_BASE_SRC (src));
switch (errno) {
case ECONNREFUSED:
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
@ -388,7 +388,7 @@ no_socket:
}
name_resolv:
{
gst_tcpclientsrc_stop (GST_BASE_SRC (src));
gst_tcp_client_src_stop (GST_BASE_SRC (src));
return FALSE;
}
}
@ -397,11 +397,11 @@ name_resolv:
* unset OPEN flag
* used both to recover from errors and go to NULL state */
static gboolean
gst_tcpclientsrc_stop (GstBaseSrc * bsrc)
gst_tcp_client_src_stop (GstBaseSrc * bsrc)
{
GstTCPClientSrc *src;
src = GST_TCPCLIENTSRC (bsrc);
src = GST_TCP_CLIENT_SRC (bsrc);
GST_DEBUG_OBJECT (src, "closing socket");
if (src->sock_fd != -1) {
@ -413,7 +413,7 @@ gst_tcpclientsrc_stop (GstBaseSrc * bsrc)
gst_caps_unref (src->caps);
src->caps = NULL;
}
GST_OBJECT_FLAG_UNSET (src, GST_TCPCLIENTSRC_OPEN);
GST_OBJECT_FLAG_UNSET (src, GST_TCP_CLIENT_SRC_OPEN);
close (READ_SOCKET (src));
close (WRITE_SOCKET (src));
@ -425,9 +425,9 @@ gst_tcpclientsrc_stop (GstBaseSrc * bsrc)
/* will be called only between calls to start() and stop() */
static gboolean
gst_tcpclientsrc_unlock (GstBaseSrc * bsrc)
gst_tcp_client_src_unlock (GstBaseSrc * bsrc)
{
GstTCPClientSrc *src = GST_TCPCLIENTSRC (bsrc);
GstTCPClientSrc *src = GST_TCP_CLIENT_SRC (bsrc);
SEND_COMMAND (src, CONTROL_STOP);

View file

@ -19,8 +19,8 @@
*/
#ifndef __GST_TCPCLIENTSRC_H__
#define __GST_TCPCLIENTSRC_H__
#ifndef __GST_TCP_CLIENT_SRC_H__
#define __GST_TCP_CLIENT_SRC_H__
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
@ -35,24 +35,24 @@ G_BEGIN_DECLS
#include "gsttcp.h"
#define GST_TYPE_TCPCLIENTSRC \
(gst_tcpclientsrc_get_type())
#define GST_TCPCLIENTSRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCPCLIENTSRC,GstTCPClientSrc))
#define GST_TCPCLIENTSRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCPCLIENTSRC,GstTCPClientSrc))
#define GST_IS_TCPCLIENTSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCPCLIENTSRC))
#define GST_IS_TCPCLIENTSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPCLIENTSRC))
#define GST_TYPE_TCP_CLIENT_SRC \
(gst_tcp_client_src_get_type())
#define GST_TCP_CLIENT_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCP_CLIENT_SRC,GstTCPClientSrc))
#define GST_TCP_CLIENT_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCP_CLIENT_SRC,GstTCPClientSrc))
#define GST_IS_TCP_CLIENT_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCP_CLIENT_SRC))
#define GST_IS_TCP_CLIENT_SRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCP_CLIENT_SRC))
typedef struct _GstTCPClientSrc GstTCPClientSrc;
typedef struct _GstTCPClientSrcClass GstTCPClientSrcClass;
typedef enum {
GST_TCPCLIENTSRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCP_CLIENT_SRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCPCLIENTSRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
GST_TCP_CLIENT_SRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
} GstTCPClientSrcFlags;
struct _GstTCPClientSrc {
@ -76,8 +76,8 @@ struct _GstTCPClientSrcClass {
GstPushSrcClass parent_class;
};
GType gst_tcpclientsrc_get_type (void);
GType gst_tcp_client_src_get_type (void);
G_END_DECLS
#endif /* __GST_TCPCLIENTSRC_H__ */
#endif /* __GST_TCP_CLIENT_SRC_H__ */

View file

@ -36,19 +36,19 @@ plugin_init (GstPlugin * plugin)
gst_dp_init ();
if (!gst_element_register (plugin, "tcpclientsink", GST_RANK_NONE,
GST_TYPE_TCPCLIENTSINK))
GST_TYPE_TCP_CLIENT_SINK))
return FALSE;
if (!gst_element_register (plugin, "tcpclientsrc", GST_RANK_NONE,
GST_TYPE_TCPCLIENTSRC))
GST_TYPE_TCP_CLIENT_SRC))
return FALSE;
if (!gst_element_register (plugin, "tcpserversink", GST_RANK_NONE,
GST_TYPE_TCPSERVERSINK))
GST_TYPE_TCP_SERVER_SINK))
return FALSE;
if (!gst_element_register (plugin, "tcpserversrc", GST_RANK_NONE,
GST_TYPE_TCPSERVERSRC))
GST_TYPE_TCP_SERVER_SRC))
return FALSE;
if (!gst_element_register (plugin, "multifdsink", GST_RANK_NONE,
GST_TYPE_MULTIFDSINK))
GST_TYPE_MULTI_FD_SINK))
return FALSE;
GST_DEBUG_CATEGORY_INIT (tcp_debug, "tcp", 0, "TCP calls");

View file

@ -43,7 +43,7 @@
#define TCP_BACKLOG 5
/* elementfactory information */
static GstElementDetails gst_tcpserversink_details =
static GstElementDetails gst_tcp_server_sink_details =
GST_ELEMENT_DETAILS ("TCP Server sink",
"Sink/Network",
"Send data as a server over the network via TCP",
@ -59,34 +59,34 @@ enum
ARG_PORT,
};
static void gst_tcpserversink_finalize (GObject * gobject);
static void gst_tcp_server_sink_finalize (GObject * gobject);
static gboolean gst_tcpserversink_handle_wait (GstMultiFdSink * sink,
static gboolean gst_tcp_server_sink_handle_wait (GstMultiFdSink * sink,
GstFDSet * set);
static gboolean gst_tcpserversink_init_send (GstMultiFdSink * this);
static gboolean gst_tcpserversink_close (GstMultiFdSink * this);
static void gst_tcpserversink_removed (GstMultiFdSink * sink, int fd);
static gboolean gst_tcp_server_sink_init_send (GstMultiFdSink * this);
static gboolean gst_tcp_server_sink_close (GstMultiFdSink * this);
static void gst_tcp_server_sink_removed (GstMultiFdSink * sink, int fd);
static void gst_tcpserversink_set_property (GObject * object, guint prop_id,
static void gst_tcp_server_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tcpserversink_get_property (GObject * object, guint prop_id,
static void gst_tcp_server_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
GST_BOILERPLATE (GstTCPServerSink, gst_tcpserversink, GstMultiFdSink,
GST_TYPE_MULTIFDSINK);
GST_BOILERPLATE (GstTCPServerSink, gst_tcp_server_sink, GstMultiFdSink,
GST_TYPE_MULTI_FD_SINK);
static void
gst_tcpserversink_base_init (gpointer g_class)
gst_tcp_server_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_tcpserversink_details);
gst_element_class_set_details (element_class, &gst_tcp_server_sink_details);
}
static void
gst_tcpserversink_class_init (GstTCPServerSinkClass * klass)
gst_tcp_server_sink_class_init (GstTCPServerSinkClass * klass)
{
GObjectClass *gobject_class;
GstMultiFdSinkClass *gstmultifdsink_class;
@ -94,9 +94,9 @@ gst_tcpserversink_class_init (GstTCPServerSinkClass * klass)
gobject_class = (GObjectClass *) klass;
gstmultifdsink_class = (GstMultiFdSinkClass *) klass;
gobject_class->set_property = gst_tcpserversink_set_property;
gobject_class->get_property = gst_tcpserversink_get_property;
gobject_class->finalize = gst_tcpserversink_finalize;
gobject_class->set_property = gst_tcp_server_sink_set_property;
gobject_class->get_property = gst_tcp_server_sink_get_property;
gobject_class->finalize = gst_tcp_server_sink_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST,
g_param_spec_string ("host", "host", "The host/IP to send the packets to",
@ -105,16 +105,17 @@ gst_tcpserversink_class_init (GstTCPServerSinkClass * klass)
g_param_spec_int ("port", "port", "The port to send the packets to",
0, TCP_HIGHEST_PORT, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
gstmultifdsink_class->init = gst_tcpserversink_init_send;
gstmultifdsink_class->wait = gst_tcpserversink_handle_wait;
gstmultifdsink_class->close = gst_tcpserversink_close;
gstmultifdsink_class->removed = gst_tcpserversink_removed;
gstmultifdsink_class->init = gst_tcp_server_sink_init_send;
gstmultifdsink_class->wait = gst_tcp_server_sink_handle_wait;
gstmultifdsink_class->close = gst_tcp_server_sink_close;
gstmultifdsink_class->removed = gst_tcp_server_sink_removed;
GST_DEBUG_CATEGORY_INIT (tcpserversink_debug, "tcpserversink", 0, "TCP sink");
}
static void
gst_tcpserversink_init (GstTCPServerSink * this, GstTCPServerSinkClass * klass)
gst_tcp_server_sink_init (GstTCPServerSink * this,
GstTCPServerSinkClass * klass)
{
this->server_port = TCP_DEFAULT_PORT;
/* should support as minimum 576 for IPV4 and 1500 for IPV6 */
@ -125,9 +126,9 @@ gst_tcpserversink_init (GstTCPServerSink * this, GstTCPServerSinkClass * klass)
}
static void
gst_tcpserversink_finalize (GObject * gobject)
gst_tcp_server_sink_finalize (GObject * gobject)
{
GstTCPServerSink *this = GST_TCPSERVERSINK (gobject);
GstTCPServerSink *this = GST_TCP_SERVER_SINK (gobject);
g_free (this->host);
}
@ -135,7 +136,7 @@ gst_tcpserversink_finalize (GObject * gobject)
/* handle a read request on the server,
* which indicates a new client connection */
static gboolean
gst_tcpserversink_handle_server_read (GstTCPServerSink * sink)
gst_tcp_server_sink_handle_server_read (GstTCPServerSink * sink)
{
/* new client */
int client_sock_fd;
@ -157,7 +158,7 @@ gst_tcpserversink_handle_server_read (GstTCPServerSink * sink)
return FALSE;
}
gst_multifdsink_add (GST_MULTIFDSINK (sink), client_sock_fd);
gst_multi_fd_sink_add (GST_MULTI_FD_SINK (sink), client_sock_fd);
GST_DEBUG_OBJECT (sink, "added new client ip %s with fd %d",
inet_ntoa (client_address.sin_addr), client_sock_fd);
@ -166,9 +167,9 @@ gst_tcpserversink_handle_server_read (GstTCPServerSink * sink)
}
static void
gst_tcpserversink_removed (GstMultiFdSink * sink, int fd)
gst_tcp_server_sink_removed (GstMultiFdSink * sink, int fd)
{
GstTCPServerSink *this = GST_TCPSERVERSINK (sink);
GstTCPServerSink *this = GST_TCP_SERVER_SINK (sink);
GST_LOG_OBJECT (this, "closing fd %d", fd);
if (close (fd) < 0) {
@ -178,13 +179,13 @@ gst_tcpserversink_removed (GstMultiFdSink * sink, int fd)
}
static gboolean
gst_tcpserversink_handle_wait (GstMultiFdSink * sink, GstFDSet * set)
gst_tcp_server_sink_handle_wait (GstMultiFdSink * sink, GstFDSet * set)
{
GstTCPServerSink *this = GST_TCPSERVERSINK (sink);
GstTCPServerSink *this = GST_TCP_SERVER_SINK (sink);
if (gst_fdset_fd_can_read (set, &this->server_sock)) {
/* handle new client connection on server socket */
if (!gst_tcpserversink_handle_server_read (this)) {
if (!gst_tcp_server_sink_handle_server_read (this)) {
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
("client connection failed: %s", g_strerror (errno)));
return FALSE;
@ -194,13 +195,13 @@ gst_tcpserversink_handle_wait (GstMultiFdSink * sink, GstFDSet * set)
}
static void
gst_tcpserversink_set_property (GObject * object, guint prop_id,
gst_tcp_server_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTCPServerSink *sink;
g_return_if_fail (GST_IS_TCPSERVERSINK (object));
sink = GST_TCPSERVERSINK (object);
g_return_if_fail (GST_IS_TCP_SERVER_SINK (object));
sink = GST_TCP_SERVER_SINK (object);
switch (prop_id) {
case ARG_HOST:
@ -222,13 +223,13 @@ gst_tcpserversink_set_property (GObject * object, guint prop_id,
}
static void
gst_tcpserversink_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
gst_tcp_server_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstTCPServerSink *sink;
g_return_if_fail (GST_IS_TCPSERVERSINK (object));
sink = GST_TCPSERVERSINK (object);
g_return_if_fail (GST_IS_TCP_SERVER_SINK (object));
sink = GST_TCP_SERVER_SINK (object);
switch (prop_id) {
case ARG_HOST:
@ -247,10 +248,10 @@ gst_tcpserversink_get_property (GObject * object, guint prop_id, GValue * value,
/* create a socket for sending to remote machine */
static gboolean
gst_tcpserversink_init_send (GstMultiFdSink * parent)
gst_tcp_server_sink_init_send (GstMultiFdSink * parent)
{
int ret;
GstTCPServerSink *this = GST_TCPSERVERSINK (parent);
GstTCPServerSink *this = GST_TCP_SERVER_SINK (parent);
/* create sending server socket */
if ((this->server_sock.fd = socket (AF_INET, SOCK_STREAM, 0)) == -1) {
@ -324,9 +325,9 @@ gst_tcpserversink_init_send (GstMultiFdSink * parent)
}
static gboolean
gst_tcpserversink_close (GstMultiFdSink * parent)
gst_tcp_server_sink_close (GstMultiFdSink * parent)
{
GstTCPServerSink *this = GST_TCPSERVERSINK (parent);
GstTCPServerSink *this = GST_TCP_SERVER_SINK (parent);
if (this->server_sock.fd != -1) {
gst_fdset_remove_fd (parent->fdset, &this->server_sock);

View file

@ -19,8 +19,8 @@
*/
#ifndef __GST_TCPSERVERSINK_H__
#define __GST_TCPSERVERSINK_H__
#ifndef __GST_TCP_SERVER_SINK_H__
#define __GST_TCP_SERVER_SINK_H__
#include <gst/gst.h>
@ -42,24 +42,24 @@ G_BEGIN_DECLS
#include <arpa/inet.h>
#include "gstmultifdsink.h"
#define GST_TYPE_TCPSERVERSINK \
(gst_tcpserversink_get_type())
#define GST_TCPSERVERSINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCPSERVERSINK,GstTCPServerSink))
#define GST_TCPSERVERSINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCPSERVERSINK,GstTCPServerSink))
#define GST_IS_TCPSERVERSINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCPSERVERSINK))
#define GST_IS_TCPSERVERSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPSERVERSINK))
#define GST_TYPE_TCP_SERVER_SINK \
(gst_tcp_server_sink_get_type())
#define GST_TCP_SERVER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCP_SERVER_SINK,GstTCPServerSink))
#define GST_TCP_SERVER_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCP_SERVER_SINK,GstTCPServerSink))
#define GST_IS_TCP_SERVER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCP_SERVER_SINK))
#define GST_IS_TCP_SERVER_SINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCP_SERVER_SINK))
typedef struct _GstTCPServerSink GstTCPServerSink;
typedef struct _GstTCPServerSinkClass GstTCPServerSinkClass;
typedef enum {
GST_TCPSERVERSINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCP_SERVER_SINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCPSERVERSINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
GST_TCP_SERVER_SINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
} GstTCPServerSinkFlags;
struct _GstTCPServerSink {
@ -78,8 +78,8 @@ struct _GstTCPServerSinkClass {
GstMultiFdSinkClass parent_class;
};
GType gst_tcpserversink_get_type (void);
GType gst_tcp_server_sink_get_type (void);
G_END_DECLS
#endif /* __GST_TCPSERVERSINK_H__ */
#endif /* __GST_TCP_SERVER_SINK_H__ */

View file

@ -56,7 +56,7 @@ GST_DEBUG_CATEGORY (tcpserversrc_debug);
#define TCP_BACKLOG 1 /* client connection queue */
static GstElementDetails gst_tcpserversrc_details =
static GstElementDetails gst_tcp_server_src_details =
GST_ELEMENT_DETAILS ("TCP Server source",
"Source/Network",
"Receive data as a server over the network via TCP",
@ -77,37 +77,37 @@ enum
};
GST_BOILERPLATE (GstTCPServerSrc, gst_tcpserversrc, GstPushSrc,
GST_BOILERPLATE (GstTCPServerSrc, gst_tcp_server_src, GstPushSrc,
GST_TYPE_PUSH_SRC);
static void gst_tcpserversrc_finalize (GObject * gobject);
static void gst_tcp_server_src_finalize (GObject * gobject);
static gboolean gst_tcpserversrc_start (GstBaseSrc * bsrc);
static gboolean gst_tcpserversrc_stop (GstBaseSrc * bsrc);
static gboolean gst_tcpserversrc_unlock (GstBaseSrc * bsrc);
static GstFlowReturn gst_tcpserversrc_create (GstPushSrc * psrc,
static gboolean gst_tcp_server_src_start (GstBaseSrc * bsrc);
static gboolean gst_tcp_server_src_stop (GstBaseSrc * bsrc);
static gboolean gst_tcp_server_src_unlock (GstBaseSrc * bsrc);
static GstFlowReturn gst_tcp_server_src_create (GstPushSrc * psrc,
GstBuffer ** buf);
static void gst_tcpserversrc_set_property (GObject * object, guint prop_id,
static void gst_tcp_server_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_tcpserversrc_get_property (GObject * object, guint prop_id,
static void gst_tcp_server_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
gst_tcpserversrc_base_init (gpointer g_class)
gst_tcp_server_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
gst_element_class_set_details (element_class, &gst_tcpserversrc_details);
gst_element_class_set_details (element_class, &gst_tcp_server_src_details);
}
static void
gst_tcpserversrc_class_init (GstTCPServerSrcClass * klass)
gst_tcp_server_src_class_init (GstTCPServerSrcClass * klass)
{
GObjectClass *gobject_class;
GstBaseSrcClass *gstbasesrc_class;
@ -117,9 +117,9 @@ gst_tcpserversrc_class_init (GstTCPServerSrcClass * klass)
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstpush_src_class = (GstPushSrcClass *) klass;
gobject_class->set_property = gst_tcpserversrc_set_property;
gobject_class->get_property = gst_tcpserversrc_get_property;
gobject_class->finalize = gst_tcpserversrc_finalize;
gobject_class->set_property = gst_tcp_server_src_set_property;
gobject_class->get_property = gst_tcp_server_src_get_property;
gobject_class->finalize = gst_tcp_server_src_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_HOST,
g_param_spec_string ("host", "Host", "The hostname to listen as",
@ -131,18 +131,18 @@ gst_tcpserversrc_class_init (GstTCPServerSrcClass * klass)
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE, G_PARAM_READWRITE));
gstbasesrc_class->start = gst_tcpserversrc_start;
gstbasesrc_class->stop = gst_tcpserversrc_stop;
gstbasesrc_class->unlock = gst_tcpserversrc_unlock;
gstbasesrc_class->start = gst_tcp_server_src_start;
gstbasesrc_class->stop = gst_tcp_server_src_stop;
gstbasesrc_class->unlock = gst_tcp_server_src_unlock;
gstpush_src_class->create = gst_tcpserversrc_create;
gstpush_src_class->create = gst_tcp_server_src_create;
GST_DEBUG_CATEGORY_INIT (tcpserversrc_debug, "tcpserversrc", 0,
"TCP Server Source");
}
static void
gst_tcpserversrc_init (GstTCPServerSrc * src, GstTCPServerSrcClass * g_class)
gst_tcp_server_src_init (GstTCPServerSrc * src, GstTCPServerSrcClass * g_class)
{
src->server_port = TCP_DEFAULT_PORT;
src->host = g_strdup (TCP_DEFAULT_HOST);
@ -153,28 +153,28 @@ gst_tcpserversrc_init (GstTCPServerSrc * src, GstTCPServerSrcClass * g_class)
READ_SOCKET (src) = -1;
WRITE_SOCKET (src) = -1;
GST_OBJECT_FLAG_UNSET (src, GST_TCPSERVERSRC_OPEN);
GST_OBJECT_FLAG_UNSET (src, GST_TCP_SERVER_SRC_OPEN);
}
static void
gst_tcpserversrc_finalize (GObject * gobject)
gst_tcp_server_src_finalize (GObject * gobject)
{
GstTCPServerSrc *src = GST_TCPSERVERSRC (gobject);
GstTCPServerSrc *src = GST_TCP_SERVER_SRC (gobject);
g_free (src->host);
}
static GstFlowReturn
gst_tcpserversrc_create (GstPushSrc * psrc, GstBuffer ** outbuf)
gst_tcp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
GstTCPServerSrc *src;
GstFlowReturn ret = GST_FLOW_OK;
fd_set testfds;
int maxfdp1;
src = GST_TCPSERVERSRC (psrc);
src = GST_TCP_SERVER_SRC (psrc);
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCPSERVERSRC_OPEN))
if (!GST_OBJECT_FLAG_IS_SET (src, GST_TCP_SERVER_SRC_OPEN))
goto wrong_state;
restart:
@ -309,10 +309,10 @@ gdp_caps_read_error:
}
static void
gst_tcpserversrc_set_property (GObject * object, guint prop_id,
gst_tcp_server_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTCPServerSrc *tcpserversrc = GST_TCPSERVERSRC (object);
GstTCPServerSrc *tcpserversrc = GST_TCP_SERVER_SRC (object);
switch (prop_id) {
case PROP_HOST:
@ -337,10 +337,10 @@ gst_tcpserversrc_set_property (GObject * object, guint prop_id,
}
static void
gst_tcpserversrc_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
gst_tcp_server_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstTCPServerSrc *tcpserversrc = GST_TCPSERVERSRC (object);
GstTCPServerSrc *tcpserversrc = GST_TCP_SERVER_SRC (object);
switch (prop_id) {
case PROP_HOST:
@ -361,10 +361,10 @@ gst_tcpserversrc_get_property (GObject * object, guint prop_id, GValue * value,
/* set up server */
static gboolean
gst_tcpserversrc_start (GstBaseSrc * bsrc)
gst_tcp_server_src_start (GstBaseSrc * bsrc)
{
int ret;
GstTCPServerSrc *src = GST_TCPSERVERSRC (bsrc);
GstTCPServerSrc *src = GST_TCP_SERVER_SRC (bsrc);
/* create the control sockets before anything */
if (socketpair (PF_UNIX, SOCK_STREAM, 0, CONTROL_SOCKETS (src)) < 0)
@ -417,7 +417,7 @@ gst_tcpserversrc_start (GstBaseSrc * bsrc)
GST_DEBUG_OBJECT (src, "received client");
GST_OBJECT_FLAG_SET (src, GST_TCPSERVERSRC_OPEN);
GST_OBJECT_FLAG_SET (src, GST_TCP_SERVER_SRC_OPEN);
return TRUE;
@ -465,9 +465,9 @@ listen_error:
}
static gboolean
gst_tcpserversrc_stop (GstBaseSrc * bsrc)
gst_tcp_server_src_stop (GstBaseSrc * bsrc)
{
GstTCPServerSrc *src = GST_TCPSERVERSRC (bsrc);
GstTCPServerSrc *src = GST_TCP_SERVER_SRC (bsrc);
if (src->server_sock_fd != -1) {
close (src->server_sock_fd);
@ -477,7 +477,7 @@ gst_tcpserversrc_stop (GstBaseSrc * bsrc)
close (src->client_sock_fd);
src->client_sock_fd = -1;
}
GST_OBJECT_FLAG_UNSET (src, GST_TCPSERVERSRC_OPEN);
GST_OBJECT_FLAG_UNSET (src, GST_TCP_SERVER_SRC_OPEN);
close (READ_SOCKET (src));
close (WRITE_SOCKET (src));
@ -489,9 +489,9 @@ gst_tcpserversrc_stop (GstBaseSrc * bsrc)
/* will be called only between calls to start() and stop() */
static gboolean
gst_tcpserversrc_unlock (GstBaseSrc * bsrc)
gst_tcp_server_src_unlock (GstBaseSrc * bsrc)
{
GstTCPServerSrc *src = GST_TCPSERVERSRC (bsrc);
GstTCPServerSrc *src = GST_TCP_SERVER_SRC (bsrc);
SEND_COMMAND (src, CONTROL_STOP);

View file

@ -19,8 +19,8 @@
*/
#ifndef __GST_TCPSERVERSRC_H__
#define __GST_TCPSERVERSRC_H__
#ifndef __GST_TCP_SERVER_SRC_H__
#define __GST_TCP_SERVER_SRC_H__
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
@ -38,24 +38,24 @@ G_END_DECLS
#include <fcntl.h>
#define GST_TYPE_TCPSERVERSRC \
(gst_tcpserversrc_get_type())
#define GST_TCPSERVERSRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCPSERVERSRC,GstTCPServerSrc))
#define GST_TCPSERVERSRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCPSERVERSRC,GstTCPServerSrc))
#define GST_IS_TCPSERVERSRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCPSERVERSRC))
#define GST_IS_TCPSERVERSRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCPSERVERSRC))
#define GST_TYPE_TCP_SERVER_SRC \
(gst_tcp_server_src_get_type())
#define GST_TCP_SERVER_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TCP_SERVER_SRC,GstTCPServerSrc))
#define GST_TCP_SERVER_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TCP_SERVER_SRC,GstTCPServerSrc))
#define GST_IS_TCP_SERVER_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TCP_SERVER_SRC))
#define GST_IS_TCP_SERVER_SRC_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TCP_SERVER_SRC))
typedef struct _GstTCPServerSrc GstTCPServerSrc;
typedef struct _GstTCPServerSrcClass GstTCPServerSrcClass;
typedef enum {
GST_TCPSERVERSRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCP_SERVER_SRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
GST_TCPSERVERSRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
GST_TCP_SERVER_SRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
} GstTCPServerSrcFlags;
struct _GstTCPServerSrc {
@ -82,8 +82,8 @@ struct _GstTCPServerSrcClass {
GstPushSrcClass parent_class;
};
GType gst_tcpserversrc_get_type (void);
GType gst_tcp_server_src_get_type (void);
G_BEGIN_DECLS
#endif /* __GST_TCPSERVERSRC_H__ */
#endif /* __GST_TCP_SERVER_SRC_H__ */