+2008-11-20 Stefan Kost <ensonic@users.sf.net>
+
+ patch by: Leandro Melo de Sales <leandroal@gmail.com>
+
+ * gst/dccp/gstdccp.c:
+ * gst/dccp/gstdccp.h:
+ * gst/dccp/gstdccpclientsink.c:
+ * gst/dccp/gstdccpclientsink.h:
+ * gst/dccp/gstdccpclientsrc.c:
+ * gst/dccp/gstdccpserversink.c:
+ * gst/dccp/gstdccpserversrc.c:
+ * gst/dccp/gstdccpserversrc.h:
+ CodeStyle improvements and minor fixes to the DCCP plugin.
+ Fixes #553823.
+
2008-11-20 Sebastian Dröge <slomo@circular-chaos.org>
* gst/rtpmanager/gstrtpjitterbuffer.c:
#endif
/* Prototypes and definitions for private functions and not exported via gstdccp.h */
-gint gst_dccp_socket_write (int socket, const void *buf, size_t count,
- int packet_size);
-gboolean gst_dccp_socket_connected (GstElement * element, int server_sock_fd);
+GstFlowReturn gst_dccp_socket_write (GstElement * element, int socket,
+ const void *buf, size_t count, int packet_size);
struct sockaddr_in gst_dccp_create_sockaddr (GstElement * element, gchar * ip,
int port);
-/* Resolves host to IP address
- * @return a gchar pointer containing the ip address or NULL
+/*
+ * Resolves host to IP address
+ * @param element - the element
+ * @return a gchar pointer containing the ip address or NULL if it
+ * couldn't resolve the host to a IP adress
*/
gchar *
gst_dccp_host_to_ip (GstElement * element, const gchar * host)
return ip;
}
-/* Read a buffer from the given socket
- * @returns:
- * a GstBuffer from which data should be read
- * or NULL, indicating a connection close or an error. Handle it with EOS.
+/*
+ * Read a buffer from the given socket
+ *
+ * @param this - the element that has the socket that will be read
+ * @param socket - the socket fd that will be read
+ * @param buf - the buffer with the data read from the socket
+ * @return GST_FLOW_OK if the read operation was successful
+ * or GST_FLOW_ERROR indicating a connection close or an error.
+ * Handle it with EOS.
*/
GstFlowReturn
gst_dccp_read_buffer (GstElement * this, int socket, GstBuffer ** buf)
int ret;
ssize_t bytes_read;
int readsize;
+ struct msghdr mh;
+ struct iovec iov;
*buf = NULL;
}
*buf = gst_buffer_new_and_alloc (readsize);
- bytes_read = read (socket, GST_BUFFER_DATA (*buf), readsize);
+
+ memset (&mh, 0, sizeof (mh));
+ mh.msg_name = NULL;
+ mh.msg_namelen = 0;
+ iov.iov_base = GST_BUFFER_DATA (*buf);
+ iov.iov_len = readsize;
+ mh.msg_iov = &iov;
+ mh.msg_iovlen = 1;
+ mh.msg_control = NULL;
+ mh.msg_controllen = 0;
+
+ bytes_read = recvmsg (socket, &mh, 0);
+
+ if (bytes_read != readsize) {
+ GST_DEBUG_OBJECT (this, ("Error while reading data"));
+ return GST_FLOW_ERROR;
+ }
GST_LOG_OBJECT (this, "bytes read %" G_GSIZE_FORMAT, bytes_read);
GST_LOG_OBJECT (this, "returning buffer of size %d", GST_BUFFER_SIZE (*buf));
return GST_FLOW_OK;
}
-/* Create a new socket
+/* Create a new DCCP socket
+ *
+ * @param element - the element
* @return the socket file descriptor
*/
gint
}
/* Connect to a server
- * @return true in case of successfull connection, false otherwise
+ * @param element - the element
+ * @param server_sin - a struct with a server address and port
+ * @param sock_fd - the socket to connect
+ * @return TRUE in case of successful connection, FALSE otherwise
*/
gboolean
gst_dccp_connect_to_server (GstElement * element, struct sockaddr_in server_sin,
if (connect (sock_fd, (struct sockaddr *) &server_sin, sizeof (server_sin))) {
switch (errno) {
case ECONNREFUSED:
- GST_ERROR_OBJECT (element, "Connection refused.");
+ GST_ELEMENT_ERROR (element, RESOURCE, OPEN_WRITE,
+ ("Connection to %s:%d refused.", inet_ntoa (server_sin.sin_addr),
+ ntohs (server_sin.sin_port)), (NULL));
return FALSE;
break;
default:
- GST_ERROR_OBJECT (element, "Connection failed.");
+ GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
+ ("Connect to %s:%d failed: %s", inet_ntoa (server_sin.sin_addr),
+ ntohs (server_sin.sin_port), g_strerror (errno)));
return FALSE;
break;
}
/* FIXME support only one client */
/*
* Accept connection on the server socket.
+ *
+ * @param element - the element
+ * @param server_sock_fd - the server socket file descriptor
* @return the socket of the client connected to the server.
*/
gint
struct sockaddr_in client_address;
unsigned int client_address_len;
- /* For some stupid reason, client_address and client_address_len has to be
- * zeroed */
memset (&client_address, 0, sizeof (client_address));
client_address_len = 0;
if ((client_sock_fd =
accept (server_sock_fd, (struct sockaddr *) &client_address,
&client_address_len)) == -1) {
+ GST_ELEMENT_ERROR (element, RESOURCE, OPEN_WRITE, (NULL),
+ ("Could not accept client on server socket %d: %s (%d)",
+ server_sock_fd, g_strerror (errno), errno));
return -1;
}
- /* to support multiple connection, fork here a new thread passing the
- * client_sock_fd returned by accept function.
- */
- GST_DEBUG_OBJECT (element, "added new client ip %s with fd %d",
+ GST_DEBUG_OBJECT (element, "Added new client ip %s with fd %d.",
inet_ntoa (client_address.sin_addr), client_sock_fd);
- /* return the thread object, instead of the fd */
return client_sock_fd;
}
/*
* Bind a server address.
+ *
+ * @param element - the element
+ * @param server_sock_fd - the server socket fd
+ * @param server_sin - the address and the port to bind the server on
* @return true in success, false otherwise.
*/
gboolean
{
int ret;
- GST_DEBUG_OBJECT (element, "binding server socket to address");
+ GST_DEBUG_OBJECT (element, "Binding server socket to address.");
+
ret = bind (server_sock_fd, (struct sockaddr *) &server_sin,
sizeof (server_sin));
if (ret) {
switch (errno) {
default:
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
- ("bind on port %d failed: %s", server_sin.sin_port,
+ ("Bind on port %d failed: %s", ntohs (server_sin.sin_port),
g_strerror (errno)));
return FALSE;
break;
return TRUE;
}
+/*
+ * Listen on server socket.
+ *
+ * @param element - the element
+ * @param server_sock_fd - the server socket fd
+ * @return true in success, false otherwise.
+ */
gboolean
gst_dccp_listen_server_socket (GstElement * element, int server_sock_fd)
{
- GST_DEBUG_OBJECT (element, "listening on server socket %d with queue of %d",
+ GST_DEBUG_OBJECT (element, "Listening on server socket %d with queue of %d",
server_sock_fd, DCCP_BACKLOG);
+
if (listen (server_sock_fd, DCCP_BACKLOG) == -1) {
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
("Could not listen on server socket: %s", g_strerror (errno)));
return FALSE;
}
+
GST_DEBUG_OBJECT (element,
- "listened on server socket %d, returning from connection setup",
+ "Listened on server socket %d, returning from connection setup",
server_sock_fd);
return TRUE;
}
-/* FIXME */
-gboolean
-gst_dccp_socket_connected (GstElement * element, int server_sock_fd)
-{
- return FALSE;
-}
-
/* Write buffer to given socket incrementally.
- * Returns number of bytes written.
+ *
+ * @param element - the element
+ * @param socket - the socket
+ * @param buf - the buffer that will be written
+ * @param size - the number of bytes of the buffer
+ * @param packet_size - the MTU
+ * @return the number of bytes written.
*/
-gint
-gst_dccp_socket_write (int socket, const void *buf, size_t size,
- int packet_size)
+GstFlowReturn
+gst_dccp_socket_write (GstElement * element, int socket, const void *buf,
+ size_t size, int packet_size)
{
size_t bytes_written = 0;
ssize_t wrote;
+ struct iovec iov;
+ struct msghdr mh;
+ memset (&mh, 0, sizeof (mh));
+
while (bytes_written < size) {
do {
- wrote = write (socket, (const char *) buf + bytes_written,
- MIN (packet_size, size - bytes_written));
+ mh.msg_name = NULL;
+ mh.msg_namelen = 0;
+ iov.iov_base = (char *) buf + bytes_written;
+ iov.iov_len = MIN (packet_size, size - bytes_written);
+ mh.msg_iov = &iov;
+ mh.msg_iovlen = 1;
+ mh.msg_control = NULL;
+ mh.msg_controllen = 0;
+
+ wrote = sendmsg (socket, &mh, 0);
} while (wrote == -1 && errno == EAGAIN);
/* TODO print the send error */
}
if (bytes_written < 0)
- GST_WARNING ("error while writing");
+ GST_WARNING ("Error while writing.");
else
- GST_LOG ("wrote %" G_GSIZE_FORMAT " bytes succesfully", bytes_written);
- return bytes_written;
+ GST_LOG_OBJECT (element, "Wrote %" G_GSIZE_FORMAT " bytes succesfully.",
+ bytes_written);
+
+ if (bytes_written != size) {
+ GST_ELEMENT_ERROR (element, RESOURCE, WRITE,
+ ("Error while sending data to socket %d.", socket),
+ ("Only %" G_GSIZE_FORMAT " of %u bytes written: %s",
+ bytes_written, size, g_strerror (errno)));
+ return GST_FLOW_ERROR;
+ }
+
+ return GST_FLOW_OK;
}
+/* Write buffer to given socket.
+ *
+ * @param this - the element
+ * @param buf - the buffer that will be written
+ * @param client_sock_fd - the client socket
+ * @param packet_size - the MTU
+ * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise.
+ */
GstFlowReturn
gst_dccp_send_buffer (GstElement * this, GstBuffer * buffer, int client_sock_fd,
int packet_size)
{
- size_t wrote;
+// size_t wrote;
gint size = 0;
guint8 *data;
GST_LOG_OBJECT (this, "writing %d bytes", size);
if (packet_size < 0) {
- GST_LOG_OBJECT (this, "error getting MTU");
return GST_FLOW_ERROR;
}
- wrote = gst_dccp_socket_write (client_sock_fd, data, size, packet_size);
-
- if (wrote != size) {
- GST_DEBUG_OBJECT (this, ("Error while sending data"));
- return GST_FLOW_ERROR;
- }
- return GST_FLOW_OK;
+ return gst_dccp_socket_write (this, client_sock_fd, data, size, packet_size);
}
/*
* Create socket address.
+ * @param element - the element
+ * @param ip - the ip address
+ * @param port - the port
* @return sockaddr_in.
*/
struct sockaddr_in
return sin;
}
+/*
+ * Make address reusable.
+ * @param element - the element
+ * @param sock_fd - the socket
+ * @return TRUE if the operation was successful, FALSE otherwise.
+ */
gboolean
gst_dccp_make_address_reusable (GstElement * element, int sock_fd)
{
return TRUE;
}
-/* DCCP socket specific stuffs */
+/*
+ * Set DCCP congestion control.
+ * @param element - the element
+ * @param sock_fd - the socket
+ * @param ccid - the ccid number
+ * @return TRUE if the operation was successful, FALSE otherwise.
+ */
gboolean
gst_dccp_set_ccid (GstElement * element, int sock_fd, uint8_t ccid)
{
return ccid;
}
+/*
+ * Get the socket MTU.
+ * @param element - the element
+ * @param sock - the socket
+ * @return the MTU if the operation was successful, -1 otherwise.
+ */
gint
gst_dccp_get_max_packet_size (GstElement * element, int sock)
{
return size;
}
-/* Still not used and need to be FIXED */
-gboolean
-gst_dccp_set_sock_windowsize (GstElement * element, int sock, int winSize,
- gboolean inSend)
+void
+gst_dccp_socket_close (GstElement * element, int *socket)
{
-#ifdef SO_SNDBUF
- int rc;
-
- if (!inSend) {
- /* receive buffer -- set
- * note: results are verified after connect() or listen(),
- * since some OS's don't show the corrected value until then. */
- rc = setsockopt (sock, SOL_DCCP, SO_RCVBUF,
- (char *) &winSize, sizeof (winSize));
- GST_DEBUG_OBJECT (element, "set rcv sockbuf: %d", winSize);
- } else {
- /* send buffer -- set
- * note: results are verified after connect() or listen(),
- * since some OS's don't show the corrected value until then. */
- rc = setsockopt (sock, SOL_DCCP, SO_SNDBUF,
- (char *) &winSize, sizeof (winSize));
- GST_DEBUG_OBJECT (element, "set snd sockbuf: %d", winSize);
+ if (socket >= 0) {
+ GST_DEBUG_OBJECT (element, "closing socket");
+ close (*socket);
+ *socket = -1;
}
-
- if (rc < 0) {
- GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS, (NULL),
- ("Could not set window size %d: %s", errno, g_strerror (errno)));
- return FALSE;
- }
-#endif /* SO_SNDBUF */
-
- return TRUE;
}
int client_sock_fd, int packet_size);
gboolean gst_dccp_make_address_reusable (GstElement * element, int sock_fd);
-gboolean gst_dccp_set_sock_windowsize(GstElement * element, int sock, int winSize,
- gboolean inSend);
+void gst_dccp_socket_close (GstElement * element, int * socket);
#endif /* __GST_DCCP_H__ */
static guint gst_dccp_client_sink_signals[LAST_SIGNAL] = { 0 };
+/*
+ * Write buffer to client socket.
+ *
+ * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise.
+ */
static GstFlowReturn
gst_dccp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
}
}
+/*
+ * Starts the element. If the sockfd property was not the default, this method
+ * will create a new socket and connect to the server.
+ *
+ * @param bsink - the element
+ * @return TRUE if the send operation was successful, FALSE otherwise.
+ */
static gboolean
gst_dccp_client_sink_start (GstBaseSink * bsink)
{
sink = GST_DCCP_CLIENT_SINK (bsink);
- if (sink->sock_fd != -1 && sink->closed) {
- GST_DEBUG_OBJECT (sink, "closing socket");
- close (sink->sock_fd);
- sink->sock_fd = -1;
+ if (sink->sock_fd != DCCP_DEFAULT_SOCK_FD && sink->closed) {
+ gst_dccp_socket_close (GST_ELEMENT (sink), &(sink->sock_fd));
}
return TRUE;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
- "The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
+ "The port to send the packets to", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
-/* FIXME property server_ip */
g_object_class_install_property (gobject_class, PROP_HOST,
g_param_spec_string ("host", "Host",
"The host IP address to send packets to", DCCP_DEFAULT_HOST,
/* signals */
/**
* GstDccpClientSink::connected:
- * @sink: the gstdccpclientsink instance
- * @fd: the connected socket fd
+ * @sink: the gstdccpclientsink element that emitted this signal
+ * @fd: the connected socket file descriptor
*
* Sign that the element has connected, return the fd of the socket.
*/
typedef struct _GstDCCPClientSinkClass GstDCCPClientSinkClass;
+/**
+ * GstDCCPClientSink:
+ *
+ * dccpclientsink object structure.
+ */
struct _GstDCCPClientSink
{
GstBaseSink element;
static guint gst_dccp_client_src_signals[LAST_SIGNAL] = { 0 };
+/*
+ * Read a buffer from the client socket
+ *
+ * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise.
+ */
static GstFlowReturn
gst_dccp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
}
}
+/*
+ * Starts the element. If the sockfd property was not the default, this method
+ * will create a new socket and connect to the server.
+ *
+ * @param bsrc - the element
+ * @return TRUE if the send operation was successful, FALSE otherwise.
+ */
static gboolean
gst_dccp_client_src_start (GstBaseSrc * bsrc)
{
src = GST_DCCP_CLIENT_SRC (bsrc);
- if (src->sock_fd != -1 && src->closed) {
- GST_DEBUG_OBJECT (src, "closing socket");
- close (src->sock_fd);
- src->sock_fd = -1;
+ if (src->sock_fd != DCCP_DEFAULT_SOCK_FD && src->closed) {
+ gst_dccp_socket_close (GST_ELEMENT (src), &(src->sock_fd));
}
return TRUE;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
- "The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
+ "The port to receive packets from", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_HOST,
/* signals */
/**
* GstDccpClientSrc::connected:
- * @src: the gstdccpclientsrc instance
- * @fd: the connected socket fd
+ * @src: the gstdccpclientsrc element that emitted this signal
+ * @fd: the connected socket file descriptor
*
* Reports that the element has connected, giving the fd of the socket
*/
static guint gst_dccp_server_sink_signals[LAST_SIGNAL] = { 0 };
+/*
+ * Create a new client with the socket and the MTU
+ *
+ * @param element - the gstdccpserversink instance
+ * @param socket - the client socket
+ * @return the client
+ */
static Client *
gst_dccp_server_create_client (GstElement * element, int socket)
{
client->pksize = gst_dccp_get_max_packet_size (element, client->socket);
client->flow_status = GST_FLOW_OK;
+ GST_DEBUG_OBJECT (element, "Creating a new client with fd %d and MTU %d.",
+ client->socket, client->pksize);
+
/* the socket is connected */
g_signal_emit (element, gst_dccp_server_sink_signals[SIGNAL_CONNECTED], 0,
socket);
return client;
}
+/*
+ * Wait connections of new clients
+ *
+ * @param arg - the gstdccpserversink instance
+ */
static void *
gst_dccp_server_accept_new_clients (void *arg)
{
}
}
+/*
+ * Send the buffer to a client
+ *
+ * @param arg - the client
+ */
static void *
gst_dccp_server_send_buffer (void *arg)
{
return NULL;
}
-/* Remove clients with problems to send */
+/* Remove clients with problems to send.
+ *
+ * @param arg - the gstdccpserversink instance
+ */
static void *
gst_dccp_server_delete_dead_clients (void *arg)
{
this->clients = NULL;
}
+/*
+ * Starts the element. If the sockfd property was not the default, this method
+ * will wait for a client connection. If wait-connections property is true, it
+ * creates a thread to wait for new client connections.
+ *
+ * @param bsink - the element
+ * @return TRUE if the send operation was successful, FALSE otherwise.
+ */
static gboolean
gst_dccp_server_sink_start (GstBaseSink * bsink)
{
GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (bsink);
- int ret = 1;
Client *client;
- /* create socket */
if ((sink->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (sink))) < 0) {
return FALSE;
}
- /* make address reusable */
- if (setsockopt (sink->sock_fd, SOL_SOCKET, SO_REUSEADDR,
- (void *) &ret, sizeof (ret)) < 0) {
- GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
- ("Could not setsockopt: %s", g_strerror (errno)));
+ if (!gst_dccp_make_address_reusable (GST_ELEMENT (sink), sink->sock_fd)) {
return FALSE;
}
pthread_cancel (accept_thread_id);
}
- if (sink->sock_fd != -1 && sink->closed == TRUE) {
- GST_DEBUG_OBJECT (sink, "closing socket");
- close (sink->sock_fd);
- sink->sock_fd = -1;
- }
+ gst_dccp_socket_close (GST_ELEMENT (sink), &(sink->sock_fd));
pthread_mutex_lock (&lock);
for (i = 0; i < g_list_length (sink->clients); i++) {
Client *client = (Client *) g_list_nth_data (sink->clients, i);
- close (client->socket);
+ if (client->socket != DCCP_DEFAULT_CLIENT_SOCK_FD && sink->closed == TRUE) {
+ gst_dccp_socket_close (GST_ELEMENT (sink), &(client->socket));
+ }
g_free (client);
}
pthread_mutex_unlock (&lock);
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
- "The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
+ "The port to listen to", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLIENT_SOCK_FD,
g_object_class_install_property (gobject_class, PROP_CLOSED,
g_param_spec_boolean ("close-socket", "Close",
- "Close socket at end of stream",
+ "Close the client sockets at end of stream",
DCCP_DEFAULT_CLOSED, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
/* signals */
/**
* GstDccpServerSink::connected:
- * @src: the gstdccpserversink instance
- * @fd: the connected socket fd
+ * @sink: the gstdccpserversink element that emitted this signal
+ * @fd: the connected socket file descriptor
*
* Reports that the element has connected, giving the fd of the socket
*/
#include <fcntl.h>
#define DCCP_DEFAULT_CAPS NULL
-#define DCCP_DEFAULT_LISTEN_HOST NULL /* listen on all interfaces */
/* signals */
enum
{
PROP_0,
PROP_PORT,
- PROP_HOST,
PROP_CLIENT_SOCK_FD,
PROP_CLOSED,
PROP_CCID,
static guint gst_dccp_server_src_signals[LAST_SIGNAL] = { 0 };
+/*
+ * Read a buffer from the server socket
+ *
+ * @return GST_FLOW_OK if the send operation was successful, GST_FLOW_ERROR otherwise.
+ */
static GstFlowReturn
gst_dccp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (object);
switch (prop_id) {
- case PROP_HOST:
- if (!g_value_get_string (value)) {
- g_warning ("host property cannot be NULL");
- break;
- }
- g_free (src->host);
- src->host = g_strdup (g_value_get_string (value));
- break;
case PROP_PORT:
src->port = g_value_get_int (value);
break;
GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (object);
switch (prop_id) {
- case PROP_HOST:
- g_value_set_string (value, src->host);
- break;
case PROP_PORT:
g_value_set_int (value, src->port);
break;
}
}
-
+/*
+ * Starts the element. If the sockfd property was not the default, this method
+ * will create a new server socket and wait for a client connection.
+ *
+ * @param bsrc - the element
+ * @return TRUE if the send operation was successful, FALSE otherwise.
+ */
static gboolean
gst_dccp_server_src_start (GstBaseSrc * bsrc)
{
return FALSE;
}
- gst_dccp_make_address_reusable (GST_ELEMENT (src), src->sock_fd);
+ if (!gst_dccp_make_address_reusable (GST_ELEMENT (src), src->sock_fd)) {
+ return FALSE;
+ }
/* name the server socket */
memset (&src->server_sin, 0, sizeof (src->server_sin));
GstDCCPServerSrcClass * g_class)
{
this->port = DCCP_DEFAULT_PORT;
- this->host = g_strdup (DCCP_DEFAULT_HOST);
this->sock_fd = DCCP_DEFAULT_SOCK_FD;
this->client_sock_fd = DCCP_DEFAULT_CLIENT_SOCK_FD;
this->closed = DCCP_DEFAULT_CLOSED;
this->caps = NULL;
}
- g_free (this->host);
-
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
src = GST_DCCP_SERVER_SRC (bsrc);
- if (src->sock_fd != -1 && src->closed == TRUE) {
- GST_DEBUG_OBJECT (src, "closing socket");
- close (src->sock_fd);
- src->sock_fd = -1;
+ gst_dccp_socket_close (GST_ELEMENT (src), &(src->sock_fd));
+ if (src->client_sock_fd != DCCP_DEFAULT_CLIENT_SOCK_FD && src->closed == TRUE) {
+ gst_dccp_socket_close (GST_ELEMENT (src), &(src->client_sock_fd));
}
return TRUE;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
- "The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
+ "The port to listen to", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_HOST,
- g_param_spec_string ("host", "Host", "The hostname to listen as",
- DCCP_DEFAULT_LISTEN_HOST, G_PARAM_READWRITE));
-
g_object_class_install_property (gobject_class, PROP_CLIENT_SOCK_FD,
g_param_spec_int ("sockfd", "Socket fd",
"The client socket file descriptor", -1, G_MAXINT,
g_object_class_install_property (gobject_class, PROP_CLOSED,
g_param_spec_boolean ("close-socket", "Close socket",
- "Close socket at the end of stream", DCCP_DEFAULT_CLOSED,
+ "Close client socket at the end of stream", DCCP_DEFAULT_CLOSED,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
/* signals */
/**
* GstDccpServerSrc::connected:
- * @src: the gstdccpserversrc instance
- * @fd: the connected socket fd
+ * @src: the gstdccpserversrc element that emitted this signal
+ * @fd: the connected socket file descriptor
*
* Reports that the element has connected, giving the fd of the socket
*/
/* server information */
int port;
- gchar *host;
struct sockaddr_in server_sin;
/* socket */