PROP_HANDLE_READ,
- PROP_NUM_FDS,
-
PROP_LAST
};
return fdset_mode_type;
}
-static void gst_multi_fd_sink_finalize (GObject * object);
-
static void gst_multi_fd_sink_clear_post (GstMultiHandleSink * mhsink);
static void gst_multi_fd_sink_stop_pre (GstMultiHandleSink * mhsink);
static void gst_multi_fd_sink_stop_post (GstMultiHandleSink * mhsink);
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;
/**
* GstMultiFdSink::mode
"Handle client reads and discard the data",
DEFAULT_HANDLE_READ, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_NUM_FDS,
- g_param_spec_uint ("num-fds", "Number of fds",
- "The current number of client file descriptors.",
- 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
/**
* GstMultiFdSink::add:
* @gstmultifdsink: the multifdsink element to emit this signal on
gstmultihandlesink_class->remove_client_link =
GST_DEBUG_FUNCPTR (gst_multi_fd_sink_remove_client_link);
-
klass->add = GST_DEBUG_FUNCPTR (gst_multi_fd_sink_add);
klass->add_full = GST_DEBUG_FUNCPTR (gst_multi_fd_sink_add_full);
klass->remove = GST_DEBUG_FUNCPTR (gst_multi_fd_sink_remove);
static void
gst_multi_fd_sink_init (GstMultiFdSink * this)
{
+ GstMultiHandleSink *mhsink = GST_MULTI_HANDLE_SINK (this);
+
this->mode = DEFAULT_MODE;
- this->handle_hash = g_hash_table_new (g_int_hash, g_int_equal);
+ mhsink->handle_hash = g_hash_table_new (g_int_hash, g_int_equal);
this->handle_read = DEFAULT_HANDLE_READ;
}
-static void
-gst_multi_fd_sink_finalize (GObject * object)
-{
- GstMultiFdSink *this = GST_MULTI_FD_SINK (object);
-
- g_hash_table_destroy (this->handle_hash);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
static int
gst_multi_fd_sink_client_get_fd (GstMultiHandleClient * client)
{
CLIENTS_LOCK (sink);
/* check the hash to find a duplicate fd */
- clink = g_hash_table_lookup (sink->handle_hash, &client->gfd.fd);
+ clink = g_hash_table_lookup (mhsink->handle_hash, &client->gfd.fd);
if (clink != NULL)
goto duplicate;
/* we can add the fd now */
clink = mhsink->clients = g_list_prepend (mhsink->clients, client);
- g_hash_table_insert (sink->handle_hash, &client->gfd.fd, clink);
+ g_hash_table_insert (mhsink->handle_hash, &client->gfd.fd, clink);
mhsink->clients_cookie++;
/* set the socket to non blocking */
GST_DEBUG_OBJECT (sink, "%s removing client", debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, &fd);
+ clink = g_hash_table_lookup (mhsink->handle_hash, &fd);
if (clink != NULL) {
GstTCPClient *client = (GstTCPClient *) clink->data;
GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client;
GST_DEBUG_OBJECT (sink, "%s flushing client", debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, &fd);
+ clink = g_hash_table_lookup (mhsink->handle_hash, &fd);
if (clink != NULL) {
GstTCPClient *client = (GstTCPClient *) clink->data;
GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client;
mhsinkclass->handle_debug (handle, debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, &fd);
+ clink = g_hash_table_lookup (mhsink->handle_hash, &fd);
if (clink == NULL)
goto noclient;
/* fd cannot be reused in the above signal callback so we can safely
* remove it from the hashtable here */
- if (!g_hash_table_remove (mfsink->handle_hash, &client->gfd.fd)) {
+ if (!g_hash_table_remove (sink->handle_hash, &client->gfd.fd)) {
GST_WARNING_OBJECT (sink,
"%s error removing client %p from hash", mhclient->debug, client);
}
case PROP_HANDLE_READ:
g_value_set_boolean (value, multifdsink->handle_read);
break;
- case PROP_NUM_FDS:
- g_value_set_uint (value, g_hash_table_size (multifdsink->handle_hash));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
gst_poll_free (mfsink->fdset);
mfsink->fdset = NULL;
}
- g_hash_table_foreach_remove (mfsink->handle_hash, multifdsink_hash_remove,
+ g_hash_table_foreach_remove (mhsink->handle_hash, multifdsink_hash_remove,
mfsink);
}
GstMultiHandleSink element;
/*< private >*/
- GHashTable *handle_hash; /* index on fd to client */
-
gint mode;
GstPoll *fdset;
PROP_RESEND_STREAMHEADER,
-#if 0
- PROP_NUM_SOCKETS,
-#endif
+ PROP_NUM_HANDLES,
PROP_LAST
};
DEFAULT_RESEND_STREAMHEADER,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-#if 0
- g_object_class_install_property (gobject_class, PROP_NUM_SOCKETS,
- g_param_spec_uint ("num-sockets", "Number of sockets",
- "The current number of client sockets",
+ g_object_class_install_property (gobject_class, PROP_NUM_HANDLES,
+ g_param_spec_uint ("num-handles", "Number of handles",
+ "The current number of client handles",
0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+#if 0
/**
* GstMultiHandleSink::add:
* @gstmultihandlesink: the multihandlesink element to emit this signal on
CLIENTS_LOCK_CLEAR (this);
g_array_free (this->bufqueue, TRUE);
+ g_hash_table_destroy (this->handle_hash);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
case PROP_RESEND_STREAMHEADER:
g_value_set_boolean (value, multihandlesink->resend_streamheader);
break;
-#if 0
- case PROP_NUM_SOCKETS:
+ case PROP_NUM_HANDLES:
g_value_set_uint (value,
- g_hash_table_size (multihandlesink->socket_hash));
+ g_hash_table_size (multihandlesink->handle_hash));
break;
-#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
GList *clients; /* list of clients we are serving */
guint clients_cookie; /* Cookie to detect changes to the clients list */
+ GHashTable *handle_hash; /* index of handle -> GstMultiHandleClient */
+
GMainContext *main_context;
GCancellable *cancellable;
GstStructure* (*get_stats) (GstMultiHandleSink *sink, GstMultiSinkHandle handle);
void (*remove_client_link) (GstMultiHandleSink * sink, GList * link);
+
/* vtable */
gboolean (*init) (GstMultiHandleSink *sink);
gboolean (*close) (GstMultiHandleSink *sink);
{
PROP_0,
- PROP_NUM_SOCKETS,
-
PROP_LAST
};
gobject_class->get_property = gst_multi_socket_sink_get_property;
gobject_class->finalize = gst_multi_socket_sink_finalize;
- g_object_class_install_property (gobject_class, PROP_NUM_SOCKETS,
- g_param_spec_uint ("num-sockets", "Number of sockets",
- "The current number of client sockets",
- 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
/**
* GstMultiSocketSink::add:
* @gstmultisocketsink: the multisocketsink element to emit this signal on
static void
gst_multi_socket_sink_init (GstMultiSocketSink * this)
{
- this->handle_hash = g_hash_table_new (g_direct_hash, g_int_equal);
+ GstMultiHandleSink *mhsink = GST_MULTI_HANDLE_SINK (this);
+
+ mhsink->handle_hash = g_hash_table_new (g_direct_hash, g_int_equal);
this->cancellable = g_cancellable_new ();
}
{
GstMultiSocketSink *this = GST_MULTI_SOCKET_SINK (object);
- g_hash_table_destroy (this->handle_hash);
if (this->cancellable) {
g_object_unref (this->cancellable);
this->cancellable = NULL;
CLIENTS_LOCK (sink);
/* check the hash to find a duplicate fd */
- clink = g_hash_table_lookup (sink->handle_hash, handle.socket);
+ clink = g_hash_table_lookup (mhsink->handle_hash, handle.socket);
if (clink != NULL)
goto duplicate;
/* we can add the fd now */
clink = mhsink->clients = g_list_prepend (mhsink->clients, client);
- g_hash_table_insert (sink->handle_hash, handle.socket, clink);
+ g_hash_table_insert (mhsink->handle_hash, handle.socket, clink);
mhsink->clients_cookie++;
/* set the socket to non blocking */
GST_DEBUG_OBJECT (sink, "%s removing client", debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, handle.socket);
+ clink = g_hash_table_lookup (mhsink->handle_hash, handle.socket);
if (clink != NULL) {
GstSocketClient *client = clink->data;
GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client;
GST_DEBUG_OBJECT (sink, "%s flushing client", debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, handle.socket);
+ clink = g_hash_table_lookup (mhsink->handle_hash, handle.socket);
if (clink != NULL) {
GstSocketClient *client = clink->data;
GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client;
mhsinkclass->handle_debug (handle, debug);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, handle.socket);
+ clink = g_hash_table_lookup (mhsink->handle_hash, handle.socket);
if (clink == NULL)
goto noclient;
GTimeVal now;
GstSocketClient *client = link->data;
GstMultiHandleClient *mhclient = (GstMultiHandleClient *) client;
- GstMultiSocketSink *mssink = GST_MULTI_SOCKET_SINK (sink);
GstMultiSocketSinkClass *fclass;
fclass = GST_MULTI_SOCKET_SINK_GET_CLASS (sink);
/* fd cannot be reused in the above signal callback so we can safely
* remove it from the hashtable here */
- if (!g_hash_table_remove (mssink->handle_hash, mhclient->handle.socket)) {
+ if (!g_hash_table_remove (sink->handle_hash, mhclient->handle.socket)) {
GST_WARNING_OBJECT (sink,
"%s error removing client %p from hash", mhclient->debug, client);
}
GST_MULTI_HANDLE_SINK_GET_CLASS (mhsink);
CLIENTS_LOCK (sink);
- clink = g_hash_table_lookup (sink->handle_hash, handle.socket);
+ clink = g_hash_table_lookup (mhsink->handle_hash, handle.socket);
if (clink == NULL) {
ret = FALSE;
goto done;
}
}
+// FIXME: remove ?
static void
gst_multi_socket_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
- GstMultiSocketSink *multisocketsink;
-
- multisocketsink = GST_MULTI_SOCKET_SINK (object);
-
switch (prop_id) {
- case PROP_NUM_SOCKETS:
- g_value_set_uint (value,
- g_hash_table_size (multisocketsink->handle_hash));
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
mssink->main_context = NULL;
}
- g_hash_table_foreach_remove (mssink->handle_hash, multisocketsink_hash_remove,
+ g_hash_table_foreach_remove (mhsink->handle_hash, multisocketsink_hash_remove,
mssink);
}
GstMultiHandleSink element;
/*< private >*/
- GHashTable *handle_hash; /* index on socket to client */
-
GMainContext *main_context;
GCancellable *cancellable;
#define fail_unless_num_handles(sink,num) \
G_STMT_START { \
gint handles; \
- g_object_get (sink, "num-fds", &handles, NULL); \
+ g_object_get (sink, "num-handles", &handles, NULL); \
fail_unless (handles == num, \
"sink has %d handles instead of expected %d", handles, num); \
} G_STMT_END;
#define fail_unless_num_handles(sink,num) \
G_STMT_START { \
gint handles; \
- g_object_get (sink, "num-sockets", &handles, NULL); \
+ g_object_get (sink, "num-handles", &handles, NULL); \
fail_unless (handles == num, \
"sink has %d handles instead of expected %d", handles, num); \
} G_STMT_END;