Merge branch 'dccp'
authorAndre <maan@p133.(none)>
Sat, 11 Mar 2006 16:45:20 +0000 (17:45 +0100)
committerAndre <maan@p133.(none)>
Sat, 11 Mar 2006 16:45:20 +0000 (17:45 +0100)
Fix up merge conflicts by hand.
Conflicts:

configure.ac
error.h
server.ggo

14 files changed:
CREDITS
configure.ac
dccp.c [new file with mode: 0644]
dccp.h [new file with mode: 0644]
dccp_recv.c [new file with mode: 0644]
dccp_recv.ggo [new file with mode: 0644]
dccp_send.c [new file with mode: 0644]
error.h
http_recv.ggo
recv.c
recv.h
send.h
server.c
server.ggo

diff --git a/CREDITS b/CREDITS
index 8d778c8..aeb1d2d 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -25,6 +25,8 @@ Jaroslav Kysela <perex@suse.cz> (aplay)
 
 Robert Leslie (libmad)
 
+Ian McDonald <imcdnzl@gmail.com> (dccp example code)
+
 Simon Morlat <simon.morlat@linphone.org> (ortp)
 
 Christof Müller (bug reports)
index 06cbe7a..fd34ed9 100644 (file)
@@ -56,24 +56,24 @@ AC_CHECK_LIB([readline], [readline], [],
 AC_CHECK_LIB([menu], [new_menu], [extras="$extras para_dbadm"],
        [AC_MSG_WARN([libmenu not found,  cannot build para_dbadm])])
 
-########################################################################### 
-recv_cmdline_objs="recv.cmdline http_recv.cmdline"
-recv_errlist_objs="http_recv recv_common recv time string net"
+
+recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
+recv_errlist_objs="http_recv recv_common recv time string net dccp_recv dccp"
 recv_ldflags=""
 
 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
 filter_errlist_objs="filter_chain wav compress filter string"
 filter_ldflags=""
 
-audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline 
-       http_recv.cmdline"
-audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net 
-       time grab_client filter_chain wav compress http_recv recv_common ringbuffer"
+audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
+       http_recv.cmdline dccp_recv.cmdline"
+audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
+       time grab_client filter_chain wav compress http_recv dccp dccp_recv recv_common ringbuffer"
 audiod_ldflags=""
 
 server_cmdline_objs="server.cmdline"
 server_errlist_objs="server mp3 afs command net string signal random_selector
-       time daemon stat crypt http_send db close_on_fork playlist_selector ipc"
+       time daemon stat crypt http_send db close_on_fork playlist_selector ipc dccp dccp_send"
 server_ldflags=""
 
 ########################################################################### ssl
diff --git a/dccp.c b/dccp.c
new file mode 100644 (file)
index 0000000..b5cf7fd
--- /dev/null
+++ b/dccp.c
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */
+
+/*
+ * based on common.c of dccp-cs-0.01.tar.bz2,
+ * (C) 2005 Ian McDonald <imcdnzl@gmail.com>
+ */
+
+#include "para.h"
+#include "error.h"
+#include "dccp.h"
+
+int dccp_get_socket(void)
+{
+       int s = socket(AF_INET, SOCK_DCCP, IPPROTO_DCCP);
+
+       if (s < 0)
+               return -E_DCCP_SOCKET;
+       return s;
+}
+
+int dccp_set_socket(int fd)
+{
+       int pkt_size = 256, ret;
+
+       /* hack to get a service code */
+       ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_PACKET_SIZE,
+               (char*)&pkt_size, sizeof(pkt_size));
+       if (ret < 0)
+               return -E_DCCP_PACKET_SIZE;
+       ret = setsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_SERVICE,
+               (char*)&pkt_size, sizeof(pkt_size));
+       if (ret < 0)
+               return -E_DCCP_SERVICE;
+       return 1;
+}
diff --git a/dccp.h b/dccp.h
new file mode 100644 (file)
index 0000000..2443db8
--- /dev/null
+++ b/dccp.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */
+
+/*
+ * based on common.h of dccp-cs-0.01.tar.bz2,
+ * (C) 2005 Ian McDonald <imcdnzl@gmail.com>
+ */
+
+#define SOL_DCCP 269
+#define SOCK_DCCP 6
+#define IPPROTO_DCCP 33
+#define DCCP_SOCKOPT_PACKET_SIZE 1
+#define DCCP_SOCKOPT_SERVICE 2
+
+int dccp_get_socket(void);
+int dccp_set_socket(int fd);
diff --git a/dccp_recv.c b/dccp_recv.c
new file mode 100644 (file)
index 0000000..95d2ba8
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */
+
+/*
+ * based on client.c of dccp-cs-0.01.tar.bz2,
+ * (C) 2005 Ian McDonald <imcdnzl@gmail.com>
+ */
+
+#include "para.h"
+#include "error.h"
+#include "dccp.h"
+#include "recv.h"
+#include "string.h"
+#include "net.h"
+
+#include "dccp_recv.cmdline.h"
+
+/* needed by getaddrinfo */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+
+
+#define DCCP_BUFSIZE 4096
+
+/**
+ * data specific to the dccp receiver
+ *
+ * \sa receiver receiver_node
+ */
+struct private_dccp_recv_data {
+       /** the file descriptor for the dccp socket */
+       int fd;
+};
+
+
+static void dccp_recv_close(struct receiver_node *rn)
+{
+
+       struct private_dccp_recv_data *pdd = rn->private_data;
+
+       if (pdd && pdd->fd > 0)
+               close(pdd->fd);
+       free(rn->buf);
+       rn->buf = NULL;
+       free(rn->private_data);
+       rn->private_data = NULL;
+}
+
+
+static int dccp_recv_open(struct receiver_node *rn)
+{
+       struct private_dccp_recv_data *pdd;
+       struct gengetopt_args_info *conf = rn->conf;
+       int ret;
+       struct addrinfo *ai;
+       char *tmp;
+
+       rn->buf = para_calloc(DCCP_BUFSIZE);
+       rn->private_data = para_calloc(sizeof(struct private_dccp_recv_data));
+       pdd = rn->private_data;
+       ret = dccp_get_socket();
+       if (ret < 0)
+               goto err_out;
+       pdd->fd = ret;
+
+       tmp = make_message("%d", conf->port_arg);
+       ret = getaddrinfo(conf->host_arg, tmp, NULL, &ai);
+       free(tmp);
+       if (ret) {
+               ret = -E_ADDR_INFO;
+               goto err_out;
+       }
+       ret = dccp_set_socket(pdd->fd);
+       if (ret < 0)
+               goto err_out;
+       PARA_NOTICE_LOG("connecting to %s:%d\n", conf->host_arg, conf->port_arg);
+       ret = -E_DCCP_CONNECT;
+       if (connect(pdd->fd, ai->ai_addr, ai->ai_addrlen) < 0)
+               goto err_out;
+       return 1;
+err_out:
+       dccp_recv_close(rn);
+       return ret;
+}
+
+static void dccp_shutdown(void)
+{
+       ; /* nothing to do */
+}
+
+static void *dccp_recv_parse_config(int argc, char **argv)
+{
+       struct gengetopt_args_info *tmp = para_calloc(sizeof(struct gengetopt_args_info));
+
+       if (!dccp_recv_cmdline_parser(argc, argv, tmp))
+               return tmp;
+       free(tmp);
+       return NULL;
+}
+
+static int dccp_recv_pre_select(struct receiver_node *rn, fd_set *rfds,
+               __unused fd_set *wfds, __unused struct timeval *timeout)
+{
+       struct private_dccp_recv_data *pdd = rn->private_data;
+
+       if (pdd)
+               FD_SET(pdd->fd, rfds);
+       return pdd->fd;
+}
+
+static int dccp_recv_post_select(struct receiver_node *rn, int select_ret,
+               fd_set *rfds, __unused fd_set *wfds)
+{
+       int ret;
+       struct private_dccp_recv_data *pdd = rn->private_data;
+
+       if (!select_ret || !pdd || !FD_ISSET(pdd->fd, rfds))
+               return 1; /* nothing to do */
+       if (rn->loaded >= DCCP_BUFSIZE)
+               return -E_DCCP_OVERRUN;
+       ret = recv_bin_buffer(pdd->fd, rn->buf + rn->loaded,
+               DCCP_BUFSIZE - rn->loaded);
+       if (ret <= 0)
+               return ret;
+       rn->loaded += ret;
+       return 1;
+}
+
+/**
+ * the init function of the dccp receiver
+ *
+ * \param r pointer to the receiver struct to initialize
+ *
+ * Initialize all function pointers of \a r
+ */
+void dccp_recv_init(struct receiver *r)
+{
+       r->shutdown = dccp_shutdown;
+       r->open = dccp_recv_open;
+       r->close = dccp_recv_close;
+       r->pre_select = dccp_recv_pre_select;
+       r->post_select = dccp_recv_post_select;
+       r->parse_config = dccp_recv_parse_config;
+}
diff --git a/dccp_recv.ggo b/dccp_recv.ggo
new file mode 100644 (file)
index 0000000..481dcb3
--- /dev/null
@@ -0,0 +1,3 @@
+section "options of the dccp receiver"
+option "host" i "ip or host" string default="localhost" no
+option "port" p "port to connect to" int default="5001" no
diff --git a/dccp_send.c b/dccp_send.c
new file mode 100644 (file)
index 0000000..08b3069
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2006 Andre Noll <maan@systemlinux.org>
+ *
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ *
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ *
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */
+
+/*
+ * based on server.c of dccp-cs-0.01.tar.bz2,
+ * (C) 2005 Ian McDonald <imcdnzl@gmail.com>
+ */
+
+#include "server.h"
+#include "net.h"
+#include "list.h"
+#include "afs.h"
+#include "send.h"
+#include "dccp.h"
+#include "error.h"
+#include "string.h"
+#include "server.cmdline.h"
+extern struct gengetopt_args_info conf;
+/** the list of connected clients **/
+static struct list_head clients;
+static int listen_fd = -1;
+static struct sender *self;
+
+/** describes one connected client */
+struct dccp_client {
+       /** the dccp socket */
+       int fd;
+       /** address information about the client */
+       struct sockaddr_in addr;
+       /** the position of this client in the client list */
+       struct list_head node;
+       int header_sent; /* non-zero if audio file header has been sent */
+};
+
+static void dccp_pre_select(__unused struct audio_format *af, int *max_fileno, fd_set *rfds,
+               __unused fd_set *wfds)
+{
+       if (listen_fd < 0)
+               return;
+       FD_SET(listen_fd, rfds);
+       *max_fileno = MAX(*max_fileno, listen_fd);
+}
+
+static void dccp_post_select(__unused struct audio_format *af, fd_set *rfds,
+               __unused fd_set *wfds)
+{
+       struct dccp_client *dc;
+       int ret;
+
+       if (!FD_ISSET(listen_fd, rfds))
+               return;
+       PARA_NOTICE_LOG("%s", "accepting...\n");
+       dc = para_calloc(sizeof(struct dccp_client));
+       ret = para_accept(listen_fd, &dc->addr, sizeof(struct sockaddr_in));
+       if (ret < 0) {
+               PARA_ERROR_LOG("%s", PARA_STRERROR(-ret));
+               return;
+       }
+       PARA_NOTICE_LOG("%s", "connection\n");
+       dc->fd = ret;
+       list_add(&dc->node, &clients);
+}
+
+static int dccp_open(void)
+{
+       struct sockaddr_in servaddr;
+       int ret;
+
+       ret = dccp_get_socket();
+       if (ret < 0)
+               return ret;
+       listen_fd = ret;
+
+       bzero(&servaddr, sizeof(servaddr));
+       servaddr.sin_family = AF_INET;
+       servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
+       servaddr.sin_port = htons(conf.dccp_port_arg);
+       ret = bind(listen_fd, (struct sockaddr *)&servaddr, sizeof(servaddr));
+       if (ret < 0)
+               return -E_DCCP_BIND;
+       ret = dccp_set_socket(listen_fd);
+       if (ret < 0)
+               return ret;
+       ret = listen(listen_fd, 0);
+       if (ret < 0)
+               return -E_DCCP_LISTEN;
+       PARA_DEBUG_LOG("listening on fd %d\n", listen_fd);
+       return 1;
+}
+
+static void dccp_shutdown_client(struct dccp_client *dc)
+{
+       close(dc->fd);
+       list_del(&dc->node);
+       free(dc);
+}
+
+static void dccp_send(__unused struct audio_format *af,
+               long unsigned current_chunk,
+               __unused long unsigned chunks_sent, const char *buf, size_t len)
+{
+       struct dccp_client *dc, *tmp;
+       int ret, header_len;
+       char *header_buf;
+
+       if (listen_fd < 0 || !len)
+               return;
+
+       list_for_each_entry_safe(dc, tmp, &clients, node) {
+               if (!_write_ok(dc->fd))
+                       continue;
+               if (!dc->header_sent && af->get_header_info && current_chunk) {
+                       header_buf = af->get_header_info(&header_len);
+                       if (!header_buf || header_len <= 0)
+                               continue; /* header not yet available */
+                       ret = write(dc->fd, header_buf, header_len);
+                       if (ret != header_len) {
+                               dccp_shutdown_client(dc);
+                               continue;
+                       }
+                       if (!_write_ok(dc->fd))
+                               continue;
+               }
+               PARA_DEBUG_LOG("writing %d bytes to fd %d\n", len, dc->fd);
+               ret = write(dc->fd, buf, len);
+               if (ret != len)
+                       dccp_shutdown_client(dc);
+       }
+}
+
+static void dccp_shutdown_clients(void)
+{
+       struct dccp_client *dc, *tmp;
+
+       list_for_each_entry_safe(dc, tmp, &clients, node)
+               dccp_shutdown_client(dc);
+}
+
+static char *dccp_info(void)
+{
+       static char *buf;
+       int num_clients = 0;
+       struct dccp_client *dc, *tmp;
+
+       free(buf);
+       list_for_each_entry_safe(dc, tmp, &clients, node)
+               num_clients++;
+       buf = make_message("%d connected clients\n", num_clients);
+       return buf;
+}
+
+static char *dccp_help(void)
+{
+       return make_message("no help available\n");
+}
+
+void dccp_send_init(struct sender *s)
+{
+       int ret;
+
+       INIT_LIST_HEAD(&clients);
+       s->info = dccp_info;
+       s->send = dccp_send;
+       s->pre_select = dccp_pre_select;
+       s->post_select = dccp_post_select;
+       s->shutdown_clients = dccp_shutdown_clients;
+       s->help = dccp_help;
+       s->client_cmds[SENDER_ON] = NULL;
+       s->client_cmds[SENDER_OFF] = NULL;
+       s->client_cmds[SENDER_DENY] = NULL;
+       s->client_cmds[SENDER_ALLOW] = NULL;
+       s->client_cmds[SENDER_ADD] = NULL;
+       s->client_cmds[SENDER_DELETE] = NULL;
+       self = s;
+       ret = dccp_open();
+       if (ret < 0)
+               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+       else
+               s->status = SENDER_ON;
+}
diff --git a/error.h b/error.h
index 335950b..4b3cce2 100644 (file)
--- a/error.h
+++ b/error.h
 /** \file error.h list of error messages for all subsystems */
 
 /** \cond list of all subsystems that support the shiny new error facility */
-enum para_subsystem {SS_RECV,
-       SS_NET, SS_ORTP_RECV, SS_AUDIOD, SS_EXEC, SS_CLOSE_ON_FORK, SS_SIGNAL,
-       SS_STRING, SS_DAEMON, SS_STAT, SS_TIME, SS_GRAB_CLIENT, SS_HTTP_RECV,
-       SS_RECV_COMMON, SS_FILTER_CHAIN, SS_WAV, SS_COMPRESS, SS_OGGDEC, SS_FILTER,
-       SS_COMMAND, SS_RANDOM_SELECTOR, SS_PLAYLIST_SELECTOR, SS_CRYPT,
-       SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG,
-       SS_MP3, SS_MP3DEC, SS_SERVER, SS_AFS, SS_MYSQL_SELECTOR,
-       SS_IPC, SS_RINGBUFFER};
+enum para_subsystem {
+       SS_RECV,
+       SS_NET,
+       SS_ORTP_RECV,
+       SS_AUDIOD,
+       SS_EXEC,
+       SS_CLOSE_ON_FORK,
+       SS_SIGNAL,
+       SS_STRING,
+       SS_DAEMON,
+       SS_STAT,
+       SS_TIME,
+       SS_GRAB_CLIENT,
+       SS_HTTP_RECV,
+       SS_RECV_COMMON,
+       SS_FILTER_CHAIN,
+       SS_WAV,
+       SS_COMPRESS,
+       SS_OGGDEC,
+       SS_FILTER,
+       SS_COMMAND,
+       SS_RANDOM_SELECTOR,
+       SS_PLAYLIST_SELECTOR,
+       SS_CRYPT,
+       SS_HTTP_SEND,
+       SS_ORTP_SEND,
+       SS_DB,
+       SS_OGG,
+       SS_MP3,
+       SS_MP3DEC,
+       SS_SERVER,
+       SS_AFS,
+       SS_MYSQL_SELECTOR,
+       SS_IPC,
+       SS_DCCP,
+       SS_DCCP_RECV,
+       SS_DCCP_SEND,
+       SS_RINGBUFFER};
+
 #define NUM_SS (SS_RINGBUFFER + 1)
 extern const char **para_errlist[];
 /** \endcond */
@@ -238,6 +269,23 @@ extern const char **para_errlist[];
        PARA_ERROR(SHM_ATTACH, "can not attach shared memory area"), \
        PARA_ERROR(SHM_DETACH, "can not detach shared memory area"), \
 
+
+#define DCCP_ERRORS \
+       PARA_ERROR(DCCP_SOCKET, "can not create dccp socket"), \
+       PARA_ERROR(DCCP_PACKET_SIZE, "failed to set dccp packet size"), \
+       PARA_ERROR(DCCP_SERVICE, "could not get service code"), \
+
+
+#define DCCP_RECV_ERRORS \
+       PARA_ERROR(ADDR_INFO, "getaddrinfo error"), \
+       PARA_ERROR(DCCP_OVERRUN, "dccp output buffer buffer overrun"), \
+       PARA_ERROR(DCCP_CONNECT, "dccp connect error"), \
+
+#define DCCP_SEND_ERRORS \
+       PARA_ERROR(DCCP_BIND, "dccp bind error"), \
+       PARA_ERROR(DCCP_LISTEN, "dccp listen error"), \
+
+
 /* these do not need error handling (yet) */
 #define SERVER_ERRORS
 #define WAV_ERRORS
@@ -352,6 +400,9 @@ SS_ENUM(ORTP_SEND);
 SS_ENUM(DB);
 SS_ENUM(MYSQL_SELECTOR);
 SS_ENUM(IPC);
+SS_ENUM(DCCP);
+SS_ENUM(DCCP_RECV);
+SS_ENUM(DCCP_SEND);
 SS_ENUM(RINGBUFFER);
 /** \endcond */
 #undef PARA_ERROR
index 5c4ef4e..925e4e6 100644 (file)
@@ -1,2 +1,3 @@
+section "options of the http receiver"
 option "host" i "ip or host" string default="localhost" no
 option "port" p "tcp port to connect to" int default="8000" no
diff --git a/recv.c b/recv.c
index 31c18a3..c7bca83 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -122,6 +122,6 @@ out:
        if (r)
                r->shutdown();
        if (ret < 0)
-               PARA_NOTICE_LOG("%d: (%s)\n", ret, PARA_STRERROR(-ret));
+               PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
        return ret;
 }
diff --git a/recv.h b/recv.h
index 3284c29..f7fc725 100644 (file)
--- a/recv.h
+++ b/recv.h
@@ -149,6 +149,8 @@ struct receiver {
 /** \cond */
 extern void http_recv_init(struct receiver *r);
 #define HTTP_RECEIVER {.name = "http", .init = http_recv_init},
+extern void dccp_recv_init(struct receiver *r);
+#define DCCP_RECEIVER {.name = "dccp", .init = dccp_recv_init},
 
 #ifdef HAVE_ORTP
 extern void ortp_recv_init(struct receiver *r);
@@ -166,6 +168,7 @@ extern void (*crypt_function_send)(unsigned long len, const unsigned char *indat
 
 #define DEFINE_RECEIVER_ARRAY struct receiver receivers[] = { \
        HTTP_RECEIVER \
+       DCCP_RECEIVER \
        ORTP_RECEIVER \
        {.name = NULL}};
 
diff --git a/send.h b/send.h
index 2c6c727..75c1373 100644 (file)
--- a/send.h
+++ b/send.h
@@ -84,3 +84,22 @@ struct sender {
  */
        int (*client_cmds[NUM_SENDER_CMDS])(struct sender_command_data*);
 };
+
+
+
+static inline int _write_ok(int fd)
+{
+       struct timeval tv = {0, 0};
+       fd_set wfds;
+       int ret;
+again:
+       FD_ZERO(&wfds);
+       FD_SET(fd, &wfds);
+       ret = select(fd + 1, NULL, &wfds, NULL, &tv);
+       if (ret < 0 && errno == EINTR)
+               goto again;
+       if (ret < 0)
+               ret = 0;
+       return ret;
+}
+
index 6964320..c2ede7a 100644 (file)
--- a/server.c
+++ b/server.c
@@ -57,6 +57,7 @@ struct misc_meta_data *mmd;
 */
 struct gengetopt_args_info conf;
 char *user_list = NULL;
+extern void dccp_send_init(struct sender *);
 extern void http_send_init(struct sender *);
 extern void ortp_send_init(struct sender *);
 extern struct audio_format afl[];
@@ -95,6 +96,10 @@ struct sender senders[] = {
                .name = "http",
                .init = http_send_init,
        },
+       {
+               .name = "dccp",
+               .init = dccp_send_init,
+       },
 #ifdef HAVE_ORTP
        {
                .name = "ortp",
@@ -317,7 +322,7 @@ static void init_random_seed(void)
        int fd, ret = -1, len = sizeof(unsigned int);
        unsigned int seed;
 
-       fd = open("/dev/random", O_RDONLY);
+       fd = open("/dev/urandom", O_RDONLY);
        if (fd < 0)
                goto out;
        ret = -2;
index 27727de..0cf4bb6 100644 (file)
@@ -33,6 +33,9 @@ option "http_access" - "Add given host/network to access control list (whitelist
 option "http_no_autostart" - "do not open tcp port on server startup" flag off
 option "http_max_clients" - "maximal simultaneous connections, non-positive value means unlimited" int typestr="number" default="-1" no
 
+section "dccp sender"
+option "dccp_port" - "port for http streaming" int typestr="portnumber" default="5001" no
+
 section "ortp sender"
 option "ortp_target" - "Add given host/port to the list of targets. This option can be given multiple times. Example: '224.0.1.38:1500' instructs the ortp sender to send to udp port 1500 on host 224.0.1.38 (unassigned ip in the Local Network Control Block 224.0.0/24). This is useful for LAN-streaming." string typestr="a.b.c.d:p" no multiple
 option "ortp_no_autostart" - "do not start to send automatically" flag off