]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
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

1  2 
configure.ac
error.h
server.c
server.ggo

diff --combined configure.ac
index 06cbe7acf9ad56860280a80254290f2f8987ebf1,224d840aed872e2cd26f75e0d46a7e7ae50f765d..fd34ed900790d90cd0eee4da239699ebcc00bb9e
@@@ -56,24 -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_dbtool time daemon stat
 -      crypt http_send dccp dccp_send db close_on_fork plm_dbtool ipc"
 +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
@@@ -150,10 -150,10 +150,10 @@@ AC_CHECK_LIB([mysqlclient], [mysql_init
  ])
  if test "$have_mysql" = "yes"; then
        server_ldflags="$server_ldflags -lmysqlclient"
 -      server_errlist_objs="$server_errlist_objs mysql"
 +      server_errlist_objs="$server_errlist_objs mysql_selector"
        AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
  else
 -      AC_MSG_WARN([no libmysqlclient, cannot build mysql-based dbtool])
 +      AC_MSG_WARN([cannot build mysql-based audio file selector])
  fi
  ########################################################################### ogg
  have_ogg="yes"
diff --combined error.h
index 335950b76b5c949a3be38a7f1e9c74d68e513f3d,9ed59c15564d50da538528c6b931f15d6be5323d..4b3cce28bf4f67b69d4d5abe8749a8d8e4846daa
+++ 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};
 -      SS_COMMAND, SS_RANDOM_DBTOOL, SS_PLM_DBTOOL, SS_CRYPT, SS_HTTP_SEND, SS_ORTP_SEND, SS_DB, SS_OGG,
 -      SS_MP3, SS_MP3DEC, SS_SERVER, SS_AFS, SS_MYSQL, SS_IPC, SS_DCCP, SS_DCCP_RECV,
 -      SS_DCCP_SEND, 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 */
        PARA_ERROR(WRITE_OK, "can not check whether fd is writable"), \
  
  
 -#define RANDOM_DBTOOL_ERRORS \
 +#define RANDOM_SELECTOR_ERRORS \
        PARA_ERROR(FILE_COUNT, "audio file count exceeded"), \
        PARA_ERROR(NOTHING_FOUND, "no audio files found"), \
  
  
 -#define MYSQL_ERRORS \
 +#define MYSQL_SELECTOR_ERRORS \
        PARA_ERROR(MYSQL_SYNTAX, "mysql syntax error"), \
        PARA_ERROR(NOTCONN, "not connected to mysql server"), \
        PARA_ERROR(TOOBIG, "mysql: file too large"), \
  #define COMMAND_ERRORS \
        PARA_ERROR(COMMAND_SYNTAX, "syntax error in command"), \
        PARA_ERROR(AUTH, "did not receive auth request"), \
 -      PARA_ERROR(BAD_DBTOOL, "no such database tool"), \
 +      PARA_ERROR(BAD_SELECTOR, "no such audio file selector"), \
        PARA_ERROR(NO_AUDIO_FILE, "no audio file"), \
        PARA_ERROR(BAD_CMD, "invalid command"), \
        PARA_ERROR(PERM, "permission denied"), \
        PARA_ERROR(LOCK, "lock error"), \
        PARA_ERROR(SENDER_CMD, "command not supported by this sender"), \
  
 -#define PLM_DBTOOL_ERRORS \
 +#define PLAYLIST_SELECTOR_ERRORS \
        PARA_ERROR(LOAD_PLAYLIST, "failed to load playlist"), \
  
  
        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
@@@ -344,14 -360,17 +392,17 @@@ SS_ENUM(OGG)
  SS_ENUM(SERVER);
  SS_ENUM(AFS);
  SS_ENUM(COMMAND);
 -SS_ENUM(RANDOM_DBTOOL);
 -SS_ENUM(PLM_DBTOOL);
 +SS_ENUM(RANDOM_SELECTOR);
 +SS_ENUM(PLAYLIST_SELECTOR);
  SS_ENUM(CRYPT);
  SS_ENUM(HTTP_SEND);
  SS_ENUM(ORTP_SEND);
  SS_ENUM(DB);
 -SS_ENUM(MYSQL);
 +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
diff --combined server.c
index 69643208beea484ea067cac2f09b8ad1fe6c24f5,67d9bce4e5aea8822f5c4462af37fa2fb36c6ec1..c2ede7aa92566337c8d5644d1913da5b247ff512
+++ b/server.c
@@@ -21,9 -21,8 +21,9 @@@
  
  /** \mainpage Paraslash API Reference
   *
 - *  Good starting points for reading are probably \ref dbtool, \ref sender,
 - *  \ref receiver, \ref receiver_node, \ref filter, \ref filter_node.
 + *  Good starting points for reading are probably \ref audio_file_selector,
 + *  \ref sender, \ref receiver, \ref receiver_node, \ref filter, \ref
 + *  filter_node.
   *
   */
  
@@@ -48,29 -47,30 +48,30 @@@ INIT_SERVER_ERRLISTS
  /** shut down non-authorized connections after that many seconds */
  #define ALARM_TIMEOUT 10
  
 -/* these are exported to afs/command/dbtool */
 +/* these are exported to afs.c. command.c and to all selectors */
  struct misc_meta_data *mmd;
  /** the configuration of para_server
   *
 - * It also contains the options for all database tools and all supported
 + * It also contains the options for all audio file selectors and all supported
   * senders.
  */
  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[];
  
 -/** the list of supported database tools */
 -struct dbtool dblist[] = {
 +/** the list of supported audio file selectors */
 +struct audio_file_selector dblist[] = {
        {
                .name = "random",
 -              .init = random_dbtool_init,
 +              .init = random_selector_init,
                .update_audio_file = NULL,
        },
        {
 -              .name = "plm",
 -              .init = plm_dbtool_init,
 +              .name = "playlist",
 +              .init = playlist_selector_init,
                .update_audio_file = NULL,
                .pre_select = NULL,
                .post_select = NULL,
@@@ -78,7 -78,7 +79,7 @@@
  #ifdef HAVE_MYSQL
        {
                .name = "mysql",
 -              .init = mysql_dbtool_init,
 +              .init = mysql_selector_init,
                .update_audio_file = NULL,
                .pre_select = NULL,
                .post_select = NULL,
@@@ -95,6 -95,10 +96,10 @@@ struct sender senders[] = 
                .name = "http",
                .init = http_send_init,
        },
+       {
+               .name = "dccp",
+               .init = dccp_send_init,
+       },
  #ifdef HAVE_ORTP
        {
                .name = "ortp",
@@@ -174,7 -178,7 +179,7 @@@ static void shm_init(void
                goto err_out;
        mmd_mutex = ret;
  
 -      mmd->dbt_num = 0;
 +      mmd->selector_num = 0;
        mmd->num_played = 0;
        mmd->num_commands = 0;
        mmd->events = 0;
@@@ -277,29 -281,29 +282,29 @@@ static void setup_signal_handling(void
        }
  }
  
 -static void init_dbtool(void)
 +static void init_selector(void)
  {
        int i, ret;
  
 -      mmd->dbt_change = -1; /* no change nec., set to new dbt num by com_cdt */
 -      if (!conf.dbtool_given)
 +      mmd->selector_change = -1; /* no change nec., set to new num by com_chs */
 +      if (!conf.selector_given)
                goto random;
        for (i = 0; dblist[i].name; i++) {
 -              if (strcmp(dblist[i].name, conf.dbtool_arg))
 +              if (strcmp(dblist[i].name, conf.selector_arg))
                        continue;
 -              PARA_NOTICE_LOG("initializing %s database tool\n",
 +              PARA_NOTICE_LOG("initializing %s audio file selector\n",
                        dblist[i].name);
                ret = dblist[i].init(&dblist[i]);
                if (ret < 0) {
                        PARA_WARNING_LOG("%s", PARA_STRERROR(-ret));
                        break;
                }
 -              mmd->dbt_num = i;
 +              mmd->selector_num = i;
                return;
        }
 -      PARA_WARNING_LOG("%s", "falling back to the random dbtool\n");
 +      PARA_WARNING_LOG("%s", "falling back to the random selector\n");
  random:
 -      mmd->dbt_num = 0;
 +      mmd->selector_num = 0;
        dblist[0].init(&dblist[0]); /* always successful */
  }
  
@@@ -317,7 -321,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;
@@@ -352,7 -356,7 +357,7 @@@ static unsigned do_inits(int argc, cha
        /* become daemon */
        if (conf.daemon_given)
                daemon_init();
 -      init_dbtool();
 +      init_selector();
        PARA_NOTICE_LOG("%s", "initializing audio file sender\n");
        /* audio file sender */
        afs_init();
        return sockfd;
  }
  
 -static void handle_dbt_change(void)
 +static void change_selector(void)
  {
 -      int ret, old = mmd->dbt_num, new = mmd->dbt_change;
 +      int ret, old = mmd->selector_num, new = mmd->selector_change;
  
        dblist[old].shutdown();
        ret = dblist[new].init(&dblist[new]);
 -      mmd->dbt_change = -1; /* reset */
 +      mmd->selector_change = -1; /* reset */
        if (ret >= 0) {
 -              mmd->dbt_num = new;
 +              mmd->selector_num = new;
                return;
        }
        /* init failed */
 -      PARA_ERROR_LOG("%s -- switching to the random dbtool\n", PARA_STRERROR(-ret));
 +      PARA_ERROR_LOG("%s -- switching to the random selector\n", PARA_STRERROR(-ret));
        dblist[0].init(&dblist[0]);
 -      mmd->dbt_num = 0;
 +      mmd->selector_num = 0;
  }
  
  /*
@@@ -396,8 -400,8 +401,8 @@@ static void handle_sighup(void
        close_log(logfile); /* gets reopened if necessary by parse_config */
        logfile = NULL;
        parse_config(1); /* reopens log */
 -      mmd->dbt_change = mmd->dbt_num; /* do not change dbtool */
 -      handle_dbt_change(); /* force reloading dbtool */
 +      mmd->selector_change = mmd->selector_num; /* do not change selector.. */
 +      change_selector(); /* .. just reload */
  }
  
  static void status_refresh(void)
@@@ -459,8 -463,8 +464,8 @@@ repeat
                        &max_fileno,
                        &rfds, &wfds);
        }
 -      if (dblist[mmd->dbt_num].pre_select) {
 -              ret = dblist[mmd->dbt_num].pre_select(&rfds, &wfds);
 +      if (dblist[mmd->selector_num].pre_select) {
 +              ret = dblist[mmd->selector_num].pre_select(&rfds, &wfds);
                max_fileno = MAX(max_fileno, ret);
        }
        mmd_unlock();
        err = errno;
        //PARA_DEBUG_LOG("%s: select returned  %i\n", __func__, ret);
        mmd_lock();
 -      if (mmd->dbt_change >= 0)
 -              handle_dbt_change();
 -      if (dblist[mmd->dbt_num].post_select)
 -              dblist[mmd->dbt_num].post_select(&rfds, &wfds);
 +      if (mmd->selector_change >= 0)
 +              change_selector();
 +      if (dblist[mmd->selector_num].post_select)
 +              dblist[mmd->selector_num].post_select(&rfds, &wfds);
        if (ret < 0 && err == EINTR)
                goto repeat;
        if (ret < 0) {
                case SIGTERM:
                        PARA_EMERG_LOG("terminating on signal %d\n", sig);
                        kill(0, SIGTERM);
 -                      dblist[mmd->dbt_num].shutdown();
 +                      dblist[mmd->selector_num].shutdown();
                        mutex_destroy(mmd_mutex);
                        shm_detach(mmd);
                        shm_destroy(mmd_shm_id);
diff --combined server.ggo
index 27727deb92587f26971b05252867b9bf064fe8cb,418b2b4aaaa7bbe2cb38d2bc378e3921c2a2f441..0cf4bb625bcf56b4bf53c19558044c4137252055
@@@ -9,12 -9,12 +9,12 @@@ option "logfile" L "(default=stdout/std
  option "config_file" c "(default='~/.paraslash/server.conf'" string typestr="filename" no
  option "user_list" - "(default='~/.paraslash/server.users')" string typestr="filename" no
  
 -section "Options concerning the audio file sender"
 +section "audio file sender"
  option "autoplay" a "start playing on startup" flag off
  option "announce_time" A "Delay betweeen announcing the stream and sending data" int typestr="milliseconds" default="300" no
 -option "dbtool" D "(default=first available that works)" string typestr="name_of_dbtool" no
 +option "selector" S "(default=random)" string typestr="name" no
  
 -section "Mysql database tool options"
 +section "mysql selector:"
  option "mysql_host" - "mysql server" string default="localhost" no
  option "mysql_port" - "where mysql is listening" int default="3306" no
  option "mysql_user" - "default value: username from /etc/passwd" string no
@@@ -23,17 -23,22 +23,20 @@@ option "mysql_database" - "name of mysq
  option "mysql_audio_file_dir"  - "dir to search for audio files (required)" string no
  option "mysql_default_score" - "scoring rule to use if stream definition does not contain explicit score definition" string default="(LASTPLAYED() / 1440 - 1000 / (LASTPLAYED() + 1) - sqrt(NUMPLAYED()))" no
  
 +section "random selector"
 +option "random_dir" - "dir to search for audio files" string default="/home/music" no
  
 -
 -section "Random database tool options"
 -option "random_dbtool_dir" - "dir to search for files to be streamed" string default="/home/music" no
 -
 -section "Http sender options"
 +section "http sender"
  option "http_port" - "tcp port for http streaming" int typestr="portnumber" default="8000" no
  option "http_default_deny" - "deny connections from hosts which are not explicitly allowed" flag off
  option "http_access" - "Add given host/network to access control list (whitelist if http_default_deny was given, blacklist otherwise) before opening the tcp port. This option can be given multiple times. Example: '192.168.0.0/24' whitelists/blacklists the 256 hosts 192.168.0.x" string typestr="a.b.c.d/n" no multiple
  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 options"
++section "dccp sender"
+ option "dccp_port" - "port for http streaming" int typestr="portnumber" default="5001" no
 -section "Ortp sender options"
 +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
  option "ortp_default_port" - "default udp port if not specified" int typestr="portnumber" default="1500" no