+2004-06-08 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * gst/tcp/Makefile.am:
+ * gst/tcp/gsttcpclientsink.c: (gst_tcpclientsink_get_type),
+ (gst_tcpclientsink_class_init), (gst_tcpclientsink_init),
+ (gst_tcpclientsink_set_property), (gst_tcpclientsink_get_property):
+ * gst/tcp/gsttcpclientsrc.c: (gst_tcpclientsrc_class_init),
+ (gst_tcpclientsrc_init), (gst_tcpclientsrc_set_property),
+ (gst_tcpclientsrc_get_property):
+ * gst/tcp/gsttcpserversink.c: (gst_tcpserversink_class_init),
+ (gst_tcpserversink_init), (gst_tcpserversink_handle_server_read),
+ (gst_tcpserversink_handle_client_read),
+ (gst_tcpserversink_handle_client_write),
+ (gst_tcpserversink_set_property), (gst_tcpserversink_get_property):
+ * gst/tcp/gsttcpserversink.h:
+ add signals client-added and client-removed
+ * gst/tcp/gsttcpserversrc.c: (gst_tcpserversrc_class_init),
+ (gst_tcpserversrc_init), (gst_tcpserversrc_set_property),
+ (gst_tcpserversrc_get_property):
+ uniformized, change default protocol to NONE
+ * gst/tcp/gsttcp-marshal.list: added
2004-06-07 Benjamin Otte <otte@gnome.org>
* ext/alsa/gstalsasink.c: (gst_alsa_sink_check_event):
# variables used for enum/marshal generation
glib_enum_headers = gsttcp.h
-glib_enum_define = GST_TCP_PROTOCOL
-glib_enum_prefix = gst_tcp_protocol
+glib_enum_define = GST_TCP
+glib_enum_prefix = gst_tcp
include $(top_srcdir)/common/glib-gen.mak
-built_sources = gsttcp-enumtypes.c
-built_headers = gsttcp-enumtypes.h
+built_sources = gsttcp-enumtypes.c gsttcp-marshal.c
+built_headers = gsttcp-enumtypes.h gsttcp-marshal.h
BUILT_SOURCES = $(built_sources) $(built_headers)
--- /dev/null
+VOID:STRING,UINT
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PROTOCOL,
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
- GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_GDP,
+ GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_NONE,
G_PARAM_READWRITE));
gobject_class->set_property = gst_tcpclientsink_set_property;
gobject_class->get_property = gst_tcpclientsink_get_property;
/* this->mtu = 1500; */
this->sock_fd = -1;
- this->protocol = GST_TCP_PROTOCOL_TYPE_GDP;
+ this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
GST_FLAG_UNSET (this, GST_TCPCLIENTSINK_OPEN);
this->clock = NULL;
switch (prop_id) {
case ARG_HOST:
- if (tcpclientsink->host != NULL)
- g_free (tcpclientsink->host);
- if (g_value_get_string (value) == NULL)
- tcpclientsink->host = NULL;
- else
- tcpclientsink->host = g_strdup (g_value_get_string (value));
+ g_free (tcpclientsink->host);
+ tcpclientsink->host = g_strdup (g_value_get_string (value));
break;
case ARG_PORT:
tcpclientsink->port = g_value_get_int (value);
case ARG_PROTOCOL:
tcpclientsink->protocol = g_value_get_enum (value);
break;
+
default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
case ARG_PROTOCOL:
g_value_set_enum (value, tcpclientsink->protocol);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
enum
{
ARG_0,
- ARG_PORT,
ARG_HOST,
+ ARG_PORT,
ARG_PROTOCOL
};
32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PROTOCOL,
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
- GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_GDP,
+ GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_NONE,
G_PARAM_READWRITE));
gobject_class->set_property = gst_tcpclientsrc_set_property;
this->host = g_strdup (TCP_DEFAULT_HOST);
this->clock = NULL;
this->sock_fd = -1;
- this->protocol = GST_TCP_PROTOCOL_TYPE_GDP;
+ this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
this->curoffset = 0;
GST_FLAG_UNSET (this, GST_TCPCLIENTSRC_OPEN);
tcpclientsrc = GST_TCPCLIENTSRC (object);
switch (prop_id) {
- case ARG_PORT:
- tcpclientsrc->port = g_value_get_int (value);
- break;
case ARG_HOST:
- /* FIXME: create a setter and handle changes correctly */
g_free (tcpclientsrc->host);
tcpclientsrc->host = g_strdup (g_value_get_string (value));
break;
+ case ARG_PORT:
+ tcpclientsrc->port = g_value_get_int (value);
+ break;
case ARG_PROTOCOL:
tcpclientsrc->protocol = g_value_get_enum (value);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
tcpclientsrc = GST_TCPCLIENTSRC (object);
switch (prop_id) {
- case ARG_PORT:
- g_value_set_int (value, tcpclientsrc->port);
- break;
case ARG_HOST:
g_value_set_string (value, tcpclientsrc->host);
break;
+ case ARG_PORT:
+ g_value_set_int (value, tcpclientsrc->port);
+ break;
case ARG_PROTOCOL:
g_value_set_enum (value, tcpclientsrc->protocol);
break;
#endif
#include "gsttcpserversink.h"
+#include "gsttcp-marshal.h"
#define TCP_DEFAULT_HOST "127.0.0.1"
#define TCP_DEFAULT_PORT 4953
"Send data as a server over the network via TCP",
"Thomas Vander Stichele <thomas at apestaart dot org>");
+GST_DEBUG_CATEGORY (tcpserversink_debug);
+#define GST_CAT_DEFAULT (tcpserversink_debug)
+
/* TCPServerSink signals and args */
enum
{
- FRAME_ENCODED,
- /* FILL ME */
+ SIGNAL_CLIENT_ADDED,
+ SIGNAL_CLIENT_REMOVED,
LAST_SIGNAL
};
-GST_DEBUG_CATEGORY (tcpserversink_debug);
-#define GST_CAT_DEFAULT (tcpserversink_debug)
-
enum
{
ARG_0,
ARG_HOST,
- ARG_PORT
- /* FILL ME */
+ ARG_PORT,
+ ARG_PROTOCOL
};
static void gst_tcpserversink_base_init (gpointer g_class);
static GstElementClass *parent_class = NULL;
-/*static guint gst_tcpserversink_signals[LAST_SIGNAL] = { 0 }; */
+static guint gst_tcpserversink_signals[LAST_SIGNAL] = { 0 };
GType
gst_tcpserversink_get_type (void)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
g_param_spec_int ("port", "port", "The port to send the packets to",
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_PROTOCOL,
+ g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
+ GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_NONE,
+ G_PARAM_READWRITE));
+
+ gst_tcpserversink_signals[SIGNAL_CLIENT_ADDED] =
+ g_signal_new ("client-added", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTCPServerSinkClass, client_added),
+ NULL, NULL, gst_tcp_marshal_VOID__STRING_UINT, G_TYPE_NONE, 2,
+ G_TYPE_STRING, G_TYPE_UINT);
+ gst_tcpserversink_signals[SIGNAL_CLIENT_REMOVED] =
+ g_signal_new ("client-removed", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTCPServerSinkClass,
+ client_removed), NULL, NULL, gst_tcp_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_UINT);
+
gobject_class->set_property = gst_tcpserversink_set_property;
gobject_class->get_property = gst_tcpserversink_get_property;
this->server_sock_fd = -1;
GST_FLAG_UNSET (this, GST_TCPSERVERSINK_OPEN);
- this->protocol = GST_TCP_PROTOCOL_TYPE_GDP;
+ this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
this->clock = NULL;
}
FD_SET (client_sock_fd, &(sink->clientfds));
GST_DEBUG_OBJECT (sink, "added new client ip %s with fd %d",
inet_ntoa (client_address.sin_addr), client_sock_fd);
+ g_signal_emit (G_OBJECT (sink),
+ gst_tcpserversink_signals[SIGNAL_CLIENT_ADDED], 0,
+ inet_ntoa (client_address.sin_addr), client_sock_fd);
return TRUE;
}
}
FD_CLR (fd, &sink->clientfds);
FD_CLR (fd, &sink->caps_sent);
+ /* FIXME: we need to keep track of IP info so we can signal it here */
+ g_signal_emit (G_OBJECT (sink),
+ gst_tcpserversink_signals[SIGNAL_CLIENT_REMOVED], 0, NULL, fd);
} else {
/* FIXME: we should probably just Read 'n' Drop */
g_warning ("Don't know what to do with %d bytes to read", nread);
break;
case GST_TCP_PROTOCOL_TYPE_GDP:
- /* if we haven't send caps yet, send them first */
+ /* if we haven't sent caps yet, send them first */
if (!FD_ISSET (fd, &(sink->caps_sent))) {
const GstCaps *caps;
gchar *string;
*/
/* FIXME: there should be a better way to report problems, since we
want to continue for other clients and just drop this particular one */
- g_warning ("Write failed: %d of %d written", wrote, GST_BUFFER_SIZE (buf));
+ GST_DEBUG_OBJECT (sink, "Write failed: %d of %d bytes written", wrote,
+ GST_BUFFER_SIZE (buf));
/* write failed, so drop the client */
GST_DEBUG_OBJECT (sink, "removing client on fd %d", fd);
if (close (fd) != 0) {
}
FD_CLR (fd, &sink->clientfds);
FD_CLR (fd, &sink->caps_sent);
+ g_signal_emit (G_OBJECT (sink),
+ gst_tcpserversink_signals[SIGNAL_CLIENT_REMOVED], 0, NULL, fd);
return FALSE;
}
return TRUE;
switch (prop_id) {
case ARG_HOST:
- if (tcpserversink->host != NULL)
- g_free (tcpserversink->host);
- if (g_value_get_string (value) == NULL)
- tcpserversink->host = NULL;
- else
- tcpserversink->host = g_strdup (g_value_get_string (value));
+ g_free (tcpserversink->host);
+ tcpserversink->host = g_strdup (g_value_get_string (value));
break;
case ARG_PORT:
tcpserversink->server_port = g_value_get_int (value);
break;
+ case ARG_PROTOCOL:
+ tcpserversink->protocol = g_value_get_enum (value);
+ break;
+
default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
case ARG_PORT:
g_value_set_int (value, tcpserversink->server_port);
break;
+ case ARG_PROTOCOL:
+ g_value_set_enum (value, tcpserversink->protocol);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
size_t data_written; /* how much bytes have we written ? */
fd_set clientfds; /* all the client file descriptors that are open */
- fd_set caps_sent; /* all the client file descriptors that have had caps sent */
+ fd_set caps_sent; /* all the client file descriptors
+ * that have had caps sent */
+ fd_set streamheader_sent; /* all the client file descriptors that have had
+ * streamheader sent */
GstTCPProtocolType protocol;
guint mtu;
struct _GstTCPServerSinkClass {
GstElementClass parent_class;
+
+ /* signals */
+ void (*client_added) (GstElement *element, gchar *host, gint fd);
+ void (*client_removed) (GstElement *element, gchar *host, gint fd);
};
GType gst_tcpserversink_get_type (void);
enum
{
ARG_0,
- ARG_PORT,
ARG_HOST,
+ ARG_PORT,
ARG_PROTOCOL
};
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
+ g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST,
+ g_param_spec_string ("host", "Host", "The hostname to listen",
+ TCP_DEFAULT_HOST, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PORT,
g_param_spec_int ("port", "Port", "The port to listen to",
0, 32768, TCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, ARG_PROTOCOL,
g_param_spec_enum ("protocol", "Protocol", "The protocol to wrap data in",
- GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_GDP,
+ GST_TYPE_TCP_PROTOCOL_TYPE, GST_TCP_PROTOCOL_TYPE_NONE,
G_PARAM_READWRITE));
- g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_HOST,
- g_param_spec_string ("host", "Host", "The hostname to listen",
- TCP_DEFAULT_HOST, G_PARAM_READWRITE));
gobject_class->set_property = gst_tcpserversrc_set_property;
gobject_class->get_property = gst_tcpserversrc_get_property;
this->server_sock_fd = -1;
this->client_sock_fd = -1;
this->curoffset = 0;
- this->protocol = GST_TCP_PROTOCOL_TYPE_GDP;
+ this->protocol = GST_TCP_PROTOCOL_TYPE_NONE;
GST_FLAG_UNSET (this, GST_TCPSERVERSRC_OPEN);
}
tcpserversrc = GST_TCPSERVERSRC (object);
switch (prop_id) {
+ case ARG_HOST:
+ g_free (tcpserversrc->host);
+ tcpserversrc->host = g_strdup (g_value_get_string (value));
+ break;
case ARG_PORT:
tcpserversrc->server_port = g_value_get_int (value);
break;
case ARG_PROTOCOL:
tcpserversrc->protocol = g_value_get_enum (value);
break;
- case ARG_HOST:
- if (tcpserversrc->host)
- g_free (tcpserversrc->host);
- tcpserversrc->host = g_strdup (g_value_get_string (value));
- break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
tcpserversrc = GST_TCPSERVERSRC (object);
switch (prop_id) {
+ case ARG_HOST:
+ g_value_set_string (value, tcpserversrc->host);
+ break;
case ARG_PORT:
g_value_set_int (value, tcpserversrc->server_port);
break;
case ARG_PROTOCOL:
g_value_set_enum (value, tcpserversrc->protocol);
break;
- case ARG_HOST:
- g_value_set_string (value, tcpserversrc->host);
- break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;